From: leonidk Date: Thu, 11 May 2006 08:41:40 +0000 (+0000) Subject: [MTHCA] 1. preliminary support for livefish devices (not released yet); X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=742307b902ada4d744b1c2a3c5a991624ef553e0;p=~shefty%2Frdma-win.git [MTHCA] 1. preliminary support for livefish devices (not released yet); 2. (36436) fixed with kernel memory overconsumption on creating/destroying AVs; 3. (36433) bugfix: incorrect error code on create_cq with bad number of cqes; 4. (36427) bugfix: incorrect error code on create_qp with bad number of WRs; 5. fixed PREFAST errors; 6. fixed a bug in the cleanup after an unsuccessful driver start up; 7. fixed a bug in using debug print macros; git-svn-id: svn://openib.tc.cornell.edu/gen1@340 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/trunk/hw/mthca/kernel/hca_data.h b/trunk/hw/mthca/kernel/hca_data.h index b721ba61..8dda3ccb 100644 --- a/trunk/hw/mthca/kernel/hca_data.h +++ b/trunk/hw/mthca/kernel/hca_data.h @@ -230,6 +230,7 @@ extern mlnx_hobul_t *mlnx_hobul_array[]; void setup_ci_interface( IN const ib_net64_t ca_guid, + IN const int is_livefish, OUT ci_interface_t *p_interface ); void @@ -316,6 +317,10 @@ void mlnx_memory_if( IN OUT ci_interface_t *p_interface ); +void +mlnx_memory_if_livefish( + IN OUT ci_interface_t *p_interface ); + void mlnx_ecc_if( IN OUT ci_interface_t *p_interface ); diff --git a/trunk/hw/mthca/kernel/hca_driver.h b/trunk/hw/mthca/kernel/hca_driver.h index e6734122..153c36c9 100644 --- a/trunk/hw/mthca/kernel/hca_driver.h +++ b/trunk/hw/mthca/kernel/hca_driver.h @@ -156,6 +156,8 @@ typedef struct _hca_dev_ext } hca_dev_ext_t; #define EXT_FROM_HOB(hob_p) (container_of(hob_p, hca_dev_ext_t, hca.hob)) +#define HCA_FROM_HOB(hob_p) (container_of(hob_p, mlnx_hca_t, hob)) +#define MDEV_FROM_HOB(hob_p) (HCA_FROM_HOB(hob_p)->mdev) #define IBDEV_FROM_HOB(hob_p) (&EXT_FROM_HOB(hob_p)->hca.mdev->ib_dev) #define HOBUL_FROM_HOB(hob_p) (&EXT_FROM_HOB(hob_p)->hca.hobul) #define HOB_FROM_IBDEV(dev_p) (mlnx_hob_t *)&dev_p->mdev->ext->hca.hob diff --git a/trunk/hw/mthca/kernel/hca_memory.c b/trunk/hw/mthca/kernel/hca_memory.c index ca276a6b..1775cba2 100644 --- a/trunk/hw/mthca/kernel/hca_memory.c +++ b/trunk/hw/mthca/kernel/hca_memory.c @@ -189,7 +189,7 @@ 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) + if (p_pmr_create->length == (uint64_t)-1i64) { mr_p = ibv_get_dma_mr( ib_pd_p, map_qp_ibal_acl(p_pmr_create->access_ctrl) ); @@ -406,3 +406,11 @@ mlnx_memory_if( p_interface->destroy_mw = mlnx_destroy_mw; } +void +mlnx_memory_if_livefish( + IN OUT ci_interface_t *p_interface ) +{ + p_interface->register_pmr = mlnx_register_pmr; + p_interface->deregister_mr = mlnx_deregister_mr; +} + diff --git a/trunk/hw/mthca/kernel/hca_pci.c b/trunk/hw/mthca/kernel/hca_pci.c index 9efa74fa..5e12d4f7 100644 --- a/trunk/hw/mthca/kernel/hca_pci.c +++ b/trunk/hw/mthca/kernel/hca_pci.c @@ -653,6 +653,9 @@ hca_enable_pci( void hca_disable_pci(PBUS_INTERFACE_STANDARD phcaBusIfc) { // no need to disable the card, so just release the PCI bus i/f - phcaBusIfc->InterfaceDereference( phcaBusIfc->Context ); + if (phcaBusIfc) { + phcaBusIfc->InterfaceDereference( phcaBusIfc->Context ); + phcaBusIfc = NULL; + } } diff --git a/trunk/hw/mthca/kernel/hca_pnp.c b/trunk/hw/mthca/kernel/hca_pnp.c index bb1b3876..0590f3dc 100644 --- a/trunk/hw/mthca/kernel/hca_pnp.c +++ b/trunk/hw/mthca/kernel/hca_pnp.c @@ -25,7 +25,6 @@ extern const char *mthca_version; - static NTSTATUS hca_start( IN DEVICE_OBJECT* const p_dev_obj, @@ -408,7 +407,9 @@ __alloc_hca_ifc( return NULL; } - setup_ci_interface( p_ext->hca.guid, pIfc ); + setup_ci_interface( p_ext->hca.guid, + !!mthca_is_livefish(p_ext->hca.mdev), + pIfc ); pIfc->p_hca_dev = p_ext->cl_ext.p_pdo; pIfc->vend_id = (uint32_t)p_ext->hcaConfig.VendorID; @@ -687,6 +688,14 @@ __UnmapHcaMemoryResources( } +static int mthca_get_livefish_info(struct mthca_dev *mdev, __be64 *node_guid, u32 *hw_id) +{ + *node_guid = cl_hton64((uint64_t)(ULONG_PTR)mdev); + mdev->ib_dev.node_guid = *node_guid; + *hw_id = 0; + return 0; +} + static NTSTATUS hca_start( IN DEVICE_OBJECT* const p_dev_obj, @@ -778,7 +787,11 @@ hca_start( /*leo: get node GUID */ { - int err = mthca_get_dev_info( p_ext->hca.mdev, &p_ext->hca.guid, &p_ext->hca.hw_ver ); + int err; + if (mthca_is_livefish(p_ext->hca.mdev)) + err = mthca_get_livefish_info( p_ext->hca.mdev, &p_ext->hca.guid, &p_ext->hca.hw_ver ); + else + err = mthca_get_dev_info( p_ext->hca.mdev, &p_ext->hca.guid, &p_ext->hca.hw_ver ); if (err) { //TODO: no cleanup on error HCA_PRINT( TRACE_LEVEL_ERROR,HCA_DBG_PNP, diff --git a/trunk/hw/mthca/kernel/hca_verbs.c b/trunk/hw/mthca/kernel/hca_verbs.c index 81d5a6ba..1a750670 100644 --- a/trunk/hw/mthca/kernel/hca_verbs.c +++ b/trunk/hw/mthca/kernel/hca_verbs.c @@ -82,6 +82,9 @@ mlnx_open_ca ( ib_dev = &p_hca->mdev->ib_dev; + if (mthca_is_livefish(p_hca->mdev)) + goto done; + HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_SHIM, ("context 0x%p\n", ca_context)); status = mlnx_hobs_set_cb(&p_hca->hob, @@ -104,6 +107,7 @@ mlnx_open_ca ( //TODO: do we need something for kernel users ? // Return pointer to HOB object +done: if (ph_ca) *ph_ca = &p_hca->hob; status = IB_SUCCESS; @@ -345,7 +349,7 @@ mlnx_modify_ca ( HCA_PRINT(TRACE_LEVEL_ERROR , HCA_DBG_SHIM ,("mthca_modify_port failed (%d) \n",err)); goto err_modify_port; } - + status = IB_SUCCESS; err_modify_port: @@ -357,13 +361,15 @@ ib_api_status_t mlnx_close_ca ( IN ib_ca_handle_t h_ca) { + mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; HCA_ENTER(HCA_DBG_SHIM); - // release HOB resources - mlnx_hobs_remove(h_ca); + if (mthca_is_livefish(MDEV_FROM_HOB( hob_p ))) + goto done; - //TODO: release HOBUL resources + mlnx_hobs_remove(h_ca); +done: HCA_EXIT(HCA_DBG_SHIM); return IB_SUCCESS; @@ -469,7 +475,10 @@ mlnx_um_close( struct ib_ucontext *p_ucontext = (struct ib_ucontext *)h_um_ca; UNREFERENCED_PARAMETER(h_ca); + if (mthca_is_livefish(to_mdev(p_ucontext->device))) + goto done; unmap_crspace_for_all(p_ucontext); +done: if( !p_ucontext->pd ) cl_free( h_um_ca ); else @@ -613,7 +622,7 @@ mlnx_create_av ( if (ph_av) *ph_av = (ib_av_handle_t)ib_av_p; status = IB_SUCCESS; - + err_alloc_av: err_inval_params: if (p_umv_buf && p_umv_buf->command) @@ -765,85 +774,84 @@ _create_qp ( OUT ib_qp_handle_t *ph_qp, IN OUT ci_umv_buf_t *p_umv_buf ) { - int err; - ib_api_status_t status; - struct ib_qp * ib_qp_p; - struct mthca_qp *qp_p; - struct ib_qp_init_attr qp_init_attr; - struct ib_ucontext *p_context = NULL; - struct ib_pd *ib_pd_p = (struct ib_pd *)h_pd; - struct ib_device *ib_dev = ib_pd_p->device; - mlnx_hob_t *hob_p = HOB_FROM_IBDEV(ib_dev); - - HCA_ENTER(HCA_DBG_QP); - - - if( p_umv_buf && p_umv_buf->command ) { - // sanity checks - if (p_umv_buf->input_size < sizeof(struct ibv_create_qp) || - p_umv_buf->output_size < sizeof(struct ibv_create_qp_resp) || - !p_umv_buf->p_inout_buf) { - status = IB_INVALID_PARAMETER; - goto err_inval_params; - } - p_context = ib_pd_p->ucontext; - } - else - p_context = NULL; - - // prepare the parameters - RtlZeroMemory(&qp_init_attr, sizeof(qp_init_attr)); - qp_init_attr.qp_type = p_create_attr->qp_type; - qp_init_attr.event_handler = qp_event_handler; - qp_init_attr.qp_context = hob_p; - qp_init_attr.recv_cq = (struct ib_cq *)p_create_attr->h_rq_cq; - qp_init_attr.send_cq = (struct ib_cq *)p_create_attr->h_sq_cq; - qp_init_attr.cap.max_recv_sge = p_create_attr->rq_sge; - qp_init_attr.cap.max_send_sge = p_create_attr->sq_sge; - qp_init_attr.cap.max_recv_wr = p_create_attr->rq_depth; - qp_init_attr.cap.max_send_wr = p_create_attr->sq_depth; - qp_init_attr.sq_sig_type = (p_create_attr->sq_signaled) ? IB_SIGNAL_ALL_WR : IB_SIGNAL_REQ_WR; - qp_init_attr.port_num = port_num; - - - // create qp - ib_qp_p = ibv_create_qp( ib_pd_p, &qp_init_attr, p_context, 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)); - status = errno_to_iberr(err); - goto err_create_qp; - } - - // fill the object - qp_p = (struct mthca_qp *)ib_qp_p; - qp_p->qp_context = (void*)qp_context; - qp_p->qp_init_attr = qp_init_attr; + int err; + ib_api_status_t status; + struct ib_qp * ib_qp_p; + struct mthca_qp *qp_p; + struct ib_qp_init_attr qp_init_attr; + struct ib_ucontext *p_context = NULL; + struct ib_pd *ib_pd_p = (struct ib_pd *)h_pd; + struct ib_device *ib_dev = ib_pd_p->device; + mlnx_hob_t *hob_p = HOB_FROM_IBDEV(ib_dev); - // Query QP to obtain requested attributes - if (p_qp_attr) { - status = mlnx_query_qp ((ib_qp_handle_t)ib_qp_p, p_qp_attr, p_umv_buf); - if (status != IB_SUCCESS) - goto err_query_qp; + HCA_ENTER(HCA_DBG_QP); + + if( p_umv_buf && p_umv_buf->command ) { + // sanity checks + if (p_umv_buf->input_size < sizeof(struct ibv_create_qp) || + p_umv_buf->output_size < sizeof(struct ibv_create_qp_resp) || + !p_umv_buf->p_inout_buf) { + status = IB_INVALID_PARAMETER; + goto err_inval_params; } - - // return the results - if (ph_qp) *ph_qp = (ib_qp_handle_t)ib_qp_p; - - status = IB_SUCCESS; - goto end; + p_context = ib_pd_p->ucontext; + } + else + p_context = NULL; + + // prepare the parameters + RtlZeroMemory(&qp_init_attr, sizeof(qp_init_attr)); + qp_init_attr.qp_type = p_create_attr->qp_type; + qp_init_attr.event_handler = qp_event_handler; + qp_init_attr.qp_context = hob_p; + qp_init_attr.recv_cq = (struct ib_cq *)p_create_attr->h_rq_cq; + qp_init_attr.send_cq = (struct ib_cq *)p_create_attr->h_sq_cq; + qp_init_attr.cap.max_recv_sge = p_create_attr->rq_sge; + qp_init_attr.cap.max_send_sge = p_create_attr->sq_sge; + qp_init_attr.cap.max_recv_wr = p_create_attr->rq_depth; + qp_init_attr.cap.max_send_wr = p_create_attr->sq_depth; + qp_init_attr.sq_sig_type = (p_create_attr->sq_signaled) ? IB_SIGNAL_ALL_WR : IB_SIGNAL_REQ_WR; + qp_init_attr.port_num = port_num; + + + // create qp + ib_qp_p = ibv_create_qp( ib_pd_p, &qp_init_attr, p_context, 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)); + status = errno_to_iberr(err); + goto err_create_qp; + } + + // fill the object + qp_p = (struct mthca_qp *)ib_qp_p; + qp_p->qp_context = (void*)qp_context; + qp_p->qp_init_attr = qp_init_attr; + + // Query QP to obtain requested attributes + if (p_qp_attr) { + status = mlnx_query_qp ((ib_qp_handle_t)ib_qp_p, p_qp_attr, p_umv_buf); + if (status != IB_SUCCESS) + goto err_query_qp; + } - err_query_qp: - ibv_destroy_qp( ib_qp_p ); - err_create_qp: - err_inval_params: - 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))); - return status; + // return the results + if (ph_qp) *ph_qp = (ib_qp_handle_t)ib_qp_p; + + status = IB_SUCCESS; + goto end; + +err_query_qp: + ibv_destroy_qp( ib_qp_p ); +err_create_qp: +err_inval_params: +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))); + return status; } ib_api_status_t @@ -1082,7 +1090,7 @@ mlnx_create_cq ( mlnx_hob_t *hob_p; struct ib_device *ib_dev; struct ib_ucontext *p_context; - + HCA_ENTER(HCA_DBG_CQ); if( p_umv_buf ) { @@ -1105,6 +1113,12 @@ mlnx_create_cq ( ib_dev = IBDEV_FROM_HOB( hob_p ); } + /* sanity check */ + if (*p_size > (uint32_t)ib_dev->mdev->limits.max_cqes) { + status = IB_INVALID_CQ_SIZE; + goto err_cqe; + } + // allocate cq ib_cq_p = ibv_create_cq(ib_dev, cq_comp_handler, cq_event_handler, @@ -1130,6 +1144,7 @@ mlnx_create_cq ( err_create_cq: err_inval_params: +err_cqe: if (p_umv_buf && p_umv_buf->command) p_umv_buf->status = status; HCA_PRINT_EXIT(TRACE_LEVEL_ERROR ,HCA_DBG_CQ, @@ -1203,6 +1218,7 @@ err_destroy_cq: void setup_ci_interface( IN const ib_net64_t ca_guid, + IN const int is_livefish, IN OUT ci_interface_t *p_interface ) { cl_memclr(p_interface, sizeof(*p_interface)); @@ -1221,38 +1237,43 @@ setup_ci_interface( /* The real interface. */ p_interface->open_ca = mlnx_open_ca; p_interface->query_ca = mlnx_query_ca; - p_interface->modify_ca = mlnx_modify_ca; p_interface->close_ca = mlnx_close_ca; p_interface->um_open_ca = mlnx_um_open; p_interface->um_close_ca = mlnx_um_close; p_interface->allocate_pd = mlnx_allocate_pd; p_interface->deallocate_pd = mlnx_deallocate_pd; - - p_interface->create_av = mlnx_create_av; - p_interface->query_av = mlnx_query_av; - p_interface->modify_av = mlnx_modify_av; - p_interface->destroy_av = mlnx_destroy_av; - - p_interface->create_qp = mlnx_create_qp; - p_interface->create_spl_qp = mlnx_create_spl_qp; - p_interface->modify_qp = mlnx_modify_qp; - p_interface->query_qp = mlnx_query_qp; - p_interface->destroy_qp = mlnx_destroy_qp; - - p_interface->create_cq = mlnx_create_cq; - p_interface->resize_cq = mlnx_resize_cq; - p_interface->query_cq = mlnx_query_cq; - p_interface->destroy_cq = mlnx_destroy_cq; - - p_interface->local_mad = mlnx_local_mad; - p_interface->vendor_call = fw_access_ctrl; - mlnx_memory_if(p_interface); - mlnx_direct_if(p_interface); - mlnx_mcast_if(p_interface); + if (is_livefish) { + mlnx_memory_if_livefish(p_interface); + } + else { + p_interface->modify_ca = mlnx_modify_ca; + + p_interface->create_av = mlnx_create_av; + p_interface->query_av = mlnx_query_av; + p_interface->modify_av = mlnx_modify_av; + p_interface->destroy_av = mlnx_destroy_av; + + p_interface->create_qp = mlnx_create_qp; + p_interface->create_spl_qp = mlnx_create_spl_qp; + p_interface->modify_qp = mlnx_modify_qp; + p_interface->query_qp = mlnx_query_qp; + p_interface->destroy_qp = mlnx_destroy_qp; + + p_interface->create_cq = mlnx_create_cq; + p_interface->resize_cq = mlnx_resize_cq; + p_interface->query_cq = mlnx_query_cq; + p_interface->destroy_cq = mlnx_destroy_cq; + + p_interface->local_mad = mlnx_local_mad; + + mlnx_memory_if(p_interface); + mlnx_direct_if(p_interface); + mlnx_mcast_if(p_interface); + } return; } diff --git a/trunk/hw/mthca/kernel/ib_verbs.h b/trunk/hw/mthca/kernel/ib_verbs.h index 0ba30ccf..ef4df023 100644 --- a/trunk/hw/mthca/kernel/ib_verbs.h +++ b/trunk/hw/mthca/kernel/ib_verbs.h @@ -84,7 +84,6 @@ struct ib_device_attr { u64 page_size_cap; u32 vendor_id; u32 vendor_part_id; - u8 board_id[16]; u32 hw_ver; int max_qp; int max_qp_wr; diff --git a/trunk/hw/mthca/kernel/mt_device.c b/trunk/hw/mthca/kernel/mt_device.c index 6e520bc4..5091b3cd 100644 --- a/trunk/hw/mthca/kernel/mt_device.c +++ b/trunk/hw/mthca/kernel/mt_device.c @@ -140,14 +140,16 @@ static int alloc_name(char *name) continue; if (i < 0 || i >= PAGE_SIZE * 8) continue; - snprintf(buf, sizeof buf, name, i); + snprintf(buf, sizeof(buf)-1, name, i); + buf[sizeof(buf)-1] = '\0'; if (!strncmp(buf, device->name, IB_DEVICE_NAME_MAX)) set_bit(i, inuse); } i = find_first_zero_bit((const unsigned long *)inuse, PAGE_SIZE * 8); free_page(inuse); - snprintf(buf, sizeof buf, name, i); + snprintf(buf, sizeof(buf)-1, name, i); + buf[sizeof(buf)-1] = '\0'; if (__ib_device_get_by_name(buf)) return -ENFILE; diff --git a/trunk/hw/mthca/kernel/mt_packer.c b/trunk/hw/mthca/kernel/mt_packer.c index afba3a66..c11fb1b8 100644 --- a/trunk/hw/mthca/kernel/mt_packer.c +++ b/trunk/hw/mthca/kernel/mt_packer.c @@ -87,7 +87,7 @@ void ib_pack(const struct ib_field *desc, else val = 0; - mask = cl_hton32(((1ull << desc[i].size_bits) - 1) << shift); + mask = cl_hton32(((1Ui64 << desc[i].size_bits) - 1) << shift); addr = (__be32 *) buf + desc[i].offset_words; *addr = (*addr & ~mask) | (cl_hton32(val) & mask); } else if (desc[i].size_bits <= 64) { @@ -104,7 +104,7 @@ void ib_pack(const struct ib_field *desc, else val = 0; - mask = CPU_2_BE64((~0ull >> (64 - desc[i].size_bits)) << shift); + mask = CPU_2_BE64((~0Ui64 >> (64 - desc[i].size_bits)) << shift); addr = (__be64 *) ((__be32 *) buf + desc[i].offset_words); *addr = (*addr & ~mask) | (cl_hton64(val) & mask); } else { @@ -167,7 +167,7 @@ void ib_unpack(const struct ib_field *desc, __be32 *addr; shift = 32 - desc[i].offset_bits - desc[i].size_bits; - mask = ((1ull << desc[i].size_bits) - 1) << shift; + mask = ((1Ui64 << desc[i].size_bits) - 1) << shift; addr = (__be32 *) buf + desc[i].offset_words; val = (cl_ntoh32(*addr) & mask) >> shift; value_write(desc[i].struct_offset_bytes, @@ -181,7 +181,7 @@ void ib_unpack(const struct ib_field *desc, __be64 *addr; shift = 64 - desc[i].offset_bits - desc[i].size_bits; - mask = (~0ull >> (64 - desc[i].size_bits)) << shift; + mask = (~0Ui64 >> (64 - desc[i].size_bits)) << shift; addr = (__be64 *) buf + desc[i].offset_words; val = (cl_ntoh64(*addr) & mask) >> shift; value_write(desc[i].struct_offset_bytes, diff --git a/trunk/hw/mthca/kernel/mt_pci.h b/trunk/hw/mthca/kernel/mt_pci.h index a19ceaad..3f389ca9 100644 --- a/trunk/hw/mthca/kernel/mt_pci.h +++ b/trunk/hw/mthca/kernel/mt_pci.h @@ -34,8 +34,21 @@ #endif /* live fishes */ +#ifndef PCI_DEVICE_ID_MELLANOX_TAVOR_BD #define PCI_DEVICE_ID_MELLANOX_TAVOR_BD 0x5a45 +#endif + +#ifndef PCI_DEVICE_ID_MELLANOX_ARBEL_BD #define PCI_DEVICE_ID_MELLANOX_ARBEL_BD 0x6279 +#endif + +#ifndef PCI_DEVICE_ID_MELLANOX_SINAI_OLD_BD +#define PCI_DEVICE_ID_MELLANOX_SINAI_OLD_BD 0x5e8d +#endif + +#ifndef PCI_DEVICE_ID_MELLANOX_SINAI_BD +#define PCI_DEVICE_ID_MELLANOX_SINAI_BD 0x6275 +#endif // =========================================== // TYPES diff --git a/trunk/hw/mthca/kernel/mt_reset_tavor.c b/trunk/hw/mthca/kernel/mt_reset_tavor.c index a8367dfd..23dbea53 100644 --- a/trunk/hw/mthca/kernel/mt_reset_tavor.c +++ b/trunk/hw/mthca/kernel/mt_reset_tavor.c @@ -272,7 +272,7 @@ MdGetDevLocation( /* Get the device number */ l_Status = IoGetDeviceProperty(pi_pPdo, - DevicePropertyLocationInformation, sizeof(l_Buffer), &l_Buffer, &l_ResultLength); + DevicePropertyLocationInformation, sizeof(l_Buffer), l_Buffer, &l_ResultLength); /* Verify if the function was successful */ if ( !NT_SUCCESS(l_Status) || !l_ResultLength ) { @@ -360,11 +360,20 @@ static BOOLEAN PciFindPdoByPdoAndLocation( // suppose that there is no more than N_PCI_DEVICES, belonging to PCI.SYS #define N_PCI_DEVICES 256 // suppose that the PDO objects, once created, never get moved - PDEVICE_OBJECT pdo[N_PCI_DEVICES]; + PDEVICE_OBJECT *pdo; int i, n_pdos = 0; + KIRQL irql; + + + pdo = (PDEVICE_OBJECT *)ExAllocatePoolWithTag( + NonPagedPool, + N_PCI_DEVICES * sizeof(PDEVICE_OBJECT), + MT_TAG_KERNEL ); + if (!pdo) + return FALSE; // suppose, that PDOs are added only at PASSIVE_LEVEL - KIRQL irql = KeRaiseIrqlToDpcLevel(); + irql = KeRaiseIrqlToDpcLevel(); // get to the PCI.SYS driver l_pDrv = pi_pPdo->DriverObject; @@ -395,11 +404,9 @@ static BOOLEAN PciFindPdoByPdoAndLocation( } } - // check whether we found the PDO - if (!l_pPdo) - return FALSE; *po_pPdo = l_pPdo; - return TRUE; + ExFreePool(pdo); + return (BOOLEAN)!!*po_pPdo; } /*----------------------------------------------------------------*/ diff --git a/trunk/hw/mthca/kernel/mt_uverbsmem.c b/trunk/hw/mthca/kernel/mt_uverbsmem.c index 3fbc0056..6dce4715 100644 --- a/trunk/hw/mthca/kernel/mt_uverbsmem.c +++ b/trunk/hw/mthca/kernel/mt_uverbsmem.c @@ -78,6 +78,10 @@ int ibv_umem_get(struct ib_device *dev, struct ib_umem *mem, /* build sg list */ npages = (unsigned long)(NEXT_PAGE_ALIGN(size + mem->offset) >> PAGE_SHIFT); + if (!npages) { + ret = -EINVAL; + goto err_inval; + } cur_base = (u64)(UINT_PTR)addr & PAGE_MASK; while (npages) { /* allocate a max large chunk (it's <= PAGE_SIZE) */ @@ -129,7 +133,7 @@ int ibv_umem_get(struct ib_device *dev, struct ib_umem *mem, out: ibv_umem_release(dev, mem); -err_kmalloc: +err_kmalloc: err_inval: exit: return ret; } diff --git a/trunk/hw/mthca/kernel/mthca_cmd.c b/trunk/hw/mthca/kernel/mthca_cmd.c index 41476e42..698339e9 100644 --- a/trunk/hw/mthca/kernel/mthca_cmd.c +++ b/trunk/hw/mthca/kernel/mthca_cmd.c @@ -620,7 +620,7 @@ static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm, lg = ffs(i) - 1; if (lg < 12) { HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_LOW ,("Got FW area not aligned to 4K (%I64x/%lx).\n", - (unsigned long long) mthca_icm_addr(&iter), + (u64) mthca_icm_addr(&iter), mthca_icm_size(&iter))); err = -EINVAL; goto out; @@ -628,7 +628,7 @@ static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm, for (i = 0; i < mthca_icm_size(&iter) >> lg; ++i) { if (virt != -1) { pages[nent * 2] = cl_hton64(virt); - virt += 1ULL << lg; + virt += 1Ui64 << lg; } pages[nent * 2 + 1] = CPU_2_BE64((mthca_icm_addr(&iter) + (i << lg)) | (lg - 12)); @@ -658,7 +658,7 @@ static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm, break; case CMD_MAP_ICM: HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("Mapped %d chunks/%d KB at %I64x for ICM.\n", - tc, ts, (unsigned long long) virt - (ts << 10))); + tc, ts, (u64) virt - (ts << 10))); break; } @@ -719,9 +719,9 @@ int mthca_QUERY_FW(struct mthca_dev *dev, u8 *status) * FW subSIZE_Tor version is at more signifant bits than minor * version, so swap here. */ - dev->fw_ver = (dev->fw_ver & 0xffff00000000ull) | - ((dev->fw_ver & 0xffff0000ull) >> 16) | - ((dev->fw_ver & 0x0000ffffull) << 16); + dev->fw_ver = (dev->fw_ver & 0xffff00000000Ui64) | + ((dev->fw_ver & 0xffff0000Ui64) >> 16) | + ((dev->fw_ver & 0x0000ffffUi64) << 16); MTHCA_GET(lg, outbox, QUERY_FW_MAX_CMD_OFFSET); dev->cmd.max_cmds = 1 << lg; @@ -729,9 +729,9 @@ int mthca_QUERY_FW(struct mthca_dev *dev, u8 *status) MTHCA_GET(dev->catas_err.size, outbox, QUERY_FW_ERR_SIZE_OFFSET); HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("FW version %012I64x, max commands %d\n", - (unsigned long long) dev->fw_ver, dev->cmd.max_cmds)); + (u64) dev->fw_ver, dev->cmd.max_cmds)); HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("Catastrophic error buffer at 0x%I64x, size 0x%x\n", - (unsigned long long) dev->catas_err.addr, dev->catas_err.size)); + (u64) dev->catas_err.addr, dev->catas_err.size)); if (mthca_is_memfree(dev)) { @@ -750,17 +750,17 @@ int mthca_QUERY_FW(struct mthca_dev *dev, u8 *status) (PAGE_SHIFT - 12); HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("Clear int @ %I64x, EQ arm @ %I64x, EQ set CI @ %I64x\n", - (unsigned long long) dev->fw.arbel.clr_int_base, - (unsigned long long) dev->fw.arbel.eq_arm_base, - (unsigned long long) dev->fw.arbel.eq_set_ci_base)); + (u64) dev->fw.arbel.clr_int_base, + (u64) dev->fw.arbel.eq_arm_base, + (u64) dev->fw.arbel.eq_set_ci_base)); } else { MTHCA_GET(dev->fw.tavor.fw_start, outbox, QUERY_FW_START_OFFSET); MTHCA_GET(dev->fw.tavor.fw_end, outbox, QUERY_FW_END_OFFSET); HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("FW size %d KB (start %I64x, end %I64x)\n", (int) ((dev->fw.tavor.fw_end - dev->fw.tavor.fw_start) >> 10), - (unsigned long long) dev->fw.tavor.fw_start, - (unsigned long long) dev->fw.tavor.fw_end)); + (u64) dev->fw.tavor.fw_start, + (u64) dev->fw.tavor.fw_end)); } out: @@ -813,8 +813,8 @@ int mthca_ENABLE_LAM(struct mthca_dev *dev, u8 *status) HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("HCA memory size %d KB (start %I64x, end %I64x)\n", (int) ((dev->ddr_end - dev->ddr_start) >> 10), - (unsigned long long) dev->ddr_start, - (unsigned long long) dev->ddr_end)); + (u64) dev->ddr_start, + (u64) dev->ddr_end)); out: mthca_free_mailbox(dev, mailbox); @@ -869,8 +869,8 @@ int mthca_QUERY_DDR(struct mthca_dev *dev, u8 *status) HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("HCA memory size %d KB (start %I64x, end %I64x)\n", (int) ((dev->ddr_end - dev->ddr_start) >> 10), - (unsigned long long) dev->ddr_start, - (unsigned long long) dev->ddr_end)); + (u64) dev->ddr_start, + (u64) dev->ddr_end)); out: mthca_free_mailbox(dev, mailbox); @@ -1087,7 +1087,7 @@ int mthca_QUERY_DEV_LIM(struct mthca_dev *dev, } HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("Max ICM size %I64d MB\n", - (unsigned long long) dev_lim->hca.arbel.max_icm_sz >> 20)); + (u64) dev_lim->hca.arbel.max_icm_sz >> 20)); } else { MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SRQ_SZ_OFFSET); @@ -1430,7 +1430,7 @@ int mthca_MAP_ICM_page(struct mthca_dev *dev, u64 dma_addr, u64 virt, u8 *status if (!err) HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("Mapped page at %I64x to %I64x for ICM.\n", - (unsigned long long) dma_addr, (unsigned long long) virt)); + (u64) dma_addr, (u64) virt)); return err; } @@ -1438,7 +1438,7 @@ int mthca_MAP_ICM_page(struct mthca_dev *dev, u64 dma_addr, u64 virt, u8 *status int mthca_UNMAP_ICM(struct mthca_dev *dev, u64 virt, u32 page_count, u8 *status) { HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("Unmapping %d pages at %I64x from ICM.\n", - page_count, (unsigned long long) virt)); + page_count, (u64) virt)); return mthca_cmd(dev, virt, page_count, 0, CMD_UNMAP_ICM, CMD_TIME_CLASS_B, status); } @@ -1504,7 +1504,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap, { HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("%s mask %016I64x for eqn %d\n", unmap ? "Clearing" : "Setting", - (unsigned long long) event_mask, eq_num)); + (u64) event_mask, eq_num)); return mthca_cmd(dev, event_mask, (unmap << 31) | eq_num, 0, CMD_MAP_EQ, CMD_TIME_CLASS_B, status); } diff --git a/trunk/hw/mthca/kernel/mthca_dev.h b/trunk/hw/mthca/kernel/mthca_dev.h index febb6cfc..519d7fef 100644 --- a/trunk/hw/mthca/kernel/mthca_dev.h +++ b/trunk/hw/mthca/kernel/mthca_dev.h @@ -61,7 +61,8 @@ enum { MTHCA_FLAG_NO_LAM = 1 << 5, MTHCA_FLAG_FMR = 1 << 6, MTHCA_FLAG_MEMFREE = 1 << 7, - MTHCA_FLAG_PCIE = 1 << 8 + MTHCA_FLAG_PCIE = 1 << 8, + MTHCA_FLAG_LIVEFISH = 1 << 9 }; enum { @@ -555,18 +556,6 @@ static inline int mthca_is_memfree(struct mthca_dev *dev) return dev->mthca_flags & MTHCA_FLAG_MEMFREE; } -void mthca_get_av_params( struct mthca_ah *ah_p, u8 *port_num, __be16 *dlid, u8 *sr, u8 *path_bits ); - -void mthca_set_av_params( struct mthca_dev *dev, struct mthca_ah *ah_p, struct ib_ah_attr *ah_attr ); - -int ib_uverbs_init(void); -void ib_uverbs_cleanup(void); -int mthca_ah_grh_present(struct mthca_ah *ah); - - - - - VOID WriteEventLogEntry( PVOID pi_pIoObject, @@ -588,4 +577,19 @@ WriteEventLogEntryStr( ... ); + +static inline int mthca_is_livefish(struct mthca_dev *mdev) +{ + return mdev->mthca_flags & MTHCA_FLAG_LIVEFISH; +} + +void mthca_get_av_params( struct mthca_ah *ah_p, u8 *port_num, __be16 *dlid, u8 *sr, u8 *path_bits ); + +void mthca_set_av_params( struct mthca_dev *dev, struct mthca_ah *ah_p, struct ib_ah_attr *ah_attr ); + +int ib_uverbs_init(void); +void ib_uverbs_cleanup(void); +int mthca_ah_grh_present(struct mthca_ah *ah); + + #endif /* MTHCA_DEV_H */ diff --git a/trunk/hw/mthca/kernel/mthca_eq.c b/trunk/hw/mthca/kernel/mthca_eq.c index 10f7920d..ec9ccdf3 100644 --- a/trunk/hw/mthca/kernel/mthca_eq.c +++ b/trunk/hw/mthca/kernel/mthca_eq.c @@ -126,23 +126,23 @@ enum { MTHCA_EVENT_TYPE_SRQ_LIMIT = 0x14 }; -#define MTHCA_ASYNC_EVENT_MASK ((1ULL << MTHCA_EVENT_TYPE_PATH_MIG) | \ - (1ULL << MTHCA_EVENT_TYPE_COMM_EST) | \ - (1ULL << MTHCA_EVENT_TYPE_SQ_DRAINED) | \ - (1ULL << MTHCA_EVENT_TYPE_CQ_ERROR) | \ - (1ULL << MTHCA_EVENT_TYPE_WQ_CATAS_ERROR) | \ - (1ULL << MTHCA_EVENT_TYPE_EEC_CATAS_ERROR) | \ - (1ULL << MTHCA_EVENT_TYPE_PATH_MIG_FAILED) | \ - (1ULL << MTHCA_EVENT_TYPE_WQ_INVAL_REQ_ERROR) | \ - (1ULL << MTHCA_EVENT_TYPE_WQ_ACCESS_ERROR) | \ - (1ULL << MTHCA_EVENT_TYPE_LOCAL_CATAS_ERROR) | \ - (1ULL << MTHCA_EVENT_TYPE_PORT_CHANGE) | \ - (1ULL << MTHCA_EVENT_TYPE_ECC_DETECT)) -#define MTHCA_SRQ_EVENT_MASK ((1ULL << MTHCA_EVENT_TYPE_SRQ_CATAS_ERROR) | \ - (1ULL << MTHCA_EVENT_TYPE_SRQ_QP_LAST_WQE) | \ - (1ULL << MTHCA_EVENT_TYPE_SRQ_LIMIT)) - -#define MTHCA_CMD_EVENT_MASK (1ULL << MTHCA_EVENT_TYPE_CMD) +#define MTHCA_ASYNC_EVENT_MASK ((1Ui64 << MTHCA_EVENT_TYPE_PATH_MIG) | \ + (1Ui64 << MTHCA_EVENT_TYPE_COMM_EST) | \ + (1Ui64 << MTHCA_EVENT_TYPE_SQ_DRAINED) | \ + (1Ui64 << MTHCA_EVENT_TYPE_CQ_ERROR) | \ + (1Ui64 << MTHCA_EVENT_TYPE_WQ_CATAS_ERROR) | \ + (1Ui64 << MTHCA_EVENT_TYPE_EEC_CATAS_ERROR) | \ + (1Ui64 << MTHCA_EVENT_TYPE_PATH_MIG_FAILED) | \ + (1Ui64 << MTHCA_EVENT_TYPE_WQ_INVAL_REQ_ERROR) | \ + (1Ui64 << MTHCA_EVENT_TYPE_WQ_ACCESS_ERROR) | \ + (1Ui64 << MTHCA_EVENT_TYPE_LOCAL_CATAS_ERROR) | \ + (1Ui64 << MTHCA_EVENT_TYPE_PORT_CHANGE) | \ + (1Ui64 << MTHCA_EVENT_TYPE_ECC_DETECT)) +#define MTHCA_SRQ_EVENT_MASK ((1Ui64 << MTHCA_EVENT_TYPE_SRQ_CATAS_ERROR) | \ + (1Ui64 << MTHCA_EVENT_TYPE_SRQ_QP_LAST_WQE) | \ + (1Ui64 << MTHCA_EVENT_TYPE_SRQ_LIMIT)) + +#define MTHCA_CMD_EVENT_MASK (1Ui64 << MTHCA_EVENT_TYPE_CMD) #define MTHCA_EQ_DB_INC_CI (1 << 24) #define MTHCA_EQ_DB_REQ_NOT (2 << 24) diff --git a/trunk/hw/mthca/kernel/mthca_main.c b/trunk/hw/mthca/kernel/mthca_main.c index 92e1ef5c..d2ecd022 100644 --- a/trunk/hw/mthca/kernel/mthca_main.c +++ b/trunk/hw/mthca/kernel/mthca_main.c @@ -68,8 +68,9 @@ static struct mthca_profile default_profile = { enum __hca_type { TAVOR, /* MT23108 */ ARBEL_COMPAT, /* MT25208 in Tavor compat mode */ - ARBEL_NATIVE, /* MT25208 with extended features */ - SINAI /* MT25204 */ + ARBEL_NATIVE, /* MT25218 with extended features */ + SINAI, /* MT25204 */ + LIVEFISH /* a burning device */ }; #define MTHCA_FW_VER(major, minor, subminor) \ @@ -81,10 +82,11 @@ static struct { int is_memfree; int is_pcie; } mthca_hca_table[] = { - { MTHCA_FW_VER(3, 2, 0), MTHCA_FW_VER(3, 3, 3), 0, 0 }, - { MTHCA_FW_VER(4, 6, 0), MTHCA_FW_VER(4, 7, 0), 0, 1 }, - { MTHCA_FW_VER(5, 0, 0), MTHCA_FW_VER(5, 1, 300), 1, 1 }, - { MTHCA_FW_VER(1, 0, 0), MTHCA_FW_VER(1, 0, 1), 1, 1 } + { MTHCA_FW_VER(3, 2, 0), MTHCA_FW_VER(3, 3, 3), 0, 0 }, /* TAVOR */ + { MTHCA_FW_VER(4, 6, 0), MTHCA_FW_VER(4, 7, 0), 0, 1 }, /* ARBEL_COMPAT */ + { MTHCA_FW_VER(5, 0, 0), MTHCA_FW_VER(5, 1, 300), 1, 1 }, /* ARBEL_NATIVE */ + { MTHCA_FW_VER(1, 0, 0), MTHCA_FW_VER(1, 0, 1), 1, 1 }, /* SINAI */ + { MTHCA_FW_VER(0, 0, 0), MTHCA_FW_VER(0, 0, 0), 0, 0 } /* LIVEFISH */ }; @@ -106,6 +108,15 @@ static struct pci_device_id { HCA(TOPSPIN, ARBEL, ARBEL_NATIVE), HCA(TOPSPIN, SINAI_OLD, SINAI), HCA(TOPSPIN, SINAI, SINAI), + // live fishes + HCA(MELLANOX, TAVOR_BD, LIVEFISH), + HCA(MELLANOX, ARBEL_BD, LIVEFISH), + HCA(MELLANOX, SINAI_OLD_BD, LIVEFISH), + HCA(MELLANOX, SINAI_BD, LIVEFISH), + HCA(TOPSPIN, TAVOR_BD, LIVEFISH), + HCA(TOPSPIN, ARBEL_BD, LIVEFISH), + HCA(TOPSPIN, SINAI_OLD_BD, LIVEFISH), + HCA(TOPSPIN, SINAI_BD, LIVEFISH), }; #define MTHCA_PCI_TABLE_SIZE (sizeof(mthca_pci_table)/sizeof(struct pci_device_id)) @@ -392,8 +403,8 @@ static int mthca_init_icm(struct mthca_dev *mdev, } HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW , ("%I64d KB of HCA context requires %I64d KB aux memory.\n", - (unsigned long long) icm_size >> 10, - (unsigned long long) aux_pages << 2)); + (u64) icm_size >> 10, + (u64) aux_pages << 2)); mdev->fw.arbel.aux_icm = mthca_alloc_icm(mdev, (int)aux_pages, GFP_HIGHUSER | __GFP_NOWARN); @@ -737,7 +748,7 @@ static int mthca_setup_hca(struct mthca_dev *mdev) goto err_uar_table_free; } - mdev->kar = ioremap(mdev->driver_uar.pfn << PAGE_SHIFT, PAGE_SIZE,&mdev->kar_size); + mdev->kar = ioremap((io_addr_t)mdev->driver_uar.pfn << PAGE_SHIFT, PAGE_SIZE,&mdev->kar_size); if (!mdev->kar) { HCA_PRINT_EV(TRACE_LEVEL_ERROR,HCA_DBG_LOW,("Couldn't map kernel access region, " "aborting.\n")); @@ -929,7 +940,8 @@ NTSTATUS mthca_init_one(hca_dev_ext_t *ext) /* allocate mdev structure */ mdev = kmalloc(sizeof *mdev, GFP_KERNEL); if (!mdev) { - HCA_PRINT_EV(TRACE_LEVEL_ERROR ,HCA_DBG_LOW ,("Device struct alloc failed, " + // can't use HCA_PRINT_EV here ! + HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_LOW ,("Device struct alloc failed, " "aborting.\n")); status = STATUS_INSUFFICIENT_RESOURCES; goto end; @@ -938,13 +950,19 @@ NTSTATUS mthca_init_one(hca_dev_ext_t *ext) /* set some fields */ RtlZeroMemory(mdev, sizeof *mdev); mdev->ext = ext; /* pointer to DEVICE OBJECT extension */ + mdev->hca_type = p_id->driver_data; + mdev->ib_dev.mdev = mdev; + if (p_id->driver_data == LIVEFISH) + mdev->mthca_flags |= MTHCA_FLAG_LIVEFISH; + if (mthca_is_livefish(mdev)) + goto done; if (ext->hca_hidden) mdev->mthca_flags |= MTHCA_FLAG_DDR_HIDDEN; if (mthca_hca_table[p_id->driver_data].is_memfree) mdev->mthca_flags |= MTHCA_FLAG_MEMFREE; if (mthca_hca_table[p_id->driver_data].is_pcie) mdev->mthca_flags |= MTHCA_FLAG_PCIE; - + //TODO: after we have a FW, capable of reset, // write a routine, that only presses the button @@ -994,6 +1012,7 @@ NTSTATUS mthca_init_one(hca_dev_ext_t *ext) goto err_cleanup; } + done: ext->hca.mdev = mdev; mdev->state = MTHCA_DEV_INITIALIZED; return 0; @@ -1033,6 +1052,8 @@ void mthca_remove_one(hca_dev_ext_t *ext) int p; if (mdev) { + if (mthca_is_livefish(mdev)) + goto done; mthca_unregister_device(mdev); for (p = 1; p <= mdev->limits.num_ports; ++p) @@ -1053,7 +1074,7 @@ void mthca_remove_one(hca_dev_ext_t *ext) mthca_cleanup_uar_table(mdev); mthca_close_hca(mdev); mthca_cmd_cleanup(mdev); - +done: kfree(mdev); ext->hca.mdev = NULL; } diff --git a/trunk/hw/mthca/kernel/mthca_memfree.c b/trunk/hw/mthca/kernel/mthca_memfree.c index 1711f4e6..48a1c3a0 100644 --- a/trunk/hw/mthca/kernel/mthca_memfree.c +++ b/trunk/hw/mthca/kernel/mthca_memfree.c @@ -349,7 +349,7 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, 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)); + i, num_icm, reserved, nobj, obj_size, nobj * obj_size, (u64) virt)); return table; @@ -381,7 +381,7 @@ void mthca_free_icm_table(struct mthca_dev *dev, struct mthca_icm_table *table) 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)); + table->num_obj * table->obj_size, (u64) table->virt)); kfree(table); } diff --git a/trunk/hw/mthca/kernel/mthca_mr.c b/trunk/hw/mthca/kernel/mthca_mr.c index a6a7e50e..52e07d97 100644 --- a/trunk/hw/mthca/kernel/mthca_mr.c +++ b/trunk/hw/mthca/kernel/mthca_mr.c @@ -481,7 +481,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd, mthca_mpt_access_t access, struct mthca_mr *mr) { mr->mtt = NULL; - return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr); + return mthca_mr_alloc(dev, pd, 12, 0, ~0Ui64, access, mr); } int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd, @@ -727,7 +727,7 @@ int mthca_tavor_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, } mpt_entry.lkey = cl_hton32(key); - mpt_entry.length = CPU_2_BE64(list_len * (1ull << fmr->attr.page_shift)); + mpt_entry.length = CPU_2_BE64(list_len * (1Ui64 << fmr->attr.page_shift)); mpt_entry.start = cl_hton64(iova); __raw_writel((u32) mpt_entry.lkey, &fmr->mem.tavor.mpt->key); @@ -772,7 +772,7 @@ int mthca_arbel_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, fmr->mem.arbel.mpt->key = cl_hton32(key); fmr->mem.arbel.mpt->lkey = cl_hton32(key); - fmr->mem.arbel.mpt->length = CPU_2_BE64(list_len * (1ull << fmr->attr.page_shift)); + fmr->mem.arbel.mpt->length = CPU_2_BE64(list_len * (1Ui64 << fmr->attr.page_shift)); fmr->mem.arbel.mpt->start = cl_hton64(iova); wmb(); diff --git a/trunk/hw/mthca/kernel/mthca_profile.c b/trunk/hw/mthca/kernel/mthca_profile.c index e936b15b..05b88984 100644 --- a/trunk/hw/mthca/kernel/mthca_profile.c +++ b/trunk/hw/mthca/kernel/mthca_profile.c @@ -157,8 +157,8 @@ u64 mthca_make_profile(struct mthca_dev *dev, if (total_size > mem_avail) { HCA_PRINT(TRACE_LEVEL_ERROR,HCA_DBG_LOW,("Profile requires 0x%I64x bytes; " "won't in 0x%I64x bytes of context memory.\n", - (unsigned long long) total_size, - (unsigned long long) mem_avail)); + (u64) total_size, + (u64) mem_avail)); kfree(profile); return (u64)-ENOMEM; } @@ -167,8 +167,8 @@ u64 mthca_make_profile(struct mthca_dev *dev, HCA_PRINT(TRACE_LEVEL_VERBOSE,HCA_DBG_LOW,("profile[%2d]--%2d/%2d @ 0x%16I64x " "(size 0x%8I64x)\n", i, profile[i].type, profile[i].log_num, - (unsigned long long) profile[i].start, - (unsigned long long) profile[i].size)); + (u64) profile[i].start, + (u64) profile[i].size)); } if (mthca_is_memfree(dev)){ diff --git a/trunk/hw/mthca/kernel/mthca_provider.c b/trunk/hw/mthca/kernel/mthca_provider.c index ce3d98ec..52b65cd4 100644 --- a/trunk/hw/mthca/kernel/mthca_provider.c +++ b/trunk/hw/mthca/kernel/mthca_provider.c @@ -72,6 +72,15 @@ u8 status; + RtlZeroMemory(props, sizeof *props); + + if (mthca_is_livefish(mdev)) { + props->max_pd = 1; + props->vendor_id = mdev->ext->hcaConfig.VendorID; + props->vendor_part_id = mdev->ext->hcaConfig.DeviceID; + return 0; + } + in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL); out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); if (!in_mad || !out_mad) @@ -89,7 +98,6 @@ goto out; } - RtlZeroMemory(props, sizeof *props); props->fw_ver = mdev->fw_ver; props->device_cap_flags = mdev->device_cap_flags; props->vendor_id = cl_ntoh32(*(__be32 *) (out_mad->data + 36)) & @@ -97,7 +105,7 @@ props->vendor_part_id = cl_ntoh16(*(__be16 *) (out_mad->data + 30)); props->hw_ver = cl_ntoh32(*(__be32 *) (out_mad->data + 32)); memcpy(&props->sys_image_guid, out_mad->data + 4, 8); - props->max_mr_size = ~0ull; + props->max_mr_size = ~0Ui64; props->page_size_cap = mdev->limits.page_size_cap; props->max_qp = mdev->limits.num_qps - mdev->limits.reserved_qps; props->max_qp_wr = mdev->limits.max_wqes; @@ -334,6 +342,9 @@ struct ib_ucontext *mthca_alloc_ucontext(struct ib_device *ibdev, err = -ENOMEM; goto err_nomem; } + + if (mthca_is_livefish(to_mdev(ibdev))) + goto done; err = mthca_uar_alloc(to_mdev(ibdev), &context->uar); if (err) @@ -344,7 +355,7 @@ struct ib_ucontext *mthca_alloc_ucontext(struct ib_device *ibdev, */ /* map UAR to kernel */ - context->kva = ioremap(context->uar.pfn << PAGE_SHIFT, PAGE_SIZE,&context->uar_size); + context->kva = ioremap((io_addr_t)context->uar.pfn << PAGE_SHIFT, PAGE_SIZE,&context->uar_size); if (!context->kva) { HCA_PRINT( TRACE_LEVEL_ERROR, HCA_DBG_LOW ,("Couldn't map kernel access region, aborting.\n") ); err = -ENOMEM; @@ -377,6 +388,7 @@ struct ib_ucontext *mthca_alloc_ucontext(struct ib_device *ibdev, goto err_init_user; } +done: err = ib_copy_to_umv_buf(p_umv_buf, &uresp, sizeof uresp); if (err) goto err_copy_to_umv_buf; @@ -407,12 +419,15 @@ err_nomem: { struct mthca_ucontext *mucontext = to_mucontext(context); + if (mthca_is_livefish(to_mdev(context->device))) + goto done; mthca_cleanup_user_db_tab(to_mdev(context->device), &mucontext->uar, mucontext->db_tab); MmUnmapLockedPages( mucontext->ibucontext.user_uar, mucontext->mdl ); IoFreeMdl(mucontext->mdl); iounmap(mucontext->kva, PAGE_SIZE); mthca_uar_free(to_mdev(context->device), &mucontext->uar); +done: kfree(mucontext); return 0; @@ -440,11 +455,15 @@ struct ib_pd *mthca_alloc_pd(struct ib_device *ibdev, goto err_mem; } + if (mthca_is_livefish(to_mdev(ibdev))) + goto done; + err = mthca_pd_alloc(to_mdev(ibdev), !context, pd); if (err) { goto err_pd_alloc; } +done: if (p_umv_buf && p_umv_buf->command) { resp.pd_handle = (u64)(UINT_PTR)pd; resp.pdn = pd->pd_num; @@ -467,9 +486,13 @@ err_param: int mthca_dealloc_pd(struct ib_pd *pd) { + if (mthca_is_livefish(to_mdev(pd->device))) + goto done; + mthca_pd_free(to_mdev(pd->device), to_mpd(pd)); - kfree(pd); +done: + kfree(pd); return 0; } @@ -909,17 +932,17 @@ struct ib_mr *mthca_reg_phys_mr(struct ib_pd *pd, /* Find largest page shift we can use to cover buffers */ for (shift = PAGE_SHIFT; shift < 31; ++shift) if (num_phys_buf > 1) { - if ((1ULL << shift) & mask) + if ((1Ui64 << shift) & mask) break; } else { - if (1ULL << shift >= + if (1Ui64 << shift >= buffer_list[0].size + - (buffer_list[0].addr & ((1ULL << shift) - 1))) + (buffer_list[0].addr & ((1Ui64 << shift) - 1))) break; } - buffer_list[0].size += buffer_list[0].addr & ((1ULL << shift) - 1); - buffer_list[0].addr &= ~0ull << shift; + buffer_list[0].size += buffer_list[0].addr & ((1Ui64 << shift) - 1); + buffer_list[0].addr &= ~0Ui64 << shift; mr = kmalloc(sizeof *mr, GFP_KERNEL); if (!mr) @@ -928,7 +951,7 @@ struct ib_mr *mthca_reg_phys_mr(struct ib_pd *pd, npages = 0; for (i = 0; i < num_phys_buf; ++i) - npages += (int)((buffer_list[i].size + (1ULL << shift) - 1) >> shift); + npages += (int)((buffer_list[i].size + (1Ui64 << shift) - 1) >> shift); if (!npages) return &mr->ibmr; @@ -942,14 +965,14 @@ struct ib_mr *mthca_reg_phys_mr(struct ib_pd *pd, n = 0; for (i = 0; i < num_phys_buf; ++i) for (j = 0; - j < (buffer_list[i].size + (1ULL << shift) - 1) >> shift; + j < (buffer_list[i].size + (1Ui64 << shift) - 1) >> shift; ++j) page_list[n++] = buffer_list[i].addr + ((u64) j << shift); HCA_PRINT( TRACE_LEVEL_VERBOSE ,HCA_DBG_LOW ,("Registering memory at %I64x (iova %I64x) " "in PD %x; shift %d, npages %d.\n", - (unsigned long long) buffer_list[0].addr, - (unsigned long long) *iova_start, + (u64) buffer_list[0].addr, + (u64) *iova_start, to_mpd(pd)->pd_num, shift, npages)); diff --git a/trunk/hw/mthca/kernel/mthca_qp.c b/trunk/hw/mthca/kernel/mthca_qp.c index 78f67e38..5ca10094 100644 --- a/trunk/hw/mthca/kernel/mthca_qp.c +++ b/trunk/hw/mthca/kernel/mthca_qp.c @@ -1215,10 +1215,6 @@ int mthca_alloc_qp(struct mthca_dev *dev, int err; SPIN_LOCK_PREP(lh); - err = mthca_set_qp_size(dev, cap, pd, qp); - if (err) - return err; - switch (type) { case IB_QPT_RELIABLE_CONN: qp->transport = RC; break; case IB_QPT_UNRELIABLE_CONN: qp->transport = UC; break; @@ -1226,6 +1222,10 @@ int mthca_alloc_qp(struct mthca_dev *dev, default: return -EINVAL; } + err = mthca_set_qp_size(dev, cap, pd, qp); + if (err) + return err; + qp->qpn = mthca_alloc(&dev->qp_table.alloc); if (qp->qpn == -1) return -ENOMEM; diff --git a/trunk/hw/mthca/kernel/mthca_srq.c b/trunk/hw/mthca/kernel/mthca_srq.c index 0dcb0568..c731fce0 100644 --- a/trunk/hw/mthca/kernel/mthca_srq.c +++ b/trunk/hw/mthca/kernel/mthca_srq.c @@ -109,7 +109,7 @@ static void mthca_tavor_init_srq_context(struct mthca_dev *dev, RtlZeroMemory(context, sizeof *context); - context->wqe_base_ds = CPU_2_BE64(1ULL << (srq->wqe_shift - 4)); + context->wqe_base_ds = CPU_2_BE64(1Ui64 << (srq->wqe_shift - 4)); context->state_pd = cl_hton32(pd->pd_num); context->lkey = cl_hton32(srq->mr.ibmr.lkey); diff --git a/trunk/hw/mthca/mx_abi.h b/trunk/hw/mthca/mx_abi.h index e64ac6d8..6d931652 100644 --- a/trunk/hw/mthca/mx_abi.h +++ b/trunk/hw/mthca/mx_abi.h @@ -154,18 +154,13 @@ struct ibv_modify_qp_resp { uint8_t reserved[3]; }; -struct __ibv_ah { - uint64_t user_handle; - int use_mr; -}; - struct ibv_create_ah { - struct __ibv_ah; + uint64_t user_handle; struct ibv_reg_mr mr; }; struct ibv_create_ah_resp { - struct __ibv_ah; + uint64_t user_handle; uint64_t start; struct ibv_reg_mr_resp mr; }; diff --git a/trunk/hw/mthca/user/mlnx_ual_av.c b/trunk/hw/mthca/user/mlnx_ual_av.c index cd60fb86..393c7bc6 100644 --- a/trunk/hw/mthca/user/mlnx_ual_av.c +++ b/trunk/hw/mthca/user/mlnx_ual_av.c @@ -144,7 +144,6 @@ mlnx_pre_create_av ( struct ibv_ah_attr attr; struct ibv_create_ah *p_create_av; ib_api_status_t status = IB_SUCCESS; - int AV_created = TRUE; size_t size = max( sizeof(struct ibv_create_ah), sizeof(struct ibv_create_ah_resp) ); mlnx_ual_pd_info_t *p_pd = (mlnx_ual_pd_info_t *)h_uvp_pd; mlnx_ual_hobul_t *p_hobul = p_pd->p_hobul; @@ -180,9 +179,6 @@ mlnx_pre_create_av ( // try to create AV err = mthca_alloc_av(to_mpd(p_pd->ibv_pd), &attr, ah, NULL); - if (err == -EAGAIN) - AV_created = FALSE; - else if (err) { UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_AV , ("mthca_alloc_av failed (%d)\n", err)); status = errno_to_iberr(err); @@ -205,7 +201,7 @@ mlnx_pre_create_av ( p_umv_buf->command = TRUE; p_create_av = (struct ibv_create_ah *)p_umv_buf->p_inout_buf; p_create_av->user_handle = (uint64_t)(ULONG_PTR)ah; - if (!AV_created) { + if (ah->in_kernel) { struct mthca_ah_page *page = ah->page; p_create_av->mr.start = (uint64_t)(ULONG_PTR)page->buf; p_create_av->mr.length = g_page_size; @@ -213,7 +209,6 @@ mlnx_pre_create_av ( p_create_av->mr.pd_handle = p_pd->ibv_pd->handle; p_create_av->mr.pdn = to_mpd(p_pd->ibv_pd)->pdn; p_create_av->mr.access_flags = 0; //local read - p_create_av->use_mr = TRUE; status = IB_SUCCESS; } else @@ -256,7 +251,7 @@ mlnx_post_create_av ( if (!mthca_is_memfree(p_pd->ibv_pd->context)) { page = ah->page; - if (p_resp->use_mr) { + if (ah->in_kernel) { // fill mr parameters page->mr.handle = p_resp->mr.mr_handle; page->mr.lkey = p_resp->mr.lkey; @@ -367,9 +362,15 @@ ib_api_status_t mlnx_pre_destroy_av ( IN const ib_av_handle_t h_uvp_av) { + ib_api_status_t status ; + struct mthca_ah *mthca_ah = (struct mthca_ah *)h_uvp_av; UVP_ENTER(UVP_DBG_AV); + if (mthca_ah->in_kernel) + status = IB_SUCCESS; + else + status = IB_VERBS_PROCESSING_DONE; UVP_EXIT(UVP_DBG_AV); - return IB_SUCCESS; + return status; } void diff --git a/trunk/hw/mthca/user/mlnx_ual_ca.c b/trunk/hw/mthca/user/mlnx_ual_ca.c index 64ca42a0..83dd92ce 100644 --- a/trunk/hw/mthca/user/mlnx_ual_ca.c +++ b/trunk/hw/mthca/user/mlnx_ual_ca.c @@ -105,16 +105,17 @@ mlnx_post_open_ca ( { ib_api_status_t status = ioctl_status; mlnx_ual_hobul_t *new_ca; - struct ibv_get_context_resp *resp_p; + struct ibv_get_context_resp *p_resp; struct ibv_context * ibvcontext; int err; UVP_ENTER(UVP_DBG_SHIM); + p_resp = (struct ibv_get_context_resp *)p_umv_buf->p_inout_buf; + if (IB_SUCCESS == status) { /* allocate ibv context */ - resp_p = (struct ibv_get_context_resp *)p_umv_buf->p_inout_buf; - ibvcontext = mthca_alloc_context(resp_p); + ibvcontext = mthca_alloc_context(p_resp); if (IS_ERR(ibvcontext)) { err = PTR_ERR(ibvcontext); UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM ,("mthca_alloc_context failed (%d)\n", err)); @@ -137,7 +138,8 @@ mlnx_post_open_ca ( err_memory: err_alloc_context: - cl_free( resp_p ); + if (p_resp) + cl_free( p_resp ); UVP_EXIT(UVP_DBG_SHIM); return status; } diff --git a/trunk/hw/mthca/user/mlnx_ual_qp.c b/trunk/hw/mthca/user/mlnx_ual_qp.c index d708f64a..d4597e86 100644 --- a/trunk/hw/mthca/user/mlnx_ual_qp.c +++ b/trunk/hw/mthca/user/mlnx_ual_qp.c @@ -80,9 +80,19 @@ ib_api_status_t size_t size = max( sizeof(struct ibv_create_qp), sizeof(struct ibv_create_qp_resp) ); mlnx_ual_pd_info_t *p_pd = (mlnx_ual_pd_info_t *)h_uvp_pd; mlnx_ual_hobul_t *p_hobul = p_pd->p_hobul; + ib_ca_attr_t *p_hca_attr = p_hobul->p_hca_attr; UVP_ENTER(UVP_DBG_QP); + /* sanity checks */ + if(p_create_attr->sq_depth > p_hca_attr->max_wrs ||p_create_attr->rq_depth > p_hca_attr->max_wrs ) + status = IB_INVALID_MAX_WRS; + else + if(p_create_attr->sq_sge> p_hca_attr->max_sges ||p_create_attr->rq_sge> p_hca_attr->max_sges ) + status = IB_INVALID_MAX_SGE; + if (status) + goto err_params; + CL_ASSERT(p_umv_buf); if( !p_umv_buf->p_inout_buf ) @@ -99,9 +109,9 @@ ib_api_status_t p_umv_buf->command = TRUE; /* convert attributes */ - attr.send_cq = p_create_attr->h_sq_cq->ibv_cq; - attr.recv_cq = p_create_attr->h_rq_cq->ibv_cq; - attr.srq = NULL; /* absent in IBAL */ + attr.send_cq = p_create_attr->h_sq_cq->ibv_cq; + attr.recv_cq = p_create_attr->h_rq_cq->ibv_cq; + attr.srq = NULL; /* absent in IBAL */ attr.cap.max_send_wr = p_create_attr->sq_depth; attr.cap.max_recv_wr = p_create_attr->rq_depth; attr.cap.max_send_sge = p_create_attr->sq_sge; @@ -116,17 +126,11 @@ ib_api_status_t if (IS_ERR(ibv_qp)) { err = PTR_ERR(ibv_qp); UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_QP ,("mthca_create_qp_pre failed (%d)\n", err)); - //fix return values - if(err == -EINVAL && (attr.cap.max_send_wr > 65536 ||attr.cap.max_recv_wr > 65536 )) - status = IB_INVALID_MAX_WRS; - else if(err == -EINVAL && (attr.cap.max_send_sge> 64 ||attr.cap.max_recv_sge> 64 )) - status = IB_INVALID_MAX_SGE; - else if(err == -ENOMEM && (attr.cap.max_send_sge == 0 ||attr.cap.max_recv_sge == 0|| + if(err == -ENOMEM && (attr.cap.max_send_sge == 0 ||attr.cap.max_recv_sge == 0|| attr.cap.max_send_wr == 0 || attr.cap.max_recv_wr == 0)) status = IB_INVALID_SETTING; else status = errno_to_iberr(err); - goto err_alloc_qp; } @@ -135,6 +139,7 @@ ib_api_status_t err_alloc_qp: cl_free(p_umv_buf->p_inout_buf); err_memory: +err_params: end: UVP_EXIT(UVP_DBG_QP); return status; @@ -251,13 +256,14 @@ mlnx_post_modify_qp ( { memset( &attr, 0, sizeof(attr)); attr.qp_state = p_resp->qp_state; - if (p_qp_info->ibv_qp) + if (p_qp_info->ibv_qp) { err = p_qp_info->h_uvp_pd->p_hobul->ibv_ctx->ops.modify_qp( h_uvp_qp->ibv_qp, &attr, p_resp->attr_mask); - if (err) { - UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , ("mthca_modify_qp failed (%d)\n", err)); - status = errno_to_iberr(err); - goto err_modify_qp; + if (err) { + UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_SHIM , ("mthca_modify_qp failed (%d)\n", err)); + status = errno_to_iberr(err); + goto err_modify_qp; + } } UVP_PRINT(TRACE_LEVEL_INFORMATION ,UVP_DBG_SHIM , ("Committed to modify QP to state %d\n", p_resp->qp_state)); diff --git a/trunk/hw/mthca/user/mlnx_uvp.c b/trunk/hw/mthca/user/mlnx_uvp.c index fd383eeb..9038f5e4 100644 --- a/trunk/hw/mthca/user/mlnx_uvp.c +++ b/trunk/hw/mthca/user/mlnx_uvp.c @@ -71,6 +71,24 @@ size_t g_page_size = 0; #define PCI_VENDOR_ID_TOPSPIN 0x1867 #endif +/* live fishes */ +#ifndef PCI_DEVICE_ID_MELLANOX_TAVOR_BD +#define PCI_DEVICE_ID_MELLANOX_TAVOR_BD 0x5a45 +#endif + +#ifndef PCI_DEVICE_ID_MELLANOX_ARBEL_BD +#define PCI_DEVICE_ID_MELLANOX_ARBEL_BD 0x6279 +#endif + +#ifndef PCI_DEVICE_ID_MELLANOX_SINAI_OLD_BD +#define PCI_DEVICE_ID_MELLANOX_SINAI_OLD_BD 0x5e8d +#endif + +#ifndef PCI_DEVICE_ID_MELLANOX_SINAI_BD +#define PCI_DEVICE_ID_MELLANOX_SINAI_BD 0x6275 +#endif + + #define HCA(v, d, t) \ { PCI_VENDOR_ID_##v, PCI_DEVICE_ID_MELLANOX_##d, MTHCA_##t } @@ -89,6 +107,15 @@ static struct pci_device_id { HCA( TOPSPIN, ARBEL, ARBEL), HCA( TOPSPIN, SINAI_OLD, ARBEL), HCA( TOPSPIN, SINAI, ARBEL), + // live fishes + HCA(MELLANOX, TAVOR_BD, LIVEFISH), + HCA(MELLANOX, ARBEL_BD, LIVEFISH), + HCA(MELLANOX, SINAI_OLD_BD, LIVEFISH), + HCA(MELLANOX, SINAI_BD, LIVEFISH), + HCA(TOPSPIN, TAVOR_BD, LIVEFISH), + HCA(TOPSPIN, ARBEL_BD, LIVEFISH), + HCA(TOPSPIN, SINAI_OLD_BD, LIVEFISH), + HCA(TOPSPIN, SINAI_BD, LIVEFISH), }; static struct ibv_context_ops mthca_ctx_ops = { diff --git a/trunk/hw/mthca/user/mlnx_uvp.h b/trunk/hw/mthca/user/mlnx_uvp.h index 47a1a877..b9ed87cc 100644 --- a/trunk/hw/mthca/user/mlnx_uvp.h +++ b/trunk/hw/mthca/user/mlnx_uvp.h @@ -45,7 +45,8 @@ enum mthca_hca_type { MTHCA_TAVOR, - MTHCA_ARBEL + MTHCA_ARBEL, + MTHCA_LIVEFISH }; enum { @@ -200,6 +201,7 @@ struct mthca_ah { ib_pd_handle_t h_uvp_pd; struct mthca_ah_page *page; uint32_t key; + int in_kernel; }; struct mthca_ah_page { diff --git a/trunk/hw/mthca/user/mlnx_uvp_ah.c b/trunk/hw/mthca/user/mlnx_uvp_ah.c index 74201fd3..f68fc3b1 100644 --- a/trunk/hw/mthca/user/mlnx_uvp_ah.c +++ b/trunk/hw/mthca/user/mlnx_uvp_ah.c @@ -68,7 +68,6 @@ static struct mthca_ah_page *__add_page( int mthca_alloc_av(struct mthca_pd *pd, struct ibv_ah_attr *attr, struct mthca_ah *ah, struct ibv_create_ah_resp *resp) { - int added_page = FALSE; if (mthca_is_memfree(pd->ibv_pd.context)) { ah->av = cl_malloc(sizeof *ah->av); if (!ah->av) @@ -94,7 +93,7 @@ int mthca_alloc_av(struct mthca_pd *pd, struct ibv_ah_attr *attr, ReleaseMutex( pd->ah_mutex ); return -ENOMEM; } - added_page = TRUE; + ah->in_kernel = TRUE; found: ++page->use_cnt; @@ -135,11 +134,7 @@ int mthca_alloc_av(struct mthca_pd *pd, struct ibv_ah_attr *attr, /* Arbel workaround -- low byte of GID must be 2 */ ah->av->dgid[3] = cl_hton32(2); } - - if (added_page) - return -EAGAIN; - else - return 0; + return 0; } void mthca_free_av(struct mthca_ah *ah) @@ -156,30 +151,13 @@ void mthca_free_av(struct mthca_ah *ah) page = ah->page; i = ((uint8_t *)ah->av - (uint8_t *)page->buf) / sizeof *ah->av; page->free[i / (8 * sizeof (int))] |= 1 << (i % (8 * sizeof (int))); - - if (!--page->use_cnt) { - if (page->prev) - page->prev->next = page->next; - else - pd->ah_list = page->next; - if (page->next) - page->next->prev = page->prev; - -#ifdef NOT_USE_VIRTUAL_ALLOC - cl_free(page->buf); -#else - VirtualFree( page->buf, 0, MEM_RELEASE); -#endif - - cl_free(page); - } - + --page->use_cnt; ReleaseMutex( pd->ah_mutex ); } } //NB: temporary, for support of modify_qp -void mthca_set_av_params( struct mthca_ah *ah_p, struct ibv_ah_attr *ah_attr ) +void mthca_set_av_params( struct mthca_ah *ah_p, struct ibv_ah_attr *ah_attr ) { struct mthca_av *av = ah_p->av; mlnx_ual_pd_info_t *p_pd = (mlnx_ual_pd_info_t *)ah_p->h_uvp_pd; diff --git a/trunk/hw/mthca/user/mlnx_uvp_qp.c b/trunk/hw/mthca/user/mlnx_uvp_qp.c index 9ebcbd62..e61e9ed8 100644 --- a/trunk/hw/mthca/user/mlnx_uvp_qp.c +++ b/trunk/hw/mthca/user/mlnx_uvp_qp.c @@ -572,7 +572,7 @@ int mthca_arbel_post_send(struct ibv_qp *ibqp, struct _ib_send_wr *wr, ((struct mthca_next_seg *) wqe)->flags = ((wr->send_opt & IB_SEND_OPT_SIGNALED) ? cl_hton32(MTHCA_NEXT_CQ_UPDATE) : 0) | - ((wr->send_opt & IB_SEND_OPT_SIGNALED) ? + ((wr->send_opt & IB_SEND_OPT_SOLICITED) ? cl_hton32(MTHCA_NEXT_SOLICIT) : 0) | cl_hton32(1); if (opcode == MTHCA_OPCODE_SEND_IMM|| diff --git a/trunk/hw/mthca/user/mlnx_uvp_verbs.c b/trunk/hw/mthca/user/mlnx_uvp_verbs.c index 03211102..557d1bef 100644 --- a/trunk/hw/mthca/user/mlnx_uvp_verbs.c +++ b/trunk/hw/mthca/user/mlnx_uvp_verbs.c @@ -73,8 +73,21 @@ err_malloc: int mthca_free_pd(struct ibv_pd *ibv_pd) { struct mthca_pd *pd = to_mpd(ibv_pd); - if (!mthca_is_memfree(ibv_pd->context)) + if (!mthca_is_memfree(ibv_pd->context)) { + struct mthca_ah_page *page, *next_page; + WaitForSingleObject( pd->ah_mutex, INFINITE ); + for (page = pd->ah_list; page; page = next_page) { + next_page = page->next; + #ifdef NOT_USE_VIRTUAL_ALLOC + cl_free(page->buf); + #else + VirtualFree( page->buf, 0, MEM_RELEASE); + #endif + cl_free(page); + } + ReleaseMutex( pd->ah_mutex ); CloseHandle(pd->ah_mutex); + } cl_free(pd); return 0; } @@ -248,7 +261,7 @@ struct ibv_qp *mthca_create_qp_pre(struct ibv_pd *pd, { struct mthca_qp *qp; struct ibv_context *context = pd->context; - int ret; + int ret = -ENOMEM; UVP_ENTER(UVP_DBG_QP); /* Sanity check QP size before proceeding */ @@ -264,7 +277,6 @@ struct ibv_qp *mthca_create_qp_pre(struct ibv_pd *pd, qp = cl_malloc(sizeof *qp); if (!qp) { - ret = -ENOMEM; UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_QP ,("cl_malloc failed (%d)\n",ret)); goto err_nomem; } @@ -273,7 +285,6 @@ struct ibv_qp *mthca_create_qp_pre(struct ibv_pd *pd, qp->rq.max = align_queue_size(context, attr->cap.max_recv_wr, 0); if (mthca_alloc_qp_buf(pd, &attr->cap, attr->qp_type, qp)) { - ret = -ENOMEM; UVP_PRINT(TRACE_LEVEL_ERROR ,UVP_DBG_QP ,("mthca_alloc_qp_buf failed (%d)\n",ret)); goto err_nomem; }