From b4f820f2bcceb880d3adfd28640d8e13596c7d3d Mon Sep 17 00:00:00 2001 From: tzachid Date: Tue, 7 Mar 2006 10:15:28 +0000 Subject: [PATCH] [MTHCA] Update files from trunk to the mtcha branch. git-svn-id: svn://openib.tc.cornell.edu/gen1@228 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- branches/MTHCA/hw/mt23108/kernel/hca_data.c | 1 + .../MTHCA/hw/mt23108/kernel/infinihost.inf | 25 +- branches/MTHCA/hw/mt23108/user/hca_data.h | 2 +- branches/MTHCA/hw/mt23108/user/mlnx_ual_ca.c | 3 +- branches/MTHCA/hw/mt23108/user/mlnx_ual_cq.c | 4 +- .../MTHCA/hw/mt23108/vapi/Hca/hcahal/hh.h | 33 ++- .../hw/mt23108/vapi/Hca/hcahal/hh_common.h | 2 +- .../vapi/Hca/hcahal/tavor/thh_common.h | 47 +++- .../vapi/Hca/hcahal/tavor/thh_hob/thh_hob.c | 7 +- .../vapi/Hca/hcahal/tavor/thh_hob/thh_hob.h | 4 +- .../vapi/mlxsys/os_dep/win/tdriver/MdCard.h | 2 +- .../vapi/mlxsys/os_dep/win/tdriver/MdConf.c | 15 +- .../vapi/mlxsys/os_dep/win/tdriver/MdIoctl.c | 1 + .../vapi/mlxsys/os_dep/win/tdriver/MdPnp.c | 7 +- .../vapi/mlxsys/os_dep/win/tdriver/MdRdWr.c | 3 +- .../vapi/mlxsys/os_dep/win/tdriver/MdUtil.c | 6 +- .../ulp/opensm/user/include/iba/ib_types.h | 6 +- .../user/include/iba/ib_types_extended.h | 4 + .../ulp/opensm/user/include/opensm/osm_log.h | 22 +- .../ulp/opensm/user/include/opensm/osm_req.h | 4 + .../ulp/opensm/user/libopensm/osm_helper.c | 32 ++- .../ulp/opensm/user/libvendor/winosm_common.c | 1 + branches/MTHCA/ulp/opensm/user/opensm/SOURCES | 5 - branches/MTHCA/ulp/opensm/user/opensm/main.c | 2 +- .../ulp/opensm/user/opensm/osm_lid_mgr.c | 218 ++++++++++----- .../ulp/opensm/user/opensm/osm_link_mgr.c | 1 + .../ulp/opensm/user/opensm/osm_mcast_mgr.c | 1 + .../opensm/user/opensm/osm_port_info_rcv.c | 18 +- .../MTHCA/ulp/opensm/user/opensm/osm_req.c | 3 +- .../ulp/opensm/user/opensm/osm_sm_mad_ctrl.c | 18 +- .../ulp/opensm/user/opensm/osm_state_mgr.c | 1 + .../ulp/opensm/user/opensm/osm_sw_info_rcv.c | 1 + .../ulp/opensm/user/opensm/osm_ucast_mgr.c | 2 + .../ulp/opensm/user/opensm/osm_vl15intf.c | 17 +- branches/MTHCA/ulp/srp/kernel/ib_srp.inf | 15 +- branches/MTHCA/ulp/wsd/user/ib_cm.c | 6 +- branches/MTHCA/ulp/wsd/user/ibsp_duplicate.c | 253 ++++++++---------- branches/MTHCA/ulp/wsd/user/ibsp_iblow.c | 46 ++-- branches/MTHCA/ulp/wsd/user/ibsp_ip.c | 217 ++++++--------- branches/MTHCA/ulp/wsd/user/ibspdebug.c | 134 ++++++++++ branches/MTHCA/ulp/wsd/user/ibspdebug.h | 39 +++ branches/MTHCA/ulp/wsd/user/ibspdll.c | 99 +++---- branches/MTHCA/ulp/wsd/user/ibspdll.h | 2 + branches/MTHCA/ulp/wsd/user/ibspproto.h | 15 +- branches/MTHCA/ulp/wsd/user/ibspstruct.h | 20 +- branches/MTHCA/ulp/wsd/user/misc.c | 5 +- 46 files changed, 813 insertions(+), 556 deletions(-) diff --git a/branches/MTHCA/hw/mt23108/kernel/hca_data.c b/branches/MTHCA/hw/mt23108/kernel/hca_data.c index 8c453952..7cc876c4 100644 --- a/branches/MTHCA/hw/mt23108/kernel/hca_data.c +++ b/branches/MTHCA/hw/mt23108/kernel/hca_data.c @@ -2074,6 +2074,7 @@ mlnx_conv_vapi_hca_cap( ca_attr_p->vend_id = hca_info_p->vendor_id; ca_attr_p->dev_id = (uint16_t)hca_info_p->dev_id; ca_attr_p->revision = (uint16_t)hca_info_p->hw_ver; + ca_attr_p->fw_ver = hca_info_p->fw_ver; ca_attr_p->ca_guid = *(UNALIGNED64 u_int64_t *)vapi_hca_cap_p->node_guid; ca_attr_p->num_ports = vapi_hca_cap_p->phys_port_num; diff --git a/branches/MTHCA/hw/mt23108/kernel/infinihost.inf b/branches/MTHCA/hw/mt23108/kernel/infinihost.inf index 938c29bf..13552eba 100644 --- a/branches/MTHCA/hw/mt23108/kernel/infinihost.inf +++ b/branches/MTHCA/hw/mt23108/kernel/infinihost.inf @@ -1,13 +1,12 @@ -; SilverStorm Technologies InfiniBand HCAs. +; OpenIB InfiniBand HCAs. ; Copyright 2005 SilverStorm Technologies all Rights Reserved. [Version] Signature="$Windows NT$" Class=InfiniBandHca ClassGUID=%HcaClassGuid% -Provider=%SST% -CatalogFile=infiniserv.cat -DriverVer=09/01/2005,3.0.0036.0 +Provider=%OPENIB% +DriverVer=01/12/2006,1.0.0000.213 ; ================= Destination directory section ===================== @@ -72,7 +71,7 @@ mt23108ud.dll=1 ;uvpd32d.dll=1 [Manufacturer] -%SST% = HCA.DeviceSection,ntx86,ntamd64,ntia64 +%OPENIB% = HCA.DeviceSection,ntx86,ntamd64,ntia64 [HCA.DeviceSection] ; empty since we don't support W9x/Me @@ -193,14 +192,14 @@ HKR,"Parameters","IocPollInterval",%REG_DWORD_NO_CLOBBER%,30000 [Strings] HcaClassGuid = "{58517E00-D3CF-40c9-A679-CEE5752F4491}" -SST = "SilverStorm Technologies" -MT23108.DeviceDesc = "SilverStorm HCA 7000 InfiniBand HCA" -MT23108.ServiceDesc = "SilverStorm HCA 7000 InfiniBand HCA Driver" -MT25208.DeviceDesc = "SilverStorm HCA 9000 InfiniBand HCA" -MT25208.ServiceDesc = "SilverStorm HCA 9000 InfiniBand HCA Driver" -THCA.ServiceDesc = "SilverStorm HCA 7000/9000 HCA VPD for IBAL" -Ibal.ServiceDesc = "SilverStorm InfiniBand Access Layer" -DiskId = "SilverStorm InfiniBand HCA installation disk" +OPENIB = "OpenIB Alliance" +MT23108.DeviceDesc = "Mellanox MT23108 InfiniBand HCA" +MT23108.ServiceDesc = "Mellanox MT23108 InfiniBand HCA Driver" +MT25208.DeviceDesc = "Mellanox MT25208 InfiniBand HCA" +MT25208.ServiceDesc = "Mellanox MT25208 InfiniBand HCA Driver" +THCA.ServiceDesc = "Mellanox HCA VPD for IBAL" +Ibal.ServiceDesc = "OpenIB InfiniBand Access Layer" +DiskId = "OpenIB InfiniBand HCA installation disk" SPSVCINST_NULL = 0x0 SPSVCINST_ASSOCSERVICE = 0x00000002 SERVICE_KERNEL_DRIVER = 1 diff --git a/branches/MTHCA/hw/mt23108/user/hca_data.h b/branches/MTHCA/hw/mt23108/user/hca_data.h index 9efcea1c..8a53c5df 100644 --- a/branches/MTHCA/hw/mt23108/user/hca_data.h +++ b/branches/MTHCA/hw/mt23108/user/hca_data.h @@ -35,7 +35,7 @@ typedef struct _ib_ca { - HH_hca_dev_t *p_hca_ul_info; + HH_hca_dev_t * __ptr64 p_hca_ul_info; void *p_hca_ul_resources; ib_ca_attr_t *p_hca_attr; HHUL_hca_hndl_t hhul_hca_hndl; diff --git a/branches/MTHCA/hw/mt23108/user/mlnx_ual_ca.c b/branches/MTHCA/hw/mt23108/user/mlnx_ual_ca.c index 072e72f6..09edb90d 100644 --- a/branches/MTHCA/hw/mt23108/user/mlnx_ual_ca.c +++ b/branches/MTHCA/hw/mt23108/user/mlnx_ual_ca.c @@ -200,8 +200,9 @@ mlnx_post_query_ca ( if ( ioctl_status == IB_SUCCESS && p_ca_attr && byte_count && !h_uvp_ca->p_hca_attr ) { + CL_ASSERT( byte_count >= p_ca_attr->size ); h_uvp_ca->p_hca_attr = p_umv_buf->p_inout_buf; - cl_memcpy(h_uvp_ca->p_hca_attr, p_ca_attr, byte_count); + ib_copy_ca_attr( h_uvp_ca->p_hca_attr, p_ca_attr ); } else if (p_umv_buf->p_inout_buf) { diff --git a/branches/MTHCA/hw/mt23108/user/mlnx_ual_cq.c b/branches/MTHCA/hw/mt23108/user/mlnx_ual_cq.c index b9c11ab2..083bec97 100644 --- a/branches/MTHCA/hw/mt23108/user/mlnx_ual_cq.c +++ b/branches/MTHCA/hw/mt23108/user/mlnx_ual_cq.c @@ -202,7 +202,7 @@ mlnx_pre_create_cq ( } FUNC_EXIT; - return IB_SUCCESS; + return status; } @@ -329,7 +329,7 @@ mlnx_pre_resize_cq ( ("Before resize_cq_prep *p_size = %d\n", *p_size)); status = THHUL_cqm_resize_cq_prep ( p_hobul->hhul_hca_hndl, p_cq_info->hhul_cq_hndl, - *p_size, p_size, + *p_size, &p_cq_info->cq_size, p_cq_ul_resources); if( status != IB_SUCCESS ) { diff --git a/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/hh.h b/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/hh.h index 9816d3a3..e4f280aa 100644 --- a/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/hh.h +++ b/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/hh.h @@ -62,26 +62,47 @@ typedef enum * Device information (public object/context) * */ - +#pragma warning( disable : 4201 ) typedef struct HH_hca_dev_st { - char *dev_desc; /* Device description (name, etc.) */ - char *user_lib; /* User level library (dyn-link) */ + char * __ptr64 dev_desc; /* Device description (name, etc.) */ + char * __ptr64 user_lib; /* User level library (dyn-link) */ u_int32_t vendor_id; /* IEEE's 24 bit Device Vendor ID */ u_int32_t dev_id; /* Device ID */ u_int32_t hw_ver; /* Hardware version (step/rev) */ - struct hh_if_ops* if_ops; /* Interface operations */ + u_int64_t fw_ver; + struct hh_if_ops* __ptr64 if_ops; /* Interface operations */ /* Size (bytes) of user-level ... */ + union + { MT_size_t hca_ul_resources_sz; /* .. resources context for an HCA */ + void* __ptr64 resv0; + }; + union + { MT_size_t pd_ul_resources_sz; /* .. resources context for a PD */ + void* __ptr64 resv1; + }; + union + { MT_size_t cq_ul_resources_sz; /* .. resources context for a CQ */ + void* __ptr64 resv2; + }; + union + { MT_size_t srq_ul_resources_sz; /* .. resources context for a SRQ */ + void* __ptr64 resv3; + }; + union + { MT_size_t qp_ul_resources_sz; /* .. resources context for a QP */ + void* __ptr64 resv4; + }; - void* device; /* Device private data */ + void* __ptr64 device; /* Device private data */ HH_hca_status_t status; /* Device Status */ } HH_hca_dev_t; - +#pragma warning( default : 4201 ) typedef enum { HH_TPT_PAGE, diff --git a/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/hh_common.h b/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/hh_common.h index 886ed6b3..6e3eff88 100644 --- a/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/hh_common.h +++ b/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/hh_common.h @@ -44,7 +44,7 @@ * */ -typedef struct HH_hca_dev_st* HH_hca_hndl_t; +typedef struct HH_hca_dev_st* __ptr64 HH_hca_hndl_t; typedef struct HHUL_sr_wqe_st HHUL_sr_wqe_t; typedef struct HHUL_rr_wqe_st HHUL_rr_wqe_t; diff --git a/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/tavor/thh_common.h b/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/tavor/thh_common.h index 6778cd07..2e9943c7 100644 --- a/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/tavor/thh_common.h +++ b/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/tavor/thh_common.h @@ -54,6 +54,8 @@ typedef u_int32_t THH_uar_index_t; typedef struct THH_uar_st *THH_uar_t; +#pragma warning( disable : 4201 ) + /* VERSION INFORMATION: used in order to retrieve major version numbers in order to deal with differences in different versions. */ typedef struct THH_ver_info_st { @@ -68,12 +70,16 @@ typedef struct THH_hca_ul_resources_st { HH_hca_hndl_t hh_hca_hndl; THH_ver_info_t version; THH_uar_index_t uar_index; + union + { MT_virt_addr_t uar_map; + void* __ptr64 resv0; + }; /* HCA capabilities to validate or use in THHUL */ MT_bool priv_ud_av; /* Privileged UD AV are enforced ? */ u_int32_t log2_mpt_size; - char *av_ddr_base; - char *av_host_base; + char * __ptr64 av_ddr_base; + char * __ptr64 av_host_base; u_int32_t max_qp_ous_wr; /* Maximum Number of oustanding WR on any WQ. */ u_int32_t max_srq_ous_wr; /* Maximum Number of oustanding WR on any WQ. */ @@ -90,34 +96,71 @@ typedef struct THH_pd_ul_resources_st { * needed. Therefore, the udavm_buf_size value is the size of the actual udavm * table, not the size of the malloc'ed buffer. */ + union + { MT_virt_addr_t udavm_buf; /* IN */ + void* __ptr64 resv0; + }; + union + { MT_size_t udavm_buf_sz; /* IN */ + void* __ptr64 resv1; + }; HH_pdm_pd_flags_t pd_flags; /* IN - if non-zero, is a PD for a special QP*/ VAPI_lkey_t udavm_buf_memkey; /* OUT - set by THH_uldm */ } THH_pd_ul_resources_t; typedef struct { + union + { MT_virt_addr_t cqe_buf; /* CQE buffer virtual addr. CQE size aligned */ + void* __ptr64 resv0; + }; + union + { MT_size_t cqe_buf_sz; /* Buffer size in bytes (mult of CQE size) */ + void* __ptr64 resv1; + }; THH_uar_index_t uar_index; /* Index of UAR used for this CQ. */ u_int32_t new_producer_index; /* New producer index after "resize_cq" (OUT)*/ } THH_cq_ul_resources_t; typedef struct { + union + { MT_virt_addr_t wqes_buf; /* WQEs buffer virtual address */ + void* __ptr64 resv0; + }; + union + { MT_size_t wqes_buf_sz; /* Buffer size in bytes */ + void* __ptr64 resv1; + }; THH_uar_index_t uar_index; /* index of UAR used for this QP */ /* ER: Not used anywhere: MT_virt_addr_t uar_map; */ /* Address in user space of UAR */ } THH_qp_ul_resources_t; typedef struct { + union + { MT_virt_addr_t wqes_buf; /* WQEs buffer virtual address */ + void* __ptr64 resv0; + }; + union + { MT_size_t wqes_buf_sz; /* Buffer size in bytes */ + void* __ptr64 resv1; + }; + union + { MT_size_t wqe_sz; /* WQE (descriptor) size in bytes */ + void* __ptr64 resv2; + }; THH_uar_index_t uar_index; /* index of UAR used for this QP */ } THH_srq_ul_resources_t; +#pragma warning( default : 4201 ) #endif /* H_THH_COMMON_H */ diff --git a/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/tavor/thh_hob/thh_hob.c b/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/tavor/thh_hob/thh_hob.c index 0484cf9f..e514476c 100644 --- a/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/tavor/thh_hob/thh_hob.c +++ b/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/tavor/thh_hob/thh_hob.c @@ -4176,6 +4176,9 @@ cmdif_dbg_ddr = hob_p->ddr_props.ddr_start_adr; /* address in ddr used for out p tdev.dev_id = (u_int32_t)hw_props_p->device_id; MTL_DEBUG1("hw_props_p: device_id = 0x%X, pci_vendor_id=0x%X,hw_ver=0x%X\n", hw_props_p->device_id, hw_props_p->pci_vendor_id, hw_props_p->hw_ver); + tdev.fw_ver= tdev.fw_ver = hob_p->fw_props.fw_rev_major; + tdev.fw_ver = (tdev.fw_ver <<16) | hob_p->fw_props.fw_rev_minor; + tdev.fw_ver = (tdev.fw_ver <<16) | hob_p->fw_props.fw_rev_subminor;; tdev.hw_ver = hob_p->hw_props.hw_ver; tdev.if_ops = if_ops_p; tdev.hca_ul_resources_sz = sizeof(THH_hca_ul_resources_t); @@ -4997,7 +5000,7 @@ HH_ret_t THH_hob_free_pd(HH_hca_hndl_t hca_hndl, HH_pd_hndl_t pd_num) /****************************************************************************** * Function: THH_hob_alloc_rdd <==> THH_eecm_alloc_rdd *****************************************************************************/ -HH_ret_t THH_hob_alloc_rdd(HH_hca_dev_t *hh_dev_p, +HH_ret_t THH_hob_alloc_rdd(HH_hca_hndl_t hh_dev_p, HH_rdd_hndl_t *rdd_p) { #if 0 @@ -5036,7 +5039,7 @@ HH_ret_t THH_hob_alloc_rdd(HH_hca_dev_t *hh_dev_p, /****************************************************************************** * Function: THH_hob_free_rdd <==> THH_eecm_free_rdd *****************************************************************************/ -HH_ret_t THH_hob_free_rdd(HH_hca_dev_t *hh_dev_p, HH_rdd_hndl_t rdd) +HH_ret_t THH_hob_free_rdd(HH_hca_hndl_t hh_dev_p, HH_rdd_hndl_t rdd) { #if 0 THH_hob_t thh_hob_p; diff --git a/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/tavor/thh_hob/thh_hob.h b/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/tavor/thh_hob/thh_hob.h index d2b5cf06..dc517719 100644 --- a/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/tavor/thh_hob/thh_hob.h +++ b/branches/MTHCA/hw/mt23108/vapi/Hca/hcahal/tavor/thh_hob/thh_hob.h @@ -336,8 +336,8 @@ DLL_API HH_ret_t THH_hob_alloc_ul_res(HH_hca_hndl_t hca_hndl,MOSAL_protection_ct DLL_API HH_ret_t THH_hob_free_ul_res(HH_hca_hndl_t hca_hndl,void *hca_ul_resources_p); DLL_API HH_ret_t THH_hob_alloc_pd(HH_hca_hndl_t hca_hndl, MOSAL_protection_ctx_t prot_ctx, void * pd_ul_resources_p,HH_pd_hndl_t *pd_num_p); DLL_API HH_ret_t THH_hob_free_pd(HH_hca_hndl_t hca_hndl, HH_pd_hndl_t pd_num); -DLL_API HH_ret_t THH_hob_alloc_rdd(HH_hca_dev_t *hh_dev_p, HH_rdd_hndl_t *rdd_p); -DLL_API HH_ret_t THH_hob_free_rdd(HH_hca_dev_t *hh_dev_p, HH_rdd_hndl_t rdd); +DLL_API HH_ret_t THH_hob_alloc_rdd(HH_hca_hndl_t hh_dev_p, HH_rdd_hndl_t *rdd_p); +DLL_API HH_ret_t THH_hob_free_rdd(HH_hca_hndl_t hh_dev_p, HH_rdd_hndl_t rdd); DLL_API HH_ret_t THH_hob_create_ud_av(HH_hca_hndl_t hca_hndl,HH_pd_hndl_t pd,VAPI_ud_av_t *av_p, HH_ud_av_hndl_t *ah_p); DLL_API HH_ret_t THH_hob_modify_ud_av(HH_hca_hndl_t hca_hndl, HH_ud_av_hndl_t ah,VAPI_ud_av_t *av_p); DLL_API HH_ret_t THH_hob_query_ud_av(HH_hca_hndl_t hca_hndl, HH_ud_av_hndl_t ah,VAPI_ud_av_t *av_p); diff --git a/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdCard.h b/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdCard.h index ce7f2e3c..f4bda55b 100644 --- a/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdCard.h +++ b/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdCard.h @@ -497,7 +497,7 @@ typedef struct MD_DEV_CONTEXT_S { /* for TAVOR_SD */ { L"5A5A", "mt%d_pci%d", "mt%d_pci%d", MD_DEV_ID_TAVOR_SD, MD_DEV_IX_TAVOR_SD, TRUE, 0x00100000, 0x01000000, 0x00000000, 167000000, 4, 0 }, /* for TAVOR_SD */ - { L"6278", "InfiniHost%d", "InfiniHosA%d", MD_DEV_ID_ARBEL_TM, MD_DEV_IX_ARBEL_TM, TRUE, 0x00100000, 0x01000000, 0x00000000, 167000000, 4, 0 }, + { L"6278", "InfiniHostEx%d", "InfiniHosEx%d", MD_DEV_ID_ARBEL_TM, MD_DEV_IX_ARBEL_TM, TRUE, 0x00100000, 0x01000000, 0x00000000, 167000000, 4, 0 }, }; #else diff --git a/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdConf.c b/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdConf.c index d9cf0b61..12b8db2e 100644 --- a/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdConf.c +++ b/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdConf.c @@ -586,7 +586,8 @@ PciFixCmdReg( } /* fix HCA command register from SHRIMP */ - if (pi_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR ) + if (pi_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR + || pi_pMdDevContext->m_eDevType ==MD_DEV_IX_ARBEL_TM) { /* fix command register for TAVOR */ l_pInterface = &pi_pMdDevContext->m_Interface; @@ -680,7 +681,8 @@ PciHdrWrite( return l_Status; } else - if (pi_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR) { + if (pi_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR || + pi_pMdDevContext->m_eDevType == MD_DEV_IX_ARBEL_TM) { /* protect */ KSEM_ACQ(&pi_pMdDevContext->m_Sem); @@ -849,7 +851,8 @@ PciHdrSave( } else - if (pi_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR ) { + if (pi_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR || + pi_pMdDevContext->m_eDevType == MD_DEV_IX_ARBEL_TM) { /* * HCA device @@ -936,7 +939,8 @@ PciHdrRestore( } } else - if (pi_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR ) { + if (pi_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR || + pi_pMdDevContext->m_eDevType == MD_DEV_IX_ARBEL_TM) { /* * Bridge device @@ -987,7 +991,8 @@ PciReset( l_Status ); } else - if (pi_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR) { /* we are Tavor device */ + if (pi_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR || + pi_pMdDevContext->m_eDevType == MD_DEV_IX_ARBEL_TM) { /* we are Tavor device */ l_Status = PciDevReset(pi_pMdDevContext, l_ResetOffset, l_ResetValue ); } else diff --git a/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdIoctl.c b/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdIoctl.c index e3b022e0..ea967bd3 100644 --- a/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdIoctl.c +++ b/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdIoctl.c @@ -140,6 +140,7 @@ Return Value: case MD_DEV_IX_TAVOR_SD: case MD_DEV_IX_TAVOR: + case MD_DEV_IX_ARBEL_TM: l_Status = PciIoctl( l_pMdDevContext, l_pPcs, l_nIoControlCode, l_pInBuffer, l_nInBufLength, l_pOutBuffer, l_nOutBufLength, (PULONG)&pi_pIrp->IoStatus.Information ); break; diff --git a/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdPnp.c b/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdPnp.c index 1e04bd19..1c73e036 100644 --- a/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdPnp.c +++ b/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdPnp.c @@ -932,7 +932,9 @@ Return Value: * add device to TAVOR */ - if (l_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR && g_pDrvContext->m_fSupportTavor) + if ((l_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR || + l_pMdDevContext->m_eDevType == MD_DEV_IX_ARBEL_TM) + && g_pDrvContext->m_fSupportTavor) { /* add HCA to Tavor functional DLLs */ unsigned char l_RevId = 0; @@ -1128,7 +1130,8 @@ Return Value: // stop the card by sending some commands to it or suspend all new requests and wait for the end of in-progress ones // - if (l_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR && g_pDrvContext->m_fSupportTavor) + if ((l_pMdDevContext->m_eDevType == MD_DEV_IX_TAVOR || + l_pMdDevContext->m_eDevType == MD_DEV_IX_ARBEL_TM)&& g_pDrvContext->m_fSupportTavor) { /* remove HCA from Tavor functional DLLs */ HH_ret_t l_HhRet; diff --git a/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdRdWr.c b/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdRdWr.c index 8398471a..ea85c7b7 100644 --- a/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdRdWr.c +++ b/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdRdWr.c @@ -103,8 +103,9 @@ Return Value: break; case MD_DEV_IX_TAVOR: + case MD_DEV_IX_ARBEL_TM: // MDCTL - PciRelease( l_pMdDevContext, l_pPcs ); + PciRelease( l_pMdDevContext, l_pPcs ); break; case MD_DEV_IX_TAVOR_BD: diff --git a/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdUtil.c b/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdUtil.c index 927d0b59..ec7839f3 100644 --- a/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdUtil.c +++ b/branches/MTHCA/hw/mt23108/vapi/mlxsys/os_dep/win/tdriver/MdUtil.c @@ -447,6 +447,7 @@ Return Value: break; case MD_DEV_IX_TAVOR: + case MD_DEV_IX_ARBEL_TM: GetRegistryDword( L"DdrMapOffset", MD_DFLT_CONF_DATA, &l_pMdDevContext->m_ulDdrMapOffset ); GetRegistryDword( L"DdrMapSize", MD_DFLT_CONF_DATA, &l_pMdDevContext->m_ulDdrMapSize ); GetRegistryDword( L"ResetCard", MD_DFLT_CONF_DATA, &l_pMdDevContext->m_PerformReset ); @@ -1415,8 +1416,9 @@ NTSTATUS CreateOneDevice( /* create Control Device names */ /* !!! from now on work with ARBEL_TM as with TAVOR */ - l_pDevInfo = (pi_DevIx == (int)MD_DEV_IX_ARBEL_TM) ? &g_DevParams[MD_DEV_IX_TAVOR] : &g_DevParams[pi_DevIx]; - if (l_pDevInfo->m_DevId == MD_DEV_ID_TAVOR) + //l_pDevInfo = (pi_DevIx == (int)MD_DEV_IX_ARBEL_TM) ? &g_DevParams[MD_DEV_IX_TAVOR] : &g_DevParams[pi_DevIx]; + l_pDevInfo = &g_DevParams[pi_DevIx]; + if (l_pDevInfo->m_DevId == MD_DEV_ID_TAVOR || l_pDevInfo->m_DevId == MD_DEV_ID_ARBEL_TM) sprintf( l_DevName, l_pDevInfo->m_Format, g_pDrvContext->m_uCardNo ); else sprintf( l_DevName, l_pDevInfo->m_Format, l_pDevInfo->m_DevId, g_pDrvContext->m_uCardNo ); diff --git a/branches/MTHCA/ulp/opensm/user/include/iba/ib_types.h b/branches/MTHCA/ulp/opensm/user/include/iba/ib_types.h index 9bd0c189..eb1e11d2 100644 --- a/branches/MTHCA/ulp/opensm/user/include/iba/ib_types.h +++ b/branches/MTHCA/ulp/opensm/user/include/iba/ib_types.h @@ -4650,7 +4650,7 @@ ib_port_info_get_timeout( * * SYNOPSIS */ -AL_INLINE uint8_t AL_API +OSM_INLINE uint8_t AL_API ib_port_info_get_client_rereg( IN ib_port_info_t const* p_pi ) { @@ -7536,6 +7536,7 @@ typedef struct _ib_ca_attr uint32_t vend_id; uint16_t dev_id; uint16_t revision; + uint64_t fw_ver; /* * Total size of the ca attributes in bytes @@ -7625,6 +7626,9 @@ typedef struct _ib_ca_attr * 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 diff --git a/branches/MTHCA/ulp/opensm/user/include/iba/ib_types_extended.h b/branches/MTHCA/ulp/opensm/user/include/iba/ib_types_extended.h index 3340c914..b3672902 100644 --- a/branches/MTHCA/ulp/opensm/user/include/iba/ib_types_extended.h +++ b/branches/MTHCA/ulp/opensm/user/include/iba/ib_types_extended.h @@ -607,6 +607,7 @@ typedef struct _ib_ca_attr uint32_t vend_id; uint16_t dev_id; uint16_t revision; + uint64_t fw_ver; /* * Total size of the ca attributes in bytes @@ -691,6 +692,9 @@ typedef struct _ib_ca_attr * 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 diff --git a/branches/MTHCA/ulp/opensm/user/include/opensm/osm_log.h b/branches/MTHCA/ulp/opensm/user/include/opensm/osm_log.h index 55e1695c..869297e6 100644 --- a/branches/MTHCA/ulp/opensm/user/include/opensm/osm_log.h +++ b/branches/MTHCA/ulp/opensm/user/include/opensm/osm_log.h @@ -69,16 +69,20 @@ BEGIN_C_DECLS #ifndef PRIx64 #if __WORDSIZE == 64 -#define __PRI64_PREFIX "l" -#else -#define __PRI64_PREFIX "L" -#endif +#define PRId64 "I64d" +#define PRIx64 "I64x" +#define PRIo64 "I64o" +#define PRIu64 "I64u" +#else // __WORDSIZE +#define PRId64 "I64d" +#define PRIx64 "I64x" +#define PRIo64 "I64o" +#define PRIu64 "I64u" + +#endif //__WORDSIZE +#endif // PRIx64 + -#define PRId64 __PRI64_PREFIX"d" -#define PRIo64 __PRI64_PREFIX"o" -#define PRIu64 __PRI64_PREFIX"u" -#define PRIx64 __PRI64_PREFIX"x" -#endif #define LOG_ENTRY_SIZE_MAX 4096 #define BUF_SIZE LOG_ENTRY_SIZE_MAX diff --git a/branches/MTHCA/ulp/opensm/user/include/opensm/osm_req.h b/branches/MTHCA/ulp/opensm/user/include/opensm/osm_req.h index 72e4ff00..43c3aa4b 100644 --- a/branches/MTHCA/ulp/opensm/user/include/opensm/osm_req.h +++ b/branches/MTHCA/ulp/opensm/user/include/opensm/osm_req.h @@ -305,6 +305,7 @@ osm_req_set( IN const osm_req_t* const p_req, 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, @@ -320,6 +321,9 @@ osm_req_set( * 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. * diff --git a/branches/MTHCA/ulp/opensm/user/libopensm/osm_helper.c b/branches/MTHCA/ulp/opensm/user/libopensm/osm_helper.c index 1fb2a382..bac57b39 100644 --- a/branches/MTHCA/ulp/opensm/user/libopensm/osm_helper.c +++ b/branches/MTHCA/ulp/opensm/user/libopensm/osm_helper.c @@ -608,6 +608,7 @@ osm_dump_port_info( "\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" @@ -644,6 +645,7 @@ osm_dump_port_info( 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 @@ -959,7 +961,7 @@ osm_dump_service_record( if( osm_log_is_active( p_log, log_level ) ) { sprintf(buf_service_key, - "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + "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], @@ -1382,9 +1384,9 @@ osm_dump_notice( osm_log( p_log, log_level, "Generic Notice dump:\n" - "\t\t\t\ttype....................0x%02X\n" - "\t\t\t\tprod_type...............%u\n" - "\t\t\t\ttrap_num................%u\n%s" + "\t\t\t\ttype.....................0x%02X\n" + "\t\t\t\tprod_type................%u\n" + "\t\t\t\ttrap_num.................%u\n%s" "", ib_notice_get_type(p_ntci), cl_ntoh32(ib_notice_get_prod_type(p_ntci)), @@ -1396,9 +1398,9 @@ osm_dump_notice( { osm_log( p_log, log_level, "Vendor Notice dump:\n" - "\t\t\t\ttype....................0x%04x\n" - "\t\t\t\tvendor..................%u\n" - "\t\t\t\tdevice_id...............%u\n" + "\t\t\t\ttype.....................0x%04x\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)), @@ -1845,6 +1847,9 @@ osm_get_node_type_str_fixed_width( #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 /********************************************************************** **********************************************************************/ @@ -1853,12 +1858,15 @@ osm_get_manufacturer_str( IN uint64_t const guid_ho ) { static const char* intel_str = "Intel "; - static const char* mellanox_str = "Mellanox "; + static const char* mellanox_str = "Mellanox "; static const char* redswitch_str = "Redswitch "; - static const char* silverstorm_str = "SilverStorm "; + 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* unknown_str = "Unknown "; switch( (uint32_t)(guid_ho >> (5 * 8)) ) @@ -1878,6 +1886,12 @@ osm_get_manufacturer_str( 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 ); default: return( unknown_str ); } diff --git a/branches/MTHCA/ulp/opensm/user/libvendor/winosm_common.c b/branches/MTHCA/ulp/opensm/user/libvendor/winosm_common.c index 9523beab..a12410ab 100644 --- a/branches/MTHCA/ulp/opensm/user/libvendor/winosm_common.c +++ b/branches/MTHCA/ulp/opensm/user/libvendor/winosm_common.c @@ -74,6 +74,7 @@ int getopt_long_only(int argc, char *const*argv, if (strcmp (tok, longopts[i].name) == 0) { /* We have a match */ + if (longindex != NULL ) *longindex = i; if (longopts[i].flag != NULL) { diff --git a/branches/MTHCA/ulp/opensm/user/opensm/SOURCES b/branches/MTHCA/ulp/opensm/user/opensm/SOURCES index 66a0bedf..29324d00 100644 --- a/branches/MTHCA/ulp/opensm/user/opensm/SOURCES +++ b/branches/MTHCA/ulp/opensm/user/opensm/SOURCES @@ -1,9 +1,4 @@ -!if $(FREEBUILD) TARGETNAME=opensm -!else -TARGETNAME=opensmd -!endif - !if !defined(WINIBHOME) WINIBHOME=..\..\..\.. diff --git a/branches/MTHCA/ulp/opensm/user/opensm/main.c b/branches/MTHCA/ulp/opensm/user/opensm/main.c index 8059ec50..facbd6f4 100644 --- a/branches/MTHCA/ulp/opensm/user/opensm/main.c +++ b/branches/MTHCA/ulp/opensm/user/opensm/main.c @@ -454,7 +454,7 @@ main( boolean_t cache_options = FALSE; char *ignore_guids_file_name = NULL; uint32_t val; - const char * const short_option = "i:f:ed:g:l:s:t:vVhorc"; + const char * const short_option = "i:f:ed:g:l:s:t:a:uvVhorc"; /* In the array below, the 2nd parameter specified the number diff --git a/branches/MTHCA/ulp/opensm/user/opensm/osm_lid_mgr.c b/branches/MTHCA/ulp/opensm/user/opensm/osm_lid_mgr.c index f4c25f72..c42ab7d5 100644 --- a/branches/MTHCA/ulp/opensm/user/opensm/osm_lid_mgr.c +++ b/branches/MTHCA/ulp/opensm/user/opensm/osm_lid_mgr.c @@ -56,7 +56,7 @@ * 1. During initialization: * 1.1 initialize the guid2lid database domain. * 1.2 if reassign_lid is not set: - * 1.2.1 read the persistant data for the domain. + * 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: @@ -205,7 +205,7 @@ __osm_lid_mgr_validate_db( /* check that if the lids define a range - that range is valid for the current LMC mask */ osm_log( p_mgr->p_log, OSM_LOG_ERROR, - "__osm_lid_mgr_validate_db: ERR 0313: " + "__osm_lid_mgr_validate_db: ERR 0313: " "LID range [0x%x:0x%x] for guid:0x%016" PRIx64 " is not aligned acording to mask:0x%04x.\n", min_lid, max_lid, p_item->guid, lmc_mask @@ -221,7 +221,7 @@ __osm_lid_mgr_validate_db( ( cl_ptr_vector_get( &p_mgr->used_lids, lid ) ) ) { osm_log( p_mgr->p_log, OSM_LOG_ERROR, - "__osm_lid_mgr_validate_db: ERR 0314: " + "__osm_lid_mgr_validate_db: ERR 0314: " "0x%04x for guid:0x%016" PRIx64 " was previously used.\n", lid, p_item->guid @@ -235,9 +235,9 @@ __osm_lid_mgr_validate_db( { if (osm_db_guid2lid_delete( p_mgr->p_g2l, p_item->guid )) osm_log( p_mgr->p_log, OSM_LOG_ERROR, - "__osm_lid_mgr_validate_db: ERR 0315: " + "__osm_lid_mgr_validate_db: ERR 0315: " "failed to delete entry for guid:0x%016" PRIx64 - " .\n", + ".\n", p_item->guid ); } @@ -287,8 +287,8 @@ osm_lid_mgr_init( if (! p_mgr->p_g2l) { osm_log( p_mgr->p_log, OSM_LOG_ERROR, - "osm_lid_mgr_init: ERR 0316: " - "Error initializing Guid-to-Lid persistant database.\n"); + "osm_lid_mgr_init: ERR 0316: " + "Error initializing Guid-to-Lid persistent database.\n"); status = IB_ERROR; goto Exit; } @@ -302,8 +302,8 @@ osm_lid_mgr_init( if (osm_db_restore(p_mgr->p_g2l)) { osm_log( p_mgr->p_log, OSM_LOG_ERROR, - "osm_lid_mgr_init: ERR 0317: " - "Error restoring Guid-to-Lid persistant database.\n"); + "osm_lid_mgr_init: ERR 0317: " + "Error restoring Guid-to-Lid persistent database.\n"); status = IB_ERROR; goto Exit; } @@ -313,7 +313,7 @@ osm_lid_mgr_init( __osm_lid_mgr_validate_db(p_mgr); } -Exit: + Exit: OSM_LOG_EXIT( p_mgr->p_log ); return( status ); } @@ -334,7 +334,7 @@ __osm_lid_mgr_init_sweep( uint16_t max_defined_lid; uint16_t max_persistent_lid; uint16_t max_discovered_lid; - uint16_t lid, l; + uint16_t lid; uint16_t disc_min_lid; uint16_t disc_max_lid; uint16_t db_min_lid; @@ -346,16 +346,23 @@ __osm_lid_mgr_init_sweep( 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, __osm_lid_mgr_init_sweep ); - /* if we came out of standby we need to discard any previous guid 2 lid - info we might had */ + 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 */ if ( p_mgr->p_subn->coming_out_of_standby == TRUE ) { 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_mgr->used_lids, lid, NULL); + cl_ptr_vector_set(p_persistent_vec, lid, NULL); } /* we need to cleanup the empty ranges list */ @@ -370,9 +377,9 @@ __osm_lid_mgr_init_sweep( 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 on the first sweep and in re-assign lids mode - we should ignore all the available info and simply define one - hufe empty range */ + /* we if are in the first sweep and in re-assign 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 )) { @@ -385,7 +392,7 @@ __osm_lid_mgr_init_sweep( goto AfterScanningLids; } - /* go over all discvered ports and mark their entries */ + /* 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 ); @@ -395,13 +402,41 @@ __osm_lid_mgr_init_sweep( osm_port_get_lid_range_ho(p_port, &disc_min_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 ( osm_node_get_type( osm_port_get_parent_node( p_port ) ) != + IB_NODE_TYPE_SWITCH) + 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 - remove the entry */ + osm_log( p_mgr->p_log, OSM_LOG_DEBUG, + "__osm_lid_mgr_init_sweep: " + "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 + 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 @@ -431,7 +466,7 @@ __osm_lid_mgr_init_sweep( { 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)) + if ((lid <= max_persistent_lid) && cl_ptr_vector_get(p_persistent_vec, lid)) { osm_log( p_mgr->p_log, OSM_LOG_DEBUG, "__osm_lid_mgr_init_sweep: " @@ -439,61 +474,87 @@ __osm_lid_mgr_init_sweep( lid); is_free = FALSE; } - - /* check the discovered port if there is one */ - if ((lid < max_discovered_lid) && - (p_port = (osm_port_t *)cl_ptr_vector_get(p_discovered_vec, lid))) + else { - /* get the lid range of that port - but we know how many lids we - are about to assign to it */ - osm_port_get_lid_range_ho(p_port, &disc_min_lid, &disc_max_lid); - if ( osm_node_get_type( osm_port_get_parent_node( p_port ) ) != - IB_NODE_TYPE_SWITCH) - disc_max_lid = disc_min_lid + lmc_num_lids - 1; - - /* 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)) + /* check this is a discovered port */ + if (lid <= max_discovered_lid && (p_port = (osm_port_t *)cl_ptr_vector_get(p_discovered_vec, lid))) { - /* ok there is an asignment - is it the same ? */ - if ((disc_min_lid == db_min_lid) && (disc_max_lid == db_max_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, "__osm_lid_mgr_init_sweep: " - "[0x%04x,0x%04x] is not free as it was discovered " - " and mapped by the persistent db.\n", - disc_min_lid, disc_max_lid); - is_free = FALSE; + "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 { - osm_log( p_mgr->p_log, OSM_LOG_DEBUG, - "__osm_lid_mgr_init_sweep: " - "[0x%04x,0x%04x] is free as it was discovered" - " but mapped to range: [0x%x:0x%x] by the persistent db.\n", - disc_min_lid, disc_max_lid, db_min_lid, db_max_lid); - for (l = disc_min_lid; l <= disc_max_lid; l++) - cl_ptr_vector_set(p_discovered_vec, l, NULL); + /* 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 ( osm_node_get_type( osm_port_get_parent_node( p_port ) ) != + IB_NODE_TYPE_SWITCH) + { + 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, + "__osm_lid_mgr_init_sweep: " + "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, + "__osm_lid_mgr_init_sweep: " + "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; + } + } } } - else - { - osm_log( p_mgr->p_log, OSM_LOG_DEBUG, - "__osm_lid_mgr_init_sweep: " - "0x%04x is not free as it was discovered" - " and there is no persistent db entry for it.\n", - lid); - is_free = FALSE; - } - - /* if there is more then one lid on that port - and the discovered port - is going to retain its lids advance to the max lid */ - if (is_free == FALSE) - { - lid = disc_max_lid; - } } if (is_free) @@ -532,7 +593,14 @@ __osm_lid_mgr_init_sweep( { p_range = (osm_lid_mgr_range_t *)cl_malloc(sizeof(osm_lid_mgr_range_t)); - p_range->min_lid = 1; + /* + 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. + */ + p_range->min_lid = lid; } p_range->max_lid = p_mgr->p_subn->max_unicast_lid_ho - 1; cl_qlist_insert_tail( &p_mgr->free_ranges, &p_range->item ); @@ -667,9 +735,9 @@ __osm_lid_mgr_find_free_lid_range( /********************************************************************** **********************************************************************/ void - __osm_lid_mgr_cleanup_discovered_port_lid_range( - IN osm_lid_mgr_t* p_mgr, - IN osm_port_t *p_port ) +__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; @@ -861,7 +929,7 @@ __osm_lid_mgr_set_physp_pi( (port_num != 0) ) { /* - Switches ports that are not 0 - should not be set with the + Switch ports that are not numbered 0 - should not be set with the following attributes set later (during NO_CHANGE state in link mgr). */ if( osm_log_is_active( p_mgr->p_log, OSM_LOG_DEBUG ) ) @@ -1075,6 +1143,8 @@ __osm_lid_mgr_set_physp_pi( if ( ( p_mgr->p_subn->first_time_master_sweep == TRUE ) && ( (p_old_pi->capability_mask & IB_PORT_CAP_HAS_CLIENT_REREG) != 0 ) ) ib_port_info_set_client_rereg( p_pi, 1 ); + else + ib_port_info_set_client_rereg( p_pi, 0 ); /* We need to send the PortInfoSet request with the new sm_lid in the following cases: @@ -1093,6 +1163,7 @@ __osm_lid_mgr_set_physp_pi( status = osm_req_set( p_mgr->p_req, 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, @@ -1193,7 +1264,7 @@ osm_lid_mgr_process_sm( CL_PLOCK_EXCL_ACQUIRE( p_mgr->p_lock ); /* initialize the port_lid_tbl and empty ranges list following the - persistant db */ + persistent db */ __osm_lid_mgr_init_sweep( p_mgr ); if (p_mgr->p_subn->opt.pfn_ui_pre_lid_assign) @@ -1297,11 +1368,10 @@ osm_lid_mgr_process_subnet( /* the proc returns the fact it sent a set port info */ if (__osm_lid_mgr_set_physp_pi( p_mgr, p_physp, cl_hton16( min_lid_ho ))) p_mgr->send_set_reqs = TRUE; - } } /* all ports */ - /* store the guid to lid table in persistant db */ + /* store the guid to lid table in persistent db */ osm_db_store( p_mgr->p_g2l ); if ( p_mgr->send_set_reqs == FALSE ) diff --git a/branches/MTHCA/ulp/opensm/user/opensm/osm_link_mgr.c b/branches/MTHCA/ulp/opensm/user/opensm/osm_link_mgr.c index 469c5916..cf99298c 100644 --- a/branches/MTHCA/ulp/opensm/user/opensm/osm_link_mgr.c +++ b/branches/MTHCA/ulp/opensm/user/opensm/osm_link_mgr.c @@ -352,6 +352,7 @@ osm_link_mgr_set_physp_pi( status = osm_req_set( p_mgr->p_req, osm_physp_get_dr_path_ptr( p_physp ), payload, + sizeof(payload), IB_MAD_ATTR_PORT_INFO, cl_hton32(port_num), CL_DISP_MSGID_NONE, diff --git a/branches/MTHCA/ulp/opensm/user/opensm/osm_mcast_mgr.c b/branches/MTHCA/ulp/opensm/user/opensm/osm_mcast_mgr.c index b152fc3e..4401c96b 100644 --- a/branches/MTHCA/ulp/opensm/user/opensm/osm_mcast_mgr.c +++ b/branches/MTHCA/ulp/opensm/user/opensm/osm_mcast_mgr.c @@ -485,6 +485,7 @@ __osm_mcast_mgr_set_tbl( status = osm_req_set( p_mgr->p_req, p_path, (void*)block, + sizeof(block), IB_MAD_ATTR_MCAST_FWD_TBL, cl_hton32( block_id_ho ), CL_DISP_MSGID_NONE, diff --git a/branches/MTHCA/ulp/opensm/user/opensm/osm_port_info_rcv.c b/branches/MTHCA/ulp/opensm/user/opensm/osm_port_info_rcv.c index f11a3a71..8ca5b321 100644 --- a/branches/MTHCA/ulp/opensm/user/opensm/osm_port_info_rcv.c +++ b/branches/MTHCA/ulp/opensm/user/opensm/osm_port_info_rcv.c @@ -136,7 +136,7 @@ __osm_pi_rcv_process_endport( { osm_log( p_rcv->p_log, OSM_LOG_VERBOSE, "__osm_pi_rcv_process_endport: " - "Setting endport minimal rate to:%u defiend by port:0x%" + "Setting endport minimal rate to:%u defined by port:0x%" PRIx64 ".\n", rate, cl_ntoh64( port_guid ) ); @@ -241,7 +241,7 @@ __osm_pi_rcv_process_switch_port( /* 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 managment port. + 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 in on the switch, @@ -405,6 +405,7 @@ void osm_pkey_get_tables( osm_dr_path_t path; uint8_t port_num; uint16_t block_num, max_blocks; + uint32_t attr_mod_ho; osm_switch_t* p_switch; OSM_LOG_ENTER( p_log, osm_physp_has_pkey ); @@ -430,7 +431,7 @@ void osm_pkey_get_tables( else { /* This is a switch, and not a management port. The maximum blocks is defined - on the switch info partition enforcement cap. */ + in the switch info partition enforcement cap. */ p_switch = osm_get_switch_by_guid(p_subn, p_node->node_info.node_guid); if (! p_switch) @@ -441,16 +442,25 @@ void osm_pkey_get_tables( cl_ntoh64(p_node->node_info.node_guid) ); goto Exit; } + + /* bail out if this is a switch with no partition enforcement capability */ + if (cl_ntoh16(p_switch->switch_info.enforce_cap) == 0) + goto Exit; + max_blocks = (cl_ntoh16(p_switch->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( p_req, &path, IB_MAD_ATTR_P_KEY_TABLE, - cl_hton32(block_num | (port_num << 16) ), + cl_hton32(attr_mod_ho), CL_DISP_MSGID_NONE, &context ); diff --git a/branches/MTHCA/ulp/opensm/user/opensm/osm_req.c b/branches/MTHCA/ulp/opensm/user/opensm/osm_req.c index 908bb9f8..7306a9df 100644 --- a/branches/MTHCA/ulp/opensm/user/opensm/osm_req.c +++ b/branches/MTHCA/ulp/opensm/user/opensm/osm_req.c @@ -207,6 +207,7 @@ osm_req_set( IN const osm_req_t* const p_req, 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, @@ -283,7 +284,7 @@ osm_req_set( p_madw->context = *p_context; cl_memcpy( osm_madw_get_smp_ptr( p_madw )->data, - p_payload, IB_SMP_DATA_SIZE ); + p_payload, payload_size ); osm_vl15_post( p_req->p_vl15, p_madw ); diff --git a/branches/MTHCA/ulp/opensm/user/opensm/osm_sm_mad_ctrl.c b/branches/MTHCA/ulp/opensm/user/opensm/osm_sm_mad_ctrl.c index c01b808b..9ae897cf 100644 --- a/branches/MTHCA/ulp/opensm/user/opensm/osm_sm_mad_ctrl.c +++ b/branches/MTHCA/ulp/opensm/user/opensm/osm_sm_mad_ctrl.c @@ -102,10 +102,11 @@ __osm_sm_mad_ctrl_retire_trans_mad( "__osm_sm_mad_ctrl_retire_trans_mad: ERR 3120: " "Trying to dec qp0_mads_outstanding=0. " "Problem with transaction mgr!\n"); + outstanding = 0; } else { - cl_atomic_dec( &p_ctrl->p_stats->qp0_mads_outstanding ); + outstanding = cl_atomic_dec( &p_ctrl->p_stats->qp0_mads_outstanding ); } if( osm_log_is_active( p_ctrl->p_log, OSM_LOG_DEBUG ) ) @@ -116,21 +117,6 @@ __osm_sm_mad_ctrl_retire_trans_mad( p_ctrl->p_stats->qp0_mads_outstanding ); } - /* - Acquire the lock non-exclusively. - Other modules that send MADs grab this lock exclusively. - These modules that are in the process of sending MADs - will hold the lock until they finish posting all the MADs - they plan to send. While the other module is sending MADs - the outstanding count may temporarily go to zero. - Thus, by grabbing the lock ourselves, we get an accurate - view of whether or not the number of outstanding MADs is - really zero. - */ - CL_PLOCK_ACQUIRE( p_ctrl->p_lock ); - outstanding = p_ctrl->p_stats->qp0_mads_outstanding; - CL_PLOCK_RELEASE( p_ctrl->p_lock ); - if( outstanding == 0 ) { /* diff --git a/branches/MTHCA/ulp/opensm/user/opensm/osm_state_mgr.c b/branches/MTHCA/ulp/opensm/user/opensm/osm_state_mgr.c index df29764d..3d94c45d 100644 --- a/branches/MTHCA/ulp/opensm/user/opensm/osm_state_mgr.c +++ b/branches/MTHCA/ulp/opensm/user/opensm/osm_state_mgr.c @@ -1665,6 +1665,7 @@ __osm_state_mgr_send_handover( status = osm_req_set( p_mgr->p_req, osm_physp_get_dr_path_ptr ( osm_port_get_default_phys_ptr( p_port ) ), payload, + sizeof(payload), IB_MAD_ATTR_SM_INFO, IB_SMINFO_ATTR_MOD_HANDOVER, CL_DISP_MSGID_NONE, &context ); diff --git a/branches/MTHCA/ulp/opensm/user/opensm/osm_sw_info_rcv.c b/branches/MTHCA/ulp/opensm/user/opensm/osm_sw_info_rcv.c index 5ac945df..51762ae3 100644 --- a/branches/MTHCA/ulp/opensm/user/opensm/osm_sw_info_rcv.c +++ b/branches/MTHCA/ulp/opensm/user/opensm/osm_sw_info_rcv.c @@ -81,6 +81,7 @@ __osm_si_rcv_clear_sc_bit( status = osm_req_set( p_rcv->p_req, osm_node_get_any_dr_path_ptr( p_node ), payload, + sizeof(payload), IB_MAD_ATTR_SWITCH_INFO, 0, CL_DISP_MSGID_NONE, diff --git a/branches/MTHCA/ulp/opensm/user/opensm/osm_ucast_mgr.c b/branches/MTHCA/ulp/opensm/user/opensm/osm_ucast_mgr.c index 796eb940..2a93e9ca 100644 --- a/branches/MTHCA/ulp/opensm/user/opensm/osm_ucast_mgr.c +++ b/branches/MTHCA/ulp/opensm/user/opensm/osm_ucast_mgr.c @@ -847,6 +847,7 @@ __osm_ucast_mgr_set_table( status = osm_req_set( p_mgr->p_req, p_path, (uint8_t*)&si, + sizeof(si), IB_MAD_ATTR_SWITCH_INFO, 0, CL_DISP_MSGID_NONE, @@ -881,6 +882,7 @@ __osm_ucast_mgr_set_table( status = osm_req_set( p_mgr->p_req, p_path, block, + sizeof(block), IB_MAD_ATTR_LIN_FWD_TBL, cl_hton32( block_id_ho ), CL_DISP_MSGID_NONE, diff --git a/branches/MTHCA/ulp/opensm/user/opensm/osm_vl15intf.c b/branches/MTHCA/ulp/opensm/user/opensm/osm_vl15intf.c index ae382851..3eb14c54 100644 --- a/branches/MTHCA/ulp/opensm/user/opensm/osm_vl15intf.c +++ b/branches/MTHCA/ulp/opensm/user/opensm/osm_vl15intf.c @@ -178,28 +178,13 @@ __osm_vl15_poller( the cl_disp_post with OSM_SIGNAL_NO_PENDING_TRANSACTION (in order to wake up the state mgr). */ - cl_atomic_dec( &p_vl->p_stats->qp0_mads_outstanding ); + outstanding = cl_atomic_dec( &p_vl->p_stats->qp0_mads_outstanding ); osm_log( p_vl->p_log, OSM_LOG_DEBUG, "__osm_vl15_poller: " "%u QP0 MADs outstanding.\n", p_vl->p_stats->qp0_mads_outstanding ); - /* - Acquire the lock non-exclusively. - Other modules that send MADs grab this lock exclusively. - These modules that are in the process of sending MADs - will hold the lock until they finish posting all the MADs - they plan to send. While the other module is sending MADs - the outstanding count may temporarily go to zero. - Thus, by grabbing the lock ourselves, we get an accurate - view of whether or not the number of outstanding MADs is - really zero. - */ - CL_PLOCK_ACQUIRE( p_vl->p_lock ); - outstanding = p_vl->p_stats->qp0_mads_outstanding; - CL_PLOCK_RELEASE( p_vl->p_lock ); - if( outstanding == 0 ) { /* diff --git a/branches/MTHCA/ulp/srp/kernel/ib_srp.inf b/branches/MTHCA/ulp/srp/kernel/ib_srp.inf index 6c68d6f3..d9d3f85d 100644 --- a/branches/MTHCA/ulp/srp/kernel/ib_srp.inf +++ b/branches/MTHCA/ulp/srp/kernel/ib_srp.inf @@ -1,13 +1,12 @@ -; SilverStorm Technologies InfiniBand SRP Miniport. +; OpenIB InfiniBand SRP Miniport. ; Copyright 2005 SilverStorm Technologies all Rights Reserved. [Version] Signature="$Windows NT$" Class=SCSIAdapter ClassGUID={4D36E97B-E325-11CE-BFC1-08002BE10318} -Provider=%SST% -CatalogFile=ibsrp.cat -DriverVer=09/01/2005,3.0.0036.0 +Provider=%OPENIB% +DriverVer=01/12/2006,1.0.0000.213 ; ================= Device Install section ===================== @@ -28,7 +27,7 @@ DefaultDestDir=12 ibsrp.sys=1 [Manufacturer] -%SST% = SRP.DeviceSection,ntx86...0x1,ntx86,ntamd64,ntia64 +%OPENIB% = SRP.DeviceSection,ntx86...0x1,ntx86,ntamd64,ntia64 [SRP.DeviceSection] ; empty since we don't support W9x/Me @@ -103,10 +102,10 @@ HKR,,EventMessageFile,0x00020000,"%%SystemRoot%%\System32\IoLogMsg.dll" HKR,,TypesSupported,0x00010001,7 [Strings] -SST = "SilverStorm Technologies" +OPENIB = "OpenIB Alliance" SRP.DeviceDesc = "InfiniBand SRP Miniport" -SRP.ServiceDesc = "SilverStorm InfiniBand SRP Miniport" -DiskId = "SilverStorm InfiniBand SRP installation disk" +SRP.ServiceDesc = "OpenIB InfiniBand SRP Miniport" +DiskId = "OpenIB InfiniBand SRP installation disk" InternalBus = 0 PNPBus = 15 SPSVCINST_NULL = 0x0 diff --git a/branches/MTHCA/ulp/wsd/user/ib_cm.c b/branches/MTHCA/ulp/wsd/user/ib_cm.c index 7c28c0b0..b77376a8 100644 --- a/branches/MTHCA/ulp/wsd/user/ib_cm.c +++ b/branches/MTHCA/ulp/wsd/user/ib_cm.c @@ -156,12 +156,14 @@ cm_req_callback( { int ret; - wait_cq_drain( socket_info ); - /* Non-blocking cancel since we're in CM callback context */ ib_cm_cancel( socket_info->listen.handle, NULL ); socket_info->listen.handle = NULL; + cl_spinlock_release( &socket_info->mutex ); + + wait_cq_drain( socket_info ); + cl_spinlock_acquire( &socket_info->mutex ); ret = ib_accept( socket_info, p_cm_req_rec ); if( ret ) { diff --git a/branches/MTHCA/ulp/wsd/user/ibsp_duplicate.c b/branches/MTHCA/ulp/wsd/user/ibsp_duplicate.c index 6a1d0adc..1838054d 100644 --- a/branches/MTHCA/ulp/wsd/user/ibsp_duplicate.c +++ b/branches/MTHCA/ulp/wsd/user/ibsp_duplicate.c @@ -41,9 +41,15 @@ static void create_name( OUT char *fname, IN const DWORD dwProcessId, - IN const DWORD identifier ) + IN const GUID *p_guid ) { - sprintf( fname, "SilverStorm-WSD-%08lx-%08lx", dwProcessId, identifier ); + sprintf( fname, "Global\\OpenIB-WSD-%08lx-" + "%08lx-%04hx-%04hx-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x", + dwProcessId, p_guid->Data1, p_guid->Data2, p_guid->Data3, + (int)p_guid->Data4[0], (int)p_guid->Data4[1], + (int)p_guid->Data4[2], (int)p_guid->Data4[3], + (int)p_guid->Data4[4], (int)p_guid->Data4[5], + (int)p_guid->Data4[6], (int)p_guid->Data4[7] ); } @@ -53,51 +59,19 @@ create_name( int setup_duplicate_socket( IN struct ibsp_socket_info *socket_info, - IN DWORD identifier ) + IN HANDLE h_dup_info ) { - char fname[100]; - HANDLE h = NULL; int ret, err; struct ibsp_duplicate_info *dup_info; ib_net64_t dest_port_guid; ib_path_rec_t path_rec; - CL_ASSERT( socket_info->socket_state == IBSP_CREATE ); - - fzprint(("%s():%d:0x%x:0x%x: socket=0x%p dwProcessId=0x%x\n", __FUNCTION__, - __LINE__, GetCurrentProcessId(), GetCurrentThreadId(), socket_info)); - + IBSP_ENTER( IBSP_DBG_DUP ); - /* Find the info created and shared by the previous controlling socket. */ - create_name( fname, GetCurrentProcessId(), identifier ); - - h = CreateFileMapping( INVALID_HANDLE_VALUE, // use paging file - NULL, // default security attributes - PAGE_READWRITE, // read access - 0, // size: high 32-bits - sizeof(struct ibsp_duplicate_info), // size: low 32-bits - fname ); // name of map object - if( h == NULL ) - { - IBSP_ERROR( ("CreateFileMapping failed with %d\n", GetLastError()) ); - ret = WSAENETDOWN; - goto err1; - } - - /* Make sure this file already existed. */ - if( GetLastError() != ERROR_ALREADY_EXISTS ) - { - IBSP_ERROR( ("not mapping for socket duplicate info\n") ); - ret = WSAENETDOWN; - goto err1; - } + CL_ASSERT( socket_info->socket_state == IBSP_CREATE ); /* Get a pointer to the file-mapped shared memory. */ - dup_info = MapViewOfFile( h, // object to map view of - FILE_MAP_WRITE, // read/write access - 0, // high offset: map from - 0, // low offset: beginning - 0 ); // default: map entire file + dup_info = MapViewOfFile( h_dup_info, FILE_MAP_READ, 0, 0, 0 ); if( dup_info == NULL ) { IBSP_ERROR( ("MapViewOfFile failed with %d\n", GetLastError()) ); @@ -109,10 +83,8 @@ setup_duplicate_socket( socket_info->local_addr = dup_info->local_addr; socket_info->socket_options = dup_info->socket_options; socket_info->duplicate.dwProcessId = dup_info->dwProcessId; - socket_info->duplicate.identifier = identifier; + socket_info->duplicate.identifier = dup_info->identifier; - /* Get the port info */ - /* Find the destination IP address */ socket_info->port = get_port_from_ip_address( dup_info->local_addr.sin_addr ); if( socket_info->port == NULL ) { @@ -185,145 +157,158 @@ err2: } else { + ret = 0; cl_spinlock_release( &socket_info->mutex ); } err1: - if( h ) - CloseHandle( h ); - if( socket_info->h_event ) { CloseHandle( socket_info->h_event ); socket_info->h_event = NULL; } - IBSP_EXIT( IBSP_DBG_CONN ); + CloseHandle( h_dup_info ); + + IBSP_EXIT( IBSP_DBG_DUP ); return ret; } -/* - * This function is called by the previous controlling process. - * Called with the socket_info->mutex held. - */ -int -prepare_duplicate_socket( - IN struct ibsp_socket_info *socket_info, - IN DWORD dwProcessId ) +/* Function: IBSPDuplicateSocket + + Description: + This function provides a WSAPROTOCOL_INFOW structure which can be passed + to another process to open a handle to the same socket. First we need + to translate the user socket into the provider socket and call the underlying + WSPDuplicateSocket. Note that the lpProtocolInfo structure passed into us + is an out parameter only! +*/ +int WSPAPI +IBSPDuplicateSocket( + SOCKET s, + DWORD dwProcessId, + LPWSAPROTOCOL_INFOW lpProtocolInfo, + LPINT lpErrno ) { + struct ibsp_socket_info *socket_info = (struct ibsp_socket_info *)s; struct ibsp_duplicate_info *dup_info = NULL; - int i; - DWORD identifier = 0; + char fname[100]; + GUID guid; + HANDLE h_dup_info, h_target_process, h_target_dup_info; struct disconnect_reason reason; - fzprint(("%s():%d:0x%x:0x%x: socket=0x%p dwProcessId=0x%x \n", __FUNCTION__, - __LINE__, GetCurrentProcessId(), - GetCurrentThreadId(), socket_info, dwProcessId)); + IBSP_ENTER( IBSP_DBG_DUP ); + + IBSP_TRACE4( IBSP_DBG_DUP, + ("Duplicating socket=0x%p to dwProcessId=0x%x \n", + socket_info, dwProcessId) ); + + cl_spinlock_acquire( &socket_info->mutex ); + if( socket_info->socket_state != IBSP_CONNECTED ) + { + cl_spinlock_release( &socket_info->mutex ); + IBSP_TRACE_EXIT( IBSP_DBG_DUP, + ("Socket state not IBSP_CONNECTED, state=%s.\n", + IBSP_SOCKET_STATE_STR( socket_info->socket_state )) ); + *lpErrno = WSAENOTCONN; + return SOCKET_ERROR; + } - /* First, flush all the receive buffers. There should be no send/rdma buffers left. */ - CL_ASSERT( socket_info->socket_state == IBSP_CONNECTED ); IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_DUPLICATING_OLD ); /* We changed the state - remove from connection map. */ ibsp_conn_remove( socket_info ); - /* We might have a left-over from the previous duplicate. */ - if( socket_info->duplicate.mmap_handle != NULL ) + cl_spinlock_release( &socket_info->mutex ); + + /* Create a GUID to use as unique identifier for this duplication. */ + UuidCreate( &guid ); + create_name( fname, dwProcessId, &guid ); + + h_dup_info = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, + PAGE_READWRITE, 0, sizeof(struct ibsp_duplicate_info), fname ); + if( !h_dup_info ) + { + IBSP_ERROR_EXIT( + ("CreateFileMapping for %s failed with %d\n", + fname, GetLastError()) ); + *lpErrno = WSAENETDOWN; + return SOCKET_ERROR; + } + + /* Get a pointer to the file-mapped shared memory. */ + dup_info = MapViewOfFile( h_dup_info, FILE_MAP_WRITE, 0, 0, 0 ); + if( !dup_info ) { - CloseHandle( socket_info->duplicate.mmap_handle ); - socket_info->duplicate.mmap_handle = NULL; + IBSP_ERROR_EXIT( + ("MapViewOfFile failed with %d\n", GetLastError()) ); + CloseHandle( h_dup_info ); + *lpErrno = WSAENETDOWN; + return SOCKET_ERROR; } /* - * Share this socket_info so the next-controlling process can get the necessary - * information to create the duplicated socket. Ensure a unique identifier. + * Store addressing information so that the duplicating + * process can reconnect. */ - for( i = 0; i < 50; i++ ) + dup_info->identifier = guid; + dup_info->socket_options = socket_info->socket_options; + dup_info->peer_addr = socket_info->peer_addr; + dup_info->local_addr = socket_info->local_addr; + dup_info->dwProcessId = dwProcessId; + + /* Release the reference on the underlying file */ + UnmapViewOfFile( dup_info ); + + /* Open the target process. */ + h_target_process = OpenProcess( PROCESS_DUP_HANDLE, FALSE, dwProcessId ); + if( !h_target_process ) { - char fname[100]; - GUID guid; - - /* Create a GUID and collapse it into 32 bits. */ - UuidCreate( &guid ); - identifier = guid.Data1 ^ (guid.Data2 << 16 | guid.Data3) ^ - (guid.Data4[7] << 24 | guid.Data4[6] << 16 | guid.Data4[5] << 8 | guid. - Data4[4]) ^ (guid.Data4[3] << 24 | guid.Data4[2] << 16 | guid. - Data4[1] << 8 | guid.Data4[0]); - - create_name( fname, dwProcessId, identifier ); - - socket_info->duplicate.mmap_handle = CreateFileMapping( INVALID_HANDLE_VALUE, // use paging file - NULL, // default security attributes - PAGE_READWRITE, // read access - 0, // size: high 32-bits - sizeof(struct ibsp_duplicate_info), // size: low 32-bits - fname ); // name of map object - - if( socket_info->duplicate.mmap_handle == NULL ) - { - IBSP_ERROR_EXIT( - ("CreateFileMapping failed with %d\n", GetLastError()) ); - return WSAENETDOWN; - } - - /* Make sure this identifier is unique for that process. */ - if( GetLastError() == ERROR_ALREADY_EXISTS ) - { - CloseHandle( socket_info->duplicate.mmap_handle ); - socket_info->duplicate.mmap_handle = NULL; - - /* Try again. */ - continue; - } - - /* Get a pointer to the file-mapped shared memory. */ - dup_info = MapViewOfFile( socket_info->duplicate.mmap_handle, // object to map view of - FILE_MAP_WRITE, // read/write access - 0, // high offset: map from - 0, // low offset: beginning - 0 ); // default: map entire file - if( dup_info == NULL ) - { - IBSP_ERROR_EXIT( - ("MapViewOfFile failed with %d\n", GetLastError()) ); - CloseHandle( socket_info->duplicate.mmap_handle ); - socket_info->duplicate.mmap_handle = NULL; - return WSAENETDOWN; - } + IBSP_ERROR_EXIT( + ("OpenProcess failed with %d\n", GetLastError()) ); + CloseHandle( h_dup_info ); + *lpErrno = WSAENETDOWN; + return SOCKET_ERROR; } - if( dup_info == NULL ) + if( !DuplicateHandle( GetCurrentProcess(), h_dup_info, + h_target_process, &h_target_dup_info, 0, TRUE, + DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS ) ) { - IBSP_ERROR_EXIT( ("failed to get a unique identifier\n") ); - CloseHandle( socket_info->duplicate.mmap_handle ); - socket_info->duplicate.mmap_handle = NULL; - return WSAENETDOWN; + IBSP_ERROR_EXIT( + ("DuplicateHandle failed with %d\n", GetLastError()) ); + CloseHandle( h_target_process ); + *lpErrno = WSAENETDOWN; + return SOCKET_ERROR; } - socket_info->duplicate.identifier = identifier; + CloseHandle( h_target_process ); + + CL_ASSERT( !((ULONG_PTR)h_target_dup_info >> 32) ); + lpProtocolInfo->dwProviderReserved = (DWORD)(ULONG_PTR)h_target_dup_info; + + socket_info->duplicate.identifier = guid; memset( &reason, 0, sizeof(reason) ); reason.type = DISC_DUPLICATING; - reason.duplicating.identifier = identifier; + reason.duplicating.identifier = guid; reason.duplicating.dwProcessId = dwProcessId; - cl_spinlock_release( &socket_info->mutex ); + /* + * Flush all the receive buffers. There should be no + * send/rdma buffers left. + */ ib_disconnect( socket_info, &reason ); - cl_spinlock_acquire( &socket_info->mutex ); wait_cq_drain( socket_info ); + cl_spinlock_acquire( &socket_info->mutex ); ib_destroy_socket( socket_info ); - - /* Put enough info in dup_info so that the remote socket can recreate the connection. */ - dup_info->port_guid = socket_info->port->guid; - dup_info->socket_options = socket_info->socket_options; - dup_info->peer_addr = socket_info->peer_addr; - dup_info->local_addr = socket_info->local_addr; - dup_info->dwProcessId = dwProcessId; + cl_spinlock_release( &socket_info->mutex ); /* And that's it */ - IBSP_EXIT( IBSP_DBG_CONN ); + IBSP_EXIT( IBSP_DBG_DUP ); + *lpErrno = 0; return 0; } diff --git a/branches/MTHCA/ulp/wsd/user/ibsp_iblow.c b/branches/MTHCA/ulp/wsd/user/ibsp_iblow.c index ca682509..87c318e1 100644 --- a/branches/MTHCA/ulp/wsd/user/ibsp_iblow.c +++ b/branches/MTHCA/ulp/wsd/user/ibsp_iblow.c @@ -90,8 +90,18 @@ complete_wq( * GetOverlappedResult() even if we call lpWPUCompleteOverlappedRequest() */ if( wc->wc_type == IB_WC_RECV ) + { lpOverlapped->InternalHigh = wc->length; +#ifdef IBSP_LOGGING + cl_spinlock_acquire( &socket_info->recv_lock ); + DataLogger_WriteData(&socket_info->RecvDataLogger, + p_recv_wr->idx, (void * __ptr64)p_recv_wr->ds_array[0].vaddr, + wc->length); + cl_spinlock_release( &socket_info->recv_lock ); +#endif + } + lpOverlapped->OffsetHigh = 0; break; @@ -127,6 +137,7 @@ complete_wq( cl_spinlock_release( &socket_info->recv_lock ); cl_spinlock_release( &socket_info->mutex ); + p_io_info->p_ov = NULL; IBSP_EXIT( IBSP_DBG_IO ); return; } @@ -269,12 +280,6 @@ complete_wq( g_ibsp.overlap_h1_comp_count, g_ibsp.send_count, g_ibsp.recv_count)); #endif - IBSP_TRACE1( IBSP_DBG_IO, - ("Calling lpWPUCompleteOverlappedRequest: " - "socket=%p, ov=%p OffsetHigh=%d InternalHigh=%d hEvent=%p\n", - socket_info, lpOverlapped, lpOverlapped->OffsetHigh, - lpOverlapped->InternalHigh, lpOverlapped->hEvent) ); - p_io_info->p_ov = lpOverlapped; cl_atomic_inc( &socket_info->ref_cnt ); } @@ -372,8 +377,11 @@ ib_cq_comp( if( info[i].p_ov ) { IBSP_TRACE1( IBSP_DBG_IO, - ("Calling WPUCompleteOverlappedRequest for ov=%p\n", - info[i].p_ov) ); + ("Calling lpWPUCompleteOverlappedRequest: " + "socket=%p, ov=%p OffsetHigh=%d " + "InternalHigh=%d hEvent=%p\n", + info[i].p_socket, info[i].p_ov, info[i].p_ov->OffsetHigh, + info[i].p_ov->InternalHigh, info[i].p_ov->hEvent) ); ret = g_ibsp.up_call_table.lpWPUCompleteOverlappedRequest( info[i].p_socket->switch_socket, info[i].p_ov, @@ -438,7 +446,7 @@ ib_cq_thread( } /* - * TODO: By rearanging thread creation and cq creation, this check + * TODO: By rearranging thread creation and cq creation, this check * may be eliminated. */ if( cq_tinfo->cq != NULL ) @@ -515,7 +523,6 @@ ib_alloc_cq_tinfo( cq_tinfo->hca = hca; cq_tinfo->ib_cq_thread_exit_wanted = FALSE; - /* Create a cleanup thread */ cq_tinfo->ib_cq_thread = CreateThread( NULL, 0, ib_cq_thread, cq_tinfo, 0, (LPDWORD)&cq_tinfo->ib_cq_thread_id ); if( cq_tinfo->ib_cq_thread == NULL ) @@ -533,9 +540,8 @@ ib_alloc_cq_tinfo( cq_create.pfn_comp_cb = NULL; cq_create.h_wait_obj = cq_tinfo->cq_waitobj; - status = ib_create_cq( hca->hca_handle, &cq_create, cq_tinfo, /* context */ - NULL, /* async handler */ - &cq_tinfo->cq ); + status = ib_create_cq( hca->hca_handle, &cq_create, cq_tinfo, + NULL, &cq_tinfo->cq ); if( status ) { ib_destroy_cq_tinfo( cq_tinfo ); @@ -856,9 +862,6 @@ ibsp_initialize(void) goto done; } - /* Populate IP list. */ - update_all_ip_addrs(); - STAT_INC( thread_num ); ret = 0; @@ -1095,12 +1098,6 @@ shutdown_and_destroy_socket_info( IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_CLOSED ); cl_spinlock_release( &socket_info->mutex ); - if( socket_info->duplicate.mmap_handle ) - { - CloseHandle( socket_info->duplicate.mmap_handle ); - socket_info->duplicate.mmap_handle = NULL; - } - if( socket_info->listen.handle ) { /* Stop listening and reject queued connections. */ @@ -1147,6 +1144,11 @@ shutdown_and_destroy_socket_info( ib_destroy_socket( socket_info ); +#ifdef IBSP_LOGGING + DataLogger_Shutdown(&socket_info->SendDataLogger); + DataLogger_Shutdown(&socket_info->RecvDataLogger); +#endif + /* Release the initial reference and clean up. */ deref_socket_info( socket_info ); diff --git a/branches/MTHCA/ulp/wsd/user/ibsp_ip.c b/branches/MTHCA/ulp/wsd/user/ibsp_ip.c index 0ad69600..532fd340 100644 --- a/branches/MTHCA/ulp/wsd/user/ibsp_ip.c +++ b/branches/MTHCA/ulp/wsd/user/ibsp_ip.c @@ -72,137 +72,101 @@ ip_cmp( } -static void AL_API -query_ip_address_callback( - ib_query_rec_t *p_query_rec ) -{ - struct ip_query_context *query_context = - (struct ip_query_context * __ptr64)p_query_rec->query_context; - cl_fmap_item_t *p_item; - - IBSP_ENTER( IBSP_DBG_HW ); - IBSP_TRACE( IBSP_DBG_HW, - ("status is %s\n", ib_get_err_str( p_query_rec->status )) ); - - if( p_query_rec->status == IB_SUCCESS ) - { - unsigned int i; - - IBSP_TRACE( IBSP_DBG_HW, ("got %d records\n", p_query_rec->result_cnt) ); - - for( i = 0; i < p_query_rec->result_cnt; i++ ) - { - ib_service_record_t *service_record = - ib_get_query_svc_rec(p_query_rec->p_result_mad, i); - struct ibsp_ip_addr *ip_addr; - - ip_addr = - HeapAlloc( g_ibsp.heap, HEAP_ZERO_MEMORY, sizeof(struct ibsp_ip_addr) ); - if( !ip_addr ) - { - IBSP_ERROR_EXIT( ("no memory\n") ); - break; - } - - /* Copy the IP address */ - ip_addr->ip_addr.S_un.S_addr = - *(ib_net32_t *) & service_record->service_data8[ATS_IPV4_OFFSET]; - ip_addr->p_port = query_context->p_port; - - p_item = cl_fmap_insert( - query_context->p_ip_map, ip_addr, &ip_addr->item ); - if( p_item != &ip_addr->item ) - { - /* Duplicate! Should never happen. */ - IBSP_ERROR( - ("Got duplicate addr %s\n", inet_ntoa( ip_addr->ip_addr )) ); - HeapFree( g_ibsp.heap, 0, ip_addr ); - continue; - } - - IBSP_TRACE( IBSP_DBG_HW, - (" Got addr %s\n", inet_ntoa( ip_addr->ip_addr )) ); - } - } - else if( p_query_rec->p_result_mad ) - { - IBSP_TRACE( IBSP_DBG_HW, ("SA status is %x\n", - p_query_rec->p_result_mad->p_mad_buf->status) ); - } - - if( p_query_rec->p_result_mad ) - ib_put_mad( p_query_rec->p_result_mad ); - - IBSP_EXIT( IBSP_DBG_HW ); -} - - /* Synchronously query the SA for an IP address. */ int query_ip_address( IN struct ibsp_port *p_port, IN OUT cl_fmap_t *p_ip_map ) { - ib_user_query_t user_query; - struct ip_query_context query_context; - ib_service_record_t service_record; - ib_query_handle_t query_handle; - ib_query_req_t query_req; - ib_api_status_t status; + IOCTL_IBAT_IP_ADDRESSES_IN in; + IOCTL_IBAT_IP_ADDRESSES_OUT *p_out; + DWORD size; + LONG i; + cl_fmap_item_t *p_item; IBSP_ENTER( IBSP_DBG_HW ); /* The list must be initialized and empty */ CL_ASSERT( !cl_fmap_count( p_ip_map ) ); - query_context.p_ip_map = p_ip_map; - query_context.p_port = p_port; + in.Version = IBAT_IOCTL_VERSION; + in.PortGuid = p_port->guid; - query_req.query_type = IB_QUERY_USER_DEFINED; - query_req.p_query_input = &user_query; - query_req.port_guid = p_port->guid; - query_req.timeout_ms = 500; /* 500ms timeout */ - query_req.retry_cnt = 4; /* retry 4 times */ - query_req.flags = IB_FLAGS_SYNC; - query_req.query_context = &query_context; - query_req.pfn_query_cb = query_ip_address_callback; + cl_spinlock_acquire( &g_ibsp.ip_mutex ); + if( g_ibsp.h_ibat_dev == INVALID_HANDLE_VALUE ) + { + g_ibsp.h_ibat_dev = CreateFileW( IBAT_WIN32_NAME, + GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); + } + cl_spinlock_release( &g_ibsp.ip_mutex ); - user_query.method = IB_MAD_METHOD_GETTABLE; - user_query.attr_id = IB_MAD_ATTR_SERVICE_RECORD; - user_query.attr_size = sizeof(ib_service_record_t); - user_query.comp_mask = IB_SR_COMPMASK_SGID | - IB_SR_COMPMASK_SPKEY | IB_SR_COMPMASK_SLEASE | IB_SR_COMPMASK_SNAME; + size = sizeof(IOCTL_IBAT_IP_ADDRESSES_OUT); - user_query.p_attr = &service_record; + do + { + p_out = HeapAlloc( g_ibsp.heap, 0, size ); - memset( &service_record, 0, sizeof(service_record) ); - service_record.service_pkey = IB_DEFAULT_PKEY; - ib_gid_set_default( &service_record.service_gid, p_port->guid ); - service_record.service_lease = 0xFFFFFFFF; - strcpy( (void *)service_record.service_name, ATS_NAME ); + if( !p_out ) + { + IBSP_ERROR_EXIT( ("Failed to allocate output buffer.\n") ); + return -1; + } + + if( !DeviceIoControl( g_ibsp.h_ibat_dev, IOCTL_IBAT_IP_ADDRESSES, + &in, sizeof(in), p_out, size, &size, NULL ) ) + { + HeapFree( g_ibsp.heap, 0, p_out ); + IBSP_ERROR_EXIT( + ("IOCTL_IBAT_IP_ADDRESSES for port %I64x failed (%x).\n", + p_port->guid, GetLastError()) ); + return -1; + } - fzprint(("%s():%d:0x%x:0x%x: Calling ib_query() pfn_query_cb=0x%p..\n", __FUNCTION__, - __LINE__, GetCurrentProcessId(), - GetCurrentThreadId(), query_req.pfn_query_cb)); + if( p_out->Size > size ) + { + size = p_out->Size; + HeapFree( g_ibsp.heap, 0, p_out ); + p_out = NULL; + } - status = ib_query( g_ibsp.al_handle, &query_req, &query_handle ); + } while( !p_out ); - if( status != IB_SUCCESS && status != IB_INVALID_GUID ) + IBSP_TRACE( IBSP_DBG_HW, ("Port %I64x has %d IP addresses.\n", + p_port->guid, p_out->AddressCount) ); + + for( i = 0; i < p_out->AddressCount; i++ ) { - IBSP_ERROR( ("ib_query failed (%d)\n", status) ); - CL_ASSERT( !cl_fmap_count( p_ip_map ) ); + struct ibsp_ip_addr *ip_addr; - IBSP_ERROR_EXIT( - ("Failed to build list of IP addr for port %016I64x\n", - CL_HTON64( p_port->guid )) ); + ip_addr = HeapAlloc( + g_ibsp.heap, 0, sizeof(struct ibsp_ip_addr) ); + if( !ip_addr ) + { + IBSP_ERROR_EXIT( ("no memory\n") ); + break; + } - IBSP_ERROR_EXIT( ("query_ip_address failed\n") ); - return 1; - } + /* Copy the IP address */ + ip_addr->ip_addr.S_un.S_addr = + *(ib_net32_t *) &p_out->Address[i].Address[ATS_IPV4_OFFSET]; + ip_addr->p_port = p_port; - fzprint(("%s():%d:0x%x:0x%x: Done calling ib_query() status=(%d)\n", __FUNCTION__, - __LINE__, GetCurrentProcessId(), GetCurrentThreadId(), status)); + p_item = cl_fmap_insert( p_ip_map, ip_addr, &ip_addr->item ); + if( p_item != &ip_addr->item ) + { + /* Duplicate! Should never happen. */ + IBSP_ERROR( + ("Got duplicate addr %s\n", inet_ntoa( ip_addr->ip_addr )) ); + HeapFree( g_ibsp.heap, 0, ip_addr ); + continue; + } + IBSP_TRACE( IBSP_DBG_HW, + ("Got addr %s\n", inet_ntoa( ip_addr->ip_addr )) ); + } + + HeapFree( g_ibsp.heap, 0, p_out ); IBSP_EXIT( IBSP_DBG_HW ); return 0; @@ -281,38 +245,6 @@ update_ip_addresses( return 0; } - -void -update_all_ip_addrs(void) -{ - cl_list_item_t *p_hca_item, *p_port_item; - struct ibsp_hca *p_hca; - struct ibsp_port *p_port; - - IBSP_ENTER( IBSP_DBG_HW ); - - cl_spinlock_acquire( &g_ibsp.hca_mutex ); - for( p_hca_item = cl_qlist_head( &g_ibsp.hca_list ); - p_hca_item != cl_qlist_end( &g_ibsp.hca_list ); - p_hca_item = cl_qlist_next( p_hca_item ) ) - { - p_hca = PARENT_STRUCT( p_hca_item, struct ibsp_hca, item ); - - cl_spinlock_acquire( &p_hca->port_lock ); - for( p_port_item = cl_qlist_head( &p_hca->port_list ); - p_port_item != cl_qlist_end( &p_hca->port_list ); - p_port_item = cl_qlist_next( p_port_item ) ) - { - p_port = PARENT_STRUCT( p_port_item, struct ibsp_port, item ); - update_ip_addresses( p_port ); - } - cl_spinlock_release( &p_hca->port_lock ); - } - cl_spinlock_release( &g_ibsp.hca_mutex ); - - IBSP_EXIT( IBSP_DBG_HW ); -} - /*--------------------------------------------------------------------------*/ /* @@ -603,6 +535,13 @@ build_ip_list( switch( num_ip ) { case 0: + cl_spinlock_acquire( &g_ibsp.ip_mutex ); + if( g_ibsp.h_ibat_dev != INVALID_HANDLE_VALUE ) + { + CloseHandle( g_ibsp.h_ibat_dev ); + g_ibsp.h_ibat_dev = INVALID_HANDLE_VALUE; + } + cl_spinlock_release( &g_ibsp.ip_mutex ); break; default: diff --git a/branches/MTHCA/ulp/wsd/user/ibspdebug.c b/branches/MTHCA/ulp/wsd/user/ibspdebug.c index a2e98c00..8460b6f5 100644 --- a/branches/MTHCA/ulp/wsd/user/ibspdebug.c +++ b/branches/MTHCA/ulp/wsd/user/ibspdebug.c @@ -161,3 +161,137 @@ debug_dump_overlapped( } #endif /* _DEBUG_ */ + + +#ifdef IBSP_LOGGING + +VOID DataLogger_Init( + DataLogger *pLogger, + char *prefix, + struct sockaddr_in *addr1, + struct sockaddr_in *addr2 ) +{ + HANDLE hFile; + HANDLE hMapFile; + + char Name[100]; + DWORD DataSize = 20 * 1024 * 1024; + + sprintf(Name,"c:\\%s_%d.%d.%d.%d_%d_%d.%d.%d.%d_%d", + prefix, + addr1->sin_addr.S_un.S_un_b.s_b1, + addr1->sin_addr.S_un.S_un_b.s_b2, + addr1->sin_addr.S_un.S_un_b.s_b3, + addr1->sin_addr.S_un.S_un_b.s_b4, + CL_NTOH16(addr1->sin_port), + addr2->sin_addr.S_un.S_un_b.s_b1, + addr2->sin_addr.S_un.S_un_b.s_b2, + addr2->sin_addr.S_un.S_un_b.s_b3, + addr2->sin_addr.S_un.S_un_b.s_b4, + CL_NTOH16(addr2->sin_port) + ); + + pLogger->NextPrint = NULL; + pLogger->BufferStart = NULL; + pLogger->ShutdownClosed = FALSE; + pLogger->ToatalPrinted = 0; + pLogger->TotalSize = DataSize; + + hFile = CreateFile( Name, GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, NULL ); + + if (hFile == INVALID_HANDLE_VALUE) + { + IBSP_ERROR( ("CreateFile failed with error %d\n", GetLastError()) ); + return; + } + + hMapFile = CreateFileMapping(hFile, // current file handle + NULL, // default security + PAGE_READWRITE, // read/write permission + 0, // max. object size + DataSize, // size of hFile + NULL); // name of mapping object + + CloseHandle( hFile ); + + if (hMapFile == NULL) + { + IBSP_ERROR( ("Could not create file mapping object.\n") ); + return; + } + + pLogger->BufferStart = MapViewOfFile(hMapFile, // handle to mapping object + FILE_MAP_ALL_ACCESS, // read/write permission + 0, // max. object size + 0, // size of hFile + 0); // map entire file + + CloseHandle( hMapFile ); + + if( pLogger->BufferStart == NULL ) + { + IBSP_ERROR( ("Could not MapViewOfFile.\n") ); + return; + } + + pLogger->NextPrint = pLogger->BufferStart; + cl_memclr(pLogger->NextPrint, DataSize); +} + + +VOID DataLogger_WriteData( + DataLogger *pLogger, + long Idx, + char *Data, + DWORD Len ) +{ + char MessageHeader[16]; + CL_ASSERT(Len < 64000); + CL_ASSERT(pLogger->ShutdownClosed == FALSE); + CL_ASSERT(Len < pLogger->TotalSize / 3); + + if( !pLogger->BufferStart ) + return; + + cl_memset( MessageHeader, 0xff, sizeof(MessageHeader) ); + cl_memcpy( MessageHeader+4, &Idx, sizeof(Idx) ); + cl_memcpy( MessageHeader+8, &Len, sizeof(Len) ); + + pLogger->ToatalPrinted += Len; + + if( pLogger->NextPrint + Len + (2 * sizeof (MessageHeader)) > + pLogger->BufferStart + pLogger->TotalSize ) + { + /* We will now zero the remaing of the buffer, and restart */ + cl_memclr( pLogger->NextPrint, + pLogger->TotalSize - (pLogger->NextPrint - pLogger->BufferStart) ); + pLogger->NextPrint = pLogger->BufferStart; + } + + /* Just simple copy */ + cl_memcpy( pLogger->NextPrint, MessageHeader, sizeof(MessageHeader) ); + pLogger->NextPrint += sizeof(MessageHeader); + + cl_memcpy( pLogger->NextPrint, Data, Len ); + pLogger->NextPrint += Len; + + /* + * Add the end marker but don't update NextPrint so the next message + * overwrites the previous message's end marker. + */ + cl_memset( pLogger->NextPrint, 0xff, sizeof(MessageHeader) ); +} + + +VOID DataLogger_Shutdown( + DataLogger *pLogger ) +{ + if( !pLogger->BufferStart ) + return; + + UnmapViewOfFile( pLogger->BufferStart ); +} + +#endif /* IBSP_LOGGING */ diff --git a/branches/MTHCA/ulp/wsd/user/ibspdebug.h b/branches/MTHCA/ulp/wsd/user/ibspdebug.h index 7d14e570..5fed257b 100644 --- a/branches/MTHCA/ulp/wsd/user/ibspdebug.h +++ b/branches/MTHCA/ulp/wsd/user/ibspdebug.h @@ -48,6 +48,7 @@ extern uint32_t gdbg_lvl; #define IBSP_DBG_NEV 0x00000400 /* network events */ #define IBSP_DBG_HW 0x00000800 /* Hardware */ #define IBSP_DBG_IO 0x00001000 /* Overlapped I/O request */ +#define IBSP_DBG_DUP 0x00002000 /* Socket Duplication */ #define IBSP_DBG_LEVEL4 0x01000000 /* debug use */ #define IBSP_DBG_LEVEL3 0x02000000 /* debug use */ @@ -129,3 +130,41 @@ debug_dump_overlapped( #define STATS(expr) #endif /* _DEBUG_ */ + +/* + * To enable logging of all Send/Receive data for each socket + * uncomment the following line. + */ +//#define IBSP_LOGGING + +#ifdef IBSP_LOGGING + +typedef struct DataLogger +{ + char *BufferStart; + size_t TotalSize; + char *NextPrint; + size_t ToatalPrinted; + BOOL ShutdownClosed; + HANDLE hMapFile; + +}DataLogger; + + +VOID DataLogger_Init( + DataLogger *pLoger, + char *prefix, + struct sockaddr_in *addr1, + struct sockaddr_in *addr2 ); + + +VOID DataLogger_WriteData( + DataLogger *pLoger, + long Idx, + char *Data, + DWORD Len ); + +VOID DataLogger_Shutdown( + DataLogger *pLoger ); + +#endif /* IBSP_LOGGING */ diff --git a/branches/MTHCA/ulp/wsd/user/ibspdll.c b/branches/MTHCA/ulp/wsd/user/ibspdll.c index e12a8675..177b7357 100644 --- a/branches/MTHCA/ulp/wsd/user/ibspdll.c +++ b/branches/MTHCA/ulp/wsd/user/ibspdll.c @@ -143,6 +143,11 @@ _DllMain( { struct ibsp_socket_info *socket_info = NULL; socket_info = PARENT_STRUCT(socket_item, struct ibsp_socket_info, item); + +#ifdef IBSP_LOGGING + DataLogger_Shutdown(&socket_info->SendDataLogger); + DataLogger_Shutdown(&socket_info->RecvDataLogger); +#endif } cl_spinlock_release( &g_ibsp.socket_info_mutex ); @@ -275,6 +280,13 @@ accept_socket( new_socket_info->peer_addr = p_incoming->params.source; +#ifdef IBSP_LOGGING + DataLogger_Init( &new_socket_info->SendDataLogger, "Send", + &new_socket_info->peer_addr, &new_socket_info->local_addr ); + DataLogger_Init( &new_socket_info->RecvDataLogger, "Recv", + &new_socket_info->local_addr, &new_socket_info->peer_addr ); +#endif + cl_spinlock_acquire( &new_socket_info->mutex ); /* Update the state of the socket context */ IBSP_CHANGE_SOCKET_STATE( new_socket_info, IBSP_CONNECTED ); @@ -785,6 +797,13 @@ IBSPConnect( /* Store the peer entity's address in socket context */ socket_info->peer_addr = *addr; +#ifdef IBSP_LOGGING + DataLogger_Init( &socket_info->SendDataLogger, "Send", + &socket_info->peer_addr, &socket_info->local_addr ); + DataLogger_Init( &socket_info->RecvDataLogger, "Recv", + &socket_info->local_addr, &socket_info->peer_addr ); +#endif + /* Update the socket state */ IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_CONNECT ); @@ -806,61 +825,6 @@ done: } -/* Function: IBSPDuplicateSocket - - Description: - This function provides a WSAPROTOCOL_INFOW structure which can be passed - to another process to open a handle to the same socket. First we need - to translate the user socket into the provider socket and call the underlying - WSPDuplicateSocket. Note that the lpProtocolInfo structure passed into us - is an out parameter only! -*/ -static int WSPAPI -IBSPDuplicateSocket( - SOCKET s, - DWORD dwProcessId, - LPWSAPROTOCOL_INFOW lpProtocolInfo, - LPINT lpErrno ) -{ - struct ibsp_socket_info *socket_info = (struct ibsp_socket_info *)s; - int ret; - - IBSP_ENTER( IBSP_DBG_CONN ); - - fzprint(("%s():%d:0x%x:0x%x: socket=0x%p state=%s\n", __FUNCTION__, - __LINE__, GetCurrentProcessId(), - GetCurrentThreadId(), s, IBSP_SOCKET_STATE_STR( socket_info->socket_state ))); - - cl_spinlock_acquire( &socket_info->mutex ); - if( socket_info->socket_state != IBSP_CONNECTED ) - { - cl_spinlock_release( &socket_info->mutex ); - IBSP_TRACE_EXIT( IBSP_DBG_CONN, - ("Socket state not IBSP_CONNECTED, state=%s.\n", - IBSP_SOCKET_STATE_STR( socket_info->socket_state )) ); - *lpErrno = WSAENOTCONN; - return SOCKET_ERROR; - } - - ret = prepare_duplicate_socket( socket_info, dwProcessId ); - cl_spinlock_release( &socket_info->mutex ); - if( ret ) - { - IBSP_TRACE_EXIT( IBSP_DBG_CONN, - ("prepare_duplicate_socket failed with %d\n", ret) ); - *lpErrno = ret; - return SOCKET_ERROR; - } - else - { - IBSP_EXIT( IBSP_DBG_CONN ); - lpProtocolInfo->dwProviderReserved = socket_info->duplicate.identifier; - *lpErrno = 0; - return 0; - } -} - - /* Function: IBSPEnumNetworkEvents * * Description: @@ -1412,7 +1376,8 @@ IBSPListen( IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_LISTEN ); socket_info->listen.listen_req_param.dwProcessId = 0; - socket_info->listen.listen_req_param.identifier = 0; + cl_memclr( &socket_info->listen.listen_req_param.identifier, + sizeof(socket_info->listen.listen_req_param.identifier) ); ret = ib_listen( socket_info ); if( ret ) @@ -1605,10 +1570,11 @@ IBSPRecv( GetCurrentThreadId(), lpOverlapped, g_ibsp.overlap_h0_count, g_ibsp.overlap_h1_count, g_ibsp.overlap_h1_comp_count, g_ibsp.send_count, g_ibsp.recv_count)); - - #endif +#ifdef IBSP_LOGGING + wr->idx = socket_info->recv_log_idx++; +#endif fzprint(("%s():%d:0x%x:0x%x: posting RECV socket=0x%p overlap=%p wr=0x%p\n", __FUNCTION__, __LINE__, GetCurrentProcessId(), GetCurrentThreadId(), s, @@ -1858,6 +1824,19 @@ IBSPSend( } #endif +#ifdef IBSP_LOGGING + { + DWORD i; + + for( i=0; i < dwBufferCount; i++ ) + { + DataLogger_WriteData( &socket_info->SendDataLogger, + socket_info->send_log_idx++, lpBuffers[i].buf, + lpBuffers[i].len); + } + } +#endif + status = ib_post_send( socket_info->qp, &send_wr, NULL ); if( status == IB_SUCCESS ) @@ -2056,8 +2035,8 @@ IBSPSocket( if( lpProtocolInfo->dwProviderReserved != 0 ) { /* This is a duplicate socket. */ - *lpErrno = setup_duplicate_socket( - socket_info, lpProtocolInfo->dwProviderReserved ); + *lpErrno = setup_duplicate_socket( socket_info, + (HANDLE)(ULONG_PTR)lpProtocolInfo->dwProviderReserved ); if( *lpErrno ) { deref_socket_info( socket_info ); diff --git a/branches/MTHCA/ulp/wsd/user/ibspdll.h b/branches/MTHCA/ulp/wsd/user/ibspdll.h index 0feaa3d8..75e2eea6 100644 --- a/branches/MTHCA/ulp/wsd/user/ibspdll.h +++ b/branches/MTHCA/ulp/wsd/user/ibspdll.h @@ -41,8 +41,10 @@ #include #include #include +#include #include +#include #include #include "ibspdefines.h" diff --git a/branches/MTHCA/ulp/wsd/user/ibspproto.h b/branches/MTHCA/ulp/wsd/user/ibspproto.h index f799fe15..98ad7eaa 100644 --- a/branches/MTHCA/ulp/wsd/user/ibspproto.h +++ b/branches/MTHCA/ulp/wsd/user/ibspproto.h @@ -151,9 +151,6 @@ ibal_to_wsa_error( IN const ib_api_status_t status ); /* Protos from ibsp_ip.c */ -void -update_all_ip_addrs(void); - intn_t CL_API ip_cmp( IN const void* const p_key1, @@ -230,12 +227,14 @@ pnp_ca_remove( int setup_duplicate_socket( IN struct ibsp_socket_info *socket_info, - IN DWORD identifier ); + IN HANDLE h_dup_info ); -int -prepare_duplicate_socket( - IN struct ibsp_socket_info *socket_info, - IN DWORD dwProcessId ); +int WSPAPI +IBSPDuplicateSocket( + SOCKET s, + DWORD dwProcessId, + LPWSAPROTOCOL_INFOW lpProtocolInfo, + LPINT lpErrno ); /* ibsp_mem.c */ diff --git a/branches/MTHCA/ulp/wsd/user/ibspstruct.h b/branches/MTHCA/ulp/wsd/user/ibspstruct.h index 7936050a..4d152f24 100644 --- a/branches/MTHCA/ulp/wsd/user/ibspstruct.h +++ b/branches/MTHCA/ulp/wsd/user/ibspstruct.h @@ -73,7 +73,7 @@ struct ibsp_socket_options struct listen_req_param { DWORD dwProcessId; - DWORD identifier; + GUID identifier; }; /* Parameters given to establish a connection */ @@ -109,6 +109,9 @@ struct _recv_wr struct _wr wr; ib_recv_wr_t recv; ib_local_ds_t ds_array[QP_ATTRIB_RQ_SGE]; +#ifdef IBSP_LOGGING + LONG idx; +#endif }; @@ -122,7 +125,7 @@ struct mr_list /* Information necessary to duplicate sockets */ struct ibsp_duplicate_info { - ib_net64_t port_guid; + GUID identifier; struct ibsp_socket_options socket_options; struct sockaddr_in local_addr; struct sockaddr_in peer_addr; @@ -141,7 +144,7 @@ struct disconnect_reason struct _disconnect_reason_dup { - DWORD identifier; + GUID identifier; DWORD dwProcessId; } duplicating; @@ -313,10 +316,16 @@ struct ibsp_socket_info /* Stuff for socket duplication */ struct { - HANDLE mmap_handle; - DWORD identifier; /* Unique identifier */ + GUID identifier; /* Unique identifier */ DWORD dwProcessId; } duplicate; + +#ifdef IBSP_LOGGING + DataLogger SendDataLogger; + DataLogger RecvDataLogger; + long recv_log_idx; + long send_log_idx; +#endif }; @@ -432,6 +441,7 @@ struct ibspdll_globals cl_qlist_t hca_list; cl_spinlock_t hca_mutex; + HANDLE h_ibat_dev; cl_fmap_t ip_map; /* list of all IP addresses supported by all the ports. */ cl_spinlock_t ip_mutex; diff --git a/branches/MTHCA/ulp/wsd/user/misc.c b/branches/MTHCA/ulp/wsd/user/misc.c index 1bf45987..2f92f822 100644 --- a/branches/MTHCA/ulp/wsd/user/misc.c +++ b/branches/MTHCA/ulp/wsd/user/misc.c @@ -98,6 +98,7 @@ init_globals( void ) cl_qlist_init( &g_ibsp.hca_list ); cl_spinlock_init( &g_ibsp.hca_mutex ); + g_ibsp.h_ibat_dev = INVALID_HANDLE_VALUE; cl_fmap_init( &g_ibsp.ip_map, ip_cmp ); cl_spinlock_init( &g_ibsp.ip_mutex ); @@ -114,7 +115,9 @@ void release_globals( void ) { HeapDestroy( g_ibsp.heap ); - g_ibsp.heap = NULL; + + if( g_ibsp.h_ibat_dev != INVALID_HANDLE_VALUE ) + CloseHandle( g_ibsp.h_ibat_dev ); cl_spinlock_destroy( &g_ibsp.socket_info_mutex ); cl_spinlock_destroy( &g_ibsp.hca_mutex ); -- 2.41.0