From ef6263f9c3066986b8711cc98d8f78d4ef8bf58d Mon Sep 17 00:00:00 2001 From: tzachid Date: Wed, 29 Mar 2006 17:14:21 +0000 Subject: [PATCH] [MTHCA] 1. Applied - with a little improvement - a patch, removing dependency of MTCHA driver from IBAL.SYS. 2. Applied a patch for support of user-mode calls without a UVP. 3. Applied a patch, eliminating usage of mt_time.h and its abstraction. 4. Cleaning: Removed most of the '#ifdef WIN_TO_BE_CHANGED' stuff. 5. Cleaning: Removed '#if 0'. git-svn-id: svn://openib.tc.cornell.edu/gen1@259 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/hw/dirs | 3 +- trunk/hw/mthca/kernel/SOURCES | 1 - trunk/hw/mthca/kernel/hca_data.c | 10 +- trunk/hw/mthca/kernel/hca_data.h | 2 - trunk/hw/mthca/kernel/hca_direct.c | 47 +- trunk/hw/mthca/kernel/hca_driver.c | 191 +-- trunk/hw/mthca/kernel/hca_driver.h | 7 +- trunk/hw/mthca/kernel/hca_mcast.c | 29 +- trunk/hw/mthca/kernel/hca_memory.c | 34 +- trunk/hw/mthca/kernel/hca_pci.c | 7 +- trunk/hw/mthca/kernel/hca_pnp.c | 30 +- trunk/hw/mthca/kernel/hca_smp.c | 85 +- trunk/hw/mthca/kernel/hca_verbs.c | 2272 ++----------------------- trunk/hw/mthca/kernel/mt_l2w.c | 28 - trunk/hw/mthca/kernel/mt_l2w.h | 2 +- trunk/hw/mthca/kernel/mt_time.h | 54 - trunk/hw/mthca/kernel/mt_verbs.c | 16 +- trunk/hw/mthca/kernel/mthca_av.c | 4 +- trunk/hw/mthca/kernel/mthca_cmd.c | 30 +- trunk/hw/mthca/kernel/mthca_cq.c | 33 +- trunk/hw/mthca/kernel/mthca_eq.c | 10 +- trunk/hw/mthca/kernel/mthca_mad.c | 14 +- trunk/hw/mthca/kernel/mthca_mcg.c | 2 - trunk/hw/mthca/kernel/mthca_memfree.c | 13 +- trunk/hw/mthca/kernel/mthca_mr.c | 21 +- trunk/hw/mthca/kernel/mthca_qp.c | 20 +- trunk/hw/mthca/user/mlnx_ual_av.c | 235 --- trunk/hw/mthca/user/mlnx_ual_mrw.c | 230 +-- trunk/hw/mthca/user/mlnx_ual_qp.c | 338 ---- trunk/hw/mthca/user/mlnx_uvp.c | 4 +- trunk/hw/mthca/user/mlnx_uvp.h | 4 - trunk/hw/mthca/user/mlnx_uvp_cq.c | 14 +- trunk/hw/mthca/user/mlnx_uvp_qp.c | 15 +- trunk/hw/mthca/user/mlnx_uvp_verbs.c | 167 -- trunk/hw/mthca/user/mlnx_uvp_verbs.h | 8 - 35 files changed, 386 insertions(+), 3594 deletions(-) delete mode 100644 trunk/hw/mthca/kernel/mt_time.h diff --git a/trunk/hw/dirs b/trunk/hw/dirs index 0cf85a2c..f65d5562 100644 --- a/trunk/hw/dirs +++ b/trunk/hw/dirs @@ -1,2 +1,3 @@ DIRS=\ - mt23108 + mt23108 \ + mthca diff --git a/trunk/hw/mthca/kernel/SOURCES b/trunk/hw/mthca/kernel/SOURCES index 3c9fe3c2..66f4f52e 100644 --- a/trunk/hw/mthca/kernel/SOURCES +++ b/trunk/hw/mthca/kernel/SOURCES @@ -67,7 +67,6 @@ C_DEFINES=$(C_DEFINES) -DDRIVER -DDEPRECATE_DDK_FUNCTIONS -D__LITTLE_ENDIAN TARGETLIBS= \ $(TARGETPATH)\*\complib.lib \ - $(TARGETPATH)\*\ibal.lib \ $(DDK_LIB_PATH)\wdmguid.lib diff --git a/trunk/hw/mthca/kernel/hca_data.c b/trunk/hw/mthca/kernel/hca_data.c index 29d83fb9..1fea7e85 100644 --- a/trunk/hw/mthca/kernel/hca_data.c +++ b/trunk/hw/mthca/kernel/hca_data.c @@ -309,10 +309,8 @@ mlnx_conv_hca_cap( ibal_port_p->subnet_timeout = mthca_port_p->subnet_timeout; // ibal_port_p->local_ack_timeout = 3; // TBD: currently ~32 usec -#if 0 - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM ,("Port %d port_guid 0x%I64x\n", + HCA_PRINT(TRACE_LEVEL_VERBOSE, HCA_DBG_SHIM ,("Port %d port_guid 0x%I64x\n", ibal_port_p->port_num, ibal_port_p->port_guid)); -#endif } } @@ -649,7 +647,8 @@ mlnx_conv_qp_modify_attr( qp_attr_p->max_dest_rd_atomic = modify_attr_p->state.rts.resp_res; } -#if 0 +#ifdef WIN_TO_BE_REMOVED + //TODO: do we need that ? // Linux patch 4793: PKEY_INDEX is not a legal parameter in the RTR->RTS transition. // IB_QP_PKEY_INDEX @@ -700,7 +699,8 @@ mlnx_conv_qp_modify_attr( qp_attr_p->max_dest_rd_atomic = modify_attr_p->state.rts.resp_res; } -#if 0 +#ifdef WIN_TO_BE_REMOVED + //TODO: do we need that ? // Linux patch 4793: PKEY_INDEX is not a legal parameter in the RTR->RTS transition. // IB_QP_PKEY_INDEX diff --git a/trunk/hw/mthca/kernel/hca_data.h b/trunk/hw/mthca/kernel/hca_data.h index 47575b98..ca0ba9e6 100644 --- a/trunk/hw/mthca/kernel/hca_data.h +++ b/trunk/hw/mthca/kernel/hca_data.h @@ -171,7 +171,6 @@ typedef struct _ib_ca { uint32_t index; cl_async_proc_t *async_proc_mgr_p; mlnx_cache_t *cache; // Cached port attributes. - const void * __ptr64 p_dev_obj; // store underlying device object } mlnx_hob_t; typedef struct HOBUL_t { @@ -210,7 +209,6 @@ typedef struct _mlnx_hca_t { struct mthca_dev *mdev; // VP Driver device uint32_t hw_ver; // HCA HW version mlnx_hob_t hob; // HOB - IBAL-related HCA resources - mlnx_hobul_t hobul; // HOBUL - - IBAL-related kernel client resources #ifdef WIN_TO_BE_REMOVED // removed as it is found in p_ext->cl_ext.p_pdo diff --git a/trunk/hw/mthca/kernel/hca_direct.c b/trunk/hw/mthca/kernel/hca_direct.c index cdece3e0..8a68de95 100644 --- a/trunk/hw/mthca/kernel/hca_direct.c +++ b/trunk/hw/mthca/kernel/hca_direct.c @@ -61,16 +61,17 @@ mlnx_post_send ( int err; ib_api_status_t status; struct ib_qp *ib_qp_p = (struct ib_qp *)h_qp; - struct ib_device *ib_dev_p = ib_qp_p->device; - + struct ib_device *ib_dev = ib_qp_p->device; + HCA_ENTER(HCA_DBG_QP); // sanity checks // create CQ - err = ib_dev_p->post_send(ib_qp_p, p_send_wr, pp_failed ); + err = ib_dev->post_send(ib_qp_p, p_send_wr, pp_failed ); if (err) { - HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_QP ,("post_send failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_QP, + ("post_send failed (%d)\n", err)); if (err == -ENOMEM) status = IB_INSUFFICIENT_RESOURCES; else @@ -81,7 +82,8 @@ mlnx_post_send ( status = IB_SUCCESS; err_post_send: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_QP ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_QP, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; } @@ -96,16 +98,17 @@ mlnx_post_recv ( int err; ib_api_status_t status; struct ib_qp *ib_qp_p = (struct ib_qp *)h_qp; - struct ib_device *ib_dev_p = ib_qp_p->device; + struct ib_device *ib_dev = ib_qp_p->device; HCA_ENTER(HCA_DBG_QP); // sanity checks // create CQ - err = ib_dev_p->post_recv(ib_qp_p, p_recv_wr, pp_failed ); + err = ib_dev->post_recv(ib_qp_p, p_recv_wr, pp_failed ); if (err) { - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_QP ,("post_recv failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_QP, + ("post_recv failed (%d)\n", err)); if (err == -ENOMEM) status = IB_INSUFFICIENT_RESOURCES; else @@ -116,7 +119,8 @@ mlnx_post_recv ( status = IB_SUCCESS; err_post_recv: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_QP ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_QP, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; } @@ -145,7 +149,8 @@ mlnx_poll_cq ( int err; ib_api_status_t status = IB_SUCCESS; struct ib_cq *ib_cq_p = (struct ib_cq *)h_cq; - + PREP_IBDEV_FOR_PRINT(ib_cq_p->device) + HCA_ENTER(HCA_DBG_CQ); // sanity checks @@ -157,14 +162,16 @@ mlnx_poll_cq ( // poll CQ err = mthca_poll_cq_list(ib_cq_p, pp_free_wclist, pp_done_wclist ); if (err) { - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_CQ ,("mthca_poll_cq_list failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_CQ, + ("mthca_poll_cq_list failed (%d)\n", err)); status = errno_to_iberr(err); }else if (!*pp_done_wclist) status = IB_NOT_FOUND; err_invalid_params: if (status != IB_NOT_FOUND){ - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_CQ ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_CQ, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); }else HCA_EXIT(HCA_DBG_CQ); return status; @@ -179,17 +186,20 @@ mlnx_enable_cq_notify ( int err; ib_api_status_t status = IB_SUCCESS; struct ib_cq *ib_cq_p = (struct ib_cq *)h_cq; - + PREP_IBDEV_FOR_PRINT(ib_cq_p->device) + HCA_ENTER(HCA_DBG_SHIM); // REARM CQ err = ib_req_notify_cq(ib_cq_p, (solicited) ? IB_CQ_SOLICITED : IB_CQ_NEXT_COMP ); if (err) { - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("ib_req_notify_cq failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM, + ("ib_req_notify_cq failed (%d)\n", err)); status = errno_to_iberr(err); } - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; } @@ -201,16 +211,19 @@ mlnx_enable_ncomp_cq_notify ( int err; ib_api_status_t status = IB_SUCCESS; struct ib_cq *ib_cq_p = (struct ib_cq *)h_cq; + PREP_IBDEV_FOR_PRINT(ib_cq_p->device) HCA_ENTER(HCA_DBG_SHIM); err = ib_req_ncomp_notif(ib_cq_p, n_cqes ); if (err) { - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("ib_req_ncomp_notif failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM, + ("ib_req_ncomp_notif failed (%d)\n", err)); status = errno_to_iberr(err); } - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; } diff --git a/trunk/hw/mthca/kernel/hca_driver.c b/trunk/hw/mthca/kernel/hca_driver.c index 49b88ebc..13e62390 100644 --- a/trunk/hw/mthca/kernel/hca_driver.c +++ b/trunk/hw/mthca/kernel/hca_driver.c @@ -127,11 +127,6 @@ fw_flash_read_data ( IN ULONG offset, IN ULONG POINTER_ALIGNMENT length ); -static NTSTATUS -fw_flash_get_ca_guid( - IN DEVICE_OBJECT *p_dev_obj, - OUT uint64_t *ca_guid ); - static NTSTATUS fw_flash_read4( IN BUS_INTERFACE_STANDARD *p_BusInterface, @@ -162,7 +157,6 @@ fw_flash_deinit( #pragma alloc_text (INIT, __read_registry) #pragma alloc_text (PAGE, hca_drv_unload) #pragma alloc_text (PAGE, hca_sysctl) -#pragma alloc_text (PAGE, fw_flash_get_ca_guid) #endif NTSTATUS @@ -197,9 +191,6 @@ DriverEntry( /*leo: init function table */ hca_init_vfptr(); - - /*leo: calibrate CPU */ - MT_time_calibrate(); p_driver_obj->MajorFunction[IRP_MJ_PNP] = cl_pnp; p_driver_obj->MajorFunction[IRP_MJ_POWER] = cl_power; @@ -445,7 +436,7 @@ End: ib_api_status_t fw_access_ctrl( - IN const void* __ptr64 p_context, + IN const ib_ca_handle_t h_ca, IN const void* __ptr64* const handle_array OPTIONAL, IN uint32_t num_handles, IN ib_ci_op_t* const p_ci_op, @@ -466,9 +457,13 @@ fw_access_ctrl( UNREFERENCED_PARAMETER(p_umv_buf); status = STATUS_SUCCESS; - p_hob = (mlnx_hob_t *)(const void *)p_context; - p_dev_obj = (DEVICE_OBJECT *)(const void *)p_hob->p_dev_obj; + if( p_umv_buf ) + p_hob = HOB_FROM_IBDEV( ((struct ib_ucontext*)h_ca)->device ); + else + p_hob = (mlnx_hob_t *)(const void *)h_ca; + + p_dev_obj = (DEVICE_OBJECT *)EXT_FROM_HOB(p_hob)->cl_ext.p_self_do; p_ci = p_ci_op; if ( !p_ci ) @@ -482,52 +477,49 @@ fw_access_ctrl( switch ( p_ci->command ) { - case FW_READ: // read data from flash - if ( if_ready ) - { - status = fw_flash_read_data(&BusInterface, p_data, offset, length); - } - break; - case FW_WRITE: // write data to flash - if ( if_ready ) - { - - status = fw_flash_write_data(&BusInterface, p_data, offset, length); - } - break; - case FW_READ_CMD: - if ( if_ready ) - { - status = fw_access_pciconf(&BusInterface, 0 , p_data, offset, 4); - } - break; - case FW_WRITE_CMD: - if ( if_ready ) - { - status = fw_access_pciconf(&BusInterface, 1 , p_data, offset, 4); - } - break; - case FW_CLOSE_IF: // close BusInterface - if (if_ready ) - { - if_ready = 0; - BusInterface.InterfaceDereference((PVOID)BusInterface.Context); - } - return status; - case FW_OPEN_IF: // open BusInterface - if ( !if_ready ) - { - status = fw_get_pci_bus_interface(p_dev_obj, &BusInterface); - - if ( NT_SUCCESS( status ) ) - { - if_ready = 1; - status = STATUS_SUCCESS; - } - } - return status; - default: - status = STATUS_NOT_SUPPORTED; + case FW_READ: // read data from flash + if ( if_ready ) + status = fw_flash_read_data(&BusInterface, p_data, offset, length); + break; + + case FW_WRITE: // write data to flash + if ( if_ready ) + status = fw_flash_write_data(&BusInterface, p_data, offset, length); + break; + + case FW_READ_CMD: + if ( if_ready ) + status = fw_access_pciconf(&BusInterface, 0 , p_data, offset, 4); + break; + + case FW_WRITE_CMD: + if ( if_ready ) + status = fw_access_pciconf(&BusInterface, 1 , p_data, offset, 4); + break; + + case FW_CLOSE_IF: // close BusInterface + if (if_ready ) + { + if_ready = 0; + BusInterface.InterfaceDereference((PVOID)BusInterface.Context); + } + return status; + + case FW_OPEN_IF: // open BusInterface + if ( !if_ready ) + { + status = fw_get_pci_bus_interface(p_dev_obj, &BusInterface); + + if ( NT_SUCCESS( status ) ) + { + if_ready = 1; + status = STATUS_SUCCESS; + } + } + return status; + + default: + status = STATUS_NOT_SUPPORTED; } if ( status != STATUS_SUCCESS ) @@ -618,77 +610,6 @@ fw_flash_read_data ( return status; } -static NTSTATUS -fw_flash_get_ca_guid( - IN DEVICE_OBJECT *p_dev_obj, - OUT net64_t *ca_guid ) -{ - NTSTATUS status = STATUS_SUCCESS; - BUS_INTERFACE_STANDARD BusInterface; - - uint32_t NODE_GUIDH, NODE_GUIDL; - uint32_t prim_ptr = 0; - uint32_t signature; - - primary_sector_t ps; - cl_memset( &ps, 0, sizeof(primary_sector_t)); - - status = fw_get_pci_bus_interface(p_dev_obj, &BusInterface); - - if ( !NT_SUCCESS( status ) ) - return status; - - status = fw_flash_init (&BusInterface); - if (status != STATUS_SUCCESS ) - return status; - status = fw_flash_read_data(&BusInterface, &signature, 0x24, 4); - if (status != STATUS_SUCCESS ) - return status; - //signature = cl_ntoh32(signature); - - if (signature == FW_SIGNATURE) - { - //Fail Safe image - - // Assume flash has been verified, and both images have the same guids, therefore, - // we only need to read the primary image's guids - status = fw_flash_readbuf(&BusInterface, FW_SECT_SIZE, &ps, sizeof(ps)); - if ( status == STATUS_SUCCESS ) - { - status = fw_flash_read_data(&BusInterface, &prim_ptr, ps.fi_addr+0x24, 4); - if (status == STATUS_SUCCESS ) - prim_ptr = prim_ptr + ps.fi_addr; - } - } - else - { - // Short image - prim_ptr = signature; - } - - if ( signature == FW_SIGNATURE || prim_ptr < MAX_FLASH_SIZE ) - { - /* now we can read ca guid - * since we read it in host mode fw_flash_read4() - * swaps it back in BE - how it was stored in FW - */ - if (( status = fw_flash_read4(&BusInterface, prim_ptr, &NODE_GUIDL)) == STATUS_SUCCESS ) - if (( status = fw_flash_read4(&BusInterface, prim_ptr+4, &NODE_GUIDH)) == STATUS_SUCCESS ) - { - *ca_guid = NODE_GUIDH; - *ca_guid = (*ca_guid << 32) | NODE_GUIDL; - } - } - else - { - //invalid GUID pointer - return STATUS_NO_SUCH_DEVICE; - } - fw_flash_deinit(&BusInterface); - BusInterface.InterfaceDereference((PVOID)BusInterface.Context); - return status; -} - static NTSTATUS fw_flash_read4( IN BUS_INTERFACE_STANDARD *p_BusInterface, @@ -701,14 +622,22 @@ fw_flash_read4( static uint32_t curr_bank = 0xffffffff; if (addr & 0x3) + { + HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_INIT, + ("Invalid address %08x\n", addr) ); return STATUS_INVALID_PARAMETER; + } bank = addr & BANK_MASK; if (bank != curr_bank) { curr_bank = bank; if ((status = fw_set_bank(p_BusInterface, bank)) != STATUS_SUCCESS ) + { + HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_INIT, + ("fw_set_bank returned %08x\n", status) ); return STATUS_INVALID_PARAMETER; + } } status = fw_flash_read_data(p_BusInterface, &lcl_data, addr, 4); *p_data = cl_ntoh32(lcl_data); @@ -729,11 +658,15 @@ fw_flash_readbuf( if (offset & 0x3) { //Address should be 4-bytes aligned + HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_INIT, + ("Invalid address %08x\n", offset) ); return STATUS_INVALID_PARAMETER; } if (len & 0x3) { //Length should be 4-bytes aligned + HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_INIT, + ("Invalid length %d\n", len) ); return STATUS_INVALID_PARAMETER; } p_lcl_data = (uint32_t *)p_data; diff --git a/trunk/hw/mthca/kernel/hca_driver.h b/trunk/hw/mthca/kernel/hca_driver.h index 3099c4f8..50c27f7d 100644 --- a/trunk/hw/mthca/kernel/hca_driver.h +++ b/trunk/hw/mthca/kernel/hca_driver.h @@ -160,7 +160,12 @@ typedef struct _hca_dev_ext #define HOB_FROM_IBDEV(dev_p) (mlnx_hob_t *)&dev_p->mdev->ext->hca.hob - +#define IB_GET_ERR_STR ib_dev->mdev->ext->ci_ifc.get_err_str +#if DBG || defined( EVENT_TRACING ) +#define PREP_IBDEV_FOR_PRINT(val) struct ib_device *ib_dev = val; +#else +#define PREP_IBDEV_FOR_PRINT(val) struct ib_device *ib_dev = val; +#endif /*********************************** Firmware Update definitions diff --git a/trunk/hw/mthca/kernel/hca_mcast.c b/trunk/hw/mthca/kernel/hca_mcast.c index 5813b215..9e90576d 100644 --- a/trunk/hw/mthca/kernel/hca_mcast.c +++ b/trunk/hw/mthca/kernel/hca_mcast.c @@ -58,14 +58,15 @@ mlnx_attach_mcast ( int err; ib_api_status_t status; struct ib_qp *ib_qp_p = (struct ib_qp *)h_qp; + PREP_IBDEV_FOR_PRINT(ib_qp_p->device) mlnx_mcast_t *mcast_p; HCA_ENTER(HCA_DBG_SHIM); // sanity checks if( p_umv_buf && p_umv_buf->command ) { - HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("User mode is not supported yet\n")); - HCA_PRINT(TRACE_LEVEL_ERROR, HCA_DBG_SHIM ,("User mode is not supported yet\n")); + HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("User mode is not supported yet\n")); status = IB_UNSUPPORTED; goto err_user_unsupported; } @@ -88,7 +89,8 @@ mlnx_attach_mcast ( else { err = ibv_attach_mcast(ib_qp_p, (union ib_gid *)p_mcast_gid, (u16)mcast_lid); if (err) { - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("ibv_attach_mcast failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM , + ("ibv_attach_mcast failed (%d)\n", err)); status = errno_to_iberr(err); goto err_attach; } @@ -115,7 +117,8 @@ err_no_mem: err_invalid_param: err_user_unsupported: end: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; } @@ -123,15 +126,21 @@ ib_api_status_t mlnx_detach_mcast ( IN const ib_mcast_handle_t h_mcast) { - ib_api_status_t status; + ib_api_status_t status = IB_INVALID_PARAMETER; int err; mlnx_mcast_t *mcast_p = (mlnx_mcast_t*)h_mcast; + struct ib_device *ib_dev; // sanity check - if (!mcast_p || !mcast_p->ib_qp_p) { - status = IB_INVALID_PARAMETER; - goto err_invalid_param; + if (!mcast_p || !mcast_p->ib_qp_p) + { + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status IB_INVALID_PARAMETER\n")); + return IB_INVALID_PARAMETER; } + + ib_dev = mcast_p->ib_qp_p->device; + HCA_PRINT(TRACE_LEVEL_WARNING, HCA_DBG_SHIM,("mcasth %p, qp_p %p, mlid %hx, mgid %I64x`%I64x\n", mcast_p, mcast_p->ib_qp_p, mcast_p->mcast_lid, *(uint64_t*)&mcast_p->mcast_gid.raw[0], @@ -155,8 +164,8 @@ mlnx_detach_mcast ( err_detach_mcast: kfree(mcast_p); -err_invalid_param: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM , + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; } diff --git a/trunk/hw/mthca/kernel/hca_memory.c b/trunk/hw/mthca/kernel/hca_memory.c index 96fbad02..0950f36b 100644 --- a/trunk/hw/mthca/kernel/hca_memory.c +++ b/trunk/hw/mthca/kernel/hca_memory.c @@ -31,8 +31,8 @@ */ -#include "hca_driver.h" #include "hca_utils.h" +#include "mthca_dev.h" #if defined(EVENT_TRACING) #ifdef offsetof @@ -59,7 +59,8 @@ mlnx_register_mr ( struct ib_mr *mr_p; struct mthca_mr *mro_p; struct ib_pd *ib_pd_p = (struct ib_pd *)h_pd; - + PREP_IBDEV_FOR_PRINT(ib_pd_p->device) + HCA_ENTER(HCA_DBG_MEMORY); // sanity checks @@ -68,7 +69,8 @@ mlnx_register_mr ( goto err_unsupported; } if (!p_mr_create || 0 == p_mr_create->length) { - HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_MEMORY ,("invalid attributes")); + HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_MEMORY, + ("invalid attributes")); status = IB_INVALID_PARAMETER; goto err_invalid_parm; } @@ -78,7 +80,8 @@ mlnx_register_mr ( */ if (p_mr_create->access_ctrl & (IB_AC_RDMA_WRITE | IB_AC_ATOMIC) && !(p_mr_create->access_ctrl & IB_AC_LOCAL_WRITE)) { - HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_MEMORY ,("invalid access rights")); + HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_MEMORY, + ("invalid access rights")); status = IB_INVALID_PERMISSION; goto err_invalid_access; } @@ -93,7 +96,8 @@ mlnx_register_mr ( (int)p_mr_create->access_ctrl, &iobuf ); if (err) { - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_MEMORY ,("iobuf_register failed(%d)",err)); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_MEMORY, + ("iobuf_register failed(%d)",err)); status = errno_to_iberr(err); goto err_lock; } @@ -142,7 +146,8 @@ err_lock: err_invalid_access: err_invalid_parm: err_unsupported: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_MEMORY ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_MEMORY, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; } @@ -161,7 +166,8 @@ mlnx_register_pmr ( struct ib_mr *mr_p; struct ib_phys_buf *buffer_list; struct ib_pd *ib_pd_p = (struct ib_pd *)h_pd; - + PREP_IBDEV_FOR_PRINT(ib_pd_p->device) + UNUSED_PARAM( um_call ); HCA_ENTER(HCA_DBG_SHIM); @@ -183,8 +189,11 @@ mlnx_register_pmr ( //NB: p_pmr_create->hca_page_size is not used, i.e. supposed it is always the same // register pmr - if (p_pmr_create->length == (uint64_t)-1LL) - mr_p = ibv_get_dma_mr(ib_pd_p, map_qp_ibal_acl(p_pmr_create->access_ctrl) ); + if (p_pmr_create->length == (uint64_t)-1LL) + { + mr_p = ibv_get_dma_mr( ib_pd_p, + map_qp_ibal_acl(p_pmr_create->access_ctrl) ); + } else mr_p = ibv_reg_phys_mr(ib_pd_p, buffer_list, p_pmr_create->num_ranges, map_qp_ibal_acl(p_pmr_create->access_ctrl), p_vaddr ); @@ -206,7 +215,8 @@ mlnx_register_pmr ( err_reg_phys_mr: err_invalid_parm: err_unsupported: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_MEMORY ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_MEMORY, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; } @@ -297,6 +307,7 @@ mlnx_deregister_mr ( { ib_api_status_t status; int err; + PREP_IBDEV_FOR_PRINT(((struct ib_mr *)h_mr)->device) HCA_ENTER(HCA_DBG_SHIM); @@ -328,7 +339,8 @@ mlnx_deregister_mr ( err_dereg_mr: err_unsupported: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_MEMORY ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_MEMORY, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; } diff --git a/trunk/hw/mthca/kernel/hca_pci.c b/trunk/hw/mthca/kernel/hca_pci.c index 40342e41..171549dc 100644 --- a/trunk/hw/mthca/kernel/hca_pci.c +++ b/trunk/hw/mthca/kernel/hca_pci.c @@ -9,9 +9,6 @@ #include #include #include -#ifdef WIN_TO_BE_CHANGED -#include -#endif #define HCA_RESET_HCR_OFFSET 0x000F0010 #define HCA_RESET_TOKEN CL_HTON32(0x00000001) @@ -404,7 +401,7 @@ hca_reset( DEVICE_OBJECT* const pDevObj, int is_tavor ) } if (is_tavor) { -#if 0 +#ifdef WIN_TO_BE_REMOVED /* Get the HCA Bridge's bus interface. */ status = __get_bus_ifc( pDevObj, &GUID_HCA_BRIDGE_INTERFACE, &brBusIfc ); if( !NT_SUCCESS( status ) ) @@ -686,7 +683,7 @@ hca_tune_pci( /* Update Max_Read_Request_Size. */ HCA_PRINT( TRACE_LEVEL_WARNING ,HCA_DBG_PNP, - ("Updating max recv byte count of PCI-X capability.\n")); + ("Updating max recv byte count of PCI-Express capability.\n")); pPciExpCap->DevControl = (pPciExpCap->DevControl & ~PCI_EXP_DEVCTL_READRQ) | (5 << 12); len = hcaBusIfc.SetBusData( hcaBusIfc.Context, PCI_WHICHSPACE_CONFIG, &pPciExpCap->DevControl, diff --git a/trunk/hw/mthca/kernel/hca_pnp.c b/trunk/hw/mthca/kernel/hca_pnp.c index 216add0c..24c2e730 100644 --- a/trunk/hw/mthca/kernel/hca_pnp.c +++ b/trunk/hw/mthca/kernel/hca_pnp.c @@ -766,7 +766,7 @@ hca_start( { //TODO: no cleanup on error HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_PNP, - ("mthca_start returned %08X\n", status)); + ("mthca_init_one returned %08X\n", status)); return status; } @@ -923,8 +923,6 @@ hca_query_bus_relations( IN IRP* const p_irp, OUT cl_irp_action_t* const p_action ) { -#ifndef WIN_TO_BE_CHANGED - NTSTATUS status; DEVICE_RELATIONS *p_rel; hca_dev_ext_t *p_ext; @@ -966,32 +964,6 @@ hca_query_bus_relations( *p_action = IrpPassDown; HCA_EXIT( HCA_DBG_PNP ); return STATUS_SUCCESS; - -#else - return cl_irp_skip( p_dev_obj, p_irp, p_action ); - //NTSTATUS status; - //hca_dev_ext_t *p_ext; - - //HCA_ENTER( HCA_DBG_PNP ); - - //p_ext = p_dev_obj->DeviceExtension; - - //if( p_ext->state == HCA_REGISTERED ) - //{ - // status = p_ext->ci_ifc.get_relations( p_ext->hca.guid, p_irp ); - // if( !NT_SUCCESS( status ) ) - // { - // *p_action = IrpComplete; - // HCA_PRINT( TRACE_LEVEL_ERROR, - // "AL get_relations returned %08x.\n", status); - // return status; - // } - //} - - //*p_action = IrpPassDown; - //HCA_EXIT( HCA_DBG_PNP ); - //return STATUS_SUCCESS; -#endif } diff --git a/trunk/hw/mthca/kernel/hca_smp.c b/trunk/hw/mthca/kernel/hca_smp.c index 84159d5d..adb9d7e2 100644 --- a/trunk/hw/mthca/kernel/hca_smp.c +++ b/trunk/hw/mthca/kernel/hca_smp.c @@ -523,14 +523,12 @@ mlnx_local_mad ( IN const ib_ca_handle_t h_ca, IN const uint8_t port_num, IN const ib_mad_t *p_mad_in, - OUT ib_mad_t *p_mad_out ) + OUT ib_mad_t *p_mad_out ) { -#ifndef WIN_TO_BE_CHANGED - int err; ib_api_status_t status = IB_SUCCESS; mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; - struct ib_device *ib_dev_p = IBDEV_FROM_HOB( hob_p ); + struct ib_device *ib_dev = IBDEV_FROM_HOB( hob_p ); //TODO: do we need use flags (IB_MAD_IGNORE_MKEY, IB_MAD_IGNORE_BKEY) ? int mad_flags = 0; struct _ib_wc *wc_p; @@ -545,19 +543,7 @@ mlnx_local_mad ( goto err_port_num; } -#ifdef WIN_TO_BE_REMOVED - //TODO: seems like non need in that - //TODO: don't know: wr_id, pkey_index !!! - if (p_mad_in->mgmt_class == IB_MCLASS_SUBN_DIR) { - ib_smp_t *smp = (ib_smp_t *)p_mad_in; - u64 wr_id = 0; - u16 pkey_index = 0; - build_smp_wc(wr_id, cl_ntoh16(smp->dr_slid), pkey_index, port_num, &wc); - wc_p = &wc; - } -#else wc_p = NULL; -#endif // debug print { @@ -573,7 +559,7 @@ mlnx_local_mad ( // process mad if( !mlnx_cachable_mad( h_ca, port_num, p_mad_in, p_mad_out ) ) { - err = mthca_process_mad(ib_dev_p, mad_flags, (uint8_t)port_num, + err = mthca_process_mad(ib_dev, mad_flags, (uint8_t)port_num, wc_p, grh_p, (struct ib_mad*)p_mad_in, (struct ib_mad*)p_mad_out); if (!err) { HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_MAD, @@ -591,67 +577,8 @@ mlnx_local_mad ( err_process_mad: err_port_num: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_MAD ,("completes with ERROR status %s\n", ib_get_err_str(status))); - return status; - -#else - ib_api_status_t status; - - mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; - uint32_t hca_idx; - mlnx_hobul_t *hobul_p; - HH_hca_dev_t *hca_ul_info; - - HCA_ENTER(HCA_DBG_MAD); - - if (port_num > 2) { - status = IB_INVALID_PARAMETER; - goto cleanup; - } - - if (!hob_p || E_MARK_CA != hob_p->mark) { - status = IB_INVALID_CA_HANDLE; - goto cleanup; - } - - hca_idx = hob_p->index; - hobul_p = mlnx_hobul_array[hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_CA_HANDLE; - goto cleanup; - } - - hca_ul_info = (HH_hca_dev_t *)hobul_p->hh_hndl; - if (NULL == hca_ul_info) { - status = IB_INVALID_CA_HANDLE; - goto cleanup; - } - - if( !mlnx_cachable_mad( h_ca, port_num, p_mad_in, p_mad_out ) ) - { - if( HH_OK != THH_hob_process_local_mad( hobul_p->hh_hndl, port_num, - 0x0, 0, (void *)p_mad_in, p_mad_out ) ) - { - HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_MAD, - ("MAD failed:\n\tClass 0x%x\n\tMethod 0x%x\n\tAttr 0x%x", - p_mad_in->mgmt_class, p_mad_in->method, p_mad_in->attr_id )); - status = IB_ERROR; - goto cleanup; - } - - mlnx_update_cache( h_ca, port_num, p_mad_out ); - } - - /* Modify direction for Direct MAD */ - if ( p_mad_in->mgmt_class == IB_MCLASS_SUBN_DIR ) - p_mad_out->status |= IB_SMP_DIRECTION; - - HCA_EXIT(HCA_DBG_MAD); - return IB_SUCCESS; - -cleanup: - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_MAD ,("status %d\n", status))); - HCA_EXIT(HCA_DBG_MAD); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_MAD, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; -#endif } + diff --git a/trunk/hw/mthca/kernel/hca_verbs.c b/trunk/hw/mthca/kernel/hca_verbs.c index 0a6100a4..ed458f88 100644 --- a/trunk/hw/mthca/kernel/hca_verbs.c +++ b/trunk/hw/mthca/kernel/hca_verbs.c @@ -67,23 +67,27 @@ mlnx_open_ca ( IN const void*const ca_context, OUT ib_ca_handle_t *ph_ca) { -#ifndef WIN_TO_BE_CHANGED - mlnx_hca_t *p_hca; - ib_api_status_t status; + ib_api_status_t status = IB_NOT_FOUND; mlnx_cache_t *p_cache; + struct ib_device *ib_dev; HCA_ENTER(HCA_DBG_SHIM); - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_SHIM ,("context 0x%p\n", ca_context)); + HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_SHIM, + ("context 0x%p\n", ca_context)); // find CA object p_hca = mlnx_hca_from_guid( ca_guid ); if( !p_hca ) { - status = IB_NOT_FOUND; - goto err_hca_from_guid; + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status IB_NOT_FOUND\n")); + return IB_NOT_FOUND; } - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_SHIM ,("context 0x%p\n", ca_context)); + ib_dev = &p_hca->mdev->ib_dev; + + HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_SHIM, + ("context 0x%p\n", ca_context)); status = mlnx_hobs_set_cb(&p_hca->hob, pfn_completion_cb, pfn_async_event_cb, @@ -109,107 +113,9 @@ mlnx_open_ca ( err_mad_cache: err_set_cb: -err_hca_from_guid: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); - return status; - -#else - mlnx_hca_t *p_hca; - HH_hca_dev_t * hca_ul_info; - void * hca_ul_resources_p = NULL; // (THH_hca_ul_resources_t *) - ib_api_status_t status; - mlnx_hob_t *new_ca = NULL; - MOSAL_protection_ctx_t prot_ctx; - - HCA_ENTER( HCA_DBG_SHIM); - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM,"context 0x%p\n", ca_context) - - // find CA object - p_hca = mlnx_hca_from_guid( ca_guid ); - if( !p_hca ) { - HCA_EXIT( TRACE_LEVEL_VERBOSE ); - return IB_NOT_FOUND; - } - - hca_ul_info = p_hca->hh_hndl; - - { - // We are opening the HCA in kernel mode. - // if a HOBKL exists for this device (i.e. it is open) - return E_BUSY - if (IB_SUCCESS == mlnx_hobs_lookup(p_hca->hh_hndl, &new_ca)) { - if (ph_ca) *ph_ca = (ib_ca_handle_t)new_ca; - HCA_EXIT( HCA_DBG_SHIM); - return IB_RESOURCE_BUSY; - } - - // Create a mapping from hca index to hh_hndl - status = mlnx_hobs_insert(p_hca, &new_ca); - if (IB_SUCCESS != status) { - HCA_EXIT( HCA_DBG_SHIM); - return status; - } - - /* save copy of HCA device object */ - new_ca->p_dev_obj = p_hca->p_dev_obj; - - // Initialize the device driver - if (HH_OK != THH_hob_open_hca(p_hca->hh_hndl, NULL, NULL)) { - status = IB_ERROR; - goto cleanup; - } - - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM,"context 0x%p\n", ca_context) - status = mlnx_hobs_set_cb(new_ca, - pfn_completion_cb, - pfn_async_event_cb, - ca_context); - if (IB_SUCCESS != status) { - goto cleanup; - } - - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM ,("ul_resource sizes: hca %d pd %d\n", - hca_ul_info->hca_ul_resources_sz, - hca_ul_info->pd_ul_resources_sz)); - - hca_ul_resources_p = cl_zalloc( hca_ul_info->hca_ul_resources_sz); - - /* get the kernel protection context */ - prot_ctx = MOSAL_get_kernel_prot_ctx(); - } - - if (!hca_ul_resources_p) { - status = IB_INSUFFICIENT_MEMORY; - goto cleanup; - } - - if (HH_OK != THH_hob_alloc_ul_res(p_hca->hh_hndl, prot_ctx, hca_ul_resources_p)) { - status = IB_ERROR; - goto cleanup; - } - - // TBD: !!! in user mode (kernel hobul_idx != hob_idx) - status = mlnx_hobul_new(new_ca, p_hca->hh_hndl, hca_ul_resources_p); - if (IB_SUCCESS != status) { - goto cleanup; - } - - // Return the HOBUL index - if (ph_ca) *ph_ca = new_ca; - - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup: - if (hca_ul_resources_p) - cl_free( hca_ul_resources_p); - THH_hob_close_hca(p_hca->hh_hndl); - mlnx_hobs_remove(new_ca); - - // For user mode call - return status to user mode - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("status %d \n", status))); - HCA_EXIT( HCA_DBG_SHIM); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; -#endif } ib_api_status_t @@ -219,8 +125,6 @@ mlnx_query_ca ( IN OUT uint32_t *p_byte_count, IN OUT ci_umv_buf_t *p_umv_buf ) { -#ifndef WIN_TO_BE_CHANGED - ib_api_status_t status; uint32_t size, required_size; uint8_t port_num, num_ports; @@ -354,21 +258,18 @@ mlnx_query_ca ( } } -#if 0 - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM,"port %d gid0:", port_num) + HCA_PRINT(TRACE_LEVEL_VERBOSE, HCA_DBG_SHIM,("port %d gid0:", port_num)); for (i = 0; i < 16; i++) - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM," 0x%x", p_ca_attr->p_port_attr[port_num].p_gid_table[0].raw[i]) - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM,"\n") -#endif + HCA_PRINT(TRACE_LEVEL_VERBOSE, HCA_DBG_SHIM, + (" 0x%x", p_ca_attr->p_port_attr[port_num].p_gid_table[0].raw[i])); + HCA_PRINT(TRACE_LEVEL_VERBOSE, HCA_DBG_SHIM,("\n")); } // set result size p_ca_attr->size = required_size; CL_ASSERT( required_size == (((uintn_t)last_p) - ((uintn_t)p_ca_attr)) ); -#if 0 - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM ,HCA_DBG_SHIM ,("Space required %d used %d\n", - required_size, ((uintn_t)last_p) - ((uintn_t)p_ca_attr)))); -#endif + HCA_PRINT(TRACE_LEVEL_VERBOSE, HCA_DBG_SHIM , ("Space required %d used %d\n", + required_size, (int)((uintn_t)last_p - (uintn_t)p_ca_attr) )); // !!! GID/PKEY tables must be queried before this call !!! mlnx_conv_hca_cap(ib_dev, &props, hca_ports, p_ca_attr); @@ -385,169 +286,9 @@ err_query_device: err_byte_count: err_user_unsupported: if( status != IB_INSUFFICIENT_MEMORY && status != IB_SUCCESS ) - HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); HCA_EXIT(HCA_DBG_SHIM); return status; - - - -#else - ib_api_status_t status; - - mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; - HH_hca_hndl_t hh_hndl = NULL; - HH_hca_dev_t *hca_ul_info; - VAPI_hca_cap_t hca_cap; - VAPI_hca_port_t *hca_ports = NULL; - uint32_t size, required_size; - uint8_t port_num, num_ports; - uint32_t num_gids, num_pkeys; - uint32_t num_page_sizes = 1; // TBD: what is actually supported - uint8_t *last_p; - void *hca_ul_resources_p = NULL; - uint32_t priv_op; - - HCA_ENTER( HCA_DBG_SHIM); - - if (NULL == p_byte_count) { - status = IB_INVALID_PARAMETER; - goto cleanup; - } - - mlnx_hobs_get_handle(hob_p, &hh_hndl); - if (NULL == hh_hndl) { - HCA_PRINT(TRACE_LEVEL_INFORMATION , HCA_DBG_SHIM ,("returning E_NODEV dev\n"))); - status = IB_INVALID_CA_HANDLE; - goto cleanup; - } - - hca_ul_info = (HH_hca_dev_t *)hh_hndl; - - if (HH_OK != THH_hob_query(hh_hndl, &hca_cap)) { - status = IB_ERROR; - goto cleanup; - } - - num_ports = hca_cap.phys_port_num; /* Number of physical ports of the HCA */ - - if (NULL == (hca_ports = cl_zalloc( num_ports * sizeof(VAPI_hca_port_t)))) { - HCA_PRINT (TRACE_LEVEL_ERROR, HCA_DBG_SHIM, - ("Failed to cl_zalloc ports array\n")); - status = IB_INSUFFICIENT_MEMORY; - goto cleanup; - } - - // Loop on ports and get their properties - num_gids = 0; - num_pkeys = 0; - required_size = PTR_ALIGN(sizeof(ib_ca_attr_t)) + - PTR_ALIGN(sizeof(uint32_t) * num_page_sizes) + - PTR_ALIGN(sizeof(ib_port_attr_t) * num_ports); - for (port_num = 0; port_num < num_ports; port_num++) { - if (HH_OK != THH_hob_query_port_prop(hh_hndl, port_num+1, &hca_ports[port_num])) { - status = IB_ERROR; - goto cleanup; - } - - num_gids = hca_ports[port_num].gid_tbl_len; - size = PTR_ALIGN(sizeof(ib_gid_t) * num_gids); - required_size += size; - - num_pkeys = hca_ports[port_num].pkey_tbl_len; - size = PTR_ALIGN(sizeof(uint16_t) * num_pkeys); - required_size += size; - } - - if (NULL == p_ca_attr || *p_byte_count < required_size) { - *p_byte_count = required_size; - status = IB_INSUFFICIENT_MEMORY; - if ( p_ca_attr != NULL) { - HCA_PRINT (TRACE_LEVEL_ERROR, HCA_DBG_SHIM, - ("Failed *p_byte_count < required_size\n")); - } - goto cleanup; - } - - // Space is sufficient - setup table pointers - last_p = (uint8_t*)p_ca_attr; - last_p += PTR_ALIGN(sizeof(*p_ca_attr)); - - p_ca_attr->p_page_size = (uint32_t*)last_p; - last_p += PTR_ALIGN(num_page_sizes * sizeof(uint32_t)); - - p_ca_attr->p_port_attr = (ib_port_attr_t *)last_p; - last_p += PTR_ALIGN(num_ports * sizeof(ib_port_attr_t)); - - for (port_num = 0; port_num < num_ports; port_num++) { - p_ca_attr->p_port_attr[port_num].p_gid_table = (ib_gid_t *)last_p; - size = PTR_ALIGN(sizeof(ib_gid_t) * hca_ports[port_num].gid_tbl_len); - last_p += size; - - p_ca_attr->p_port_attr[port_num].p_pkey_table = (uint16_t *)last_p; - size = PTR_ALIGN(sizeof(uint16_t) * hca_ports[port_num].pkey_tbl_len); - last_p += size; - } - - // Separate the loops to ensure that table pointers are always setup - for (port_num = 0; port_num < num_ports; port_num++) { - status = mlnx_get_hca_pkey_tbl(hh_hndl, port_num+1, - hca_ports[port_num].pkey_tbl_len, - p_ca_attr->p_port_attr[port_num].p_pkey_table); - if (IB_SUCCESS != status) { - HCA_PRINT (TRACE_LEVEL_ERROR, HCA_DBG_SHIM, - ("Failed to mlnx_get_hca_pkey_tbl for port_num:%d\n",port_num)); - goto cleanup; - } - - status = mlnx_get_hca_gid_tbl(hh_hndl, port_num+1, - hca_ports[port_num].gid_tbl_len, - &p_ca_attr->p_port_attr[port_num].p_gid_table[0].raw); - if (IB_SUCCESS != status) { - HCA_PRINT (TRACE_LEVEL_ERROR, HCA_DBG_SHIM, - ("Failed to mlnx_get_hca_gid_tbl for port_num:%d\n",port_num)); - goto cleanup; - } - -#if 0 - { - int i; - - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM,("port %d gid0:", port_num)); - for (i = 0; i < 16; i++) - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM,(" 0x%x", p_ca_attr->p_port_attr[port_num].p_gid_table[0].raw[i])); - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM,("\n")); - } -#endif - } - - // Convert query result into IBAL structure (no cl_memset()) - p_ca_attr->size = required_size; - - // !!! GID/PKEY tables must be queried before this call !!! - mlnx_conv_vapi_hca_cap(hca_ul_info, &hca_cap, hca_ports, p_ca_attr); - - // verify: required space == used space - CL_ASSERT( required_size == (((uintn_t)last_p) - ((uintn_t)p_ca_attr)) ); - -#if 0 - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM ,HCA_DBG_SHIM ,("Space required %d used %d\n", - required_size, - ((uintn_t)last_p) - ((uintn_t)p_ca_attr)))); -#endif - - if (hca_ul_resources_p) cl_free (hca_ul_resources_p); - if (hca_ports) cl_free( hca_ports ); - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup: - if (hca_ul_resources_p) cl_free (hca_ul_resources_p); - if (hca_ports) cl_free( hca_ports); - if( p_ca_attr != NULL || status != IB_INSUFFICIENT_MEMORY ) - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("status %d\n", status))); - HCA_EXIT( HCA_DBG_SHIM); - return status; -#endif } ib_api_status_t @@ -557,8 +298,6 @@ mlnx_modify_ca ( IN const ib_ca_mod_t modca_cmd, IN const ib_port_attr_mod_t *p_port_attr) { -#ifndef WIN_TO_BE_CHANGED - #define SET_CAP_MOD(al_mask, al_fld, ib) \ if (modca_cmd & al_mask) { \ if (p_port_attr->cap.##al_fld) \ @@ -596,72 +335,14 @@ mlnx_modify_ca ( status = IB_SUCCESS; err_modify_port: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); - return status; - -#else - ib_api_status_t status; - - mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; - HH_hca_hndl_t hh_hndl = NULL; - - VAPI_hca_attr_t hca_attr; - VAPI_hca_attr_mask_t hca_attr_mask = 0; - - HCA_ENTER( HCA_DBG_SHIM); - - mlnx_hobs_get_handle(hob_p, &hh_hndl); - if (NULL == hh_hndl) { - status = IB_INVALID_CA_HANDLE; - goto cleanup; - } - - cl_memclr(&hca_attr, sizeof(hca_attr)); - if (modca_cmd & IB_CA_MOD_IS_SM) { - hca_attr_mask |= HCA_ATTR_IS_SM; - hca_attr.is_sm = (MT_bool)p_port_attr->cap.sm; - } - if (modca_cmd & IB_CA_MOD_IS_SNMP_SUPPORTED) { - hca_attr_mask |= HCA_ATTR_IS_SNMP_TUN_SUP; - hca_attr.is_snmp_tun_sup = (MT_bool)p_port_attr->cap.snmp; - } - if (modca_cmd & IB_CA_MOD_IS_DEV_MGMT_SUPPORTED) { - hca_attr_mask |= HCA_ATTR_IS_DEV_MGT_SUP; - hca_attr.is_dev_mgt_sup = (MT_bool)p_port_attr->cap.dev_mgmt; - } - if (modca_cmd & IB_CA_MOD_IS_VEND_SUPPORTED) { - hca_attr_mask |= HCA_ATTR_IS_VENDOR_CLS_SUP; - hca_attr.is_vendor_cls_sup = (MT_bool)p_port_attr->cap.vend; - } - if (modca_cmd & IB_CA_MOD_QKEY_CTR) { - if (p_port_attr->qkey_ctr == 0) - hca_attr.reset_qkey_counter = TRUE; - } - - if (0 != hca_attr_mask) { - if (HH_OK != THH_hob_modify( hh_hndl, port_num, &hca_attr, &hca_attr_mask)) - { - status = IB_ERROR; - goto cleanup; - } - } - - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup: - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("status %d\n",status))); - HCA_EXIT( HCA_DBG_SHIM); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; -#endif } ib_api_status_t mlnx_close_ca ( IN ib_ca_handle_t h_ca) { -#ifndef WIN_TO_BE_CHANGED - HCA_ENTER(HCA_DBG_SHIM); // release HOB resources @@ -672,54 +353,6 @@ mlnx_close_ca ( HCA_EXIT(HCA_DBG_SHIM); return IB_SUCCESS; - -#else - ib_api_status_t status; - - HH_hca_hndl_t hh_hndl = NULL; - mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; - HH_hca_dev_t *hca_ul_info; - void *hca_ul_resources_p = NULL; - mlnx_hobul_t *hobul_p; - - HCA_ENTER( HCA_DBG_SHIM); - - hobul_p = mlnx_hobul_array[hob_p->index]; - if( !hobul_p ) { - status = IB_INVALID_CA_HANDLE; - goto cleanup; - } - - if( hobul_p->count ) { - status = IB_RESOURCE_BUSY; - goto cleanup; - } - - mlnx_hobs_get_handle(hob_p, &hh_hndl); - if (NULL == hh_hndl) { - status = IB_INVALID_CA_HANDLE; - goto cleanup; - } - - hca_ul_info = (HH_hca_dev_t *)hh_hndl; - mlnx_hobul_get(hob_p, &hca_ul_resources_p); - - if (hca_ul_resources_p) { - THH_hob_free_ul_res(hh_hndl, hca_ul_resources_p); - cl_free( hca_ul_resources_p); - } - mlnx_hobul_delete(hob_p); - THH_hob_close_hca(hh_hndl); - mlnx_hobs_remove(hob_p); - - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup: - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("status %d\n",status))); - HCA_EXIT( HCA_DBG_SHIM); - return status; -#endif } @@ -729,8 +362,6 @@ mlnx_um_open( IN OUT ci_umv_buf_t* const p_umv_buf, OUT ib_ca_handle_t* const ph_um_ca ) { -#ifndef WIN_TO_BE_CHANGED - int err; ib_api_status_t status; mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; @@ -744,17 +375,27 @@ mlnx_um_open( HCA_ENTER(HCA_DBG_SHIM); // sanity check - if( !p_umv_buf || !p_umv_buf->command || !p_umv_buf->p_inout_buf || - (p_umv_buf->output_size < sizeof *uresp_p) ) { - status = IB_INVALID_PARAMETER; - goto mlnx_um_open_err; + ASSERT( p_umv_buf ); + if( !p_umv_buf->command ) + { + context_p = cl_zalloc( sizeof(struct ib_ucontext) ); + if( !context_p ) + { + status = IB_INSUFFICIENT_MEMORY; + goto err_alloc_ucontext; + } + /* Copy the dev info. */ + context_p->device = ib_dev; + p_umv_buf->output_size = 0; + goto done; } // create user context in kernel context_p = mthca_alloc_ucontext(ib_dev, p_umv_buf); if (IS_ERR(context_p)) { err = PTR_ERR(context_p); - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("mthca_alloc_ucontext failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM, + ("mthca_alloc_ucontext failed (%d)\n", err)); status = errno_to_iberr(err); goto err_alloc_ucontext; } @@ -767,7 +408,8 @@ mlnx_um_open( context_p->pd = ibv_alloc_pd(ib_dev, context_p, &umv_buf); if (IS_ERR(context_p->pd)) { err = PTR_ERR(context_p->pd); - HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("ibv_alloc_pd failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("ibv_alloc_pd failed (%d)\n", err)); status = errno_to_iberr(err); goto err_alloc_pd; } @@ -779,7 +421,8 @@ mlnx_um_open( uresp_p->pdn = resp.pdn; uresp_p->vend_id = (uint32_t)ext_p->hcaConfig.VendorID; uresp_p->dev_id = (uint16_t)ext_p->hcaConfig.DeviceID; - + +done: // return the result if (ph_um_ca) *ph_um_ca = (ib_ca_handle_t)context_p; @@ -789,118 +432,12 @@ mlnx_um_open( err_alloc_pd: mthca_dealloc_ucontext(context_p); err_alloc_ucontext: -mlnx_um_open_err: end: if (p_umv_buf && p_umv_buf->command) p_umv_buf->status = status; - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; - -#else - ib_api_status_t status; - - mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; - HH_hca_hndl_t hh_hndl = NULL; - HH_hca_dev_t *hca_ul_info; - mlnx_um_ca_t *p_um_ca; - MOSAL_protection_ctx_t prot_ctx; - - HCA_ENTER( TRACE_LEVEL_VERBOSE ); - - mlnx_hobs_get_handle( hob_p, &hh_hndl ); - if( !hh_hndl ) - { - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_SHIM ,("returning E_NODEV dev\n")); - status = IB_INVALID_CA_HANDLE; - goto mlnx_um_open_err1; - } - - hca_ul_info = (HH_hca_dev_t *)hh_hndl; - - if( !p_umv_buf->command ) - { - p_umv_buf->status = IB_SUCCESS; - goto mlnx_um_open_err1; - } - - /* - * Prepare the buffer with the size including hca_ul_resources_sz - * NO ALIGNMENT for this size - */ - if( !p_umv_buf->p_inout_buf || - p_umv_buf->output_size < sizeof(void*) ) - { - p_umv_buf->status = IB_INVALID_PARAMETER; - goto mlnx_um_open_err1; - } - - HCA_PRINT( TRACE_LEVEL_VERBOSE ,HCA_DBG_SHIM ,("priv_op = %d\n", p_umv_buf->command )); - - /* Yes, UVP request for hca_ul_info. */ - p_um_ca = (mlnx_um_ca_t*)cl_zalloc( - sizeof(mlnx_um_ca_t) + hca_ul_info->hca_ul_resources_sz - 1 ); - if( !p_um_ca ) - { - p_umv_buf->status = IB_INSUFFICIENT_MEMORY; - goto mlnx_um_open_err1; - } - - p_um_ca->p_mdl = IoAllocateMdl( &p_um_ca->dev_info, - (ULONG)(sizeof(HH_hca_dev_t) + hca_ul_info->hca_ul_resources_sz), - FALSE, TRUE, NULL ); - if( !p_um_ca->p_mdl ) - { - p_umv_buf->status = IB_ERROR; - goto mlnx_um_open_err2; - } - /* Build the page list... */ - MmBuildMdlForNonPagedPool( p_um_ca->p_mdl ); - - /* Map the memory into the calling process's address space. */ - __try - { - p_um_ca->p_mapped_addr = - MmMapLockedPagesSpecifyCache( p_um_ca->p_mdl, - UserMode, MmCached, NULL, FALSE, NormalPagePriority ); - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - p_umv_buf->status = IB_ERROR; - goto mlnx_um_open_err3; - } - - /* Register with THH (attach to the HCA). */ - prot_ctx = MOSAL_get_current_prot_ctx(); - if( THH_hob_alloc_ul_res(hh_hndl, prot_ctx, p_um_ca->ul_hca_res) != HH_OK ) - { - HCA_PRINT( TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("Failed to get ul_res\n")); - p_umv_buf->status = IB_ERROR; - } - - if( p_umv_buf->status == IB_SUCCESS ) - { - /* Copy the dev info. */ - p_um_ca->dev_info = *hca_ul_info; - *ph_um_ca = (ib_ca_handle_t)p_um_ca; - (*(void** __ptr64)p_umv_buf->p_inout_buf) = p_um_ca->p_mapped_addr; - p_umv_buf->status = IB_SUCCESS; - } - else - { - MmUnmapLockedPages( p_um_ca->p_mapped_addr, p_um_ca->p_mdl ); -mlnx_um_open_err3: - IoFreeMdl( p_um_ca->p_mdl ); -mlnx_um_open_err2: - cl_free( p_um_ca ); -mlnx_um_open_err1: - *ph_um_ca = NULL; - } - - //*ph_um_ca = NULL; - p_umv_buf->output_size = sizeof(void*); - HCA_EXIT( TRACE_LEVEL_VERBOSE ); - return p_umv_buf->status; -#endif } static void @@ -908,35 +445,13 @@ mlnx_um_close( IN ib_ca_handle_t h_ca, IN ib_ca_handle_t h_um_ca ) { -#ifndef WIN_TO_BE_CHANGED - UNREFERENCED_PARAMETER(h_ca); - ibv_um_close((struct ib_ucontext *)h_um_ca); - return; - -#else - mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; - HH_hca_hndl_t hh_hndl = NULL; - mlnx_um_ca_t *p_um_ca = (mlnx_um_ca_t*)h_um_ca; - - HCA_ENTER( TRACE_LEVEL_VERBOSE ); - - mlnx_hobs_get_handle( hob_p, &hh_hndl ); - if( !hh_hndl ) - goto mlnx_um_close_cleanup; - - if( !p_um_ca ) - return; - - THH_hob_free_ul_res( hh_hndl, p_um_ca->ul_hca_res ); - -mlnx_um_close_cleanup: - MmUnmapLockedPages( p_um_ca->p_mapped_addr, p_um_ca->p_mdl ); - IoFreeMdl( p_um_ca->p_mdl ); - cl_free( p_um_ca ); - HCA_EXIT( TRACE_LEVEL_VERBOSE ); -#endif + if( !((struct ib_ucontext*)h_um_ca)->pd ) + cl_free( h_um_ca ); + else + ibv_um_close((struct ib_ucontext *)h_um_ca); + return; } @@ -951,8 +466,6 @@ mlnx_allocate_pd ( OUT ib_pd_handle_t *ph_pd, IN OUT ci_umv_buf_t *p_umv_buf ) { -#ifndef WIN_TO_BE_CHANGED - ib_api_status_t status; struct ib_device *ib_dev; struct ib_ucontext *context_p; @@ -964,7 +477,7 @@ mlnx_allocate_pd ( HCA_ENTER(HCA_DBG_SHIM); - if( p_umv_buf && p_umv_buf->command ) { + if( p_umv_buf ) { context_p = (struct ib_ucontext *)h_ca; ib_dev = context_p->device; } @@ -978,7 +491,8 @@ mlnx_allocate_pd ( ib_pd_p = ibv_alloc_pd(ib_dev, context_p, p_umv_buf); if (IS_ERR(ib_pd_p)) { err = PTR_ERR(ib_pd_p); - HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("ibv_alloc_pd failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("ibv_alloc_pd failed (%d)\n", err)); status = errno_to_iberr(err); goto err_alloc_pd; } @@ -991,159 +505,19 @@ mlnx_allocate_pd ( err_alloc_pd: if (p_umv_buf && p_umv_buf->command) p_umv_buf->status = status; - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; - -#else - mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; - mlnx_hobul_t *hobul_p; - HH_hca_dev_t *hca_ul_info; - HHUL_pd_hndl_t hhul_pd_hndl = 0; - void *pd_ul_resources_p = NULL; - uint32_t pd_idx; - ib_api_status_t status; - MOSAL_protection_ctx_t prot_ctx; - - HCA_ENTER( HCA_DBG_SHIM); - - hobul_p = mlnx_hobs_get_hobul(hob_p); - if (NULL == hobul_p) { - status = IB_INVALID_CA_HANDLE; - goto cleanup; - } - - hca_ul_info = (HH_hca_dev_t *)hobul_p->hh_hndl; - if (NULL == hca_ul_info) { - status = IB_INVALID_CA_HANDLE; - goto cleanup; - } - - if( p_umv_buf && p_umv_buf->command ) - { - // For user mode calls - obtain and verify the vendor information - if ((p_umv_buf->input_size - sizeof (uint32_t)) != - hca_ul_info->pd_ul_resources_sz || - NULL == p_umv_buf->p_inout_buf) { - status = IB_INVALID_PARAMETER; - goto cleanup; - } - pd_ul_resources_p = (void *)p_umv_buf->p_inout_buf; - - /* get the current protection context */ - prot_ctx = MOSAL_get_current_prot_ctx(); - } - else - { - // for kernel mode calls - allocate app resources. Use prep->call->done sequence - pd_ul_resources_p = cl_zalloc( hca_ul_info->pd_ul_resources_sz); - if (NULL == pd_ul_resources_p) { - status = IB_INSUFFICIENT_MEMORY; - goto cleanup; - } - - switch( type ) - { - case IB_PDT_SQP: - if (HH_OK != THHUL_pdm_alloc_pd_avs_prep(hobul_p->hhul_hndl, - g_sqp_max_avs, PD_FOR_SQP, &hhul_pd_hndl, pd_ul_resources_p)) - { - status = IB_ERROR; - goto cleanup; - } - break; - - case IB_PDT_UD: - if (HH_OK != THHUL_pdm_alloc_pd_avs_prep(hobul_p->hhul_hndl, - g_sqp_max_avs, PD_NO_FLAGS, &hhul_pd_hndl, pd_ul_resources_p)) - { - status = IB_ERROR; - goto cleanup; - } - break; - - default: - if (HH_OK != THHUL_pdm_alloc_pd_prep(hobul_p->hhul_hndl, &hhul_pd_hndl, pd_ul_resources_p)) { - status = IB_ERROR; - goto cleanup; - } - } - /* get the current protection context */ - prot_ctx = MOSAL_get_kernel_prot_ctx(); - } - - // Allocate the PD (cmdif) - if (HH_OK != THH_hob_alloc_pd(hobul_p->hh_hndl, prot_ctx, pd_ul_resources_p, &pd_idx)) { - status = IB_INSUFFICIENT_RESOURCES; - goto cleanup_pd; - } - - if( !(p_umv_buf && p_umv_buf->command) ) - { - // Manage user level resources - if (HH_OK != THHUL_pdm_alloc_pd_done(hobul_p->hhul_hndl, hhul_pd_hndl, pd_idx, pd_ul_resources_p)) { - THH_hob_free_pd(hobul_p->hh_hndl, pd_idx); - status = IB_ERROR; - goto cleanup_pd; - } - } - - VALIDATE_INDEX(pd_idx, hobul_p->max_pd, IB_ERROR, cleanup_pd); - - // Save data refs for future use - cl_mutex_acquire(&hobul_p->pd_info_tbl[pd_idx].mutex); - hobul_p->pd_info_tbl[pd_idx].pd_num = pd_idx; - hobul_p->pd_info_tbl[pd_idx].hca_idx = hob_p->index; - hobul_p->pd_info_tbl[pd_idx].hhul_pd_hndl = hhul_pd_hndl; - hobul_p->pd_info_tbl[pd_idx].pd_ul_resources_p = pd_ul_resources_p; - hobul_p->pd_info_tbl[pd_idx].count = 0; - hobul_p->pd_info_tbl[pd_idx].kernel_mode = !(p_umv_buf && p_umv_buf->command); - hobul_p->pd_info_tbl[pd_idx].mark = E_MARK_PD; - cl_mutex_release(&hobul_p->pd_info_tbl[pd_idx].mutex); - - cl_atomic_inc( &hobul_p->count ); - - if (ph_pd) *ph_pd = (ib_pd_handle_t)PD_HNDL_FROM_PD(pd_idx); - HCA_PRINT(TRACE_LEVEL_INFORMATION , HCA_DBG_SHIM ,("hca_idx 0x%x pd_idx 0x%x returned 0x%p\n", hob_p->index, pd_idx, *ph_pd)); - - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->output_size = p_umv_buf->input_size; - /* - * Copy the pd_idx back to user - */ - cl_memcpy (((uint8_t* __ptr64)p_umv_buf->p_inout_buf + hca_ul_info->pd_ul_resources_sz), - &pd_idx, sizeof (pd_idx)); - p_umv_buf->status = IB_SUCCESS; - } - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup_pd: - THHUL_pdm_free_pd_prep(hobul_p->hhul_hndl, hhul_pd_hndl, FALSE); - THHUL_pdm_free_pd_done(hobul_p->hhul_hndl, hhul_pd_hndl); - -cleanup: - if( !(p_umv_buf && p_umv_buf->command) && pd_ul_resources_p ) - cl_free( pd_ul_resources_p); - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->status = status; - } - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("status %d \n", status)); - HCA_EXIT( HCA_DBG_SHIM); - return status; -#endif -} +} ib_api_status_t mlnx_deallocate_pd ( IN ib_pd_handle_t h_pd) { -#ifndef WIN_TO_BE_CHANGED - ib_api_status_t status; int err; struct ib_pd *ib_pd_p = (struct ib_pd *)h_pd; + PREP_IBDEV_FOR_PRINT(ib_pd_p->device) HCA_ENTER( HCA_DBG_QP); @@ -1153,95 +527,17 @@ mlnx_deallocate_pd ( // dealloc pd err = ibv_dealloc_pd( ib_pd_p ); if (err) { - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("ibv_dealloc_pd failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM + ,("ibv_dealloc_pd failed (%d)\n", err)); status = errno_to_iberr(err); goto err_dealloc_pd; } status = IB_SUCCESS; err_dealloc_pd: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); - return status; - -#else - uint32_t hca_idx = PD_HCA_FROM_HNDL(h_pd); - uint32_t pd_idx = PD_NUM_FROM_HNDL(h_pd); - mlnx_hobul_t *hobul_p; - HHUL_pd_hndl_t hhul_pd_hndl; - ib_api_status_t status; - - HCA_ENTER( HCA_DBG_SHIM); - - VALIDATE_INDEX(hca_idx, MLNX_MAX_HCA, IB_INVALID_CA_HANDLE, cleanup); - hobul_p = mlnx_hobul_array[hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_PD_HANDLE; - goto cleanup; - } - VALIDATE_INDEX(pd_idx, hobul_p->max_pd, IB_INVALID_PD_HANDLE, cleanup); - if (E_MARK_PD != hobul_p->pd_info_tbl[pd_idx].mark) { - status = IB_INVALID_PD_HANDLE; - goto cleanup; - } - - cl_mutex_acquire(&hobul_p->pd_info_tbl[pd_idx].mutex); - - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM,("pd %d count %d k_mod %d\n", pd_idx, - hobul_p->pd_info_tbl[pd_idx].count, hobul_p->pd_info_tbl[pd_idx].kernel_mode)); - - if (0 != hobul_p->pd_info_tbl[pd_idx].count) { - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM,("pd %d count %d\n", - pd_idx, hobul_p->pd_info_tbl[pd_idx].count)); - status = IB_RESOURCE_BUSY; - goto cleanup_locked; - } - - hhul_pd_hndl = hobul_p->pd_info_tbl[pd_idx].hhul_pd_hndl; - - // PREP: - if (hobul_p->pd_info_tbl[pd_idx].kernel_mode) { - if (HH_OK != THHUL_pdm_free_pd_prep(hobul_p->hhul_hndl, hhul_pd_hndl, FALSE)) { - status = IB_ERROR; - goto cleanup_locked; - } - } - - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM ,("pd %d before free_pd hh_hndl %p\n", - pd_idx, hobul_p->hh_hndl); - - if (HH_OK != THH_hob_free_pd(hobul_p->hh_hndl, pd_idx)) { - status = IB_ERROR; - goto cleanup_locked; - } - - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM,"pd %d after free_pd\n", pd_idx) - - if (hobul_p->pd_info_tbl[pd_idx].kernel_mode) { - if (HH_OK != THHUL_pdm_free_pd_done(hobul_p->hhul_hndl, hhul_pd_hndl)) { - status = IB_ERROR; - goto cleanup_locked; - } - if (hobul_p->pd_info_tbl[pd_idx].pd_ul_resources_p) - cl_free( hobul_p->pd_info_tbl[pd_idx].pd_ul_resources_p); - } - - hobul_p->pd_info_tbl[pd_idx].mark = E_MARK_INVALID; - hobul_p->pd_info_tbl[pd_idx].pd_ul_resources_p = NULL; - - cl_mutex_release(&hobul_p->pd_info_tbl[pd_idx].mutex); - - cl_atomic_dec( &hobul_p->count ); - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup_locked: - cl_mutex_release(&hobul_p->pd_info_tbl[pd_idx].mutex); - -cleanup: - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("status %d\n", status)); - HCA_EXIT( HCA_DBG_SHIM); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM + ,("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; -#endif } /* @@ -1254,12 +550,10 @@ mlnx_create_av ( OUT ib_av_handle_t *ph_av, IN OUT ci_umv_buf_t *p_umv_buf ) { -#ifndef WIN_TO_BE_CHANGED - int err = 0; ib_api_status_t status = IB_SUCCESS; struct ib_pd *ib_pd_p = (struct ib_pd *)h_pd; - struct ib_device *ib_dev_p = ib_pd_p->device; + struct ib_device *ib_dev = ib_pd_p->device; struct ib_ah *ib_av_p; struct ib_ah_attr ah_attr; struct ib_ucontext *context_p = NULL; @@ -1281,12 +575,13 @@ mlnx_create_av ( // fill parameters RtlZeroMemory(&ah_attr, sizeof(ah_attr)); - mlnx_conv_ibal_av( ib_dev_p, p_addr_vector, &ah_attr ); + mlnx_conv_ibal_av( ib_dev, p_addr_vector, &ah_attr ); ib_av_p = ibv_create_ah(ib_pd_p, &ah_attr, context_p, p_umv_buf); if (IS_ERR(ib_pd_p)) { err = PTR_ERR(ib_pd_p); - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_QP ,("ibv_alloc_pd failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_QP, + ("ibv_alloc_pd failed (%d)\n", err)); status = errno_to_iberr(err); goto err_alloc_av; } @@ -1305,81 +600,9 @@ mlnx_create_av ( err_alloc_av: err_inval_params: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_QP ,("completes with ERROR status %s\n", ib_get_err_str(status))); - return status; - -#else - uint32_t hca_idx = PD_HCA_FROM_HNDL(h_pd); - uint32_t pd_idx = PD_NUM_FROM_HNDL(h_pd); - HHUL_ud_av_hndl_t av_h; - mlnx_hobul_t *hobul_p; - mlnx_avo_t *avo_p = NULL; - HHUL_pd_hndl_t hhul_pd_hndl; - ib_api_status_t status; - - VAPI_ud_av_t av; - - HCA_ENTER( HCA_DBG_SHIM); - - VALIDATE_INDEX(hca_idx, MLNX_MAX_HCA, IB_INVALID_CA_HANDLE, cleanup); - hobul_p = mlnx_hobul_array[hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_PD_HANDLE; - goto cleanup; - } - VALIDATE_INDEX(pd_idx, hobul_p->max_pd, IB_INVALID_PD_HANDLE, cleanup); - if (E_MARK_PD != hobul_p->pd_info_tbl[pd_idx].mark) { - status = IB_INVALID_PD_HANDLE; - goto cleanup; - } - hhul_pd_hndl = hobul_p->pd_info_tbl[pd_idx].hhul_pd_hndl; - - if (NULL == (avo_p = cl_zalloc( sizeof(mlnx_avo_t)))) { - status = IB_INSUFFICIENT_MEMORY; - goto cleanup; - } - - cl_memclr(&av, sizeof(av)); - mlnx_conv_ibal_av(hobul_p->hh_hndl, p_addr_vector, &av); - // This creates a non priviledged ud_av. - // To create a privilged ud_av call THH_hob_create_ud_av() - if (HH_OK != THHUL_pdm_create_ud_av(hobul_p->hhul_hndl, hhul_pd_hndl, &av, &av_h)) { - status = IB_INSUFFICIENT_RESOURCES; - goto cleanup; - } - - // update PD object count - cl_atomic_inc(&hobul_p->pd_info_tbl[pd_idx].count); - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM,"pd %d count %d\n", pd_idx, hobul_p->pd_info_tbl[pd_idx].count) - - - avo_p->mark = E_MARK_AV; - avo_p->hca_idx = hca_idx; - avo_p->pd_idx = pd_idx; - avo_p->h_av = av_h; - - if (ph_av) *ph_av = (ib_av_handle_t)avo_p; - - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->status = IB_SUCCESS; - } - status = IB_SUCCESS; - goto end; - -cleanup: - if (avo_p) { - avo_p->mark = E_MARK_INVALID; - cl_free( avo_p); - } - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->status = status; - } -end: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("status %d \n", status)); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_QP, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; -#endif } ib_api_status_t @@ -1389,27 +612,28 @@ mlnx_query_av ( OUT ib_pd_handle_t *ph_pd, IN OUT ci_umv_buf_t *p_umv_buf ) { -#ifndef WIN_TO_BE_CHANGED - int err; ib_api_status_t status = IB_SUCCESS; struct ib_ah *ib_ah_p = (struct ib_ah *)h_av; + PREP_IBDEV_FOR_PRINT(ib_ah_p->device) HCA_ENTER(HCA_DBG_SHIM); // sanity checks if( p_umv_buf && p_umv_buf->command ) { - HCA_PRINT (TRACE_LEVEL_ERROR, HCA_DBG_SHIM,("User mode is not supported yet\n")); + HCA_PRINT (TRACE_LEVEL_ERROR, HCA_DBG_SHIM, + ("User mode is not supported yet\n")); status = IB_UNSUPPORTED; goto err_user_unsupported; } // query AV -#if 0 +#ifdef WIN_TO_BE_CHANGED //TODO: not implemented in low-level driver err = ibv_query_ah(ib_ah_p, &ah_attr) if (err) { - HCA_PRINT(TRACE_LEVEL_ERROR, HCA_DBG_SHIM, ("ibv_query_ah failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR, HCA_DBG_SHIM, + ("ibv_query_ah failed (%d)\n", err)); status = errno_to_iberr(err); goto err_query_ah; } @@ -1419,7 +643,8 @@ mlnx_query_av ( err = mlnx_conv_mthca_av( ib_ah_p, p_addr_vector ); if (err) { - HCA_PRINT (TRACE_LEVEL_ERROR, HCA_DBG_SHIM,("mlnx_conv_mthca_av failed (%d)\n", err)); + HCA_PRINT (TRACE_LEVEL_ERROR, HCA_DBG_SHIM, + ("mlnx_conv_mthca_av failed (%d)\n", err)); status = errno_to_iberr(err); goto err_conv_mthca_av; } @@ -1430,61 +655,9 @@ mlnx_query_av ( err_conv_mthca_av: err_user_unsupported: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); - return status; - -#else - mlnx_avo_t *avo_p = (mlnx_avo_t *)h_av; - mlnx_hobul_t *hobul_p; - ib_api_status_t status; - - VAPI_ud_av_t av; - - HCA_ENTER( HCA_DBG_SHIM); - if (!avo_p || avo_p->mark != E_MARK_AV) { - status = IB_INVALID_AV_HANDLE; - goto cleanup; - } - - VALIDATE_INDEX(avo_p->hca_idx, MLNX_MAX_HCA, IB_INVALID_CA_HANDLE, cleanup); - hobul_p = mlnx_hobul_array[avo_p->hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_AV_HANDLE; - goto cleanup; - } - VALIDATE_INDEX(avo_p->pd_idx, hobul_p->max_pd, IB_INVALID_PD_HANDLE, cleanup); - if (E_MARK_PD != hobul_p->pd_info_tbl[avo_p->pd_idx].mark) { - status = IB_INVALID_PD_HANDLE; - goto cleanup; - } - - if (p_addr_vector) { - if (HH_OK != THHUL_pdm_query_ud_av(hobul_p->hhul_hndl, avo_p->h_av, &av)) { - status = IB_ERROR; - goto cleanup; - } - mlnx_conv_vapi_av(hobul_p->hh_hndl, &av, p_addr_vector); - } - - if (ph_pd) *ph_pd = (ib_pd_handle_t)PD_HNDL_FROM_PD(avo_p->pd_idx); - - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->output_size = 0; - p_umv_buf->status = IB_SUCCESS; - } - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup: - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->status = status; - } - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("status %d \n", status)); - HCA_EXIT( HCA_DBG_SHIM); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; -#endif } ib_api_status_t @@ -1493,31 +666,31 @@ mlnx_modify_av ( IN const ib_av_attr_t *p_addr_vector, IN OUT ci_umv_buf_t *p_umv_buf ) { -#ifndef WIN_TO_BE_CHANGED - struct ib_ah_attr ah_attr; ib_api_status_t status = IB_SUCCESS; struct ib_ah *ib_ah_p = (struct ib_ah *)h_av; - struct ib_device *ib_dev_p = ib_ah_p->pd->device; + struct ib_device *ib_dev = ib_ah_p->pd->device; HCA_ENTER(HCA_DBG_SHIM); // sanity checks if( p_umv_buf && p_umv_buf->command ) { - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("User mode is not supported yet\n")); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM, + ("User mode is not supported yet\n")); status = IB_UNSUPPORTED; goto err_user_unsupported; } // fill parameters - mlnx_conv_ibal_av( ib_dev_p, p_addr_vector, &ah_attr ); + mlnx_conv_ibal_av( ib_dev, p_addr_vector, &ah_attr ); // modify AH -#if 0 +#ifdef WIN_TO_BE_CHANGED //TODO: not implemented in low-level driver err = ibv_modify_ah(ib_ah_p, &ah_attr) if (err) { - HCA_PRINT (TRACE_LEVEL_ERROR, HCA_DBG_SHIM,("ibv_query_ah failed (%d)\n", err)); + HCA_PRINT (TRACE_LEVEL_ERROR, HCA_DBG_SHIM, + ("ibv_query_ah failed (%d)\n", err)); status = errno_to_iberr(err); goto err_query_ah; } @@ -1527,127 +700,35 @@ mlnx_modify_av ( #endif err_user_unsupported: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); - return status; - -#else - mlnx_avo_t *avo_p = (mlnx_avo_t *)h_av; - mlnx_hobul_t *hobul_p; - ib_api_status_t status; - - VAPI_ud_av_t av; - - HCA_ENTER( HCA_DBG_SHIM); - if (!avo_p || avo_p->mark != E_MARK_AV) { - status = IB_INVALID_AV_HANDLE; - goto cleanup; - } - - VALIDATE_INDEX(avo_p->hca_idx, MLNX_MAX_HCA, IB_INVALID_CA_HANDLE, cleanup); - hobul_p = mlnx_hobul_array[avo_p->hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_AV_HANDLE; - goto cleanup; - } - - cl_memclr(&av, sizeof(av)); - mlnx_conv_ibal_av(hobul_p->hh_hndl, p_addr_vector, &av); - if (HH_OK != THHUL_pdm_modify_ud_av(hobul_p->hhul_hndl, avo_p->h_av, &av)) { - status = IB_ERROR; - goto cleanup; - } - - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->output_size = 0; - p_umv_buf->status = IB_SUCCESS; - } - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup: - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->status = status; - } - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("status %d\n",status)); - HCA_EXIT( HCA_DBG_SHIM); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; -#endif } ib_api_status_t mlnx_destroy_av ( IN const ib_av_handle_t h_av) { -#ifndef WIN_TO_BE_CHANGED - int err; ib_api_status_t status = IB_SUCCESS; struct ib_ah *ib_ah_p = (struct ib_ah *)h_av; + PREP_IBDEV_FOR_PRINT(ib_ah_p->device) HCA_ENTER(HCA_DBG_SHIM); // destroy AV err = ibv_destroy_ah( ib_ah_p ); if (err) { - HCA_PRINT (TRACE_LEVEL_ERROR ,HCA_DBG_SHIM,("ibv_destroy_ah failed (%d)\n", err)); + HCA_PRINT (TRACE_LEVEL_ERROR ,HCA_DBG_SHIM, + ("ibv_destroy_ah failed (%d)\n", err)); status = errno_to_iberr(err); goto err_destroy_ah; } err_destroy_ah: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); - return status; - -#else - mlnx_avo_t *avo_p = (mlnx_avo_t *)h_av; - mlnx_hobul_t *hobul_p; - ib_api_status_t status; - - HCA_ENTER( HCA_DBG_SHIM); - if (!avo_p || avo_p->mark != E_MARK_AV) { - status = IB_INVALID_AV_HANDLE; - goto cleanup; - } - - VALIDATE_INDEX(avo_p->hca_idx, MLNX_MAX_HCA, IB_INVALID_CA_HANDLE, cleanup); - hobul_p = mlnx_hobul_array[avo_p->hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_AV_HANDLE; - goto cleanup; - } - VALIDATE_INDEX(avo_p->pd_idx, hobul_p->max_pd, IB_INVALID_PD_HANDLE, cleanup); - if (E_MARK_PD != hobul_p->pd_info_tbl[avo_p->pd_idx].mark) { - status = IB_INVALID_PD_HANDLE; - goto cleanup; - } - - // This destroy's a non priviledged ud_av. - // To destroy a privilged ud_av call THH_hob_destroy_ud_av() - if (HH_OK != THHUL_pdm_destroy_ud_av(hobul_p->hhul_hndl, avo_p->h_av)) { - status = IB_ERROR; - goto cleanup; - } - - // update PD object count - cl_atomic_dec(&hobul_p->pd_info_tbl[avo_p->pd_idx].count); - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM,("pd %d count %d\n", avo_p->pd_idx, hobul_p->pd_info_tbl[avo_p->pd_idx].count)); - - avo_p->mark = E_MARK_INVALID; - cl_free( avo_p); - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup: - if (avo_p) { - avo_p->mark = E_MARK_INVALID; - cl_free( avo_p); - } - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("status %d\n", status)); - HCA_EXIT( HCA_DBG_SHIM); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; -#endif } /* @@ -1710,7 +791,8 @@ _create_qp ( ib_qp_p = ibv_create_qp( ib_pd_p, &qp_init_attr, context_p, p_umv_buf ); if (IS_ERR(ib_qp_p)) { err = PTR_ERR(ib_qp_p); - HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_QP ,("ibv_create_qp failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_QP, + ("ibv_create_qp failed (%d)\n", err)); status = errno_to_iberr(err); goto err_create_qp; } @@ -1740,7 +822,8 @@ _create_qp ( end: if (p_umv_buf && p_umv_buf->command) p_umv_buf->status = status; - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_QP ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_QP , + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; } @@ -1753,247 +836,17 @@ mlnx_create_spl_qp ( OUT ib_qp_attr_t *p_qp_attr, OUT ib_qp_handle_t *ph_qp ) { -#ifndef WIN_TO_BE_CHANGED - ib_api_status_t status; + PREP_IBDEV_FOR_PRINT(((struct ib_pd*)h_pd)->device) HCA_ENTER(HCA_DBG_SHIM); status = _create_qp( h_pd, port_num, qp_context, p_create_attr, p_qp_attr, ph_qp, NULL ); - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); - return status; - -#else - ib_api_status_t status; - ib_qp_handle_t h_qp; - ci_umv_buf_t *p_umv_buf = NULL; - - uint32_t hca_idx = PD_HCA_FROM_HNDL(h_pd); - uint32_t pd_idx = PD_NUM_FROM_HNDL(h_pd); - uint32_t qp_num; - uint32_t qp_idx; - uint32_t send_cq_num; - uint32_t send_cq_idx; - uint32_t recv_cq_num; - uint32_t recv_cq_idx; - mlnx_hobul_t *hobul_p; - HH_hca_dev_t *hca_ul_info; - HH_qp_init_attr_t hh_qp_init_attr; - HHUL_qp_init_attr_t ul_qp_init_attr; - HHUL_qp_hndl_t hhul_qp_hndl = NULL; - VAPI_special_qp_t vapi_qp_type; - VAPI_qp_cap_t hh_qp_cap; - void *qp_ul_resources_p = NULL; - VAPI_sg_lst_entry_t *send_sge_p = NULL; - VAPI_sg_lst_entry_t *recv_sge_p = NULL; - uint32_t num_sge; - - HCA_ENTER( HCA_DBG_SHIM); - - VALIDATE_INDEX(hca_idx, MLNX_MAX_HCA, IB_INVALID_CA_HANDLE, cleanup); - hobul_p = mlnx_hobul_array[hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_PD_HANDLE; - goto cleanup; - } - VALIDATE_INDEX(pd_idx, hobul_p->max_pd, IB_INVALID_PD_HANDLE, cleanup); - if (E_MARK_PD != hobul_p->pd_info_tbl[pd_idx].mark) { - status = IB_INVALID_PD_HANDLE; - goto cleanup; - } - - hca_ul_info = (HH_hca_dev_t *)hobul_p->hh_hndl; - if (NULL == hca_ul_info) { - status = IB_INVALID_PD_HANDLE; - goto cleanup; - } - - // The create attributes must be provided - if (!p_create_attr) { - status = IB_INVALID_PARAMETER; - goto cleanup; - } - - // convert input parameters - cl_memclr(&ul_qp_init_attr, sizeof(ul_qp_init_attr)); - mlnx_conv_qp_create_attr(p_create_attr, &ul_qp_init_attr, &vapi_qp_type); - send_cq_num = CQ_NUM_FROM_HNDL(p_create_attr->h_sq_cq); - recv_cq_num = CQ_NUM_FROM_HNDL(p_create_attr->h_rq_cq); - send_cq_idx = send_cq_num & hobul_p->cq_idx_mask; - recv_cq_idx = recv_cq_num & hobul_p->cq_idx_mask; - VALIDATE_INDEX(send_cq_idx, hobul_p->max_cq, IB_INVALID_CQ_HANDLE, cleanup); - if ( E_MARK_CQ != hobul_p->cq_info_tbl[send_cq_idx].mark) { - status = IB_INVALID_CQ_HANDLE; - goto cleanup; - } - VALIDATE_INDEX(recv_cq_idx, hobul_p->max_cq, IB_INVALID_CQ_HANDLE, cleanup); - if ( E_MARK_CQ != hobul_p->cq_info_tbl[recv_cq_idx].mark) { - status = IB_INVALID_CQ_HANDLE; - goto cleanup; - } - - ul_qp_init_attr.pd = hobul_p->pd_info_tbl[pd_idx].hhul_pd_hndl; - ul_qp_init_attr.sq_cq = hobul_p->cq_info_tbl[send_cq_idx].hhul_cq_hndl; - ul_qp_init_attr.rq_cq = hobul_p->cq_info_tbl[recv_cq_idx].hhul_cq_hndl; - - if( p_umv_buf && p_umv_buf->command ) - { - // For user mode calls - obtain and verify the vendor information - if (p_umv_buf->input_size != hca_ul_info->qp_ul_resources_sz || - NULL == p_umv_buf->p_inout_buf) { - status = IB_INVALID_PARAMETER; - goto cleanup; - } - qp_ul_resources_p = (void *)p_umv_buf->p_inout_buf; - - } else { - // For kernel mode calls - allocate app resources. Use prep->call->done sequence - qp_ul_resources_p = cl_zalloc( hca_ul_info->qp_ul_resources_sz); - if (!qp_ul_resources_p) { - status = IB_INSUFFICIENT_MEMORY; - goto cleanup; - } - - if (HH_OK != THHUL_qpm_special_qp_prep(hobul_p->hhul_hndl, - vapi_qp_type, - port_num, - &ul_qp_init_attr, - &hhul_qp_hndl, - &hh_qp_cap, - qp_ul_resources_p)) { - status = IB_ERROR; - goto cleanup; - } - // TBD: if not same report error to IBAL - ul_qp_init_attr.qp_cap = hh_qp_cap; // struct assign - } - - // Convert HHUL to HH structure (for HH create_qp) - hh_qp_init_attr.pd = pd_idx; - hh_qp_init_attr.rdd = 0; // TBD: RDD - if( ul_qp_init_attr.srq != HHUL_INVAL_SRQ_HNDL ) - { - // TBD: HH handle from HHUL handle. - CL_ASSERT( ul_qp_init_attr.srq == HHUL_INVAL_SRQ_HNDL ); - } - else - { - hh_qp_init_attr.srq = HH_INVAL_SRQ_HNDL; - } - hh_qp_init_attr.sq_cq = send_cq_num; - hh_qp_init_attr.rq_cq = recv_cq_num; - hh_qp_init_attr.sq_sig_type = ul_qp_init_attr.sq_sig_type; - hh_qp_init_attr.rq_sig_type = ul_qp_init_attr.rq_sig_type; - hh_qp_init_attr.ts_type = VAPI_TS_UD; - hh_qp_init_attr.qp_cap = ul_qp_init_attr.qp_cap; // struct assign - - // Allocate the QP (cmdif) - if (HH_OK != THH_hob_get_special_qp( hobul_p->hh_hndl, - vapi_qp_type, - port_num, - &hh_qp_init_attr, - qp_ul_resources_p, - &qp_num)) - { - status = IB_ERROR; - goto cleanup_qp; - } - - if( !(p_umv_buf && p_umv_buf->command) ) - { - // Manage user level resources - if (HH_OK != THHUL_qpm_create_qp_done(hobul_p->hhul_hndl, hhul_qp_hndl, qp_num, qp_ul_resources_p)) { - THH_hob_destroy_qp(hobul_p->hh_hndl, qp_num); - status = IB_ERROR; - goto cleanup_qp; - } - - // Create SQ and RQ iov - num_sge = ul_qp_init_attr.qp_cap.max_sg_size_sq; - send_sge_p = cl_zalloc( num_sge * sizeof(VAPI_sg_lst_entry_t)); - if (!send_sge_p) { - status = IB_INSUFFICIENT_MEMORY; - goto cleanup_qp; - } - - num_sge = ul_qp_init_attr.qp_cap.max_sg_size_rq; - recv_sge_p = cl_zalloc( num_sge * sizeof(VAPI_sg_lst_entry_t)); - if (!recv_sge_p) { - status = IB_INSUFFICIENT_MEMORY; - goto cleanup_qp; - } - } - - // Save data refs for future use - qp_idx = qp_num & hobul_p->qp_idx_mask; - VALIDATE_INDEX(qp_idx, hobul_p->max_qp, IB_ERROR, cleanup_qp); - - h_qp = (ib_qp_handle_t)QP_HNDL_FROM_QP(qp_idx); - cl_mutex_acquire(&h_qp->mutex); - h_qp->pd_num = pd_idx; - h_qp->hhul_qp_hndl = hhul_qp_hndl; - h_qp->qp_type = p_create_attr->qp_type; - h_qp->sq_signaled = p_create_attr->sq_signaled; - h_qp->qp_context = qp_context; - h_qp->qp_ul_resources_p = qp_ul_resources_p; - h_qp->sq_size = ul_qp_init_attr.qp_cap.max_sg_size_sq; - h_qp->rq_size = ul_qp_init_attr.qp_cap.max_sg_size_rq; - h_qp->send_sge_p = send_sge_p; - h_qp->recv_sge_p = recv_sge_p; - h_qp->qp_num = qp_num; - h_qp->h_sq_cq = &hobul_p->cq_info_tbl[send_cq_idx]; - h_qp->h_rq_cq = &hobul_p->cq_info_tbl[recv_cq_idx]; - h_qp->kernel_mode = !(p_umv_buf && p_umv_buf->command); - h_qp->mark = E_MARK_QP; - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_SHIM,("qp num 0x%x idx 0x%x cq_s 0x%x cq_r 0x%x\n", - qp_num, qp_idx, send_cq_idx, recv_cq_idx)); - cl_mutex_release(&h_qp->mutex); - - /* Mark the CQ's associated with this special QP as being high priority. */ - cl_atomic_inc( &h_qp->h_sq_cq->spl_qp_cnt ); - KeSetImportanceDpc( &h_qp->h_sq_cq->dpc, HighImportance ); - cl_atomic_inc( &h_qp->h_rq_cq->spl_qp_cnt ); - KeSetImportanceDpc( &h_qp->h_rq_cq->dpc, HighImportance ); - - // Update PD object count - cl_atomic_inc(&hobul_p->pd_info_tbl[pd_idx].count); - HCA_PRINT(TRACE_LEVEL_INFORMATION , HCA_DBG_SHIM ,("pd %d count %d\n", pd_idx, hobul_p->pd_info_tbl[pd_idx].count)); - - // Query QP to obtain requested attributes - if (p_qp_attr) { - if (IB_SUCCESS != (status = mlnx_query_qp (h_qp, p_qp_attr, p_umv_buf))) { - goto cleanup; - } - } - - if (ph_qp) *ph_qp = h_qp; - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->output_size = p_umv_buf->input_size; - p_umv_buf->status = IB_SUCCESS; - } - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup_qp: - if (send_sge_p) cl_free( send_sge_p); - if (recv_sge_p) cl_free( recv_sge_p); - if( !(p_umv_buf && p_umv_buf->command) ) - THHUL_qpm_destroy_qp_done(hobul_p->hhul_hndl, hhul_qp_hndl); - -cleanup: - if( !(p_umv_buf && p_umv_buf->command) && qp_ul_resources_p ) - cl_free( qp_ul_resources_p); - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->status = status; - } - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("stauts %d\n", status)); - HCA_EXIT( HCA_DBG_SHIM); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; -#endif } ib_api_status_t @@ -2005,9 +858,9 @@ mlnx_create_qp ( OUT ib_qp_handle_t *ph_qp, IN OUT ci_umv_buf_t *p_umv_buf ) { -#ifndef WIN_TO_BE_CHANGED - ib_api_status_t status; + PREP_IBDEV_FOR_PRINT(((struct ib_pd*)h_pd)->device) + //NB: algorithm of mthca_alloc_sqp() requires port_num // PRM states, that special pares are created in couples, so // looks like we can put here port_num = 1 always @@ -2018,244 +871,24 @@ mlnx_create_qp ( status = _create_qp( h_pd, port_num, qp_context, p_create_attr, p_qp_attr, ph_qp, p_umv_buf ); - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_QP ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_QP, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; - -#else - ib_api_status_t status; - ib_qp_handle_t h_qp; - - uint32_t hca_idx = PD_HCA_FROM_HNDL(h_pd); - uint32_t pd_idx = PD_NUM_FROM_HNDL(h_pd); - uint32_t qp_num; - uint32_t qp_idx; - uint32_t send_cq_num; - uint32_t send_cq_idx; - uint32_t recv_cq_num; - uint32_t recv_cq_idx; - mlnx_hobul_t *hobul_p; - HH_hca_dev_t *hca_ul_info; - HH_qp_init_attr_t hh_qp_init_attr; - HHUL_qp_init_attr_t ul_qp_init_attr; - HHUL_qp_hndl_t hhul_qp_hndl = NULL; - VAPI_qp_cap_t hh_qp_cap; - void *qp_ul_resources_p = NULL; - VAPI_sg_lst_entry_t *send_sge_p = NULL; - VAPI_sg_lst_entry_t *recv_sge_p = NULL; - uint32_t num_sge; +} - HCA_ENTER( HCA_DBG_QP); - - VALIDATE_INDEX(hca_idx, MLNX_MAX_HCA, IB_INVALID_CA_HANDLE, cleanup); - hobul_p = mlnx_hobul_array[hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_PD_HANDLE; - goto cleanup; - } - VALIDATE_INDEX(pd_idx, hobul_p->max_pd, IB_INVALID_PD_HANDLE, cleanup); - if (E_MARK_PD != hobul_p->pd_info_tbl[pd_idx].mark) { - status = IB_INVALID_PD_HANDLE; - goto cleanup; - } - - hca_ul_info = (HH_hca_dev_t *)hobul_p->hh_hndl; - if (NULL == hca_ul_info) { - status = IB_INVALID_PD_HANDLE; - goto cleanup; - } - - // The create attributes must be provided - if (!p_create_attr) { - status = IB_INVALID_PARAMETER; - goto cleanup; - } - - // convert input parameters - cl_memclr(&ul_qp_init_attr, sizeof(ul_qp_init_attr)); - mlnx_conv_qp_create_attr(p_create_attr, &ul_qp_init_attr, NULL); - send_cq_num = CQ_NUM_FROM_HNDL(p_create_attr->h_sq_cq); - recv_cq_num = CQ_NUM_FROM_HNDL(p_create_attr->h_rq_cq); - send_cq_idx = send_cq_num & hobul_p->cq_idx_mask; - recv_cq_idx = recv_cq_num & hobul_p->cq_idx_mask; - VALIDATE_INDEX(send_cq_idx, hobul_p->max_cq, IB_INVALID_CQ_HANDLE, cleanup); - if ( E_MARK_CQ != hobul_p->cq_info_tbl[send_cq_idx].mark) { - status = IB_INVALID_CQ_HANDLE; - goto cleanup; - } - VALIDATE_INDEX(recv_cq_idx, hobul_p->max_cq, IB_INVALID_CQ_HANDLE, cleanup); - if ( E_MARK_CQ != hobul_p->cq_info_tbl[recv_cq_idx].mark) { - status = IB_INVALID_CQ_HANDLE; - goto cleanup; - } - - ul_qp_init_attr.pd = hobul_p->pd_info_tbl[pd_idx].hhul_pd_hndl; - ul_qp_init_attr.sq_cq = hobul_p->cq_info_tbl[send_cq_idx].hhul_cq_hndl; - ul_qp_init_attr.rq_cq = hobul_p->cq_info_tbl[recv_cq_idx].hhul_cq_hndl; - - if( p_umv_buf && p_umv_buf->command ) - { - // For user mode calls - obtain and verify the vendor information - if ((p_umv_buf->input_size - sizeof (uint32_t)) != - hca_ul_info->qp_ul_resources_sz || - NULL == p_umv_buf->p_inout_buf) { - status = IB_INVALID_PARAMETER; - goto cleanup; - } - qp_ul_resources_p = (void *)p_umv_buf->p_inout_buf; - - } else { - // for kernel mode calls - allocate app resources. Use prep->call->done sequence - qp_ul_resources_p = cl_zalloc( hca_ul_info->qp_ul_resources_sz); - if (!qp_ul_resources_p) { - status = IB_INSUFFICIENT_MEMORY; - goto cleanup; - } - - if (HH_OK != THHUL_qpm_create_qp_prep(hobul_p->hhul_hndl, &ul_qp_init_attr, &hhul_qp_hndl, &hh_qp_cap, qp_ul_resources_p)) { - status = IB_ERROR; - goto cleanup; - } - // TBD: if not same report error to IBAL - ul_qp_init_attr.qp_cap = hh_qp_cap; // struct assign - } - - // Convert HHUL to HH structure (for HH create_qp) - hh_qp_init_attr.pd = pd_idx; - hh_qp_init_attr.rdd = 0; // TBD: RDD - if( ul_qp_init_attr.srq != HHUL_INVAL_SRQ_HNDL ) - { - // TBD: HH handle from HHUL handle. - CL_ASSERT( ul_qp_init_attr.srq == HHUL_INVAL_SRQ_HNDL ); - } - else - { - hh_qp_init_attr.srq = HH_INVAL_SRQ_HNDL; - } - hh_qp_init_attr.sq_cq = send_cq_num; - hh_qp_init_attr.rq_cq = recv_cq_num; - hh_qp_init_attr.sq_sig_type = ul_qp_init_attr.sq_sig_type; - hh_qp_init_attr.rq_sig_type = ul_qp_init_attr.rq_sig_type; - hh_qp_init_attr.ts_type = ul_qp_init_attr.ts_type; - hh_qp_init_attr.qp_cap = ul_qp_init_attr.qp_cap; // struct assign - - // Allocate the QP (cmdif) - if (HH_OK != THH_hob_create_qp(hobul_p->hh_hndl, &hh_qp_init_attr, qp_ul_resources_p, &qp_num)) { - status = IB_INSUFFICIENT_RESOURCES; - goto cleanup_qp; - } - - if( !(p_umv_buf && p_umv_buf->command) ) - { - // Manage user level resources - if (HH_OK != THHUL_qpm_create_qp_done(hobul_p->hhul_hndl, hhul_qp_hndl, qp_num, qp_ul_resources_p)) { - THH_hob_destroy_qp(hobul_p->hh_hndl, qp_num); - status = IB_ERROR; - goto cleanup_qp; - } - - // Create SQ and RQ iov - num_sge = ul_qp_init_attr.qp_cap.max_sg_size_sq; - send_sge_p = cl_zalloc( num_sge * sizeof(VAPI_sg_lst_entry_t)); - if (!send_sge_p) { - status = IB_INSUFFICIENT_MEMORY; - goto cleanup_qp; - } - - num_sge = ul_qp_init_attr.qp_cap.max_sg_size_rq; - recv_sge_p = cl_zalloc( num_sge * sizeof(VAPI_sg_lst_entry_t)); - if (!recv_sge_p) { - status = IB_INSUFFICIENT_MEMORY; - goto cleanup_qp; - } - } - - // Save data refs for future use - qp_idx = qp_num & hobul_p->qp_idx_mask; - VALIDATE_INDEX(qp_idx, hobul_p->max_qp, IB_ERROR, cleanup_qp); - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_QP,("hobul_p 0x%p mask 0x%x qp_idx 0x%x qp_num 0x%x\n", - hobul_p, hobul_p->qp_idx_mask, qp_idx, qp_num)); - - h_qp = (ib_qp_handle_t)QP_HNDL_FROM_QP(qp_idx); - cl_mutex_acquire(&h_qp->mutex); - h_qp->pd_num = pd_idx; - h_qp->hhul_qp_hndl = hhul_qp_hndl; - h_qp->qp_type = p_create_attr->qp_type; - h_qp->sq_signaled = p_create_attr->sq_signaled; - h_qp->qp_context = qp_context; - h_qp->qp_ul_resources_p = qp_ul_resources_p; - h_qp->sq_size = ul_qp_init_attr.qp_cap.max_sg_size_sq; - h_qp->rq_size = ul_qp_init_attr.qp_cap.max_sg_size_rq; - h_qp->send_sge_p = send_sge_p; - h_qp->recv_sge_p = recv_sge_p; - h_qp->qp_num = qp_num; - h_qp->h_sq_cq = &hobul_p->cq_info_tbl[send_cq_idx]; - h_qp->h_rq_cq = &hobul_p->cq_info_tbl[recv_cq_idx]; - h_qp->kernel_mode = !(p_umv_buf && p_umv_buf->command); - h_qp->mark = E_MARK_QP; - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_QP,("qp num 0x%x idx 0x%x cq_s 0x%x cq_r 0x%x\n", - qp_num, qp_idx, send_cq_idx, recv_cq_idx)); - cl_mutex_release(&h_qp->mutex); - // Update PD object count - cl_atomic_inc(&hobul_p->pd_info_tbl[pd_idx].count); - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_QP,("pd %d count %d\n", pd_idx, hobul_p->pd_info_tbl[pd_idx].count)); - - // Query QP to obtain requested attributes - if (p_qp_attr) { - if (IB_SUCCESS != (status = mlnx_query_qp (h_qp, p_qp_attr, p_umv_buf))) - { - if( !(p_umv_buf && p_umv_buf->command) ) - goto cleanup_qp; - else - goto cleanup; - } - } - - if (ph_qp) *ph_qp = h_qp; - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->output_size = p_umv_buf->input_size; - p_umv_buf->status = IB_SUCCESS; - /* - * Copy the qp_idx back to user - */ - cl_memcpy (((uint8_t* __ptr64)p_umv_buf->p_inout_buf + hca_ul_info->qp_ul_resources_sz), - &qp_num, sizeof (qp_num)); - } - HCA_EXIT( HCA_DBG_QP); - return IB_SUCCESS; - -cleanup_qp: - if (send_sge_p) cl_free( send_sge_p); - if (recv_sge_p) cl_free( recv_sge_p); - if( !(p_umv_buf && p_umv_buf->command) ) - THHUL_qpm_destroy_qp_done(hobul_p->hhul_hndl, hhul_qp_hndl); - -cleanup: - if( !(p_umv_buf && p_umv_buf->command) && qp_ul_resources_p) - cl_free( qp_ul_resources_p); - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->status = status; - } - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_QP ,("status %d\n", status)); - return status; -#endif -} - -ib_api_status_t -mlnx_modify_qp ( - IN const ib_qp_handle_t h_qp, - IN const ib_qp_mod_t *p_modify_attr, - OUT ib_qp_attr_t *p_qp_attr OPTIONAL, - IN OUT ci_umv_buf_t *p_umv_buf OPTIONAL ) -{ -#ifndef WIN_TO_BE_CHANGED - - ib_api_status_t status; - int err; - struct ib_qp_attr qp_attr; - int qp_attr_mask; - struct ib_qp *ib_qp_p = (struct ib_qp *)h_qp; +ib_api_status_t +mlnx_modify_qp ( + IN const ib_qp_handle_t h_qp, + IN const ib_qp_mod_t *p_modify_attr, + OUT ib_qp_attr_t *p_qp_attr OPTIONAL, + IN OUT ci_umv_buf_t *p_umv_buf OPTIONAL ) +{ + ib_api_status_t status; + int err; + struct ib_qp_attr qp_attr; + int qp_attr_mask; + struct ib_qp *ib_qp_p = (struct ib_qp *)h_qp; + PREP_IBDEV_FOR_PRINT(ib_qp_p->device) HCA_ENTER(HCA_DBG_QP); @@ -2315,115 +948,9 @@ err_mode_unsupported: err_inval_params: if (p_umv_buf && p_umv_buf->command) p_umv_buf->status = status; - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; - -#else - ib_api_status_t status; - - uint32_t hca_idx = QP_HCA_FROM_HNDL(h_qp); - uint32_t qp_num = QP_NUM_FROM_HNDL(h_qp); - uint32_t qp_idx = 0; - mlnx_hobul_t *hobul_p; - HHUL_qp_hndl_t hhul_qp_hndl; - VAPI_qp_attr_mask_t hh_qp_attr_mask; - VAPI_qp_attr_t hh_qp_attr; - VAPI_qp_state_t hh_qp_state; - - HCA_ENTER( HCA_DBG_QP); - - VALIDATE_INDEX(hca_idx, MLNX_MAX_HCA, IB_INVALID_CA_HANDLE, cleanup); - hobul_p = mlnx_hobul_array[hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_QP_HANDLE; - goto cleanup; - } - - qp_idx = qp_num & hobul_p->qp_idx_mask; - VALIDATE_INDEX(qp_idx, hobul_p->max_qp, IB_INVALID_QP_HANDLE, cleanup); - if ( E_MARK_QP != hobul_p->qp_info_tbl[qp_idx].mark) { - status = IB_INVALID_QP_HANDLE; - goto cleanup; - } - - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_QP, - ("Before acquire mutex to modify qp_idx 0x%x\n", - qp_idx)); - - cl_mutex_acquire(&hobul_p->qp_info_tbl[qp_idx].mutex); - - hhul_qp_hndl = hobul_p->qp_info_tbl[qp_idx].hhul_qp_hndl; - - // Obtain curernt state of QP - if (HH_OK != THH_hob_query_qp(hobul_p->hh_hndl, hobul_p->qp_info_tbl[qp_idx].qp_num, &hh_qp_attr)) - { - status = IB_ERROR; - goto cleanup_locked; - } - hh_qp_state = hh_qp_attr.qp_state; // The current (pre-modify) state - - // Convert the input parameters. Use query result as default (no cl_memset()) - // cl_memclr(&hh_qp_attr, sizeof(hh_qp_attr)); - status = mlnx_conv_qp_modify_attr(hobul_p->hh_hndl, - hobul_p->qp_info_tbl[qp_idx].qp_type, - p_modify_attr, &hh_qp_attr, &hh_qp_attr_mask); - if( status != IB_SUCCESS ) - goto cleanup_locked; - - if (HH_OK != THH_hob_modify_qp(hobul_p->hh_hndl, - hobul_p->qp_info_tbl[qp_idx].qp_num, - hh_qp_state, &hh_qp_attr, &hh_qp_attr_mask)) - { - status = IB_ERROR; - goto cleanup_locked; - } - - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_QP, - ("After hob_modify_qp qp_idx 0x%x k_mod %d\n", - qp_idx, hobul_p->qp_info_tbl[qp_idx].kernel_mode)); - - // Notify HHUL of the new (post-modify) state. This is done for both k-mode calls only - if (hobul_p->qp_info_tbl[qp_idx].kernel_mode) { - if (HH_OK != THHUL_qpm_modify_qp_done(hobul_p->hhul_hndl, hhul_qp_hndl, hh_qp_attr.qp_state)) - { - status = IB_ERROR; - goto cleanup_locked; - } - } - cl_mutex_release(&hobul_p->qp_info_tbl[qp_idx].mutex); - - if ((p_qp_attr) && !(p_umv_buf && p_umv_buf->command)) { - if (IB_SUCCESS != (status = mlnx_query_qp (h_qp, p_qp_attr, p_umv_buf))) { - goto cleanup; - } - } - - if ( p_umv_buf && p_umv_buf->command && (! hobul_p->qp_info_tbl[qp_idx].kernel_mode)) { - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_QP, - ("mod_qp qp_idx %d umv_buf %p inout_buf %p\n", - qp_idx, p_umv_buf, p_umv_buf->p_inout_buf)); - if (p_umv_buf->p_inout_buf) { - p_umv_buf->output_size = sizeof (VAPI_qp_state_t); - cl_memcpy (p_umv_buf->p_inout_buf, &(hh_qp_attr.qp_state), - (size_t)p_umv_buf->output_size); - p_umv_buf->status = IB_SUCCESS; - } - } - HCA_EXIT( HCA_DBG_QP); - return IB_SUCCESS; - - -cleanup_locked: - cl_mutex_release(&hobul_p->qp_info_tbl[qp_idx].mutex); - -cleanup: - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->status = status; - } - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_QP ,("status %d\n", status)); - return status; -#endif } ib_api_status_t @@ -2432,11 +959,10 @@ mlnx_query_qp ( OUT ib_qp_attr_t *p_qp_attr, IN OUT ci_umv_buf_t *p_umv_buf ) { -#ifndef WIN_TO_BE_CHANGED - ib_api_status_t status = IB_SUCCESS; struct ib_qp *ib_qp_p = (struct ib_qp *)h_qp; struct mthca_qp *qp_p = (struct mthca_qp *)ib_qp_p; + PREP_IBDEV_FOR_PRINT(ib_qp_p->device) UNREFERENCED_PARAMETER(p_umv_buf); @@ -2462,8 +988,8 @@ mlnx_query_qp ( p_qp_attr->state = mlnx_qps_to_ibal( qp_p->state ); p_qp_attr->num = cl_hton32(qp_p->ibqp.qp_num); -#if 0 -//TODO: don't know how to fill the following fileds without support of query_qp in MTHCA +#ifdef WIN_TO_BE_CHANGED +//TODO: don't know how to fill the following fields without support of query_qp in MTHCA p_qp_attr->access_ctrl = qp_p-> p_qp_attr->pkey_index = qp_p-> p_qp_attr->dest_num = qp_p- @@ -2480,72 +1006,9 @@ mlnx_query_qp ( status = IB_SUCCESS; - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_QP ,("completes with ERROR status %s\n", ib_get_err_str(status))); - return status; - - -#else - ib_api_status_t status; - - uint32_t hca_idx = QP_HCA_FROM_HNDL(h_qp); - uint32_t qp_num = QP_NUM_FROM_HNDL(h_qp); - uint32_t qp_idx = 0; - mlnx_hobul_t *hobul_p; - VAPI_qp_attr_t hh_qp_attr; - - HCA_ENTER( HCA_DBG_QP); - - VALIDATE_INDEX(hca_idx, MLNX_MAX_HCA, IB_INVALID_CA_HANDLE, cleanup); - hobul_p = mlnx_hobul_array[hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_QP_HANDLE; - goto cleanup; - } - - qp_idx = qp_num & hobul_p->qp_idx_mask; - VALIDATE_INDEX(qp_idx, hobul_p->max_qp, IB_INVALID_QP_HANDLE, cleanup); - if ( E_MARK_QP != hobul_p->qp_info_tbl[qp_idx].mark) { - status = IB_INVALID_QP_HANDLE; - goto cleanup; - } - - cl_mutex_acquire(&h_qp->mutex); - - if (HH_OK != THH_hob_query_qp(hobul_p->hh_hndl, h_qp->qp_num, &hh_qp_attr)) { - status = IB_ERROR; - goto cleanup_locked; - } - - // Convert query result into IBAL structure (no cl_memset()) - mlnx_conv_vapi_qp_attr(hobul_p->hh_hndl, &hh_qp_attr, p_qp_attr); - p_qp_attr->qp_type = h_qp->qp_type; - p_qp_attr->h_pd = (ib_pd_handle_t)PD_HNDL_FROM_PD(h_qp->pd_num); - p_qp_attr->h_sq_cq = h_qp->h_sq_cq; - p_qp_attr->h_rq_cq = h_qp->h_rq_cq; - p_qp_attr->sq_signaled = h_qp->sq_signaled; - - cl_mutex_release(&h_qp->mutex); - - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->output_size = 0; - p_umv_buf->status = IB_SUCCESS; - } - HCA_EXIT( HCA_DBG_QP); - return IB_SUCCESS; - -cleanup_locked: - cl_mutex_release(&hobul_p->qp_info_tbl[qp_idx].mutex); -cleanup: - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->output_size = 0; - p_umv_buf->status = status; - } - - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_QP ,("status %d\n", status)); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_QP, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; -#endif } ib_api_status_t @@ -2553,12 +1016,11 @@ mlnx_destroy_qp ( IN const ib_qp_handle_t h_qp, IN const uint64_t timewait ) { -#ifndef WIN_TO_BE_CHANGED - ib_api_status_t status; int err; struct ib_qp *ib_qp_p = (struct ib_qp *)h_qp; - + PREP_IBDEV_FOR_PRINT(ib_qp_p->device) + UNUSED_PARAM( timewait ); HCA_ENTER( HCA_DBG_QP); @@ -2568,7 +1030,8 @@ mlnx_destroy_qp ( err = ibv_destroy_qp( ib_qp_p ); if (err) { - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_QP ,("ibv_destroy_qp failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_QP, + ("ibv_destroy_qp failed (%d)\n", err)); status = errno_to_iberr(err); goto err_destroy_qp; } @@ -2576,113 +1039,9 @@ mlnx_destroy_qp ( status = IB_SUCCESS; err_destroy_qp: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_QP ,("completes with ERROR status %s\n", ib_get_err_str(status))); - return status; - -#else - - ib_api_status_t status; - - uint32_t hca_idx = QP_HCA_FROM_HNDL(h_qp); - uint32_t qp_num = QP_NUM_FROM_HNDL(h_qp); - uint32_t pd_idx = 0; - uint32_t qp_idx = 0; - mlnx_hobul_t *hobul_p; - HHUL_qp_hndl_t hhul_qp_hndl; - - UNUSED_PARAM( timewait ); - - HCA_ENTER( HCA_DBG_QP); - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_QP,("hca %d qp 0x%x\n", hca_idx, qp_num)); - - VALIDATE_INDEX(hca_idx, MLNX_MAX_HCA, IB_INVALID_CA_HANDLE, cleanup); - hobul_p = mlnx_hobul_array[hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_QP_HANDLE; - goto cleanup; - } - - qp_idx = qp_num & hobul_p->qp_idx_mask; - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_QP ,("hobul_p 0x%p mask 0x%x qp_idx 0x%x mark %d\n", - hobul_p, hobul_p->qp_idx_mask, qp_idx, hobul_p->qp_info_tbl[qp_idx].mark)); - - VALIDATE_INDEX(qp_idx, hobul_p->max_qp, IB_INVALID_QP_HANDLE, cleanup); - if ( E_MARK_QP != hobul_p->qp_info_tbl[qp_idx].mark) { - if (E_MARK_INVALID == hobul_p->qp_info_tbl[qp_idx].mark) { - HCA_PRINT(TRACE_LEVEL_ERROR,HCA_DBG_SHIM, - ("completes with ERROR status %s\n", ib_get_err_str(IB_INVALID_QP_HANDLE))); - return IB_SUCCESS; // Already freed - } - status = IB_INVALID_QP_HANDLE; - goto cleanup; - } - - cl_mutex_acquire(&hobul_p->qp_info_tbl[qp_idx].mutex); - - hhul_qp_hndl = hobul_p->qp_info_tbl[qp_idx].hhul_qp_hndl; - pd_idx = hobul_p->qp_info_tbl[qp_idx].pd_num; - VALIDATE_INDEX(pd_idx, hobul_p->max_pd, IB_ERROR, cleanup_locked); - - if (E_MARK_PD != hobul_p->pd_info_tbl[pd_idx].mark) { - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_QP,("file %s line %d\n", __FILE__, __LINE__)); - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_QP,("pd_idx 0x%x mark %d\n", pd_idx, hobul_p->pd_info_tbl[pd_idx].mark)); - status = IB_INVALID_PD_HANDLE; - goto cleanup_locked; - } - - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_QP, - ("Before THH_destroy qp_idx 0x%x k_mod %d pd_idx 0x%x\n", - qp_idx, hobul_p->qp_info_tbl[qp_idx].kernel_mode, pd_idx)); - - // PREP: no PREP required for destroy_qp - if (HH_OK != THH_hob_destroy_qp(hobul_p->hh_hndl, qp_num)) { - status = IB_ERROR; - goto cleanup_locked; - } - - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_QP, - ("After THH_destroy qp_idx 0x%x k_mod %d pd_idx 0x%x\n", - qp_idx, hobul_p->qp_info_tbl[qp_idx].kernel_mode, pd_idx)); - - if (hobul_p->qp_info_tbl[qp_idx].kernel_mode) { - if (HH_OK != THHUL_qpm_destroy_qp_done(hobul_p->hhul_hndl, hhul_qp_hndl)) { - status = IB_ERROR; - goto cleanup_locked; - } - if (hobul_p->qp_info_tbl[qp_idx].qp_ul_resources_p) - cl_free( hobul_p->qp_info_tbl[qp_idx].qp_ul_resources_p); - if (hobul_p->qp_info_tbl[qp_idx].send_sge_p) - cl_free( hobul_p->qp_info_tbl[qp_idx].send_sge_p); - if (hobul_p->qp_info_tbl[qp_idx].recv_sge_p) - cl_free( hobul_p->qp_info_tbl[qp_idx].recv_sge_p); - } - - if( h_qp->qp_type == IB_QPT_QP0 || h_qp->qp_type == IB_QPT_QP1 ) - { - if( !cl_atomic_dec( &h_qp->h_sq_cq->spl_qp_cnt ) ) - KeSetImportanceDpc( &h_qp->h_sq_cq->dpc, MediumImportance ); - if( !cl_atomic_dec( &h_qp->h_rq_cq->spl_qp_cnt ) ) - KeSetImportanceDpc( &h_qp->h_rq_cq->dpc, MediumImportance ); - } - - hobul_p->qp_info_tbl[qp_idx].mark = E_MARK_INVALID; - hobul_p->qp_info_tbl[qp_idx].qp_ul_resources_p = NULL; - cl_mutex_release(&hobul_p->qp_info_tbl[qp_idx].mutex); - - // Update PD object count - cl_atomic_dec(&hobul_p->pd_info_tbl[pd_idx].count); - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_QP,("pd %d count %d\n", pd_idx, hobul_p->pd_info_tbl[pd_idx].count)); - - HCA_EXIT( HCA_DBG_QP); - return IB_SUCCESS; - -cleanup_locked: - cl_mutex_release(&hobul_p->qp_info_tbl[qp_idx].mutex); -cleanup: - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_QP ,("status %d\n",status)); - HCA_EXIT( HCA_DBG_SHIM); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_QP, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; -#endif } /* @@ -2697,8 +1056,6 @@ mlnx_create_cq ( OUT ib_cq_handle_t *ph_cq, IN OUT ci_umv_buf_t *p_umv_buf ) { -#ifndef WIN_TO_BE_CHANGED - int err; ib_api_status_t status; struct ib_cq *ib_cq_p; @@ -2709,7 +1066,11 @@ mlnx_create_cq ( HCA_ENTER(HCA_DBG_CQ); - if( p_umv_buf && p_umv_buf->command ) { + if( p_umv_buf ) { + + context_p = (struct ib_ucontext *)h_ca; + hob_p = HOB_FROM_IBDEV(context_p->device); + ib_dev = context_p->device; // sanity checks if (p_umv_buf->input_size < sizeof(struct ibv_create_cq) || @@ -2718,10 +1079,6 @@ mlnx_create_cq ( status = IB_INVALID_PARAMETER; goto err_inval_params; } - - context_p = (struct ib_ucontext *)h_ca; - hob_p = HOB_FROM_IBDEV(context_p->device); - ib_dev = context_p->device; } else { hob_p = (mlnx_hob_t *)h_ca; @@ -2756,135 +1113,9 @@ err_create_cq: err_inval_params: if (p_umv_buf && p_umv_buf->command) p_umv_buf->status = status; - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_CQ ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_CQ, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; - -#else - ib_api_status_t status; - - mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; - uint32_t cq_idx; - uint32_t cq_num; - uint32_t cq_size = 0; - mlnx_hobul_t *hobul_p; - HH_hca_dev_t *hca_ul_info; - HHUL_cq_hndl_t hhul_cq_hndl = NULL; - void *cq_ul_resources_p = NULL; - MOSAL_protection_ctx_t prot_ctx; - - HCA_ENTER( HCA_DBG_CQ); - - hobul_p = mlnx_hobs_get_hobul(hob_p); - if (NULL == hobul_p) { - status = IB_INVALID_CA_HANDLE; - goto cleanup; - } - - hca_ul_info = (HH_hca_dev_t *)hobul_p->hh_hndl; - if (NULL == hca_ul_info) { - status = IB_INVALID_PD_HANDLE; - goto cleanup; - } - - // The size must be provided - if (!p_size) { - status = IB_INVALID_PARAMETER; - goto cleanup; - } - // TBD: verify that the number requested does not exceed to maximum allowed - - if( p_umv_buf && p_umv_buf->command ) - { - // For user mode calls - obtain and verify the vendor information - if ((p_umv_buf->input_size - sizeof (uint32_t)) != - hca_ul_info->cq_ul_resources_sz || - NULL == p_umv_buf->p_inout_buf) { - status = IB_INVALID_PARAMETER; - goto cleanup; - } - cq_ul_resources_p = (void *)p_umv_buf->p_inout_buf; - - /* get the current protection context */ - prot_ctx = MOSAL_get_current_prot_ctx(); - } else { - // for kernel mode calls - allocate app resources. Use prep->call->done sequence - cq_ul_resources_p = cl_zalloc( hca_ul_info->cq_ul_resources_sz); - if (!cq_ul_resources_p) { - status = IB_INSUFFICIENT_MEMORY; - goto cleanup; - } - if (HH_OK != THHUL_cqm_create_cq_prep(hobul_p->hhul_hndl, *p_size, &hhul_cq_hndl, &cq_size, cq_ul_resources_p)) { - status = IB_ERROR; - goto cleanup; - } - /* get the current protection context */ - prot_ctx = MOSAL_get_kernel_prot_ctx(); - } - - // Allocate the CQ (cmdif) - if (HH_OK != THH_hob_create_cq(hobul_p->hh_hndl, prot_ctx, cq_ul_resources_p, &cq_num)) { - status = IB_INSUFFICIENT_RESOURCES; - goto cleanup_cq; - } - - if( !(p_umv_buf && p_umv_buf->command) ) - { - // Manage user level resources - if (HH_OK != THHUL_cqm_create_cq_done(hobul_p->hhul_hndl, hhul_cq_hndl, cq_num, cq_ul_resources_p)) { - THH_hob_destroy_cq(hobul_p->hh_hndl, cq_num); - status = IB_ERROR; - goto cleanup_cq; - } - } - - // Save data refs for future use - cq_idx = cq_num & hobul_p->cq_idx_mask; - VALIDATE_INDEX(cq_idx, hobul_p->max_cq, IB_ERROR, cleanup_cq); - cl_mutex_acquire(&hobul_p->cq_info_tbl[cq_idx].mutex); - hobul_p->cq_info_tbl[cq_idx].hca_idx = hob_p->index; - hobul_p->cq_info_tbl[cq_idx].cq_num = cq_num; -// hobul_p->cq_info_tbl[cq_idx].pd_num = pd_idx; - hobul_p->cq_info_tbl[cq_idx].hhul_cq_hndl = hhul_cq_hndl; - hobul_p->cq_info_tbl[cq_idx].cq_context = cq_context; - hobul_p->cq_info_tbl[cq_idx].cq_ul_resources_p = cq_ul_resources_p; - hobul_p->cq_info_tbl[cq_idx].kernel_mode = !(p_umv_buf && p_umv_buf->command); - hobul_p->cq_info_tbl[cq_idx].mark = E_MARK_CQ; - cl_mutex_release(&hobul_p->cq_info_tbl[cq_idx].mutex); - - // Update CA object count - cl_atomic_inc(&hobul_p->count); - HCA_PRINT(TRACE_LEVEL_INFORMATION, HCA_DBG_CQ,("HCA %d count %d\n", h_ca->index, hobul_p->count)); - - *p_size = cq_size; - if (ph_cq) *ph_cq = (ib_cq_handle_t)CQ_HNDL_FROM_CQ(cq_idx); - - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->output_size = p_umv_buf->input_size; - p_umv_buf->status = IB_SUCCESS; - /* - * Copy the cq_idx back to user - */ - cl_memcpy (((uint8_t* __ptr64)p_umv_buf->p_inout_buf + hca_ul_info->cq_ul_resources_sz), - &cq_num, sizeof (cq_num)); - } - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup_cq: - THHUL_cqm_destroy_cq_done(hobul_p->hhul_hndl, hhul_cq_hndl); - -cleanup: - if( !(p_umv_buf && p_umv_buf->command) && cq_ul_resources_p ) - cl_free( cq_ul_resources_p); - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->status = status; - } - - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_CQ ,("status %d\n",status)); - return status; -#endif } ib_api_status_t @@ -2893,7 +1124,6 @@ mlnx_resize_cq ( IN OUT uint32_t *p_size, IN OUT ci_umv_buf_t *p_umv_buf ) { -#ifndef WIN_TO_BE_CHANGED UNREFERENCED_PARAMETER(h_cq); UNREFERENCED_PARAMETER(p_size); if (p_umv_buf && p_umv_buf->command) { @@ -2901,101 +1131,6 @@ mlnx_resize_cq ( } HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("mlnx_resize_cq not implemented\n")); return IB_UNSUPPORTED; -#else - ib_api_status_t status; - - uint32_t hca_idx = CQ_HCA_FROM_HNDL(h_cq); - uint32_t cq_num = CQ_NUM_FROM_HNDL(h_cq); - uint32_t cq_idx; - mlnx_hobul_t *hobul_p; - - HHUL_cq_hndl_t hhul_cq_hndl; - void *cq_ul_resources_p = NULL; - - HCA_ENTER( HCA_DBG_SHIM); - - if (!p_size) { - status = IB_INVALID_PARAMETER; - goto cleanup; - } - VALIDATE_INDEX(hca_idx, MLNX_MAX_HCA, IB_INVALID_CQ_HANDLE, cleanup); - hobul_p = mlnx_hobul_array[hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_CQ_HANDLE; - goto cleanup; - } - - cq_idx = cq_num & hobul_p->cq_idx_mask; - VALIDATE_INDEX(cq_idx, hobul_p->max_cq, IB_INVALID_CQ_HANDLE, cleanup); - if ( E_MARK_CQ != hobul_p->cq_info_tbl[cq_idx].mark) { - status = IB_INVALID_CQ_HANDLE; - goto cleanup; - } - - cl_mutex_acquire(&hobul_p->cq_info_tbl[cq_idx].mutex); - - hhul_cq_hndl = hobul_p->cq_info_tbl[cq_idx].hhul_cq_hndl; - - if( p_umv_buf && p_umv_buf->command ) - { - // For user mode calls - obtain and verify the vendor information - if( p_umv_buf->input_size != hobul_p->cq_ul_resources_sz || - NULL == p_umv_buf->p_inout_buf ) - { - status = IB_INVALID_PARAMETER; - goto cleanup_locked; - } - cq_ul_resources_p = (void *)p_umv_buf->p_inout_buf; - - } else { - // for kernel mode calls - obtain the saved app resources. Use prep->call->done sequence - cq_ul_resources_p = hobul_p->cq_info_tbl[cq_idx].cq_ul_resources_p; - - if (HH_OK != THHUL_cqm_resize_cq_prep( - hobul_p->hhul_hndl, hhul_cq_hndl, - *p_size, p_size, cq_ul_resources_p)) - { - status = IB_ERROR; - goto cleanup_locked; - } - } - - if (HH_OK != THH_hob_resize_cq(hobul_p->hh_hndl, cq_num, cq_ul_resources_p)) { - status = IB_ERROR; - goto cleanup_locked; - } - - // DONE: when called on behalf of kernel module - if (hobul_p->cq_info_tbl[cq_idx].kernel_mode) { - if (HH_OK != THHUL_cqm_resize_cq_done( hobul_p->hhul_hndl, hhul_cq_hndl, cq_ul_resources_p)) - { - status = IB_ERROR; - goto cleanup_locked; - } - } - - cl_mutex_release(&hobul_p->cq_info_tbl[cq_idx].mutex); - - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->output_size = p_umv_buf->input_size; - p_umv_buf->status = IB_SUCCESS; - } - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup_locked: - cl_mutex_release(&hobul_p->cq_info_tbl[cq_idx].mutex); - -cleanup: - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->status = status; - } - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("status %d\n", status)); - HCA_EXIT( HCA_DBG_SHIM); - return status; -#endif } ib_api_status_t @@ -3004,7 +1139,6 @@ mlnx_query_cq ( OUT uint32_t *p_size, IN OUT ci_umv_buf_t *p_umv_buf ) { -#ifndef WIN_TO_BE_CHANGED UNREFERENCED_PARAMETER(h_cq); UNREFERENCED_PARAMETER(p_size); if (p_umv_buf && p_umv_buf->command) { @@ -3012,77 +1146,17 @@ mlnx_query_cq ( } HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("mlnx_query_cq not implemented\n")); return IB_UNSUPPORTED; -#else - ib_api_status_t status; - - uint32_t hca_idx = CQ_HCA_FROM_HNDL(h_cq); - uint32_t cq_num = CQ_NUM_FROM_HNDL(h_cq); - uint32_t cq_idx; - mlnx_hobul_t *hobul_p; - HHUL_cq_hndl_t hhul_cq_hndl; - - HCA_ENTER( HCA_DBG_SHIM); - - if (!p_size) { - status = IB_INVALID_PARAMETER; - goto cleanup; - } - VALIDATE_INDEX(hca_idx, MLNX_MAX_HCA, IB_INVALID_CQ_HANDLE, cleanup); - hobul_p = mlnx_hobul_array[hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_CQ_HANDLE; - goto cleanup; - } - - cq_idx = cq_num & hobul_p->cq_idx_mask; - VALIDATE_INDEX(cq_idx, hobul_p->max_cq, IB_INVALID_CQ_HANDLE, cleanup); - if ( E_MARK_CQ != hobul_p->cq_info_tbl[cq_idx].mark) { - status = IB_INVALID_CQ_HANDLE; - goto cleanup; - } - - cl_mutex_acquire(&hobul_p->cq_info_tbl[cq_idx].mutex); - - hhul_cq_hndl = hobul_p->cq_info_tbl[cq_idx].hhul_cq_hndl; - - if (HH_OK != THH_hob_query_cq(hobul_p->hh_hndl, cq_num, p_size)) { - status = IB_ERROR; - goto cleanup_locked; - } - - cl_mutex_release(&hobul_p->cq_info_tbl[cq_idx].mutex); - - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->output_size = 0; - p_umv_buf->status = IB_SUCCESS; - } - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup_locked: - cl_mutex_release(&hobul_p->cq_info_tbl[cq_idx].mutex); - -cleanup: - if( p_umv_buf && p_umv_buf->command ) - { - p_umv_buf->status = status; - } - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("status %d\n", status)); - HCA_EXIT( HCA_DBG_SHIM); - return status; -#endif } ib_api_status_t mlnx_destroy_cq ( IN const ib_cq_handle_t h_cq) { -#ifndef WIN_TO_BE_CHANGED ib_api_status_t status; int err; struct ib_cq *ib_cq_p = (struct ib_cq *)h_cq; + PREP_IBDEV_FOR_PRINT(ib_cq_p->device) HCA_ENTER( HCA_DBG_QP); @@ -3092,7 +1166,8 @@ mlnx_destroy_cq ( // destroy CQ err = ibv_destroy_cq( ib_cq_p ); if (err) { - HCA_PRINT (TRACE_LEVEL_ERROR ,HCA_DBG_SHIM,("ibv_destroy_cq failed (%d)\n", err)); + HCA_PRINT (TRACE_LEVEL_ERROR ,HCA_DBG_SHIM, + ("ibv_destroy_cq failed (%d)\n", err)); status = errno_to_iberr(err); goto err_destroy_cq; } @@ -3100,80 +1175,9 @@ mlnx_destroy_cq ( status = IB_SUCCESS; err_destroy_cq: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); - return status; - -#else - ib_api_status_t status; - - uint32_t hca_idx = CQ_HCA_FROM_HNDL(h_cq); - uint32_t cq_num = CQ_NUM_FROM_HNDL(h_cq); - uint32_t cq_idx; -// uint32_t pd_idx = 0; - mlnx_hobul_t *hobul_p; - HHUL_cq_hndl_t hhul_cq_hndl; - - HCA_ENTER( HCA_DBG_SHIM); - - VALIDATE_INDEX(hca_idx, MLNX_MAX_HCA, IB_INVALID_CQ_HANDLE, cleanup); - hobul_p = mlnx_hobul_array[hca_idx]; - if (NULL == hobul_p) { - status = IB_INVALID_CQ_HANDLE; - goto cleanup; - } - - cq_idx = cq_num & hobul_p->cq_idx_mask; - VALIDATE_INDEX(cq_idx, hobul_p->max_cq, IB_INVALID_CQ_HANDLE, cleanup); - if ( E_MARK_CQ != hobul_p->cq_info_tbl[cq_idx].mark) { - status = IB_INVALID_CQ_HANDLE; - goto cleanup; - } - - cl_mutex_acquire(&hobul_p->cq_info_tbl[cq_idx].mutex); - - hhul_cq_hndl = hobul_p->cq_info_tbl[cq_idx].hhul_cq_hndl; -// pd_idx = hobul_p->cq_info_tbl[cq_idx].pd_num; -// VALIDATE_INDEX(pd_idx, hobul_p->max_pd, IB_ERROR, cleanup); -// if (E_MARK_PD != hobul_p->pd_info_tbl[pd_idx].mark) { -// status = IB_INVALID_PD_HANDLE; -// goto cleanup_locked; -// } - - // PREP: no PREP required for destroy_cq - if (HH_OK != THH_hob_destroy_cq(hobul_p->hh_hndl, cq_num)) { - status = IB_ERROR; - goto cleanup_locked; - } - - if (hobul_p->cq_info_tbl[cq_idx].kernel_mode) { - if (HH_OK != THHUL_cqm_destroy_cq_done(hobul_p->hhul_hndl, hhul_cq_hndl)) { - status = IB_ERROR; - goto cleanup_locked; - } - if (hobul_p->cq_info_tbl[cq_idx].cq_ul_resources_p) - cl_free( hobul_p->cq_info_tbl[cq_idx].cq_ul_resources_p); - } - - hobul_p->cq_info_tbl[cq_idx].mark = E_MARK_INVALID; - hobul_p->cq_info_tbl[cq_idx].cq_ul_resources_p = NULL; - cl_mutex_release(&hobul_p->cq_info_tbl[cq_idx].mutex); - - // Update CA object count - cl_atomic_dec(&hobul_p->count); - HCA_PRINT(TRACE_LEVEL_INFORMATION , HCA_DBG_SHIM ,("CA %d count %d\n", hca_idx, hobul_p->count)); - - - HCA_EXIT( HCA_DBG_SHIM); - return IB_SUCCESS; - -cleanup_locked: - cl_mutex_release(&hobul_p->cq_info_tbl[cq_idx].mutex); - -cleanup: - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("status %d\n", status)); - HCA_EXIT( HCA_DBG_SHIM); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return status; -#endif } diff --git a/trunk/hw/mthca/kernel/mt_l2w.c b/trunk/hw/mthca/kernel/mt_l2w.c index bfd32b16..e1d99291 100644 --- a/trunk/hw/mthca/kernel/mt_l2w.c +++ b/trunk/hw/mthca/kernel/mt_l2w.c @@ -1,33 +1,5 @@ #include -u64 mt_ticks_per_sec; - -void MT_time_calibrate() -{ -#if defined(_WIN64) && (defined(IA64) || defined(_IA64_)) - /* Itanium */ - mt_ticks_per_sec = 10000000; - -#elif defined(_WIN64) && (defined(AMD64) || defined(_AMD64_)) - /* x64 */ - - LARGE_INTEGER a; - KeQueryPerformanceCounter( &a ); - mt_ticks_per_sec = a.QuadPart; - -#elif defined(_WIN32) && (defined(i386) || defined(_x86_)) - /* x86 */ - - LARGE_INTEGER a; - KeQueryPerformanceCounter( &a ); - mt_ticks_per_sec = a.QuadPart; - -#else - #error Unsupported platform -#endif - -} - pci_pool_t * pci_pool_create (const char *name, struct mthca_dev *mdev, size_t size, size_t align, size_t allocation) diff --git a/trunk/hw/mthca/kernel/mt_l2w.h b/trunk/hw/mthca/kernel/mt_l2w.h index ccf40d10..f9690366 100644 --- a/trunk/hw/mthca/kernel/mt_l2w.h +++ b/trunk/hw/mthca/kernel/mt_l2w.h @@ -22,7 +22,7 @@ #include #include //#include -#include +#include #include diff --git a/trunk/hw/mthca/kernel/mt_time.h b/trunk/hw/mthca/kernel/mt_time.h deleted file mode 100644 index 3738ecf0..00000000 --- a/trunk/hw/mthca/kernel/mt_time.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef MT_TIME_H -#define MT_TIME_H - - -/* get time stamp */ -static inline volatile u64 MT_time_get_stamp(void) -{ - volatile u64 tsc; - -#if defined(_WIN64) && (defined(IA64) || defined(_IA64_)) - /* Itanium */ - - /* returns a value in units of 100 nsecs */ - tsc = KeQueryInterruptTime(); - -#elif defined(_WIN64) && (defined(AMD64) || defined(_AMD64_)) - /* x64 */ - - /* returns a value in units of Time-Stamp Counter (usually, clocks) */ - tsc = __rdtsc(); - -#elif defined(_WIN32) && (defined(i386) || defined(_x86_)) - /* x86 */ - - /* returns a value in units of Time-Stamp Counter (usually, clocks) */ - __asm { - lea ebx,tsc - rdtsc - mov [ebx],eax - mov [ebx+4],edx - } -#else - #error Unsupported platform -#endif - - return tsc; -} - -extern u64 mt_ticks_per_sec; - - -/* CONVERTIONS */ -#define MT_USECS_TO_TICKS(to) ((mt_ticks_per_sec * (to)) / 1000000 ) -#define MT_MSECS_TO_TICKS(to) MT_USECS_TO_TICKS(1000 * to) - -/* comparison */ -#define time_after(a,b) ((INT64)(b) - (INT64)(a) < 0) -#define time_before(a,b) time_after(b,a) -#define time_after_eq(a,b) ((INT64)(a) - (INT64)(b) >= 0) -#define time_before_eq(a,b) time_after_eq(b,a) - - -#endif - diff --git a/trunk/hw/mthca/kernel/mt_verbs.c b/trunk/hw/mthca/kernel/mt_verbs.c index 9d2b566b..739af0da 100644 --- a/trunk/hw/mthca/kernel/mt_verbs.c +++ b/trunk/hw/mthca/kernel/mt_verbs.c @@ -56,38 +56,44 @@ void ibv_um_close( struct ib_ucontext * h_um_ca ) int err; ib_api_status_t status; struct ib_ucontext *context_p = (struct ib_ucontext *)h_um_ca; + PREP_IBDEV_FOR_PRINT(context_p->device) HCA_ENTER(HCA_DBG_SHIM); context_p->is_removing = TRUE; if (atomic_read(&context_p->usecnt)) { - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("resources are not released (cnt %d)\n", context_p->usecnt)); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM, + ("resources are not released (cnt %d)\n", context_p->usecnt)); status = IB_RESOURCE_BUSY; goto err_usage; } err = ibv_dealloc_pd( context_p->pd ); if (err) { - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("ibv_dealloc_pd failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM, + ("ibv_dealloc_pd failed (%d)\n", err)); status = errno_to_iberr(err); } err = mthca_dealloc_ucontext(context_p); if (err) { - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM ,("mthca_dealloc_ucontext failed (%d)\n", err)); + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_SHIM, + ("mthca_dealloc_ucontext failed (%d)\n", err)); status = errno_to_iberr(err); goto err_dealloc_ucontext; } - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_SHIM , ("pcs %p\n", PsGetCurrentProcess()) ); + HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_SHIM, + ("pcs %p\n", PsGetCurrentProcess()) ); status = IB_SUCCESS; goto end; err_dealloc_ucontext: err_usage: end: - HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("completes with ERROR status %s\n", ib_get_err_str(status))); + HCA_PRINT_EXIT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM, + ("completes with ERROR status %s\n", IB_GET_ERR_STR(status))); return; } diff --git a/trunk/hw/mthca/kernel/mthca_av.c b/trunk/hw/mthca/kernel/mthca_av.c index 837bb3de..03ffe437 100644 --- a/trunk/hw/mthca/kernel/mthca_av.c +++ b/trunk/hw/mthca/kernel/mthca_av.c @@ -130,8 +130,7 @@ on_hca_fail: av->dgid[3] = cl_hton32(2); } -#if 0 - { + { // debug print int j; HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("Created UDAV at %p/%08lx:\n", @@ -140,7 +139,6 @@ on_hca_fail: HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,(" [%2x] %08x\n", j * 4, cl_ntoh32(((__be32 *) av)[j]))); } -#endif if (ah->type == MTHCA_AH_ON_HCA) { memcpy_toio((u8*)dev->av_table.av_map + index * MTHCA_AV_SIZE, diff --git a/trunk/hw/mthca/kernel/mthca_cmd.c b/trunk/hw/mthca/kernel/mthca_cmd.c index 3913691e..9125b670 100644 --- a/trunk/hw/mthca/kernel/mthca_cmd.c +++ b/trunk/hw/mthca/kernel/mthca_cmd.c @@ -215,9 +215,9 @@ static int wait_go_bit(struct mthca_dev *dev, unsigned long timeout_usecs) if (!go_bit(dev)) return 0; interval.QuadPart = -(__int64)(((u64)(timeout_usecs) * 10) / CMD_POLL_N_TRIES); - start = MT_time_get_stamp(); - end = start + MT_USECS_TO_TICKS(timeout_usecs); - while (go_bit(dev) && time_before( MT_time_get_stamp(), end )) { + start = cl_get_time_stamp(); + end = start + timeout_usecs; + while (go_bit(dev) && (cl_get_time_stamp() < end)) { KeDelayExecutionThread( KernelMode, FALSE, &interval ); } @@ -1617,21 +1617,19 @@ int mthca_MODIFY_QP(struct mthca_dev *dev, int trans, u32 num, mailbox = NULL; } } else { - #if 0 - { + { // debug print int i; HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,("Dumping QP context:\n")); - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW ,(" opt param mask: %08x\n", cl_ntoh32(*(__be32 *)mailbox->buf))); + HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,(" opt param mask: %08x\n", cl_ntoh32(*(__be32 *)mailbox->buf))); for (i = 0; i < 0x100 / 4; ++i) { if (i % 8 == 0) - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW ,(" [%02x] ", i * 4)); - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW ,(" %08x", + HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,(" [%02x] ", i * 4)); + HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,(" %08x", cl_ntoh32(((__be32 *) mailbox->buf)[i + 2]))); if ((i + 1) % 8 == 0) - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW ,("\n")); + HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,("\n")); } } - #endif } if (trans == MTHCA_TRANS_ANY2RST) { @@ -1639,21 +1637,19 @@ int mthca_MODIFY_QP(struct mthca_dev *dev, int trans, u32 num, (!!is_ee << 24) | num, op_mod, op[trans], CMD_TIME_CLASS_C, status); - #if 0 - if (mailbox) { + if (mailbox) { // debug print int i; HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,("Dumping QP context:\n")); - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW ,(" %08x\n", cl_ntoh32(*(__be32 *)mailbox->buf))); + HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,(" %08x\n", cl_ntoh32(*(__be32 *)mailbox->buf))); for (i = 0; i < 0x100 / 4; ++i) { if (i % 8 == 0) - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW ,("[%02x] ", i * 4)); - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW ,(" %08x", + HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,("[%02x] ", i * 4)); + HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,(" %08x", cl_ntoh32(((__be32 *) mailbox->buf)[i + 2]))); if ((i + 1) % 8 == 0) - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW ,("\n")); + HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,("\n")); } } - #endif } else err = mthca_cmd(dev, mailbox->dma, (!!is_ee << 24) | num, op_mod, op[trans], CMD_TIME_CLASS_C, status); diff --git a/trunk/hw/mthca/kernel/mthca_cq.c b/trunk/hw/mthca/kernel/mthca_cq.c index e9b210ca..12564ba7 100644 --- a/trunk/hw/mthca/kernel/mthca_cq.c +++ b/trunk/hw/mthca/kernel/mthca_cq.c @@ -182,16 +182,16 @@ 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) +static void dump_cqe(u32 print_lvl, struct mthca_dev *dev, void *cqe_ptr) { __be32 *cqe = cqe_ptr; UNREFERENCED_PARAMETER(dev); (void) cqe; /* avoid warning if mthca_dbg compiled away... */ - HCA_PRINT(TRACE_LEVEL_INFORMATION,HCA_DBG_CQ,("CQE contents \n")); - HCA_PRINT(TRACE_LEVEL_INFORMATION,HCA_DBG_CQ,("\t[%2x] %08x %08x %08x %08x\n",0, + HCA_PRINT(print_lvl,HCA_DBG_CQ,("CQE contents \n")); + HCA_PRINT(print_lvl,HCA_DBG_CQ,("\t[%2x] %08x %08x %08x %08x\n",0, cl_ntoh32(cqe[0]), cl_ntoh32(cqe[1]), cl_ntoh32(cqe[2]), cl_ntoh32(cqe[3]))); - HCA_PRINT(TRACE_LEVEL_INFORMATION,HCA_DBG_CQ,("\t[%2x] %08x %08x %08x %08x \n",16, + HCA_PRINT(print_lvl,HCA_DBG_CQ,("\t[%2x] %08x %08x %08x %08x \n",16, cl_ntoh32(cqe[4]), cl_ntoh32(cqe[5]), cl_ntoh32(cqe[6]), cl_ntoh32(cqe[7]))); } @@ -293,14 +293,13 @@ void mthca_cq_clean(struct mthca_dev *dev, u32 cqn, u32 qpn, */ for (prod_index = cq->cons_index; cqe_sw(cq, prod_index & cq->ibcq.cqe); - ++prod_index) + ++prod_index) { if (prod_index == cq->cons_index + cq->ibcq.cqe) break; + } - #if 0 - HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("Cleaning QPN %06x from CQN %06x; ci %d, pi %d\n", - qpn, cqn, cq->cons_index, prod_index)); - #endif + HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("Cleaning QPN %06x from CQN %06x; ci %d, pi %d\n", + qpn, cqn, cq->cons_index, prod_index)); /* * Now sweep backwards through the CQ, removing CQ entries @@ -347,7 +346,7 @@ static int handle_error_cqe(struct mthca_dev *dev, struct mthca_cq *cq, "(QPN %06x, WQE @ %08x, CQN %06x, index %d)\n", cl_ntoh32(cqe->my_qpn), cl_ntoh32(cqe->wqe), cq->cqn, cq->cons_index)); - dump_cqe(dev, cqe); + dump_cqe(TRACE_LEVEL_INFORMATION, dev, cqe); } @@ -460,14 +459,12 @@ static inline int mthca_poll_one(struct mthca_dev *dev, */ rmb(); - #if 0 - { + { // debug print HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_CQ,("%x/%d: CQE -> QPN %06x, WQE @ %08x\n", cq->cqn, cq->cons_index, cl_ntoh32(cqe->my_qpn), cl_ntoh32(cqe->wqe))); - dump_cqe(dev, cqe); + dump_cqe(TRACE_LEVEL_VERBOSE, dev, cqe); } - #endif is_error = (cqe->opcode & MTHCA_ERROR_CQE_OPCODE_MASK) == MTHCA_ERROR_CQE_OPCODE_MASK; @@ -898,18 +895,16 @@ void mthca_free_cq(struct mthca_dev *dev, HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_LOW ,("HW2SW_CQ returned status 0x%02x\n", status)); } - #if 0 - { + { // debug print __be32 *ctx = mailbox->buf; int j; - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_LOW ,("context for CQN %x (cons index %x, next sw %d)\n", + HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,("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) - HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_LOW ,("[%2x] %08x\n", j * 4, cl_ntoh32(ctx[j]))); + HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,("[%2x] %08x\n", j * 4, cl_ntoh32(ctx[j]))); } - #endif spin_lock_irq(&dev->cq_table.lock, &lh); mthca_array_clear(&dev->cq_table.cq, diff --git a/trunk/hw/mthca/kernel/mthca_eq.c b/trunk/hw/mthca/kernel/mthca_eq.c index fcfb4485..702dd46b 100644 --- a/trunk/hw/mthca/kernel/mthca_eq.c +++ b/trunk/hw/mthca/kernel/mthca_eq.c @@ -715,18 +715,16 @@ static void mthca_free_eq(struct mthca_dev *dev, dev->eq_table.arm_mask &= ~eq->eqn_mask; - #if 0 - { + { // debug print HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,("Dumping EQ context %02x:\n", eq->eqn)); for (i = 0; i < sizeof (struct mthca_eq_context) / 4; ++i) { if (i % 4 == 0) - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW ,("[%02x] ", i * 4)); - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW ,(" %08x", cl_ntoh32(*(u32*)((u8*)mailbox->buf + i * 4)))); + HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,("[%02x] ", i * 4)); + HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,(" %08x", cl_ntoh32(*(u32*)((u8*)mailbox->buf + i * 4)))); if ((i + 1) % 4 == 0) - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW ,("\n")); + HCA_PRINT(TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,("\n")); } } - #endif mthca_free_mr(dev, &eq->mr); for (i = 0; i < npages; ++i) { diff --git a/trunk/hw/mthca/kernel/mthca_mad.c b/trunk/hw/mthca/kernel/mthca_mad.c index 3425d685..423620c3 100644 --- a/trunk/hw/mthca/kernel/mthca_mad.c +++ b/trunk/hw/mthca/kernel/mthca_mad.c @@ -191,13 +191,10 @@ int mthca_process_mad(struct ib_device *ibdev, u8 status; u16 slid = in_wc ? in_wc->recv.ud.remote_lid : cl_ntoh16(IB_LID_PERMISSIVE); - -#if 0 - HCA_PRINT( TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW,("mthca_process_mad: \n\tin: Class %02x, Method %02x, AttrId %x, AttrMod %x, ClSpec %x, Tid %I64x\n"), + HCA_PRINT( TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW,("mthca_process_mad: \n\tin: Class %02x, Method %02x, AttrId %x, AttrMod %x, ClSpec %x, Tid %I64x\n", (u32)in_mad->mad_hdr.mgmt_class, (u32)in_mad->mad_hdr.method, (u32)in_mad->mad_hdr.attr_id, in_mad->mad_hdr.attr_mod, (u32)in_mad->mad_hdr.class_specific, in_mad->mad_hdr.tid )); -#endif /* Forward locally generated traps to the SM */ if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP && @@ -271,20 +268,11 @@ int mthca_process_mad(struct ib_device *ibdev, if (!out_mad->mad_hdr.status) smp_snoop(ibdev, port_num, in_mad); -#if 0 - //NB: excluded, because it is set in the shim. Being set here, it prevents shim MAD cache to work ! - /* 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 |= cl_hton16(1 << 15); -#endif - -#if 0 HCA_PRINT( TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW,("mthca_process_mad: \n\tout: Class %02x, Method %02x, AttrId %x, AttrMod %x, ClSpec %x, Tid %I64x, Status %x\n", (u32)in_mad->mad_hdr.mgmt_class, (u32)in_mad->mad_hdr.method, (u32)in_mad->mad_hdr.attr_id, in_mad->mad_hdr.attr_mod, (u32)in_mad->mad_hdr.class_specific, in_mad->mad_hdr.tid, (u32)in_mad->mad_hdr.status )); -#endif if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS) { /* no response for trap repress */ diff --git a/trunk/hw/mthca/kernel/mthca_mcg.c b/trunk/hw/mthca/kernel/mthca_mcg.c index 4000a4f7..7417076d 100644 --- a/trunk/hw/mthca/kernel/mthca_mcg.c +++ b/trunk/hw/mthca/kernel/mthca_mcg.c @@ -97,7 +97,6 @@ static int find_mgm(struct mthca_dev *dev, goto out; } - #if 0 HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("Hash for %04x:%04x:%04x:%04x:" "%04x:%04x:%04x:%04x is %04x\n", cl_ntoh16(((__be16 *) gid)[0]), @@ -109,7 +108,6 @@ static int find_mgm(struct mthca_dev *dev, cl_ntoh16(((__be16 *) gid)[6]), cl_ntoh16(((__be16 *) gid)[7]), *hash)); - #endif *index = *hash; *prev = -1; diff --git a/trunk/hw/mthca/kernel/mthca_memfree.c b/trunk/hw/mthca/kernel/mthca_memfree.c index e44a18fa..ad469f0b 100644 --- a/trunk/hw/mthca/kernel/mthca_memfree.c +++ b/trunk/hw/mthca/kernel/mthca_memfree.c @@ -347,10 +347,9 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, ++table->icm[i]->refcount; } -#if 0 - HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("Allocated/max chunks %d:%d, reserved/max objects %#x:%#x, one/total size %#x:%#x at %lx \n", + HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW, + ("Allocated/max chunks %d:%d, reserved/max objects %#x:%#x, one/total size %#x:%#x at %I64x \n", i, num_icm, reserved, nobj, obj_size, nobj * obj_size, (unsigned long long) virt)); -#endif return table; @@ -379,10 +378,10 @@ void mthca_free_icm_table(struct mthca_dev *dev, struct mthca_icm_table *table) mthca_free_icm(dev, table->icm[i]); } -#if 0 - HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW, ( "Released chunks %d, objects %#x, one/total size %#x:%#x at %lx \n", - table->num_icm, table->num_obj, table->obj_size, table->num_obj * table->obj_size, (unsigned long long) table->virt)); -#endif + HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW, + ( "Released chunks %d, objects %#x, one/total size %#x:%#x at %I64x \n", + table->num_icm, table->num_obj, table->obj_size, + table->num_obj * table->obj_size, (unsigned long long) table->virt)); kfree(table); } diff --git a/trunk/hw/mthca/kernel/mthca_mr.c b/trunk/hw/mthca/kernel/mthca_mr.c index b9766da2..cafcb9cb 100644 --- a/trunk/hw/mthca/kernel/mthca_mr.c +++ b/trunk/hw/mthca/kernel/mthca_mr.c @@ -91,13 +91,13 @@ struct mthca_mpt_entry { #define MTHCA_MPT_STATUS_HW 0x00 -static void dump_mtt(__be64 *mtt_entry ,int list_len) +static void dump_mtt(u32 print_lvl, __be64 *mtt_entry ,int list_len) { int i; UNREFERENCED_PARAMETER(mtt_entry); // for release version - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_MEMORY ,("Dumping MTT entry len %d :\n",list_len)); + HCA_PRINT(print_lvl ,HCA_DBG_MEMORY ,("Dumping MTT entry len %d :\n",list_len)); for (i = 0; i < list_len && i < MTHCA_MAILBOX_SIZE / 8 - 2; i=i+4) { - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_MEMORY ,("[%02x] %016I64x %016I64x %016I64x %016I64x\n",i, + HCA_PRINT(print_lvl ,HCA_DBG_MEMORY ,("[%02x] %016I64x %016I64x %016I64x %016I64x\n",i, cl_ntoh64(mtt_entry[i]), cl_ntoh64(mtt_entry[i+1]), cl_ntoh64(mtt_entry[i+2]), @@ -106,13 +106,13 @@ static void dump_mtt(__be64 *mtt_entry ,int list_len) } -static void dump_mpt(struct mthca_mpt_entry *mpt_entry ) +static void dump_mpt(u32 print_lvl, struct mthca_mpt_entry *mpt_entry ) { int i; UNREFERENCED_PARAMETER(mpt_entry); // for release version - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_MEMORY ,("Dumping MPT entry %08x :\n", mpt_entry->key)); + HCA_PRINT(print_lvl ,HCA_DBG_MEMORY ,("Dumping MPT entry %08x :\n", mpt_entry->key)); for (i = 0; i < sizeof (struct mthca_mpt_entry) / 4; i=i+4) { - HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_MEMORY ,("[%02x] %08x %08x %08x %08x \n",i, + HCA_PRINT(print_lvl ,HCA_DBG_MEMORY ,("[%02x] %08x %08x %08x %08x \n",i, cl_ntoh32(((__be32 *) mpt_entry)[i]), cl_ntoh32(((__be32 *) mpt_entry)[i+1]), cl_ntoh32(((__be32 *) mpt_entry)[i+2]), @@ -335,9 +335,7 @@ int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt, if (i & 1) mtt_entry[i + 2] = 0; - #if 0 - dump_mtt(mtt_entry ,i); - #endif + dump_mtt(TRACE_LEVEL_VERBOSE, mtt_entry ,i); err = mthca_WRITE_MTT(dev, mailbox, (i + 1) & ~1, &status); if (err) { @@ -451,7 +449,7 @@ int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift, mr->mtt->first_seg * MTHCA_MTT_SEG_SIZE); { - dump_mpt(mpt_entry); + dump_mpt(TRACE_LEVEL_VERBOSE, mpt_entry); } err = mthca_SW2HW_MPT(dev, mailbox, @@ -689,7 +687,8 @@ static inline int mthca_check_fmr(struct mthca_fmr *fmr, u64 *page_list, return -EINVAL; /* Trust the user not to pass misaligned data in page_list */ - #if 0 + #ifdef WIN_TO_BE_CHANGED + //TODO: do we need that ? for (i = 0; i < list_len; ++i) { if (page_list[i] & ~page_mask) return -EINVAL; diff --git a/trunk/hw/mthca/kernel/mthca_qp.c b/trunk/hw/mthca/kernel/mthca_qp.c index 01c53cd3..1806b5b3 100644 --- a/trunk/hw/mthca/kernel/mthca_qp.c +++ b/trunk/hw/mthca/kernel/mthca_qp.c @@ -331,21 +331,21 @@ static int is_qp0(struct mthca_dev *dev, struct mthca_qp *qp) } -static void dump_wqe(u32 *wqe_ptr , struct mthca_qp *qp_ptr) +static void dump_wqe(u32 print_lvl, u32 *wqe_ptr , struct mthca_qp *qp_ptr) { __be32 *wqe = wqe_ptr; UNREFERENCED_PARAMETER(qp_ptr); (void) wqe; /* avoid warning if mthca_dbg compiled away... */ - HCA_PRINT(TRACE_LEVEL_INFORMATION,HCA_DBG_QP,("WQE contents QPN 0x%06x \n",qp_ptr->qpn)); - HCA_PRINT(TRACE_LEVEL_INFORMATION,HCA_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",0 + HCA_PRINT(print_lvl,HCA_DBG_QP,("WQE contents QPN 0x%06x \n",qp_ptr->qpn)); + HCA_PRINT(print_lvl,HCA_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",0 , cl_ntoh32(wqe[0]), cl_ntoh32(wqe[1]), cl_ntoh32(wqe[2]), cl_ntoh32(wqe[3]))); - HCA_PRINT(TRACE_LEVEL_INFORMATION,HCA_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",4 + HCA_PRINT(print_lvl,HCA_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",4 , cl_ntoh32(wqe[4]), cl_ntoh32(wqe[5]), cl_ntoh32(wqe[6]), cl_ntoh32(wqe[7]))); - HCA_PRINT(TRACE_LEVEL_INFORMATION,HCA_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",8 + HCA_PRINT(print_lvl,HCA_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",8 , cl_ntoh32(wqe[8]), cl_ntoh32(wqe[9]), cl_ntoh32(wqe[10]), cl_ntoh32(wqe[11]))); - HCA_PRINT(TRACE_LEVEL_INFORMATION,HCA_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",12 + HCA_PRINT(print_lvl,HCA_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",12 , cl_ntoh32(wqe[12]), cl_ntoh32(wqe[13]), cl_ntoh32(wqe[14]), cl_ntoh32(wqe[15]))); } @@ -1676,9 +1676,7 @@ int mthca_tavor_post_send(struct ib_qp *ibqp, struct _ib_send_wr *wr, op0 = opcode; } - #if 0 - dump_wqe( (u32*)qp->sq.last,qp); - #endif + dump_wqe( TRACE_LEVEL_VERBOSE, (u32*)qp->sq.last,qp); ++ind; if (unlikely(ind >= qp->sq.max)) @@ -1797,9 +1795,7 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct _ib_recv_wr *wr, if (!size0) size0 = size; - #if 0 - dump_wqe( (u32*)wqe ,qp); - #endif + dump_wqe(TRACE_LEVEL_VERBOSE, (u32*)wqe ,qp); ++ind; if (unlikely(ind >= qp->rq.max)) diff --git a/trunk/hw/mthca/user/mlnx_ual_av.c b/trunk/hw/mthca/user/mlnx_ual_av.c index 1a7243c0..fe554406 100644 --- a/trunk/hw/mthca/user/mlnx_ual_av.c +++ b/trunk/hw/mthca/user/mlnx_ual_av.c @@ -91,8 +91,6 @@ gid_to_index_lookup ( return index; } -#ifndef WIN_TO_BE_CHANGED - ib_api_status_t map_itom_av_attr ( IN ib_ca_attr_t *p_ca_attr, @@ -135,54 +133,6 @@ map_itom_av_attr ( return status; } -#else -void -map_itom_av_attr ( - IN ib_ca_attr_t *p_ca_attr, - IN const ib_av_attr_t *p_av_attr, - OUT VAPI_ud_av_t *p_hhul_av) -{ - uint8_t ver; - uint8_t tclass; - uint32_t flow_lbl; - - p_hhul_av->sl = p_av_attr->sl; - p_hhul_av->port = p_av_attr->port_num; - p_hhul_av->dlid = CL_NTOH16 (p_av_attr->dlid); - /* - * VAPI uses static rate as IPD. - * 0 is matched links. 3 is suitable for 4x to 1x. - */ - p_hhul_av->static_rate = - (p_av_attr->static_rate == IB_PATH_RECORD_RATE_10_GBS? 0 : 3); - - p_hhul_av->src_path_bits = 0; - /* p_hhul_av->src_path_bits = p_av_attr->path_bits; */ - UVP_PRINT(TRACE_LEVEL_INFORMATION ,UVP_DBG_AV , - ("ib_av_attr->path_bits %d\n", p_av_attr->path_bits)); - p_hhul_av->grh_flag = (MT_bool)p_av_attr->grh_valid; - - if (p_av_attr->grh_valid) - { - ib_grh_get_ver_class_flow (p_av_attr->grh.ver_class_flow, - &ver, &tclass, &flow_lbl); - - p_hhul_av->hop_limit = p_av_attr->grh.hop_limit; - p_hhul_av->sgid_index = - gid_to_index_lookup (p_ca_attr, - p_av_attr->port_num, - (uint8_t *) p_av_attr->grh.src_gid.raw); - - cl_memcpy (p_hhul_av->dgid, p_av_attr->grh.dest_gid.raw, - sizeof (IB_gid_t)); - - p_hhul_av->traffic_class = tclass; - p_hhul_av->flow_label = flow_lbl; - } -} -#endif - - ib_api_status_t mlnx_pre_create_av ( IN const ib_pd_handle_t h_uvp_pd, @@ -240,7 +190,6 @@ end: } -#ifndef WIN_TO_BE_CHANGED void mlnx_post_create_av ( IN const ib_pd_handle_t h_uvp_pd, @@ -307,94 +256,6 @@ end: return; } -#else -void -mlnx_post_create_av ( - IN const ib_pd_handle_t h_uvp_pd, - IN ib_api_status_t ioctl_status, - OUT ib_av_handle_t *ph_uvp_av, - IN OUT ci_umv_buf_t *p_umv_buf) -{ - ib_api_status_t status; - mlnx_ual_hobul_t *p_hobul; - mlnx_ual_pd_info_t *p_pd_info = (mlnx_ual_pd_info_t *)((void*)h_uvp_pd); - ib_av_attr_t *p_av_attr; -#ifdef WIN_TO_BE_CHANGED - VAPI_ud_av_t hhul_av; -#endif - mlnx_ual_av_info_t *p_new_av = NULL; - - UVP_ENTER(UVP_DBG_AV); - CL_ASSERT (p_pd_info); - CL_ASSERT (p_umv_buf); - - p_hobul = p_pd_info->p_hobul; - CL_ASSERT (p_hobul); - - /* - * Set initial value for handle - */ - *ph_uvp_av = NULL; - - status = ioctl_status; - - if (IB_SUCCESS == status) - { - if (sizeof (ib_av_attr_t) != p_umv_buf->output_size) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_AV , - ("Priv buffer has different size\n")); - status = IB_ERROR; - goto cleanup; - } - p_av_attr = (ib_av_attr_t *) p_umv_buf->p_inout_buf; - CL_ASSERT (p_av_attr); - - p_new_av = cl_zalloc (sizeof (mlnx_ual_av_info_t)); - -#ifdef WIN_TO_BE_CHANGED - map_itom_av_attr (p_hobul->p_hca_attr, p_av_attr, &hhul_av); - - if (HH_OK != - THHUL_pdm_create_ud_av (p_hobul->hhul_hca_hndl, - p_pd_info->hhul_pd_hndl, - &hhul_av, - &p_new_av->h_av)) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_AV , - ("FAILED to create usermode UD AV\n")); - status = IB_ERROR; - goto cleanup; - } -#endif - - p_new_av->p_i_av_attr = p_av_attr; - p_new_av->h_uvp_pd = h_uvp_pd; - *ph_uvp_av = p_new_av; - p_umv_buf->p_inout_buf = NULL; - } - /* - * clean_up if required - */ -cleanup: - if ((IB_SUCCESS != status) && (IB_SUCCESS == ioctl_status)) - { - if (p_new_av) - { - if (p_new_av->p_i_av_attr); - { - cl_free (p_new_av->p_i_av_attr); - } - cl_free (p_new_av); - } - } - - UVP_EXIT(UVP_DBG_AV); - return; -} - -#endif - ib_api_status_t mlnx_pre_query_av ( IN const ib_av_handle_t h_uvp_av, @@ -433,8 +294,6 @@ mlnx_post_query_av ( UVP_EXIT(UVP_DBG_AV); } -#ifndef WIN_TO_BE_CHANGED - void mthca_set_av_params( struct mthca_ah *ah_p, struct ibv_ah_attr *ah_attr ); ib_api_status_t @@ -474,55 +333,6 @@ mlnx_pre_modify_av ( return IB_VERBS_PROCESSING_DONE; } -#else -ib_api_status_t -mlnx_pre_modify_av ( - IN const ib_av_handle_t h_uvp_av, - IN const ib_av_attr_t *p_addr_vector, - IN OUT ci_umv_buf_t *p_umv_buf) -{ - ib_api_status_t status = IB_VERBS_PROCESSING_DONE; - - mlnx_ual_av_info_t *p_av_info = (mlnx_ual_av_info_t *)((void*) h_uvp_av); - mlnx_ual_pd_info_t *p_pd_info; - mlnx_ual_hobul_t *p_hobul; -#ifdef WIN_TO_BE_CHANGED - VAPI_ud_av_t hhul_av; -#endif - - UVP_ENTER(UVP_DBG_AV); - CL_ASSERT (p_umv_buf); - - p_pd_info = (mlnx_ual_pd_info_t *)((void*) p_av_info->h_uvp_pd); - CL_ASSERT (p_pd_info); - - p_hobul = p_pd_info->p_hobul; - CL_ASSERT (p_hobul); - -#ifdef WIN_TO_BE_CHANGED - map_itom_av_attr (p_hobul->p_hca_attr, p_addr_vector, &hhul_av); - - if (HH_OK != - THHUL_pdm_modify_ud_av (p_hobul->hhul_hca_hndl, - p_av_info->h_av, - &hhul_av)) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_AV , - ("Failed to modify AV\n")); - status = IB_ERROR; - } - else -#endif - { - cl_memcpy (p_av_info->p_i_av_attr, p_addr_vector, sizeof (ib_av_attr_t)); - } - - UVP_EXIT(UVP_DBG_AV); - - return status; -} -#endif - void mlnx_post_modify_av ( IN const ib_av_handle_t h_uvp_av, @@ -544,8 +354,6 @@ mlnx_pre_destroy_av ( return IB_VERBS_PROCESSING_DONE; } -#ifndef WIN_TO_BE_CHANGED - void mlnx_post_destroy_av ( IN const ib_av_handle_t h_uvp_av, @@ -560,46 +368,3 @@ mlnx_post_destroy_av ( return; } -#else -void -mlnx_post_destroy_av ( - IN const ib_av_handle_t h_uvp_av, - IN ib_api_status_t ioctl_status) -{ - mlnx_ual_hobul_t *p_hobul; - mlnx_ual_pd_info_t *p_pd_info; - mlnx_ual_av_info_t *p_av_info = (mlnx_ual_av_info_t *)((void*) h_uvp_av); - - UVP_ENTER(UVP_DBG_AV); - CL_ASSERT (p_av_info); - - p_pd_info = (mlnx_ual_pd_info_t *)((void*) p_av_info->h_uvp_pd); - CL_ASSERT (p_pd_info); - - p_hobul = p_pd_info->p_hobul; - CL_ASSERT (p_hobul); - -#ifdef WIN_TO_BE_CHANGED - if (HH_OK != - THHUL_pdm_destroy_ud_av (p_hobul->hhul_hca_hndl, - p_av_info->h_av)) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_AV , - ("Failed to destroy av\n")); - } -#endif - - /* - * We still have to clean resources even THHUL failed - */ - if (p_av_info->p_i_av_attr); - { - cl_free (p_av_info->p_i_av_attr); - } - cl_free (p_av_info); - - UVP_EXIT(UVP_DBG_AV); - return; -} - -#endif diff --git a/trunk/hw/mthca/user/mlnx_ual_mrw.c b/trunk/hw/mthca/user/mlnx_ual_mrw.c index b74415ce..80af5abc 100644 --- a/trunk/hw/mthca/user/mlnx_ual_mrw.c +++ b/trunk/hw/mthca/user/mlnx_ual_mrw.c @@ -60,21 +60,13 @@ mlnx_get_mrw_interface ( /* * Memory Window Verbs */ -#ifndef WIN_TO_BE_CHANGED - p_uvp->pre_create_mw = NULL; - p_uvp->post_create_mw = NULL; - p_uvp->pre_query_mw = NULL; - p_uvp->post_query_mw = NULL; - p_uvp->pre_destroy_mw = NULL; - p_uvp->post_destroy_mw = NULL; -#else - p_uvp->pre_create_mw = mlnx_pre_create_mw; - p_uvp->post_create_mw = mlnx_post_create_mw; - p_uvp->pre_query_mw = mlnx_pre_query_mw; - p_uvp->post_query_mw = mlnx_post_query_mw; - p_uvp->pre_destroy_mw = mlnx_pre_destroy_mw; - p_uvp->post_destroy_mw = mlnx_post_destroy_mw; -#endif + p_uvp->pre_create_mw = NULL; // mlnx_pre_create_mw + p_uvp->post_create_mw = NULL; // mlnx_post_create_mw + p_uvp->pre_query_mw = NULL; // mlnx_pre_query_mw + p_uvp->post_query_mw = NULL; // mlnx_post_query_mw + p_uvp->pre_destroy_mw = NULL; // mlnx_pre_destroy_mw + p_uvp->post_destroy_mw = NULL; // mlnx_post_destroy_mw + /* register_pmr is not supported in user-mode */ UVP_EXIT(UVP_DBG_SHIM); @@ -235,211 +227,3 @@ mlnx_post_deregister_mr ( } -#ifdef WIN_TO_BE_CHANGED - -ib_api_status_t -mlnx_pre_create_mw ( - IN const ib_pd_handle_t h_uvp_pd, - IN OUT ci_umv_buf_t *p_umv_buf) -{ - ib_api_status_t status = IB_SUCCESS; - mlnx_ual_pd_info_t *p_pd_info = (mlnx_ual_pd_info_t *)((void*) h_uvp_pd); - mlnx_ual_hobul_t *p_hobul; - mlnx_ual_mw_info_t *p_new_mw; - - UVP_ENTER(UVP_DBG_SHIM); - CL_ASSERT(p_umv_buf); - CL_ASSERT(p_pd_info); - - p_hobul = p_pd_info->p_hobul; - CL_ASSERT(p_hobul); - - p_new_mw = cl_zalloc (sizeof (mlnx_ual_mw_info_t)); - if (p_new_mw == NULL) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , - ("Failed to alloc memory\n")); - status = IB_INSUFFICIENT_MEMORY; - goto cleanup; - } - p_new_mw->h_uvp_pd = h_uvp_pd; - - p_umv_buf->input_size = p_umv_buf->output_size = - sizeof (mlnx_ual_mw_info_t *); - - p_umv_buf->p_inout_buf = cl_zalloc (p_umv_buf->input_size); - if (p_umv_buf->p_inout_buf == NULL) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , - ("Failed to alloc memory for priv buffer\n")); - status = IB_INSUFFICIENT_MEMORY; - goto cleanup; - } - p_umv_buf->status = IB_SUCCESS; - p_umv_buf->command = TRUE; - - cl_memcpy (p_umv_buf->p_inout_buf, &p_new_mw, p_umv_buf->input_size); - -cleanup: - if (IB_SUCCESS != status) - { - if (p_new_mw) - { - cl_free (p_new_mw); - } - } - - UVP_EXIT(UVP_DBG_SHIM); - return status; -} - - -void -mlnx_post_create_mw ( - IN const ib_pd_handle_t h_uvp_pd, - IN ib_api_status_t ioctl_status, - IN net32_t rkey, - OUT ib_mw_handle_t *ph_uvp_mw, - IN ci_umv_buf_t *p_umv_buf ) -{ - ib_api_status_t status; - mlnx_ual_pd_info_t *p_pd_info = (mlnx_ual_pd_info_t *)((void*) h_uvp_pd); - mlnx_ual_hobul_t *p_hobul; - mlnx_ual_mw_info_t *p_new_mw; - - UVP_ENTER(UVP_DBG_SHIM); - CL_ASSERT(p_umv_buf); - CL_ASSERT(p_pd_info); - - p_hobul = p_pd_info->p_hobul; - CL_ASSERT(p_hobul); - - - status = ioctl_status; - - CL_ASSERT (p_umv_buf->p_inout_buf); - cl_memcpy (&p_new_mw, p_umv_buf->p_inout_buf, p_umv_buf->input_size); - - - *ph_uvp_mw = (ib_mw_handle_t) p_new_mw; - - if (IB_SUCCESS == status) - { - if (IB_SUCCESS != p_umv_buf->status) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , - ("Bad status %ld\n", p_umv_buf->status)); - status = p_umv_buf->status; - goto cleanup; - } - - p_new_mw->rkey = rkey; - -#ifdef WIN_TO_BE_CHANGED - if (HH_OK != - THHUL_mwm_alloc_mw (p_hobul->hhul_hca_hndl, - rkey, - &p_new_mw->hhul_mw_hndl)) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , - ("thhul_alloc_mw failed\n")); - status = IB_ERROR; - goto cleanup; - } -#endif - } - else - { - cl_free (p_new_mw); - } - -cleanup: - cl_free (p_umv_buf->p_inout_buf); - p_umv_buf->p_inout_buf = NULL; - - UVP_EXIT(UVP_DBG_SHIM); - return; -} - - -ib_api_status_t -mlnx_pre_query_mw ( - IN const ib_mw_handle_t h_uvp_mw, - IN OUT ci_umv_buf_t *p_umv_buf) -{ - UVP_ENTER(UVP_DBG_SHIM); - CL_ASSERT(p_umv_buf); - p_umv_buf->p_inout_buf = NULL;; - p_umv_buf->input_size = 0; - p_umv_buf->output_size = 0; - p_umv_buf->status = IB_SUCCESS; - p_umv_buf->command = TRUE; - UVP_EXIT(UVP_DBG_SHIM); - return IB_SUCCESS; -} - - -void -mlnx_post_query_mw ( - IN const ib_mw_handle_t h_uvp_mw, - IN ib_api_status_t ioctl_status, - IN net32_t rkey, - OUT ib_pd_handle_t *ph_pd, - IN ci_umv_buf_t *p_umv_buf ) -{ - UVP_ENTER(UVP_DBG_SHIM); - *ph_pd = ((mlnx_ual_mw_info_t *)((void*)h_uvp_mw))->h_uvp_pd; - - UVP_EXIT(UVP_DBG_SHIM); - return; -} - - -ib_api_status_t -mlnx_pre_destroy_mw ( - IN const ib_mw_handle_t h_uvp_mw) -{ - UVP_ENTER(UVP_DBG_SHIM); - UVP_EXIT(UVP_DBG_SHIM); - return IB_SUCCESS; -} - - -void -mlnx_post_destroy_mw ( - IN const ib_mw_handle_t h_uvp_mw, - IN ib_api_status_t ioctl_status) -{ - ib_api_status_t status = IB_SUCCESS; - mlnx_ual_pd_info_t *p_pd_info; - mlnx_ual_hobul_t *p_hobul; - mlnx_ual_mw_info_t *p_mw_info = (mlnx_ual_mw_info_t *)((void*) h_uvp_mw); - - UVP_ENTER(UVP_DBG_SHIM); - CL_ASSERT(p_mw_info); - - p_pd_info = (mlnx_ual_pd_info_t *)((void*) p_mw_info->h_uvp_pd); - CL_ASSERT(p_pd_info); - - p_hobul = p_pd_info->p_hobul; - CL_ASSERT(p_hobul); - -#ifdef WIN_TO_BE_CHANGED - if (HH_OK != - THHUL_mwm_free_mw (p_hobul->hhul_hca_hndl, p_mw_info->hhul_mw_hndl)) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , - ("thhul_free_mw failed\n")); - status = IB_ERROR; - } -#endif - if (status == IB_SUCCESS) - { - cl_free (p_mw_info); - } - - UVP_EXIT(UVP_DBG_SHIM); - return; -} - -#endif diff --git a/trunk/hw/mthca/user/mlnx_ual_qp.c b/trunk/hw/mthca/user/mlnx_ual_qp.c index ca3e41bf..d708f64a 100644 --- a/trunk/hw/mthca/user/mlnx_ual_qp.c +++ b/trunk/hw/mthca/user/mlnx_ual_qp.c @@ -66,23 +66,6 @@ mlnx_get_qp_interface ( UVP_EXIT(UVP_DBG_SHIM); } - -#ifdef WIN_TO_BE_CHANGED -IB_ts_t -map_ibal_qp_type (ib_qp_type_t ibal_qp_type) -{ - if (ibal_qp_type == IB_QPT_RELIABLE_CONN) return IB_TS_RC; - else if (ibal_qp_type == IB_QPT_UNRELIABLE_CONN) return IB_TS_UC; - // else if (ibal_qp_type == IB_QPT_RELIABLE_DGRM) return IB_TS_RD; - else if (ibal_qp_type == IB_QPT_UNRELIABLE_DGRM) return IB_TS_UD; - else if (ibal_qp_type == IB_QPT_RAW_IPV6) return IB_TS_RAW; - else if (ibal_qp_type == IB_QPT_RAW_ETHER) return IB_TS_RAW; - else return IB_TS_UD; -} -#endif - -#ifndef WIN_TO_BE_CHANGED - ib_api_status_t mlnx_pre_create_qp ( IN const ib_pd_handle_t h_uvp_pd, @@ -157,188 +140,6 @@ end: return status; } -#else - -ib_api_status_t -mlnx_pre_create_qp ( - IN const ib_pd_handle_t h_uvp_pd, - IN const ib_qp_create_t *p_create_attr, - IN OUT ci_umv_buf_t *p_umv_buf) -{ - ib_api_status_t status = IB_SUCCESS; - mlnx_ual_pd_info_t *p_pd_info = (mlnx_ual_pd_info_t *)((void *)h_uvp_pd); - mlnx_ual_hobul_t *p_hobul; - mlnx_ual_qp_info_t *p_new_qp = NULL; -#ifdef WIN_TO_BE_CHANGED - HHUL_qp_init_attr_t ul_qp_init_attr; -#endif - size_t size=0; - - UVP_ENTER(UVP_DBG_SHIM); - CL_ASSERT(p_pd_info); - CL_ASSERT(p_umv_buf); - CL_ASSERT(p_create_attr); - - p_hobul = p_pd_info->p_hobul; - CL_ASSERT(p_hobul); - - do - { - /* CA should be initialized */ -#ifdef WIN_TO_BE_CHANGED - if (!p_hobul->p_hca_ul_info) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , - ("INVALID hca_ul_info buffer\n")); - status = IB_INVALID_CA_HANDLE; - break; - } - - if (!p_hobul->p_hca_ul_resources) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , - ("INVALID hca_ul_resources buffer\n")); - status = IB_RESOURCE_BUSY; - break; - } - if (!p_pd_info->p_pd_ul_resources) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , - ("INVALID pd_ul_resources buffer\n")); - status = IB_RESOURCE_BUSY; - break; - } -#endif - - p_new_qp = cl_zalloc (sizeof(mlnx_ual_qp_info_t)); - if (!p_new_qp) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , - ("Failed alloc new QP\n")); - status = IB_INSUFFICIENT_MEMORY; - break; - } - -#ifdef WIN_TO_BE_CHANGED - p_new_qp->p_qp_ul_resources = - cl_zalloc(p_hobul->p_hca_ul_info->qp_ul_resources_sz); - if (!p_new_qp->p_qp_ul_resources) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , - ("Failed alloc new QP UL resources\n")); - status = IB_INSUFFICIENT_MEMORY; - break; - } - cl_memclr (&ul_qp_init_attr, sizeof (HHUL_qp_init_attr_t)); - - ul_qp_init_attr.qp_cap.max_oust_wr_sq = p_create_attr->sq_depth; - ul_qp_init_attr.qp_cap.max_oust_wr_rq = p_create_attr->rq_depth; - ul_qp_init_attr.qp_cap.max_sg_size_sq = p_create_attr->sq_sge; - ul_qp_init_attr.qp_cap.max_sg_size_rq = p_create_attr->rq_sge; - ul_qp_init_attr.ts_type = map_ibal_qp_type (p_create_attr->qp_type); - ul_qp_init_attr.srq = HHUL_INVAL_SRQ_HNDL; - /* - * save the qp_type to qp_info to use later on - */ - p_new_qp->type = ul_qp_init_attr.ts_type; - ul_qp_init_attr.sq_sig_type = - (p_create_attr->sq_signaled) ? VAPI_SIGNAL_ALL_WR:VAPI_SIGNAL_REQ_WR; - ul_qp_init_attr.rq_sig_type = VAPI_SIGNAL_ALL_WR; - ul_qp_init_attr.pd = p_pd_info->hhul_pd_hndl; - ul_qp_init_attr.sq_cq = - ((mlnx_ual_cq_info_t *)(p_create_attr->h_sq_cq))->hhul_cq_hndl; - ul_qp_init_attr.rq_cq = - ((mlnx_ual_cq_info_t *)(p_create_attr->h_rq_cq))->hhul_cq_hndl; - - if (HH_OK != - THHUL_qpm_create_qp_prep (p_hobul->hhul_hca_hndl, - &ul_qp_init_attr, - &p_new_qp->hhul_qp_hndl, - &p_new_qp->ul_qp_cap, - p_new_qp->p_qp_ul_resources)) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , - ("Calling THHUL_qpm_create_qp_prep Failed\n")); - status = IB_RESOURCE_BUSY; - break; - } - - /* - * Store the parent PD of this QP - */ - p_new_qp->h_uvp_pd = h_uvp_pd; - - size = p_hobul->p_hca_ul_info->qp_ul_resources_sz + - sizeof (uint32_t) + sizeof (mlnx_ual_qp_info_t *); -#endif - p_umv_buf->p_inout_buf = cl_zalloc(size); - if (!p_umv_buf->p_inout_buf) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , - ("Failed alloc user private buffer\n")); - status = IB_INSUFFICIENT_MEMORY; - break; - } - - /* - * We only set the input_size up to qp_ul_resources_sz + sizeof (qp_idx) - * The rest of the buffer we store the pointer to our allocated - * qp_info struct in order to retrieve it later in the post. - */ - p_umv_buf->input_size = p_umv_buf->output_size = - (uint32_t)size - sizeof (mlnx_ual_qp_info_t *); - -#ifdef WIN_TO_BE_CHANGED - cl_memcpy (p_umv_buf->p_inout_buf, - p_new_qp->p_qp_ul_resources, - p_hobul->p_hca_ul_info->qp_ul_resources_sz); -#endif - /* - * Store the pointer of our qp_info struct to inout_buf and retrieve - * it later in the post - */ - cl_memcpy ( ( (uint8_t *)p_umv_buf->p_inout_buf + size - - sizeof (mlnx_ual_qp_info_t *)), - &p_new_qp, - sizeof (mlnx_ual_qp_info_t *)); - p_umv_buf->command = TRUE; - - } while (0); - - /* - * clean_up if required - */ - if (IB_SUCCESS != status) - { - if (p_new_qp) - { -#ifdef WIN_TO_BE_CHANGED - if (p_new_qp->hhul_qp_hndl) - { - THHUL_qpm_destroy_qp_done (p_hobul->hhul_hca_hndl, - p_new_qp->hhul_qp_hndl); - } -#endif - if (p_new_qp->p_qp_ul_resources); - { - cl_free (p_new_qp->p_qp_ul_resources); - } - cl_free (p_new_qp); - } - if (p_umv_buf->p_inout_buf) - { - cl_free ( p_umv_buf->p_inout_buf ); - } - } - - UVP_EXIT(UVP_DBG_SHIM); - return IB_SUCCESS; -} - -#endif - -#ifndef WIN_TO_BE_CHANGED - void mlnx_post_create_qp ( IN const ib_pd_handle_t h_uvp_pd, @@ -396,99 +197,6 @@ end: return; } -#else - -void -mlnx_post_create_qp ( - IN const ib_pd_handle_t h_uvp_pd, - IN ib_api_status_t ioctl_status, - OUT ib_qp_handle_t *ph_uvp_qp, - IN ci_umv_buf_t *p_umv_buf ) -{ - mlnx_ual_pd_info_t *p_pd_info = (mlnx_ual_pd_info_t *)((void*)h_uvp_pd); - mlnx_ual_hobul_t *p_hobul; - mlnx_ual_qp_info_t *p_new_qp; - size_t buf_size=0; - - UVP_ENTER(UVP_DBG_QP); - CL_ASSERT(p_pd_info); - CL_ASSERT(p_umv_buf); - - p_hobul = p_pd_info->p_hobul; - CL_ASSERT(p_hobul); - -#ifdef WIN_TO_BE_CHANGED - buf_size = p_hobul->p_hca_ul_info->qp_ul_resources_sz + - sizeof (uint32_t) + sizeof (mlnx_ual_qp_info_t *); -#endif - - /* Retrieve our qp_info back from priv buffer */ - cl_memcpy (&p_new_qp, ((uint8_t *)p_umv_buf->p_inout_buf + buf_size - - sizeof (mlnx_ual_qp_info_t *)), sizeof (mlnx_ual_qp_info_t *)); - CL_ASSERT(p_new_qp); - - *ph_uvp_qp = (ib_qp_handle_t) p_new_qp; - - if ( ioctl_status == IB_SUCCESS ) - { - if (IB_SUCCESS != p_umv_buf->status) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_QP , - ("Bad status %ld\n", p_umv_buf->status)); - goto err; - } - else if ((buf_size - sizeof (mlnx_ual_qp_info_t *)) != - p_umv_buf->output_size) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_QP , - ("Bad user priv buffer size exp = %d, res = %ld\n", - buf_size, p_umv_buf->output_size)); - goto err; - } - -#ifdef WIN_TO_BE_CHANGED - cl_memcpy (p_new_qp->p_qp_ul_resources, - p_umv_buf->p_inout_buf, - p_hobul->p_hca_ul_info->qp_ul_resources_sz); - - cl_memcpy (&p_new_qp->qp_idx, - ((uint8_t *)p_umv_buf->p_inout_buf + - p_hobul->p_hca_ul_info->qp_ul_resources_sz), - sizeof (uint32_t)); - - if (HH_OK != - THHUL_qpm_create_qp_done (p_hobul->hhul_hca_hndl, - p_new_qp->hhul_qp_hndl, - p_new_qp->qp_idx, - p_new_qp->p_qp_ul_resources)) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_QP , - ("Call THHUL_qpm_create_qp_done Failed\n")); - goto err; - } -#endif - UVP_PRINT(TRACE_LEVEL_INFORMATION ,UVP_DBG_QP , - ("Newly created QP qp_idx 0x%x\n",p_new_qp->qp_idx)); - } - else - { -err: - if (p_new_qp->p_qp_ul_resources) - cl_free (p_new_qp->p_qp_ul_resources); - - cl_free (p_new_qp); - *ph_uvp_qp = NULL; - } - - cl_free (p_umv_buf->p_inout_buf); - p_umv_buf->p_inout_buf = NULL; - - UVP_EXIT(UVP_DBG_QP); - return; -} - -#endif - ib_api_status_t mlnx_pre_modify_qp ( IN const ib_qp_handle_t h_uvp_qp, @@ -612,8 +320,6 @@ mlnx_pre_destroy_qp ( return IB_SUCCESS; } -#ifndef WIN_TO_BE_CHANGED - void mlnx_post_destroy_qp ( IN const ib_qp_handle_t h_uvp_qp, @@ -636,47 +342,3 @@ mlnx_post_destroy_qp ( return; } -#else - -void -mlnx_post_destroy_qp ( - IN const ib_qp_handle_t h_uvp_qp, - IN ib_api_status_t ioctl_status) -{ - mlnx_ual_qp_info_t *p_qp_info = (mlnx_ual_qp_info_t *)((void *) h_uvp_qp); - mlnx_ual_pd_info_t *p_pd_info; - mlnx_ual_hobul_t *p_hobul; - - UNREFERENCED_PARAMETER(ioctl_status); - - UVP_ENTER(UVP_DBG_SHIM); - CL_ASSERT(p_qp_info); - - p_pd_info = (mlnx_ual_pd_info_t *)((void *)p_qp_info->h_uvp_pd); - CL_ASSERT(p_pd_info); - - p_hobul = p_pd_info->p_hobul; - CL_ASSERT(p_hobul); - -#ifdef WIN_TO_BE_CHANGED - if (HH_OK != - THHUL_qpm_destroy_qp_done (p_hobul->hhul_hca_hndl, - p_qp_info->hhul_qp_hndl)) - { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , - ("THHUL_destroy_qp_done failed\n")); - } -#endif - if (p_qp_info->p_qp_ul_resources); - { - cl_free (p_qp_info->p_qp_ul_resources); - p_qp_info->p_qp_ul_resources = NULL; - } - - cl_free (p_qp_info); - - UVP_EXIT(UVP_DBG_SHIM); - return; -} - -#endif diff --git a/trunk/hw/mthca/user/mlnx_uvp.c b/trunk/hw/mthca/user/mlnx_uvp.c index af4fd478..6459d1bb 100644 --- a/trunk/hw/mthca/user/mlnx_uvp.c +++ b/trunk/hw/mthca/user/mlnx_uvp.c @@ -96,8 +96,8 @@ static struct ibv_context_ops mthca_ctx_ops = { NULL, // mthca_query_port, mthca_alloc_pd, mthca_free_pd, - mthca_reg_mr, - mthca_dereg_mr, + NULL, // mthca_reg_mr, + NULL, // mthca_dereg_mr, mthca_create_cq_pre, mthca_create_cq_post, mthca_poll_cq, diff --git a/trunk/hw/mthca/user/mlnx_uvp.h b/trunk/hw/mthca/user/mlnx_uvp.h index 1c1c78a1..2812fe06 100644 --- a/trunk/hw/mthca/user/mlnx_uvp.h +++ b/trunk/hw/mthca/user/mlnx_uvp.h @@ -266,10 +266,6 @@ extern struct ibv_pd *mthca_alloc_pd(struct ibv_context *context, extern int mthca_free_pd(struct ibv_pd *pd); -extern struct ibv_mr *mthca_reg_mr(struct ibv_pd *pd, void *addr, - size_t length, enum ibv_access_flags access); -extern int mthca_dereg_mr(struct ibv_mr *mr); - extern struct ibv_cq *mthca_create_cq_pre(struct ibv_context *context, int *cqe, struct ibv_create_cq *req); extern struct ibv_cq *mthca_create_cq_post(struct ibv_context *context, diff --git a/trunk/hw/mthca/user/mlnx_uvp_cq.c b/trunk/hw/mthca/user/mlnx_uvp_cq.c index c98ab2d7..dfc587f5 100644 --- a/trunk/hw/mthca/user/mlnx_uvp_cq.c +++ b/trunk/hw/mthca/user/mlnx_uvp_cq.c @@ -159,16 +159,16 @@ static inline void update_cons_index(struct mthca_cq *cq, int incr) } -static void dump_cqe(void *cqe_ptr) +static void dump_cqe(uint32_t print_lvl, void *cqe_ptr) { uint32_t *cqe = cqe_ptr; int i; (void) cqe; /* avoid warning if mthca_dbg compiled away... */ - UVP_PRINT(TRACE_LEVEL_INFORMATION,UVP_DBG_CQ,("CQE content \n ")); - UVP_PRINT(TRACE_LEVEL_INFORMATION,UVP_DBG_CQ,(" [%2x] %08x %08x %08x %08x \n",0 + UVP_PRINT(print_lvl,UVP_DBG_CQ,("CQE content \n ")); + UVP_PRINT(print_lvl,UVP_DBG_CQ,(" [%2x] %08x %08x %08x %08x \n",0 , cl_ntoh32(cqe[0]), cl_ntoh32(cqe[1]), cl_ntoh32(cqe[2]), cl_ntoh32(cqe[3]))); - UVP_PRINT(TRACE_LEVEL_INFORMATION,UVP_DBG_CQ,(" [%2x] %08x %08x %08x %08x\n",16 + UVP_PRINT(print_lvl,UVP_DBG_CQ,(" [%2x] %08x %08x %08x %08x\n",16 , cl_ntoh32(cqe[4]), cl_ntoh32(cqe[5]), cl_ntoh32(cqe[6]), cl_ntoh32(cqe[7]))); } @@ -187,7 +187,7 @@ static int handle_error_cqe(struct mthca_cq *cq, "(QPN %06x, WQE @ %08x, CQN %06x, index %d)\n", cl_ntoh32(cqe->my_qpn), cl_ntoh32(cqe->wqe), cq->cqn, cq->cons_index)); - dump_cqe(cqe); + dump_cqe(TRACE_LEVEL_VERBOSE, cqe); } /* @@ -302,11 +302,11 @@ static inline int mthca_poll_one(struct mthca_cq *cq, */ rmb(); - if(0){ + { // debug print UVP_PRINT(TRACE_LEVEL_VERBOSE,UVP_DBG_CQ,("%x/%d: CQE -> QPN %06x, WQE @ %08x\n", cq->cqn, cq->cons_index, cl_ntoh32(cqe->my_qpn), cl_ntoh32(cqe->wqe))); - dump_cqe(cqe); + dump_cqe(TRACE_LEVEL_VERBOSE,cqe); } qpn = cl_ntoh32(cqe->my_qpn); diff --git a/trunk/hw/mthca/user/mlnx_uvp_qp.c b/trunk/hw/mthca/user/mlnx_uvp_qp.c index c0ea26e4..4052a755 100644 --- a/trunk/hw/mthca/user/mlnx_uvp_qp.c +++ b/trunk/hw/mthca/user/mlnx_uvp_qp.c @@ -73,19 +73,19 @@ static enum mthca_wr_opcode conv_ibal_wr_opcode(struct _ib_send_wr *wr) } -static void dump_wqe(uint32_t *wqe_ptr , struct mthca_qp *qp_ptr) +static void dump_wqe(uint32_t print_lvl, uint32_t *wqe_ptr , struct mthca_qp *qp_ptr) { net32_t *wqe = wqe_ptr; (void) wqe; /* avoid warning if mthca_dbg compiled away... */ - UVP_PRINT(TRACE_LEVEL_INFORMATION,UVP_DBG_QP,("WQE contents QPN 0x%06x \n",qp_ptr->ibv_qp.qp_num)); - UVP_PRINT(TRACE_LEVEL_INFORMATION,UVP_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",0 + UVP_PRINT(print_lvl,UVP_DBG_QP,("WQE contents QPN 0x%06x \n",qp_ptr->ibv_qp.qp_num)); + UVP_PRINT(print_lvl,UVP_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",0 , cl_ntoh32(wqe[0]), cl_ntoh32(wqe[1]), cl_ntoh32(wqe[2]), cl_ntoh32(wqe[3]))); - UVP_PRINT(TRACE_LEVEL_INFORMATION,UVP_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",4 + UVP_PRINT(print_lvl,UVP_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",4 , cl_ntoh32(wqe[4]), cl_ntoh32(wqe[5]), cl_ntoh32(wqe[6]), cl_ntoh32(wqe[7]))); - UVP_PRINT(TRACE_LEVEL_INFORMATION,UVP_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",8 + UVP_PRINT(print_lvl,UVP_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",8 , cl_ntoh32(wqe[8]), cl_ntoh32(wqe[9]), cl_ntoh32(wqe[10]), cl_ntoh32(wqe[11]))); - UVP_PRINT(TRACE_LEVEL_INFORMATION,UVP_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",12 + UVP_PRINT(print_lvl,UVP_DBG_QP,("WQE contents [%02x] %08x %08x %08x %08x \n",12 , cl_ntoh32(wqe[12]), cl_ntoh32(wqe[13]), cl_ntoh32(wqe[14]), cl_ntoh32(wqe[15]))); } @@ -349,8 +349,7 @@ int mthca_tavor_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr, op0 = opcode; } - if(0) - dump_wqe( (uint32_t*)qp->sq.last,qp); + dump_wqe( TRACE_LEVEL_VERBOSE, (uint32_t*)qp->sq.last,qp); ++ind; if (unlikely(ind >= qp->sq.max)) diff --git a/trunk/hw/mthca/user/mlnx_uvp_verbs.c b/trunk/hw/mthca/user/mlnx_uvp_verbs.c index ca2af0b1..10713243 100644 --- a/trunk/hw/mthca/user/mlnx_uvp_verbs.c +++ b/trunk/hw/mthca/user/mlnx_uvp_verbs.c @@ -79,47 +79,6 @@ int mthca_free_pd(struct ibv_pd *ibv_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) -{ - struct ibv_mr *mr; - struct ibv_reg_mr cmd; - - mr = cl_malloc(sizeof *mr); - if (!mr) - return NULL; - -#ifdef WIN_TO_BE_CHANGED - if (ibv_cmd_reg_mr(pd, addr, length, hca_va, - access, mr, &cmd, sizeof cmd)) { - cl_free(mr); - return NULL; - } -#endif - 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); -} - -int mthca_dereg_mr(struct ibv_mr *mr) -{ - int ret; - -#ifdef WIN_TO_BE_CHANGED - ret = ibv_cmd_dereg_mr(mr); - if (ret) - return ret; -#endif - - cl_free(mr); - return 0; -} - /* allocate create_cq infrastructure and fill it's request parameters structure */ struct ibv_cq *mthca_create_cq_pre(struct ibv_context *context, int *p_cqe, struct ibv_create_cq *req) @@ -263,132 +222,6 @@ static int align_queue_size(struct ibv_context *context, int size, int spare) return size + spare; } -#ifdef WIN_TO_BE_CHANGED -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 > 16 << 20 || attr->attr.max_sge > 64) - return NULL; - - srq = cl_malloc(sizeof *srq); - if (!srq) - return NULL; - - cl_spinlock_construct(&srq->lock); - if (cl_spinlock_init(&srq->lock)) - 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, srq->buf_size, 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; - } - - cmd.lkey = srq->mr->lkey; - -#ifdef WIN_TO_BE_CHANGED - 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: -#endif - 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: - cl_free(srq->wrid); -#ifdef NOT_USE_VIRTUAL_ALLOC - cl_free(srq->buf); -#else - VirtualFree( srq->buf, 0, MEM_RELEASE); -#endif - -err: - cl_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; - -#ifdef WIN_TO_BE_CHANGED - return ibv_cmd_modify_srq(srq, attr, attr_mask, &cmd, sizeof cmd); -#else - return -ENOSYS; -#endif -} - -int mthca_destroy_srq(struct ibv_srq *srq) -{ - int ret; - -#ifdef WIN_TO_BE_CHANGED - ret = ibv_cmd_destroy_srq(srq); - if (ret) - return ret; -#endif - - 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); - - cl_spinlock_destroy(&((struct mthca_srq *)srq)->lock); - -#ifdef NOT_USE_VIRTUAL_ALLOC - cl_free(to_msrq(srq)->buf); -#else - VirtualFree( to_msrq(srq)->buf, 0, MEM_RELEASE); -#endif - cl_free(to_msrq(srq)->wrid); - cl_free(to_msrq(srq)); - - return 0; -} -#endif - struct ibv_qp *mthca_create_qp_pre(struct ibv_pd *pd, struct ibv_qp_init_attr *attr, struct ibv_create_qp *req) { diff --git a/trunk/hw/mthca/user/mlnx_uvp_verbs.h b/trunk/hw/mthca/user/mlnx_uvp_verbs.h index e1dee1ae..435b9238 100644 --- a/trunk/hw/mthca/user/mlnx_uvp_verbs.h +++ b/trunk/hw/mthca/user/mlnx_uvp_verbs.h @@ -426,14 +426,6 @@ struct ibv_qp { uint32_t qp_num; enum ibv_qp_state state; ib_qp_type_t qp_type; - -#ifdef WIN_TO_BE_CHANGED - struct ibv_context *context; - HANDLE mutex; - void *qp_context; - pthread_cond_t cond; - uint32_t events_completed; -#endif }; struct ibv_cq { -- 2.41.0