From 0d95aabda5b24779505aeda7ff423780d3d25316 Mon Sep 17 00:00:00 2001 From: Tzachi Dar Date: Wed, 1 Sep 2010 10:25:12 +0000 Subject: [PATCH] [mthca] Remove livefish support. git-svn-id: svn://openib.tc.cornell.edu/gen1@2883 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/hw/mthca/kernel/hca_data.h | 5 - trunk/hw/mthca/kernel/hca_memory.c | 29 - trunk/hw/mthca/kernel/hca_pnp.c | 47 +- trunk/hw/mthca/kernel/hca_verbs.c | 91 +- trunk/hw/mthca/kernel/mt_verbs.c | 4 - trunk/hw/mthca/kernel/mthca.inx | 16 - trunk/hw/mthca/kernel/mthca_dev.h | 1226 ++++++++++++------------ trunk/hw/mthca/kernel/mthca_main.c | 38 +- trunk/hw/mthca/kernel/mthca_provider.c | 29 +- trunk/hw/mthca/user/mlnx_uvp.c | 450 ++++----- 10 files changed, 870 insertions(+), 1065 deletions(-) diff --git a/trunk/hw/mthca/kernel/hca_data.h b/trunk/hw/mthca/kernel/hca_data.h index 57d4c513..f6a15b74 100644 --- a/trunk/hw/mthca/kernel/hca_data.h +++ b/trunk/hw/mthca/kernel/hca_data.h @@ -239,7 +239,6 @@ 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 @@ -326,10 +325,6 @@ 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_memory.c b/trunk/hw/mthca/kernel/hca_memory.c index 4c817da8..1e3ef6e2 100644 --- a/trunk/hw/mthca/kernel/hca_memory.c +++ b/trunk/hw/mthca/kernel/hca_memory.c @@ -136,17 +136,6 @@ mlnx_register_pmr ( HCA_ENTER(HCA_DBG_MEMORY); - if (mthca_is_livefish(to_mdev(ib_pd_p->device))) { - mr_p = kzalloc(sizeof *mr_p, GFP_KERNEL); - if (!mr_p) { - status = IB_INSUFFICIENT_MEMORY; - goto err_mem; - } - mr_p->device = ib_pd_p->device; - mr_p->pd = ib_pd_p; - goto done; - } - // sanity checks if( !cl_is_blockable() ) { status = IB_UNSUPPORTED; @@ -181,7 +170,6 @@ mlnx_register_pmr ( } // results -done: if (ph_mr) *ph_mr = (ib_mr_handle_t)mr_p; *p_lkey = mr_p->lkey; *p_rkey = cl_hton32( mr_p->rkey ); @@ -191,7 +179,6 @@ done: err_reg_phys_mr: err_invalid_parm: err_unsupported: -err_mem: if (status != IB_SUCCESS) { HCA_PRINT(TRACE_LEVEL_ERROR ,HCA_DBG_MEMORY, @@ -288,15 +275,9 @@ mlnx_deregister_mr ( { ib_api_status_t status; int err; - struct ib_mr *ib_mr = (struct ib_mr *)h_mr; HCA_ENTER(HCA_DBG_SHIM); - if (mthca_is_livefish(to_mdev(ib_mr->device))) { - kfree(ib_mr); - goto done; - } - // sanity checks if( !cl_is_blockable() ) { status = IB_UNSUPPORTED; @@ -312,7 +293,6 @@ mlnx_deregister_mr ( goto err_dereg_mr; } -done: status = IB_SUCCESS; err_dereg_mr: @@ -590,12 +570,3 @@ 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_pnp.c b/trunk/hw/mthca/kernel/hca_pnp.c index 147ac6ba..76978072 100644 --- a/trunk/hw/mthca/kernel/hca_pnp.c +++ b/trunk/hw/mthca/kernel/hca_pnp.c @@ -238,9 +238,7 @@ __alloc_hca_ifc( return NULL; } - setup_ci_interface( p_ext->hca.guid, - !!mthca_is_livefish(p_ext->hca.mdev), - pIfc ); + setup_ci_interface( p_ext->hca.guid, pIfc ); pIfc->p_hca_obj = &p_ext->hca.hob; pIfc->vend_id = (uint32_t)p_ext->hcaConfig.VendorID; @@ -276,10 +274,6 @@ __SetupHcaResources( HCA_ENTER( HCA_DBG_PNP ); - // there will be no resources for "livefish" (PCI memory controller mode) - if (!pHcaResList || !pHostResList) - goto done; - p_ext = (hca_dev_ext_t*)p_dev_obj->DeviceExtension; // store the bus number for reset of Tavor @@ -304,16 +298,16 @@ __SetupHcaResources( if( pHcaRes->Type == CmResourceTypeInterrupt ) { p_ext->interruptInfo = *pHostRes; - if ( g_processor_affinity == 0xFFFFFFFF ) + if ( g_processor_affinity == 0xFFFFFFFF ) { - /* + /* * Calculate the mask of the last processor */ KAFFINITY n_active_processors_bitmask; uint32_t last_processor_mask = 0 , tmp_processor_mask = 1; n_active_processors_bitmask = KeQueryActiveProcessors(); - while ( tmp_processor_mask & n_active_processors_bitmask ) + while ( tmp_processor_mask & n_active_processors_bitmask ) { last_processor_mask = tmp_processor_mask; tmp_processor_mask = tmp_processor_mask << 1; @@ -383,7 +377,6 @@ __SetupHcaResources( status = STATUS_UNSUCCESSFUL; } -done: HCA_EXIT( HCA_DBG_PNP ); return status; } @@ -413,14 +406,6 @@ __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, @@ -432,6 +417,7 @@ hca_start( IO_STACK_LOCATION *pIoStack; POWER_STATE powerState; DEVICE_DESCRIPTION devDesc; + int err; HCA_ENTER( HCA_DBG_PNP ); @@ -504,21 +490,13 @@ hca_start( return status; } - /*leo: get node GUID */ - { - 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 ); + err = mthca_get_dev_info( p_ext->hca.mdev, &p_ext->hca.guid, &p_ext->hca.hw_ver ); + if (err) { - if (err) { - - //TODO: no cleanup on error - HCA_PRINT( TRACE_LEVEL_ERROR,HCA_DBG_PNP, - ("can't get guid - mthca_query_port()")); - return STATUS_INSUFFICIENT_RESOURCES; - } + //TODO: no cleanup on error + HCA_PRINT( TRACE_LEVEL_ERROR,HCA_DBG_PNP, + ("can't get guid - mthca_query_port()")); + return STATUS_INSUFFICIENT_RESOURCES; } /* queue HCA */ @@ -549,8 +527,7 @@ hca_start( DRV_VERSION, DRV_RELDATE )); HCA_PRINT_EV(TRACE_LEVEL_INFORMATION ,HCA_DBG_LOW , - ("Flags %s%s%s%s%s%s%s\n", - (mdev->mthca_flags & MTHCA_FLAG_LIVEFISH) ? "Flash Recovery Mode:" : "", + ("Flags %s%s%s%s%s%s\n", (mdev->mthca_flags & MTHCA_FLAG_MEMFREE) ? "MemFree:" : "", (mdev->mthca_flags & MTHCA_FLAG_NO_LAM) ? "NoLam:" : "", (mdev->mthca_flags & MTHCA_FLAG_FMR) ? "Fmr:" : "", diff --git a/trunk/hw/mthca/kernel/hca_verbs.c b/trunk/hw/mthca/kernel/hca_verbs.c index 68fd2635..6ab14fcd 100644 --- a/trunk/hw/mthca/kernel/hca_verbs.c +++ b/trunk/hw/mthca/kernel/hca_verbs.c @@ -85,24 +85,20 @@ 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)); if (pfn_async_event_cb) { - status = mlnx_hobs_set_cb(&p_hca->hob, - pfn_async_event_cb, - ca_context); - if (IB_SUCCESS != status) { - goto err_set_cb; - } + status = mlnx_hobs_set_cb(&p_hca->hob, + pfn_async_event_cb, + ca_context); + if (IB_SUCCESS != status) { + goto err_set_cb; + } } //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; @@ -417,17 +413,9 @@ 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); - - if (mthca_is_livefish(MDEV_FROM_HOB( hob_p ))) - goto done; - mlnx_hobs_remove(h_ca); - -done: HCA_EXIT(HCA_DBG_SHIM); - return IB_SUCCESS; } @@ -541,10 +529,7 @@ mlnx_um_close( mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; hca_dev_ext_t *ext_p = EXT_FROM_HOB( hob_p ); - if (mthca_is_livefish(to_mdev(p_ucontext->device))) - goto done; unmap_crspace_for_all(p_ucontext); -done: cl_spinlock_acquire( &ext_p->uctx_lock ); cl_qlist_remove_item( &ext_p->uctx_list, &p_ucontext->list_item ); cl_atomic_dec(&ext_p->usecnt); @@ -931,7 +916,7 @@ mlnx_modify_srq ( ib_api_status_t status = IB_SUCCESS; struct ib_srq *ib_srq = (struct ib_srq *)h_srq; UNUSED_PARAM(p_umv_buf); - + HCA_ENTER(HCA_DBG_SRQ); err = ibv_modify_srq(ib_srq, (void*)p_srq_attr, srq_attr_mask); @@ -1649,7 +1634,6 @@ err_port_num: 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)); @@ -1678,41 +1662,34 @@ setup_ci_interface( p_interface->deallocate_pd = mlnx_deallocate_pd; p_interface->vendor_call = fw_access_ctrl; - 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_srq = mlnx_create_srq; - p_interface->modify_srq = mlnx_modify_srq; - p_interface->query_srq = mlnx_query_srq; - p_interface->destroy_srq = mlnx_destroy_srq; - - 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->ndi_modify_qp = mlnx_ndi_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->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_srq = mlnx_create_srq; + p_interface->modify_srq = mlnx_modify_srq; + p_interface->query_srq = mlnx_query_srq; + p_interface->destroy_srq = mlnx_destroy_srq; + + 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->ndi_modify_qp = mlnx_ndi_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); - } + mlnx_memory_if(p_interface); + mlnx_direct_if(p_interface); + mlnx_mcast_if(p_interface); return; } diff --git a/trunk/hw/mthca/kernel/mt_verbs.c b/trunk/hw/mthca/kernel/mt_verbs.c index 38e8a4fa..3404d4ba 100644 --- a/trunk/hw/mthca/kernel/mt_verbs.c +++ b/trunk/hw/mthca/kernel/mt_verbs.c @@ -123,9 +123,6 @@ struct ib_pd *ibv_alloc_pd(struct ib_device *device, int ibv_dealloc_pd(struct ib_pd *pd) { - if (mthca_is_livefish(to_mdev(pd->device))) - goto done; - // we need first to release list of AV MRs to decrease pd->usecnt if (pd->ucontext) { struct ib_mr *ib_mr, *tmp; @@ -141,7 +138,6 @@ int ibv_dealloc_pd(struct ib_pd *pd) return -EBUSY; } -done: HCA_PRINT(TRACE_LEVEL_INFORMATION ,HCA_DBG_CQ ,("PD%d use cnt %d, pd_handle %p, ctx %p \n", ((struct mthca_pd*)pd)->pd_num, pd->usecnt, pd, pd->ucontext)); // direct call is a must, because "lifefish" devices doesn't fill driver i/f table diff --git a/trunk/hw/mthca/kernel/mthca.inx b/trunk/hw/mthca/kernel/mthca.inx index ce14a7d0..495e0512 100644 --- a/trunk/hw/mthca/kernel/mthca.inx +++ b/trunk/hw/mthca/kernel/mthca.inx @@ -122,36 +122,24 @@ WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll = 1,, [HCA.DeviceSection.ntx86] %MT23108.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_5A44 -%MT23109.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_5A45 %MT25208.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6278 -%MT25209.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6279 %MT25218.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6282 %MT24204.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_5E8C -%MT24205.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_5E8D %MT25204.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6274 -%MT25205.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6275 [HCA.DeviceSection.ntamd64] %MT23108.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_5A44 -%MT23109.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_5A45 %MT25208.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6278 -%MT25209.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6279 %MT25218.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6282 %MT24204.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_5E8C -%MT24205.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_5E8D %MT25204.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6274 -%MT25205.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6275 [HCA.DeviceSection.ntia64] %MT23108.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_5A44 -%MT23109.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_5A45 %MT25208.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6278 -%MT25209.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6279 %MT25218.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6282 %MT24204.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_5E8C -%MT24205.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_5E8D %MT25204.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6274 -%MT25205.DeviceDesc%=MTHCA.DDInstall, PCI\VEN_15B3&DEV_6275 [MTHCA.DDInstall.ntx86] CopyFiles = MTHCA.CopyFiles @@ -449,14 +437,10 @@ OFA = "OpenFabrics Alliance" MTL="Mellanox Technologies Ltd." MTHCA.ServiceDesc = "Driver for Mellanox InfiniHost Devices" MT23108.DeviceDesc="InfiniHost (MT23108) - Mellanox InfiniBand HCA" -MT23109.DeviceDesc="InfiniHost (MT23109) - Mellanox InfiniBand HCA (burner device)" MT25208.DeviceDesc="InfiniHost (MT25208) - Mellanox InfiniBand HCA for PCI Express" -MT25209.DeviceDesc="InfiniHost (MT25209) - Mellanox InfiniBand HCA for PCI Express (burner device)" MT25218.DeviceDesc="InfiniHost III Ex (MT25218) - Mellanox InfiniBand HCA for PCI Express" MT24204.DeviceDesc="InfiniHost III Lx (MT24204) - Mellanox InfiniBand HCA for PCI Express" -MT24205.DeviceDesc="InfiniHost III Lx (MT24205) - Mellanox InfiniBand HCA for PCI Express (burner device)" MT25204.DeviceDesc="InfiniHost III Lx (MT25204) - Mellanox InfiniBand HCA for PCI Express" -MT25205.DeviceDesc="InfiniHost III Lx (MT25205) - Mellanox InfiniBand HCA for PCI Express (burner device)" DiskId = "Mellanox InfiniBand HCA installation disk" Ibbus.ServiceDesc = "InfiniBand Bus/AL (Filter Driver)" WinVerbs.ServiceDesc = "WinVerbs Service" diff --git a/trunk/hw/mthca/kernel/mthca_dev.h b/trunk/hw/mthca/kernel/mthca_dev.h index ad31d151..013b0d63 100644 --- a/trunk/hw/mthca/kernel/mthca_dev.h +++ b/trunk/hw/mthca/kernel/mthca_dev.h @@ -1,618 +1,608 @@ -/* - * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. - * Copyright (c) 2005 Cisco Systems. All rights reserved. - * Copyright (c) 2005 Mellanox Technologies. All rights reserved. - * Copyright (c) 2004 Voltaire, Inc. All rights reserved. - * Copyright (c) 2006 SilverStorm Technologies, Inc. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Id$ - */ - -#ifndef MTHCA_DEV_H -#define MTHCA_DEV_H - -#include "hca_driver.h" -#include "mthca_log.h" -#include "mthca_provider.h" -#include "mthca_doorbell.h" - -// must be synchronized with MTHCA.INF -#define DRV_NAME "mthca" -#define PFX DRV_NAME ": " -//TODO -#define DRV_VERSION "1.0.0000.566" -#define DRV_RELDATE "12/21/2006" - -#define HZ 1000000 /* 1 sec in usecs */ - -enum { - MTHCA_FLAG_DDR_HIDDEN = 1 << 1, - MTHCA_FLAG_SRQ = 1 << 2, - MTHCA_FLAG_MSI = 1 << 3, - MTHCA_FLAG_MSI_X = 1 << 4, - MTHCA_FLAG_NO_LAM = 1 << 5, - MTHCA_FLAG_FMR = 1 << 6, - MTHCA_FLAG_MEMFREE = 1 << 7, - MTHCA_FLAG_PCIE = 1 << 8, - MTHCA_FLAG_SINAI_OPT = 1 << 9, - MTHCA_FLAG_LIVEFISH = 1 << 10 -}; - -enum { - MTHCA_MAX_PORTS = 2 -}; - -enum { - MTHCA_BOARD_ID_LEN = 64 -}; - -enum { - MTHCA_EQ_CONTEXT_SIZE = 0x40, - MTHCA_CQ_CONTEXT_SIZE = 0x40, - MTHCA_QP_CONTEXT_SIZE = 0x200, - MTHCA_RDB_ENTRY_SIZE = 0x20, - MTHCA_AV_SIZE = 0x20, - MTHCA_MGM_ENTRY_SIZE = 0x40, - - /* Arbel FW gives us these, but we need them for Tavor */ - MTHCA_MPT_ENTRY_SIZE = 0x40, - MTHCA_MTT_SEG_SIZE = 0x40, - - MTHCA_QP_PER_MGM = 4 * (MTHCA_MGM_ENTRY_SIZE / 16 - 2) -}; - -enum { - MTHCA_EQ_CMD, - MTHCA_EQ_ASYNC, - MTHCA_EQ_COMP, - MTHCA_NUM_EQ -}; - -enum { - MTHCA_BYTES_PER_ATOMIC_COMPL = 8 -}; - -enum mthca_wr_opcode{ - MTHCA_OPCODE_NOP = 0x00, - MTHCA_OPCODE_RDMA_WRITE = 0x08, - MTHCA_OPCODE_RDMA_WRITE_IMM = 0x09, - MTHCA_OPCODE_SEND = 0x0a, - MTHCA_OPCODE_SEND_IMM = 0x0b, - MTHCA_OPCODE_RDMA_READ = 0x10, - MTHCA_OPCODE_ATOMIC_CS = 0x11, - MTHCA_OPCODE_ATOMIC_FA = 0x12, - MTHCA_OPCODE_BIND_MW = 0x18, - MTHCA_OPCODE_INVALID = 0xff -}; - -struct mthca_cmd { - struct pci_pool *pool; - int use_events; - KMUTEX hcr_mutex; - KSEMAPHORE poll_sem; - KSEMAPHORE event_sem; - int max_cmds; - spinlock_t context_lock; - int free_head; - struct mthca_cmd_context *context; - u16 token_mask; -}; - -struct mthca_limits { - int num_ports; - int vl_cap; - int mtu_cap; - int gid_table_len; - int pkey_table_len; - int local_ca_ack_delay; - int num_uars; - int max_sg; - int num_qps; - int max_wqes; - int max_desc_sz; - int max_qp_init_rdma; - int reserved_qps; - int num_srqs; - int max_srq_wqes; - int max_srq_sge; - int reserved_srqs; - int num_eecs; - int reserved_eecs; - int num_cqs; - int max_cqes; - int reserved_cqs; - int num_eqs; - int reserved_eqs; - int num_mpts; - int num_mtt_segs; - int fmr_reserved_mtts; - int reserved_mtts; - int reserved_mrws; - int reserved_uars; - int num_mgms; - int num_amgms; - int reserved_mcgs; - int num_pds; - int reserved_pds; - u32 page_size_cap; - u32 flags; - u8 port_width_cap; - u64 num_avs; -}; - -struct mthca_alloc { - u32 last; - u32 top; - u32 max; - u32 mask; - spinlock_t lock; - unsigned long *table; -}; - -struct mthca_array { - struct { - void **page; - int used; - } *page_list; -}; - -struct mthca_uar_table { - struct mthca_alloc alloc; - u64 uarc_base; - int uarc_size; -}; - -struct mthca_pd_table { - struct mthca_alloc alloc; -}; - -struct mthca_buddy { - unsigned long **bits; - int max_order; - spinlock_t lock; -}; - -struct mthca_mr_table { - struct mthca_alloc mpt_alloc; - struct mthca_buddy mtt_buddy; - struct mthca_buddy *fmr_mtt_buddy; - u64 mtt_base; - u64 mpt_base; - struct mthca_icm_table *mtt_table; - struct mthca_icm_table *mpt_table; - struct { - void __iomem *mpt_base; - SIZE_T mpt_base_size; - void __iomem *mtt_base; - SIZE_T mtt_base_size; - struct mthca_buddy mtt_buddy; - } tavor_fmr; -}; - -struct mthca_eq_table { - struct mthca_alloc alloc; - void __iomem *clr_int; - u32 clr_mask; - u32 arm_mask; - struct mthca_eq eq[MTHCA_NUM_EQ]; - u64 icm_virt; - struct scatterlist sg; - int have_irq; - u8 inta_pin; - KLOCK_QUEUE_HANDLE lockh; -#if 1//WORKAROUND_POLL_EQ - KEVENT thread_start_event; - KEVENT thread_stop_event; - BOOLEAN bTerminated; - PVOID threadObject; -#endif -}; - -struct mthca_cq_table { - struct mthca_alloc alloc; - spinlock_t lock; - struct mthca_array cq; - struct mthca_icm_table *table; -}; - -struct mthca_srq_table { - struct mthca_alloc alloc; - spinlock_t lock; - struct mthca_array srq; - struct mthca_icm_table *table; -}; - -struct mthca_qp_table { - struct mthca_alloc alloc; - u32 rdb_base; - int rdb_shift; - int sqp_start; - spinlock_t lock; - struct mthca_array qp; - struct mthca_icm_table *qp_table; - struct mthca_icm_table *eqp_table; - struct mthca_icm_table *rdb_table; -}; - -struct mthca_av_table { - struct pci_pool *pool; - int num_ddr_avs; - u64 ddr_av_base; - void __iomem *av_map; - SIZE_T av_map_size; - struct mthca_alloc alloc; -}; - -struct mthca_mcg_table { - KMUTEX mutex; - struct mthca_alloc alloc; - struct mthca_icm_table *table; -}; - -struct mthca_catas_err { - u64 addr; - u32 __iomem *map; - SIZE_T map_size; - unsigned long stop; - u32 size; - KTIMER timer; - KDPC timer_dpc; - LARGE_INTEGER interval; -}; - -struct mthca_dev { - struct ib_device ib_dev; - hca_dev_ext_t *ext; - uplink_info_t uplink_info; - volatile long dpc_lock; - - int hca_type; - unsigned long mthca_flags; - unsigned long device_cap_flags; - - u32 rev_id; - char board_id[MTHCA_BOARD_ID_LEN]; - - /* firmware info */ - u64 fw_ver; - union { - struct { - u64 fw_start; - u64 fw_end; - } tavor; - struct { - u64 clr_int_base; - u64 eq_arm_base; - u64 eq_set_ci_base; - struct mthca_icm *fw_icm; - struct mthca_icm *aux_icm; - u16 fw_pages; - } arbel; - } fw; - - u64 ddr_start; - u64 ddr_end; - - MTHCA_DECLARE_DOORBELL_LOCK(doorbell_lock) - KMUTEX cap_mask_mutex; - - u8 __iomem *hcr; - SIZE_T hcr_size; - u8 __iomem *kar; - SIZE_T kar_size; - u8 __iomem *clr_base; - SIZE_T clr_base_size; - union { - struct { - void __iomem *ecr_base; - SIZE_T ecr_base_size; - } tavor; - struct { - void __iomem *eq_arm; - SIZE_T eq_arm_size; - void __iomem *eq_set_ci_base; - SIZE_T eq_set_ci_base_size; - } arbel; - } eq_regs; - - struct mthca_cmd cmd; - struct mthca_limits limits; - - struct mthca_uar_table uar_table; - struct mthca_pd_table pd_table; - struct mthca_mr_table mr_table; - struct mthca_eq_table eq_table; - struct mthca_cq_table cq_table; - struct mthca_srq_table srq_table; - struct mthca_qp_table qp_table; - struct mthca_av_table av_table; - struct mthca_mcg_table mcg_table; - struct mthca_catas_err catas_err; - struct mthca_uar driver_uar; - struct mthca_db_table *db_tab; - struct mthca_pd driver_pd; - struct mthca_mr driver_mr; - - struct ib_mad_agent *send_agent[MTHCA_MAX_PORTS][2]; - struct ib_ah *sm_ah[MTHCA_MAX_PORTS]; - spinlock_t sm_lock; - u32 state; -}; - -// mthca_dev states -enum { - MTHCA_DEV_UNINITIALIZED, - MTHCA_DEV_INITIALIZED, - MTHCA_DEV_FAILED -}; - -enum { - MTHCA_CQ_ENTRY_SIZE = 0x20 -}; - - - -#define MTHCA_GET(dest, source, offset) \ - { \ - void *__p = (char *) (source) + (offset); \ - void *__q = &(dest); \ - switch (sizeof (dest)) { \ - case 1: *(u8 *)__q = *(u8 *) __p; break; \ - case 2: *(u16 *)__q = (u16)cl_ntoh16(*(u16 *)__p); break; \ - case 4: *(u32 *)__q = (u32)cl_ntoh32(*(u32 *)__p); break; \ - case 8: *(u64 *)__q = (u64)cl_ntoh64(*(u64 *)__p); break; \ - default: ASSERT(0); \ - } \ - } - - -#define MTHCA_PUT(dest, source, offset) \ - { \ - void *__d = ((char *) (dest) + (offset)); \ - switch (sizeof(source)) { \ - case 1: *(u8 *) __d = (u8)(source); break; \ - case 2: *(__be16 *) __d = cl_hton16((u16)source); break; \ - case 4: *(__be32 *) __d = cl_hton32((u32)source); break; \ - case 8: *(__be64 *) __d = cl_hton64((u64)source); break; \ - default: ASSERT(0); \ - } \ - } - -NTSTATUS mthca_reset(struct mthca_dev *mdev); - -u32 mthca_alloc(struct mthca_alloc *alloc); -void mthca_free(struct mthca_alloc *alloc, u32 obj); -int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask, - u32 reserved); -void mthca_alloc_cleanup(struct mthca_alloc *alloc); -void *mthca_array_get(struct mthca_array *array, int index); -int mthca_array_set(struct mthca_array *array, int index, void *value); -void mthca_array_clear(struct mthca_array *array, int index); -int mthca_array_init(struct mthca_array *array, int nent); -void mthca_array_cleanup(struct mthca_array *array, int nent); -int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct, - union mthca_buf *buf, int *is_direct, struct mthca_pd *pd, - int hca_write, struct mthca_mr *mr); -void mthca_buf_free(struct mthca_dev *dev, int size, union mthca_buf *buf, - int is_direct, struct mthca_mr *mr); - -int mthca_init_uar_table(struct mthca_dev *dev); -int mthca_init_pd_table(struct mthca_dev *dev); -int mthca_init_mr_table(struct mthca_dev *dev); -int mthca_init_eq_table(struct mthca_dev *dev); -int mthca_init_cq_table(struct mthca_dev *dev); -int mthca_init_srq_table(struct mthca_dev *dev); -int mthca_init_qp_table(struct mthca_dev *dev); -int mthca_init_av_table(struct mthca_dev *dev); -int mthca_init_mcg_table(struct mthca_dev *dev); - -void mthca_cleanup_uar_table(struct mthca_dev *dev); -void mthca_cleanup_pd_table(struct mthca_dev *dev); -void mthca_cleanup_mr_table(struct mthca_dev *dev); -void mthca_cleanup_eq_table(struct mthca_dev *dev); -void mthca_cleanup_cq_table(struct mthca_dev *dev); -void mthca_cleanup_srq_table(struct mthca_dev *dev); -void mthca_cleanup_qp_table(struct mthca_dev *dev); -void mthca_cleanup_av_table(struct mthca_dev *dev); -void mthca_cleanup_mcg_table(struct mthca_dev *dev); - -int mthca_register_device(struct mthca_dev *dev); -void mthca_unregister_device(struct mthca_dev *dev); - -void mthca_start_catas_poll(struct mthca_dev *dev); -void mthca_stop_catas_poll(struct mthca_dev *dev); - -int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar); -void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar); - -int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd); -void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd); - -struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size); -void mthca_free_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt); -int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt, - int start_index, u64 *buffer_list, int list_len); -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift, - u64 iova, u64 total_size, mthca_mpt_access_t access, struct mthca_mr *mr); -int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd, - mthca_mpt_access_t access, struct mthca_mr *mr); -int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd, - u64 *buffer_list, int buffer_size_shift, - int list_len, u64 iova, u64 total_size, - mthca_mpt_access_t access, struct mthca_mr *mr); -void mthca_free_mr(struct mthca_dev *dev, struct mthca_mr *mr); - -int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd, - mthca_mpt_access_t access, struct mthca_fmr *fmr); -int mthca_tavor_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, - int list_len, u64 iova); -void mthca_tavor_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr); -int mthca_arbel_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, - int list_len, u64 iova); -void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr); -int mthca_free_fmr(struct mthca_dev *dev, struct mthca_fmr *fmr); - -int mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt); -void mthca_unmap_eq_icm(struct mthca_dev *dev); - -int mthca_poll_cq(struct ib_cq *ibcq, int num_entries, - struct _ib_wc *entry); -int mthca_tavor_arm_cq(struct ib_cq *cq, enum ib_cq_notify notify); -int mthca_arbel_arm_cq(struct ib_cq *cq, enum ib_cq_notify notify); -int mthca_init_cq(struct mthca_dev *dev, int nent, - struct mthca_ucontext *ctx, u32 pdn, - struct mthca_cq *cq); -void mthca_free_cq(struct mthca_dev *dev, - struct mthca_cq *cq); -void mthca_cq_completion(struct mthca_dev *dev, u32 cqn); -void mthca_cq_event(struct mthca_dev *dev, u32 cqn, - enum ib_event_type event_type); -void mthca_cq_clean(struct mthca_dev *dev, u32 cqn, u32 qpn, - struct mthca_srq *srq); - -int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd, - ib_srq_attr_t *attr, struct mthca_srq *srq); -void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq); -int mthca_modify_srq(struct ib_srq *ibsrq, ib_srq_attr_t *attr, - ib_srq_attr_mask_t attr_mask); -void mthca_srq_event(struct mthca_dev *dev, u32 srqn, - enum ib_event_type event_type, u8 vendor_code); -void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr); -int mthca_tavor_post_srq_recv(struct ib_srq *srq, struct _ib_recv_wr *wr, - struct _ib_recv_wr **bad_wr); -int mthca_arbel_post_srq_recv(struct ib_srq *srq, struct _ib_recv_wr *wr, - struct _ib_recv_wr **bad_wr); - -void mthca_qp_event(struct mthca_dev *dev, u32 qpn, - enum ib_event_type event_type, u8 vendor_code); -int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask); -int mthca_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask, - struct ib_qp_init_attr *qp_init_attr); -int mthca_tavor_post_send(struct ib_qp *ibqp, struct _ib_send_wr *wr, - struct _ib_send_wr **bad_wr); -int mthca_tavor_post_recv(struct ib_qp *ibqp, struct _ib_recv_wr *wr, - struct _ib_recv_wr **bad_wr); -int mthca_arbel_post_send(struct ib_qp *ibqp, struct _ib_send_wr *wr, - struct _ib_send_wr **bad_wr); -int mthca_arbel_post_recv(struct ib_qp *ibqp, struct _ib_recv_wr *wr, - struct _ib_recv_wr **bad_wr); -void mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send, - int index, int *dbd, __be32 *new_wqe); -int mthca_alloc_qp(struct mthca_dev *dev, - struct mthca_pd *pd, - struct mthca_cq *send_cq, - struct mthca_cq *recv_cq, - enum ib_qp_type_t type, - enum ib_sig_type send_policy, - struct ib_qp_cap *cap, - struct mthca_qp *qp); -int mthca_alloc_sqp(struct mthca_dev *dev, - struct mthca_pd *pd, - struct mthca_cq *send_cq, - struct mthca_cq *recv_cq, - enum ib_sig_type send_policy, - struct ib_qp_cap *cap, - int qpn, - int port, - struct mthca_sqp *sqp); -void mthca_free_qp(struct mthca_dev *dev, struct mthca_qp *qp); -int mthca_create_ah(struct mthca_dev *dev, - struct mthca_pd *pd, - struct ib_ah_attr *ah_attr, - struct mthca_ah *ah); -int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah); -int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, - struct ib_ud_header *header); - -int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); -int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); - -int mthca_process_mad(struct ib_device *ibdev, - int mad_flags, - u8 port_num, - struct _ib_wc *in_wc, - struct _ib_grh *in_grh, - struct ib_mad *in_mad, - struct ib_mad *out_mad); - -static inline struct mthca_dev *to_mdev(struct ib_device *ibdev) -{ - return container_of(ibdev, struct mthca_dev, ib_dev); -} - -static inline int mthca_is_memfree(struct mthca_dev *dev) -{ - return dev->mthca_flags & MTHCA_FLAG_MEMFREE; -} - -VOID -WriteEventLogEntry( - PVOID pi_pIoObject, - ULONG pi_ErrorCode, - ULONG pi_UniqueErrorCode, - ULONG pi_FinalStatus, - ULONG pi_nDataItems, - ... - ); - -VOID -WriteEventLogEntryStr( - PVOID pi_pIoObject, - ULONG pi_ErrorCode, - ULONG pi_UniqueErrorCode, - ULONG pi_FinalStatus, - PWCHAR pi_InsertionStr, - ULONG pi_nDataItems, - ... - ); - - -static inline int mthca_is_livefish(struct mthca_dev *mdev) -{ - if(mdev == NULL) { - return TRUE; - } - 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); - -int mthca_max_srq_sge(struct mthca_dev *dev); - - -#endif /* MTHCA_DEV_H */ +/* + * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2005 Cisco Systems. All rights reserved. + * Copyright (c) 2005 Mellanox Technologies. All rights reserved. + * Copyright (c) 2004 Voltaire, Inc. All rights reserved. + * Copyright (c) 2006 SilverStorm Technologies, Inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * $Id$ + */ + +#ifndef MTHCA_DEV_H +#define MTHCA_DEV_H + +#include "hca_driver.h" +#include "mthca_log.h" +#include "mthca_provider.h" +#include "mthca_doorbell.h" + +// must be synchronized with MTHCA.INF +#define DRV_NAME "mthca" +#define PFX DRV_NAME ": " +//TODO +#define DRV_VERSION "1.0.0000.566" +#define DRV_RELDATE "12/21/2006" + +#define HZ 1000000 /* 1 sec in usecs */ + +enum { + MTHCA_FLAG_DDR_HIDDEN = 1 << 1, + MTHCA_FLAG_SRQ = 1 << 2, + MTHCA_FLAG_MSI = 1 << 3, + MTHCA_FLAG_MSI_X = 1 << 4, + MTHCA_FLAG_NO_LAM = 1 << 5, + MTHCA_FLAG_FMR = 1 << 6, + MTHCA_FLAG_MEMFREE = 1 << 7, + MTHCA_FLAG_PCIE = 1 << 8, + MTHCA_FLAG_SINAI_OPT = 1 << 9, +}; + +enum { + MTHCA_MAX_PORTS = 2 +}; + +enum { + MTHCA_BOARD_ID_LEN = 64 +}; + +enum { + MTHCA_EQ_CONTEXT_SIZE = 0x40, + MTHCA_CQ_CONTEXT_SIZE = 0x40, + MTHCA_QP_CONTEXT_SIZE = 0x200, + MTHCA_RDB_ENTRY_SIZE = 0x20, + MTHCA_AV_SIZE = 0x20, + MTHCA_MGM_ENTRY_SIZE = 0x40, + + /* Arbel FW gives us these, but we need them for Tavor */ + MTHCA_MPT_ENTRY_SIZE = 0x40, + MTHCA_MTT_SEG_SIZE = 0x40, + + MTHCA_QP_PER_MGM = 4 * (MTHCA_MGM_ENTRY_SIZE / 16 - 2) +}; + +enum { + MTHCA_EQ_CMD, + MTHCA_EQ_ASYNC, + MTHCA_EQ_COMP, + MTHCA_NUM_EQ +}; + +enum { + MTHCA_BYTES_PER_ATOMIC_COMPL = 8 +}; + +enum mthca_wr_opcode{ + MTHCA_OPCODE_NOP = 0x00, + MTHCA_OPCODE_RDMA_WRITE = 0x08, + MTHCA_OPCODE_RDMA_WRITE_IMM = 0x09, + MTHCA_OPCODE_SEND = 0x0a, + MTHCA_OPCODE_SEND_IMM = 0x0b, + MTHCA_OPCODE_RDMA_READ = 0x10, + MTHCA_OPCODE_ATOMIC_CS = 0x11, + MTHCA_OPCODE_ATOMIC_FA = 0x12, + MTHCA_OPCODE_BIND_MW = 0x18, + MTHCA_OPCODE_INVALID = 0xff +}; + +struct mthca_cmd { + struct pci_pool *pool; + int use_events; + KMUTEX hcr_mutex; + KSEMAPHORE poll_sem; + KSEMAPHORE event_sem; + int max_cmds; + spinlock_t context_lock; + int free_head; + struct mthca_cmd_context *context; + u16 token_mask; +}; + +struct mthca_limits { + int num_ports; + int vl_cap; + int mtu_cap; + int gid_table_len; + int pkey_table_len; + int local_ca_ack_delay; + int num_uars; + int max_sg; + int num_qps; + int max_wqes; + int max_desc_sz; + int max_qp_init_rdma; + int reserved_qps; + int num_srqs; + int max_srq_wqes; + int max_srq_sge; + int reserved_srqs; + int num_eecs; + int reserved_eecs; + int num_cqs; + int max_cqes; + int reserved_cqs; + int num_eqs; + int reserved_eqs; + int num_mpts; + int num_mtt_segs; + int fmr_reserved_mtts; + int reserved_mtts; + int reserved_mrws; + int reserved_uars; + int num_mgms; + int num_amgms; + int reserved_mcgs; + int num_pds; + int reserved_pds; + u32 page_size_cap; + u32 flags; + u8 port_width_cap; + u64 num_avs; +}; + +struct mthca_alloc { + u32 last; + u32 top; + u32 max; + u32 mask; + spinlock_t lock; + unsigned long *table; +}; + +struct mthca_array { + struct { + void **page; + int used; + } *page_list; +}; + +struct mthca_uar_table { + struct mthca_alloc alloc; + u64 uarc_base; + int uarc_size; +}; + +struct mthca_pd_table { + struct mthca_alloc alloc; +}; + +struct mthca_buddy { + unsigned long **bits; + int max_order; + spinlock_t lock; +}; + +struct mthca_mr_table { + struct mthca_alloc mpt_alloc; + struct mthca_buddy mtt_buddy; + struct mthca_buddy *fmr_mtt_buddy; + u64 mtt_base; + u64 mpt_base; + struct mthca_icm_table *mtt_table; + struct mthca_icm_table *mpt_table; + struct { + void __iomem *mpt_base; + SIZE_T mpt_base_size; + void __iomem *mtt_base; + SIZE_T mtt_base_size; + struct mthca_buddy mtt_buddy; + } tavor_fmr; +}; + +struct mthca_eq_table { + struct mthca_alloc alloc; + void __iomem *clr_int; + u32 clr_mask; + u32 arm_mask; + struct mthca_eq eq[MTHCA_NUM_EQ]; + u64 icm_virt; + struct scatterlist sg; + int have_irq; + u8 inta_pin; + KLOCK_QUEUE_HANDLE lockh; +#if 1//WORKAROUND_POLL_EQ + KEVENT thread_start_event; + KEVENT thread_stop_event; + BOOLEAN bTerminated; + PVOID threadObject; +#endif +}; + +struct mthca_cq_table { + struct mthca_alloc alloc; + spinlock_t lock; + struct mthca_array cq; + struct mthca_icm_table *table; +}; + +struct mthca_srq_table { + struct mthca_alloc alloc; + spinlock_t lock; + struct mthca_array srq; + struct mthca_icm_table *table; +}; + +struct mthca_qp_table { + struct mthca_alloc alloc; + u32 rdb_base; + int rdb_shift; + int sqp_start; + spinlock_t lock; + struct mthca_array qp; + struct mthca_icm_table *qp_table; + struct mthca_icm_table *eqp_table; + struct mthca_icm_table *rdb_table; +}; + +struct mthca_av_table { + struct pci_pool *pool; + int num_ddr_avs; + u64 ddr_av_base; + void __iomem *av_map; + SIZE_T av_map_size; + struct mthca_alloc alloc; +}; + +struct mthca_mcg_table { + KMUTEX mutex; + struct mthca_alloc alloc; + struct mthca_icm_table *table; +}; + +struct mthca_catas_err { + u64 addr; + u32 __iomem *map; + SIZE_T map_size; + unsigned long stop; + u32 size; + KTIMER timer; + KDPC timer_dpc; + LARGE_INTEGER interval; +}; + +struct mthca_dev { + struct ib_device ib_dev; + hca_dev_ext_t *ext; + uplink_info_t uplink_info; + volatile long dpc_lock; + + int hca_type; + unsigned long mthca_flags; + unsigned long device_cap_flags; + + u32 rev_id; + char board_id[MTHCA_BOARD_ID_LEN]; + + /* firmware info */ + u64 fw_ver; + union { + struct { + u64 fw_start; + u64 fw_end; + } tavor; + struct { + u64 clr_int_base; + u64 eq_arm_base; + u64 eq_set_ci_base; + struct mthca_icm *fw_icm; + struct mthca_icm *aux_icm; + u16 fw_pages; + } arbel; + } fw; + + u64 ddr_start; + u64 ddr_end; + + MTHCA_DECLARE_DOORBELL_LOCK(doorbell_lock) + KMUTEX cap_mask_mutex; + + u8 __iomem *hcr; + SIZE_T hcr_size; + u8 __iomem *kar; + SIZE_T kar_size; + u8 __iomem *clr_base; + SIZE_T clr_base_size; + union { + struct { + void __iomem *ecr_base; + SIZE_T ecr_base_size; + } tavor; + struct { + void __iomem *eq_arm; + SIZE_T eq_arm_size; + void __iomem *eq_set_ci_base; + SIZE_T eq_set_ci_base_size; + } arbel; + } eq_regs; + + struct mthca_cmd cmd; + struct mthca_limits limits; + + struct mthca_uar_table uar_table; + struct mthca_pd_table pd_table; + struct mthca_mr_table mr_table; + struct mthca_eq_table eq_table; + struct mthca_cq_table cq_table; + struct mthca_srq_table srq_table; + struct mthca_qp_table qp_table; + struct mthca_av_table av_table; + struct mthca_mcg_table mcg_table; + struct mthca_catas_err catas_err; + struct mthca_uar driver_uar; + struct mthca_db_table *db_tab; + struct mthca_pd driver_pd; + struct mthca_mr driver_mr; + + struct ib_mad_agent *send_agent[MTHCA_MAX_PORTS][2]; + struct ib_ah *sm_ah[MTHCA_MAX_PORTS]; + spinlock_t sm_lock; + u32 state; +}; + +// mthca_dev states +enum { + MTHCA_DEV_UNINITIALIZED, + MTHCA_DEV_INITIALIZED, + MTHCA_DEV_FAILED +}; + +enum { + MTHCA_CQ_ENTRY_SIZE = 0x20 +}; + + + +#define MTHCA_GET(dest, source, offset) \ + { \ + void *__p = (char *) (source) + (offset); \ + void *__q = &(dest); \ + switch (sizeof (dest)) { \ + case 1: *(u8 *)__q = *(u8 *) __p; break; \ + case 2: *(u16 *)__q = (u16)cl_ntoh16(*(u16 *)__p); break; \ + case 4: *(u32 *)__q = (u32)cl_ntoh32(*(u32 *)__p); break; \ + case 8: *(u64 *)__q = (u64)cl_ntoh64(*(u64 *)__p); break; \ + default: ASSERT(0); \ + } \ + } + + +#define MTHCA_PUT(dest, source, offset) \ + { \ + void *__d = ((char *) (dest) + (offset)); \ + switch (sizeof(source)) { \ + case 1: *(u8 *) __d = (u8)(source); break; \ + case 2: *(__be16 *) __d = cl_hton16((u16)source); break; \ + case 4: *(__be32 *) __d = cl_hton32((u32)source); break; \ + case 8: *(__be64 *) __d = cl_hton64((u64)source); break; \ + default: ASSERT(0); \ + } \ + } + +NTSTATUS mthca_reset(struct mthca_dev *mdev); + +u32 mthca_alloc(struct mthca_alloc *alloc); +void mthca_free(struct mthca_alloc *alloc, u32 obj); +int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask, + u32 reserved); +void mthca_alloc_cleanup(struct mthca_alloc *alloc); +void *mthca_array_get(struct mthca_array *array, int index); +int mthca_array_set(struct mthca_array *array, int index, void *value); +void mthca_array_clear(struct mthca_array *array, int index); +int mthca_array_init(struct mthca_array *array, int nent); +void mthca_array_cleanup(struct mthca_array *array, int nent); +int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct, + union mthca_buf *buf, int *is_direct, struct mthca_pd *pd, + int hca_write, struct mthca_mr *mr); +void mthca_buf_free(struct mthca_dev *dev, int size, union mthca_buf *buf, + int is_direct, struct mthca_mr *mr); + +int mthca_init_uar_table(struct mthca_dev *dev); +int mthca_init_pd_table(struct mthca_dev *dev); +int mthca_init_mr_table(struct mthca_dev *dev); +int mthca_init_eq_table(struct mthca_dev *dev); +int mthca_init_cq_table(struct mthca_dev *dev); +int mthca_init_srq_table(struct mthca_dev *dev); +int mthca_init_qp_table(struct mthca_dev *dev); +int mthca_init_av_table(struct mthca_dev *dev); +int mthca_init_mcg_table(struct mthca_dev *dev); + +void mthca_cleanup_uar_table(struct mthca_dev *dev); +void mthca_cleanup_pd_table(struct mthca_dev *dev); +void mthca_cleanup_mr_table(struct mthca_dev *dev); +void mthca_cleanup_eq_table(struct mthca_dev *dev); +void mthca_cleanup_cq_table(struct mthca_dev *dev); +void mthca_cleanup_srq_table(struct mthca_dev *dev); +void mthca_cleanup_qp_table(struct mthca_dev *dev); +void mthca_cleanup_av_table(struct mthca_dev *dev); +void mthca_cleanup_mcg_table(struct mthca_dev *dev); + +int mthca_register_device(struct mthca_dev *dev); +void mthca_unregister_device(struct mthca_dev *dev); + +void mthca_start_catas_poll(struct mthca_dev *dev); +void mthca_stop_catas_poll(struct mthca_dev *dev); + +int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar); +void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar); + +int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd); +void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd); + +struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size); +void mthca_free_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt); +int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt, + int start_index, u64 *buffer_list, int list_len); +int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift, + u64 iova, u64 total_size, mthca_mpt_access_t access, struct mthca_mr *mr); +int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd, + mthca_mpt_access_t access, struct mthca_mr *mr); +int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd, + u64 *buffer_list, int buffer_size_shift, + int list_len, u64 iova, u64 total_size, + mthca_mpt_access_t access, struct mthca_mr *mr); +void mthca_free_mr(struct mthca_dev *dev, struct mthca_mr *mr); + +int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd, + mthca_mpt_access_t access, struct mthca_fmr *fmr); +int mthca_tavor_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, + int list_len, u64 iova); +void mthca_tavor_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr); +int mthca_arbel_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, + int list_len, u64 iova); +void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr); +int mthca_free_fmr(struct mthca_dev *dev, struct mthca_fmr *fmr); + +int mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt); +void mthca_unmap_eq_icm(struct mthca_dev *dev); + +int mthca_poll_cq(struct ib_cq *ibcq, int num_entries, + struct _ib_wc *entry); +int mthca_tavor_arm_cq(struct ib_cq *cq, enum ib_cq_notify notify); +int mthca_arbel_arm_cq(struct ib_cq *cq, enum ib_cq_notify notify); +int mthca_init_cq(struct mthca_dev *dev, int nent, + struct mthca_ucontext *ctx, u32 pdn, + struct mthca_cq *cq); +void mthca_free_cq(struct mthca_dev *dev, + struct mthca_cq *cq); +void mthca_cq_completion(struct mthca_dev *dev, u32 cqn); +void mthca_cq_event(struct mthca_dev *dev, u32 cqn, + enum ib_event_type event_type); +void mthca_cq_clean(struct mthca_dev *dev, u32 cqn, u32 qpn, + struct mthca_srq *srq); + +int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd, + ib_srq_attr_t *attr, struct mthca_srq *srq); +void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq); +int mthca_modify_srq(struct ib_srq *ibsrq, ib_srq_attr_t *attr, + ib_srq_attr_mask_t attr_mask); +void mthca_srq_event(struct mthca_dev *dev, u32 srqn, + enum ib_event_type event_type, u8 vendor_code); +void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr); +int mthca_tavor_post_srq_recv(struct ib_srq *srq, struct _ib_recv_wr *wr, + struct _ib_recv_wr **bad_wr); +int mthca_arbel_post_srq_recv(struct ib_srq *srq, struct _ib_recv_wr *wr, + struct _ib_recv_wr **bad_wr); + +void mthca_qp_event(struct mthca_dev *dev, u32 qpn, + enum ib_event_type event_type, u8 vendor_code); +int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask); +int mthca_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask, + struct ib_qp_init_attr *qp_init_attr); +int mthca_tavor_post_send(struct ib_qp *ibqp, struct _ib_send_wr *wr, + struct _ib_send_wr **bad_wr); +int mthca_tavor_post_recv(struct ib_qp *ibqp, struct _ib_recv_wr *wr, + struct _ib_recv_wr **bad_wr); +int mthca_arbel_post_send(struct ib_qp *ibqp, struct _ib_send_wr *wr, + struct _ib_send_wr **bad_wr); +int mthca_arbel_post_recv(struct ib_qp *ibqp, struct _ib_recv_wr *wr, + struct _ib_recv_wr **bad_wr); +void mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send, + int index, int *dbd, __be32 *new_wqe); +int mthca_alloc_qp(struct mthca_dev *dev, + struct mthca_pd *pd, + struct mthca_cq *send_cq, + struct mthca_cq *recv_cq, + enum ib_qp_type_t type, + enum ib_sig_type send_policy, + struct ib_qp_cap *cap, + struct mthca_qp *qp); +int mthca_alloc_sqp(struct mthca_dev *dev, + struct mthca_pd *pd, + struct mthca_cq *send_cq, + struct mthca_cq *recv_cq, + enum ib_sig_type send_policy, + struct ib_qp_cap *cap, + int qpn, + int port, + struct mthca_sqp *sqp); +void mthca_free_qp(struct mthca_dev *dev, struct mthca_qp *qp); +int mthca_create_ah(struct mthca_dev *dev, + struct mthca_pd *pd, + struct ib_ah_attr *ah_attr, + struct mthca_ah *ah); +int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah); +int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, + struct ib_ud_header *header); + +int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); +int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); + +int mthca_process_mad(struct ib_device *ibdev, + int mad_flags, + u8 port_num, + struct _ib_wc *in_wc, + struct _ib_grh *in_grh, + struct ib_mad *in_mad, + struct ib_mad *out_mad); + +static inline struct mthca_dev *to_mdev(struct ib_device *ibdev) +{ + return container_of(ibdev, struct mthca_dev, ib_dev); +} + +static inline int mthca_is_memfree(struct mthca_dev *dev) +{ + return dev->mthca_flags & MTHCA_FLAG_MEMFREE; +} + +VOID +WriteEventLogEntry( + PVOID pi_pIoObject, + ULONG pi_ErrorCode, + ULONG pi_UniqueErrorCode, + ULONG pi_FinalStatus, + ULONG pi_nDataItems, + ... + ); + +VOID +WriteEventLogEntryStr( + PVOID pi_pIoObject, + ULONG pi_ErrorCode, + ULONG pi_UniqueErrorCode, + ULONG pi_FinalStatus, + PWCHAR pi_InsertionStr, + ULONG pi_nDataItems, + ... + ); + +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); + +int mthca_max_srq_sge(struct mthca_dev *dev); + + +#endif /* MTHCA_DEV_H */ diff --git a/trunk/hw/mthca/kernel/mthca_main.c b/trunk/hw/mthca/kernel/mthca_main.c index 6b41f25f..85012dcb 100644 --- a/trunk/hw/mthca/kernel/mthca_main.c +++ b/trunk/hw/mthca/kernel/mthca_main.c @@ -69,8 +69,7 @@ enum __hca_type { TAVOR, /* MT23108 */ ARBEL_COMPAT, /* MT25208 in Tavor compat mode */ ARBEL_NATIVE, /* MT25218 with extended features */ - SINAI, /* MT25204 */ - LIVEFISH /* a burning device */ + SINAI /* MT25204 */ }; #define MTHCA_FW_VER(major, minor, subminor) \ @@ -85,8 +84,7 @@ static struct { { MTHCA_FW_VER(3, 3, 2), MTHCA_FW_VER(3, 5, 0), 0, 0 }, /* TAVOR */ { MTHCA_FW_VER(4, 7, 0), MTHCA_FW_VER(4, 8, 200), 0, 1 }, /* ARBEL_COMPAT */ { MTHCA_FW_VER(5, 1, 0), MTHCA_FW_VER(5, 3, 0), 1, 1 }, /* ARBEL_NATIVE */ - { MTHCA_FW_VER(1, 0, 800), MTHCA_FW_VER(1, 2, 0), 1, 1 }, /* SINAI */ - { MTHCA_FW_VER(0, 0, 0), MTHCA_FW_VER(0, 0, 0), 0, 0 } /* LIVEFISH */ + { MTHCA_FW_VER(1, 0, 800), MTHCA_FW_VER(1, 2, 0), 1, 1 } /* SINAI */ }; @@ -108,15 +106,6 @@ 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)) @@ -967,7 +956,6 @@ NTSTATUS mthca_init_one(hca_dev_ext_t *ext) InitializeListHead(&ext->hca.hob.event_list); KeInitializeSpinLock(&ext->hca.hob.event_list_lock); -run_as_livefish: /* allocate mdev structure */ mdev = kzalloc(sizeof *mdev, GFP_KERNEL); if (!mdev) { @@ -982,10 +970,6 @@ run_as_livefish: 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) @@ -1042,7 +1026,6 @@ run_as_livefish: goto err_cleanup; } - done: ext->hca.mdev = mdev; mdev->state = MTHCA_DEV_INITIALIZED; return 0; @@ -1071,20 +1054,6 @@ err_cmd: err_free_dev: kfree(mdev); - /* we failed device initialization - try to simulate "livefish" device to facilitate using FW burning tools */ - { - USHORT dev_id = ext->hcaConfig.DeviceID; - - if (dev_id == PCI_DEVICE_ID_MELLANOX_ARBEL) - dev_id = PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT; - p_id = mthca_find_pci_dev( (unsigned)ext->hcaConfig.VendorID, dev_id + 1 ); - if (p_id == NULL) { - status = STATUS_NO_SUCH_DEVICE; - goto end; - } - goto run_as_livefish; - } - end: return status; } @@ -1098,8 +1067,6 @@ void mthca_remove_one(hca_dev_ext_t *ext) ext->hca.mdev = NULL; if (mdev) { mdev->state = MTHCA_DEV_UNINITIALIZED; - if (mthca_is_livefish(mdev)) - goto done; mthca_unregister_device(mdev); for (p = 1; p <= mdev->limits.num_ports; ++p) @@ -1120,7 +1087,6 @@ 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); } } diff --git a/trunk/hw/mthca/kernel/mthca_provider.c b/trunk/hw/mthca/kernel/mthca_provider.c index 7332bf92..cb0a01ae 100644 --- a/trunk/hw/mthca/kernel/mthca_provider.c +++ b/trunk/hw/mthca/kernel/mthca_provider.c @@ -69,15 +69,6 @@ int mthca_query_device(struct ib_device *ibdev, RtlZeroMemory(props, sizeof *props); - if (mthca_is_livefish(mdev)) { - props->max_pd = 1; - if ( !mdev || !mdev->ext ) - return err; - 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) @@ -354,9 +345,6 @@ struct ib_ucontext *mthca_alloc_ucontext(struct ib_device *ibdev, goto err_nomem; } - if (mthca_is_livefish(to_mdev(ibdev))) - goto done; - err = mthca_uar_alloc(to_mdev(ibdev), &context->uar); if (err) goto err_uar_alloc; @@ -399,7 +387,6 @@ 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; @@ -428,17 +415,14 @@ err_nomem: int mthca_dealloc_ucontext(struct ib_ucontext *context) { - struct mthca_ucontext *mucontext = to_mucontext(context); + 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); + 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; @@ -466,15 +450,11 @@ 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; @@ -497,12 +477,7 @@ 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)); - -done: kfree(pd); return 0; } diff --git a/trunk/hw/mthca/user/mlnx_uvp.c b/trunk/hw/mthca/user/mlnx_uvp.c index 2e36bb62..c2fcba8f 100644 --- a/trunk/hw/mthca/user/mlnx_uvp.c +++ b/trunk/hw/mthca/user/mlnx_uvp.c @@ -1,238 +1,212 @@ -/* - * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. - * - * This software is available to you under a choice of one of two - * licenses. You may choose to be licensed under the terms of the GNU - * General Public License (GPL) Version 2, available from the file - * COPYING in the main directory of this source tree, or the - * OpenIB.org BSD license below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Id$ - */ - -#include "mt_l2w.h" -#include "mlnx_uvp.h" - -#if defined(EVENT_TRACING) -#include "mlnx_uvp.tmh" -#endif - -#include "mx_abi.h" - -size_t g_page_size = 0; - -#ifndef PCI_VENDOR_ID_MELLANOX -#define PCI_VENDOR_ID_MELLANOX 0x15b3 -#endif - -#ifndef PCI_DEVICE_ID_MELLANOX_TAVOR -#define PCI_DEVICE_ID_MELLANOX_TAVOR 0x5a44 -#endif - -#ifndef PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT -#define PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT 0x6278 -#endif - -#ifndef PCI_DEVICE_ID_MELLANOX_ARBEL -#define PCI_DEVICE_ID_MELLANOX_ARBEL 0x6282 -#endif - -#ifndef PCI_DEVICE_ID_MELLANOX_SINAI_OLD -#define PCI_DEVICE_ID_MELLANOX_SINAI_OLD 0x5e8c -#endif - -#ifndef PCI_DEVICE_ID_MELLANOX_SINAI -#define PCI_DEVICE_ID_MELLANOX_SINAI 0x6274 -#endif - -#ifndef PCI_VENDOR_ID_TOPSPIN -#define PCI_VENDOR_ID_TOPSPIN 0x1867 -#endif - -/* 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 } - -static struct pci_device_id { - unsigned vendor; - unsigned device; - enum mthca_hca_type type; -} mthca_pci_table[] = { - HCA( MELLANOX, TAVOR, TAVOR), - HCA( MELLANOX, ARBEL_COMPAT, TAVOR), - HCA( MELLANOX, ARBEL, ARBEL), - HCA( MELLANOX, SINAI_OLD, ARBEL), - HCA( MELLANOX, SINAI, ARBEL), - HCA( TOPSPIN, TAVOR, TAVOR), - HCA( TOPSPIN, ARBEL_COMPAT, TAVOR), - HCA( TOPSPIN, ARBEL, ARBEL), - HCA( TOPSPIN, SINAI_OLD, ARBEL), - HCA( TOPSPIN, SINAI, ARBEL), - // 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 = { - NULL, // mthca_query_device, - NULL, // mthca_query_port, - mthca_alloc_pd, - mthca_free_pd, - NULL, // mthca_reg_mr, - NULL, // mthca_dereg_mr, - mthca_create_cq_pre, - mthca_create_cq_post, - mthca_poll_cq, - mthca_poll_cq_list, - NULL, /* req_notify_cq */ - mthca_destroy_cq, - NULL, // mthca_create_srq, - NULL, // mthca_modify_srq, - NULL, // mthca_destroy_srq, - NULL, /* post_srq_recv */ - mthca_create_qp_pre, - mthca_create_qp_post, - mthca_modify_qp, - NULL, - NULL, /* post_send */ - NULL, /* post_recv */ - mthca_attach_mcast, - mthca_detach_mcast -}; - -struct ibv_context *mthca_alloc_context(struct ibv_get_context_resp *resp_p) -{ - struct mthca_context * context; - struct ibv_alloc_pd_resp pd_resp; - int i; - - /* allocate context */ - context = cl_zalloc(sizeof *context); - if (!context) - return NULL; - - /* find page size */ - if (!g_page_size) { - SYSTEM_INFO sys_info; - GetSystemInfo(&sys_info); - g_page_size = sys_info.dwPageSize; - } - - /* calculate device type */ - for (i = 0; i < sizeof mthca_pci_table / sizeof mthca_pci_table[0]; ++i) - if (resp_p->vend_id == mthca_pci_table[i].vendor && - resp_p->dev_id == mthca_pci_table[i].device) - goto found; - goto err_dev_type; - -found: - context->hca_type = mthca_pci_table[i].type; - context->uar = (void*)(UINT_PTR)resp_p->uar_addr; - context->num_qps = resp_p->qp_tab_size; - context->qp_table_shift = ffs(context->num_qps) - 1 - MTHCA_QP_TABLE_BITS; - context->qp_table_mask = (1 << context->qp_table_shift) - 1; - - if (mthca_is_memfree(&context->ibv_ctx)) { - context->db_tab = mthca_alloc_db_tab(resp_p->uarc_size); - if (!context->db_tab) - goto err_alloc_db_tab; - } else - context->db_tab = NULL; - - context->qp_table_mutex = CreateMutex( NULL, FALSE, NULL ); - if (!context->qp_table_mutex) - goto err_mutex; - for (i = 0; i < MTHCA_QP_TABLE_SIZE; ++i) - context->qp_table[i].refcnt = 0; - - cl_spinlock_construct(&context->uar_lock); - if (cl_spinlock_init(&context->uar_lock)) - goto err_spinlock; - - pd_resp.pd_handle = resp_p->pd_handle; - pd_resp.pdn = resp_p->pdn; - context->pd = mthca_alloc_pd(&context->ibv_ctx, &pd_resp); - if (!context->pd) - goto err_unmap; - - context->ibv_ctx.ops = mthca_ctx_ops; - - if (mthca_is_memfree(&context->ibv_ctx)) { - context->ibv_ctx.ops.req_notify_cq = mthca_arbel_arm_cq; - context->ibv_ctx.ops.post_send = mthca_arbel_post_send; - context->ibv_ctx.ops.post_recv = mthca_arbel_post_recv; - context->ibv_ctx.ops.post_srq_recv = mthca_arbel_post_srq_recv; - } else { - context->ibv_ctx.ops.req_notify_cq = mthca_tavor_arm_cq; - context->ibv_ctx.ops.post_send = mthca_tavor_post_send; - context->ibv_ctx.ops.post_recv = mthca_tavor_post_recv; - context->ibv_ctx.ops.post_srq_recv = mthca_tavor_post_srq_recv; - } - - return &context->ibv_ctx; - -err_unmap: -err_spinlock: -err_mutex: - mthca_free_db_tab(context->db_tab); - -err_alloc_db_tab: -err_dev_type: - cl_free(context); - return NULL; -} - -void mthca_free_context(struct ibv_context *ibctx) -{ - struct mthca_context *context = to_mctx(ibctx); - - cl_spinlock_destroy(&context->uar_lock); - mthca_free_pd(context->pd); - mthca_free_db_tab(context->db_tab); - cl_free(context); -} +/* + * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * $Id$ + */ + +#include "mt_l2w.h" +#include "mlnx_uvp.h" + +#if defined(EVENT_TRACING) +#include "mlnx_uvp.tmh" +#endif + +#include "mx_abi.h" + +size_t g_page_size = 0; + +#ifndef PCI_VENDOR_ID_MELLANOX +#define PCI_VENDOR_ID_MELLANOX 0x15b3 +#endif + +#ifndef PCI_DEVICE_ID_MELLANOX_TAVOR +#define PCI_DEVICE_ID_MELLANOX_TAVOR 0x5a44 +#endif + +#ifndef PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT +#define PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT 0x6278 +#endif + +#ifndef PCI_DEVICE_ID_MELLANOX_ARBEL +#define PCI_DEVICE_ID_MELLANOX_ARBEL 0x6282 +#endif + +#ifndef PCI_DEVICE_ID_MELLANOX_SINAI_OLD +#define PCI_DEVICE_ID_MELLANOX_SINAI_OLD 0x5e8c +#endif + +#ifndef PCI_DEVICE_ID_MELLANOX_SINAI +#define PCI_DEVICE_ID_MELLANOX_SINAI 0x6274 +#endif + +#ifndef PCI_VENDOR_ID_TOPSPIN +#define PCI_VENDOR_ID_TOPSPIN 0x1867 +#endif + + +#define HCA(v, d, t) \ + { PCI_VENDOR_ID_##v, PCI_DEVICE_ID_MELLANOX_##d, MTHCA_##t } + +static struct pci_device_id { + unsigned vendor; + unsigned device; + enum mthca_hca_type type; +} mthca_pci_table[] = { + HCA( MELLANOX, TAVOR, TAVOR), + HCA( MELLANOX, ARBEL_COMPAT, TAVOR), + HCA( MELLANOX, ARBEL, ARBEL), + HCA( MELLANOX, SINAI_OLD, ARBEL), + HCA( MELLANOX, SINAI, ARBEL), + HCA( TOPSPIN, TAVOR, TAVOR), + HCA( TOPSPIN, ARBEL_COMPAT, TAVOR), + HCA( TOPSPIN, ARBEL, ARBEL), + HCA( TOPSPIN, SINAI_OLD, ARBEL), + HCA( TOPSPIN, SINAI, ARBEL), +}; + +static struct ibv_context_ops mthca_ctx_ops = { + NULL, // mthca_query_device, + NULL, // mthca_query_port, + mthca_alloc_pd, + mthca_free_pd, + NULL, // mthca_reg_mr, + NULL, // mthca_dereg_mr, + mthca_create_cq_pre, + mthca_create_cq_post, + mthca_poll_cq, + mthca_poll_cq_list, + NULL, /* req_notify_cq */ + mthca_destroy_cq, + NULL, // mthca_create_srq, + NULL, // mthca_modify_srq, + NULL, // mthca_destroy_srq, + NULL, /* post_srq_recv */ + mthca_create_qp_pre, + mthca_create_qp_post, + mthca_modify_qp, + NULL, + NULL, /* post_send */ + NULL, /* post_recv */ + mthca_attach_mcast, + mthca_detach_mcast +}; + +struct ibv_context *mthca_alloc_context(struct ibv_get_context_resp *resp_p) +{ + struct mthca_context * context; + struct ibv_alloc_pd_resp pd_resp; + int i; + + /* allocate context */ + context = cl_zalloc(sizeof *context); + if (!context) + return NULL; + + /* find page size */ + if (!g_page_size) { + SYSTEM_INFO sys_info; + GetSystemInfo(&sys_info); + g_page_size = sys_info.dwPageSize; + } + + /* calculate device type */ + for (i = 0; i < sizeof mthca_pci_table / sizeof mthca_pci_table[0]; ++i) + if (resp_p->vend_id == mthca_pci_table[i].vendor && + resp_p->dev_id == mthca_pci_table[i].device) + goto found; + goto err_dev_type; + +found: + context->hca_type = mthca_pci_table[i].type; + context->uar = (void*)(UINT_PTR)resp_p->uar_addr; + context->num_qps = resp_p->qp_tab_size; + context->qp_table_shift = ffs(context->num_qps) - 1 - MTHCA_QP_TABLE_BITS; + context->qp_table_mask = (1 << context->qp_table_shift) - 1; + + if (mthca_is_memfree(&context->ibv_ctx)) { + context->db_tab = mthca_alloc_db_tab(resp_p->uarc_size); + if (!context->db_tab) + goto err_alloc_db_tab; + } else + context->db_tab = NULL; + + context->qp_table_mutex = CreateMutex( NULL, FALSE, NULL ); + if (!context->qp_table_mutex) + goto err_mutex; + for (i = 0; i < MTHCA_QP_TABLE_SIZE; ++i) + context->qp_table[i].refcnt = 0; + + cl_spinlock_construct(&context->uar_lock); + if (cl_spinlock_init(&context->uar_lock)) + goto err_spinlock; + + pd_resp.pd_handle = resp_p->pd_handle; + pd_resp.pdn = resp_p->pdn; + context->pd = mthca_alloc_pd(&context->ibv_ctx, &pd_resp); + if (!context->pd) + goto err_unmap; + + context->ibv_ctx.ops = mthca_ctx_ops; + + if (mthca_is_memfree(&context->ibv_ctx)) { + context->ibv_ctx.ops.req_notify_cq = mthca_arbel_arm_cq; + context->ibv_ctx.ops.post_send = mthca_arbel_post_send; + context->ibv_ctx.ops.post_recv = mthca_arbel_post_recv; + context->ibv_ctx.ops.post_srq_recv = mthca_arbel_post_srq_recv; + } else { + context->ibv_ctx.ops.req_notify_cq = mthca_tavor_arm_cq; + context->ibv_ctx.ops.post_send = mthca_tavor_post_send; + context->ibv_ctx.ops.post_recv = mthca_tavor_post_recv; + context->ibv_ctx.ops.post_srq_recv = mthca_tavor_post_srq_recv; + } + + return &context->ibv_ctx; + +err_unmap: +err_spinlock: +err_mutex: + mthca_free_db_tab(context->db_tab); + +err_alloc_db_tab: +err_dev_type: + cl_free(context); + return NULL; +} + +void mthca_free_context(struct ibv_context *ibctx) +{ + struct mthca_context *context = to_mctx(ibctx); + + cl_spinlock_destroy(&context->uar_lock); + mthca_free_pd(context->pd); + mthca_free_db_tab(context->db_tab); + cl_free(context); +} -- 2.46.0