From f66b367820760f67e53b133a048dd70e6bd8086f Mon Sep 17 00:00:00 2001 From: tzachid Date: Sun, 7 Sep 2008 15:00:12 +0000 Subject: [PATCH] [MLX4] fixed a bug in "livefish" mode. [mlnx: 3091] The bug was in returning wrong query_ca results, which caused crashes in some scenarios and incorrect work of applications.\ signed off by:leonid git-svn-id: svn://openib.tc.cornell.edu/gen1@1557 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- .../trunk/hw/mlx4/kernel/bus/net/main.c | 16 ++++- branches/WOF2-0/trunk/hw/mlx4/kernel/hca/ca.c | 11 +-- .../WOF2-0/trunk/hw/mlx4/kernel/hca/data.c | 67 ++++++++++--------- branches/WOF2-0/trunk/hw/mlx4/user/hca/mlx4.c | 13 ++-- 4 files changed, 64 insertions(+), 43 deletions(-) diff --git a/branches/WOF2-0/trunk/hw/mlx4/kernel/bus/net/main.c b/branches/WOF2-0/trunk/hw/mlx4/kernel/bus/net/main.c index 28ca2171..2c8554bd 100644 --- a/branches/WOF2-0/trunk/hw/mlx4/kernel/bus/net/main.c +++ b/branches/WOF2-0/trunk/hw/mlx4/kernel/bus/net/main.c @@ -148,6 +148,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) int i; int num_eth_ports = 0; enum mlx4_port_type port_type[MLX4_MAX_PORTS]; + struct mlx4_dev *mdev = dev; for (i = 0; i < MLX4_MAX_PORTS; i++) port_type[i] = g.mod_port_type[i]; @@ -244,8 +245,19 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) if (port_type[i-1] & dev_cap->supported_port_types[i]) dev->caps.port_type[i] = port_type[i-1]; else { - mlx4_err(dev, "Requested port type for port %d " - "not supported by HW\n", i); + MLX4_PRINT_EV(TRACE_LEVEL_ERROR ,MLX4_DBG_DRV , + ("Requested port type %#x for port %d is " + "not supported by HW. Supported %#x\n", + port_type[i-1], i, (int)dev_cap->supported_port_types[i])); + MLX4_PRINT_EV(TRACE_LEVEL_ERROR ,MLX4_DBG_DRV , + ("Ven %x Dev %d Fw %d.%d.%d, IsBurnDevice %s\n", + (unsigned)dev->pdev->ven_id, (unsigned)dev->pdev->dev_id, + (int) (dev->caps.fw_ver >> 32), + (int) (dev->caps.fw_ver >> 16) & 0xffff, + (int) (dev->caps.fw_ver & 0xffff), + mlx4_is_livefish(dev) ? "Y" : "N" + )); + return -ENODEV; } if (dev->caps.log_num_macs > dev_cap->log_max_macs[i]) { diff --git a/branches/WOF2-0/trunk/hw/mlx4/kernel/hca/ca.c b/branches/WOF2-0/trunk/hw/mlx4/kernel/hca/ca.c index 3230a621..18d5528b 100644 --- a/branches/WOF2-0/trunk/hw/mlx4/kernel/hca/ca.c +++ b/branches/WOF2-0/trunk/hw/mlx4/kernel/hca/ca.c @@ -172,8 +172,8 @@ mlnx_query_ca ( props.max_pd = 1; props.vendor_id = pdev->ven_id; props.vendor_part_id = pdev->dev_id; - status = IB_SUCCESS; - goto done; + num_ports = 0; + goto fill_the_rest; } // query the device @@ -195,6 +195,7 @@ mlnx_query_ca ( } // start calculation of ib_ca_attr_t full size +fill_the_rest: num_gids = 0; num_pkeys = 0; required_size = PTR_ALIGN(sizeof(ib_ca_attr_t)) + @@ -204,7 +205,7 @@ mlnx_query_ca ( PTR_ALIGN(sizeof(uplink_info_t)); /* uplink info */ // get port properties - for (port_num = 0; port_num <= (end_port(p_ibdev) - start_port(p_ibdev)); ++port_num) { + for (port_num = 0; port_num < num_ports; ++port_num) { // request err = p_ibdev->query_port(p_ibdev, (u8)(port_num + start_port(p_ibdev)), &hca_ports[port_num]); if (err) { @@ -321,6 +322,8 @@ mlnx_query_ca ( // !!! GID/PKEY tables must be queried before this call !!! from_hca_cap(p_ibdev, &props, hca_ports, p_ca_attr); + if ( hca_is_livefish(hca2fdo(p_hca)) ) + p_ca_attr->num_ports = 0; status = IB_SUCCESS; @@ -338,7 +341,7 @@ err_user_unsupported: if( status != IB_INSUFFICIENT_MEMORY && status != IB_SUCCESS ) HCA_PRINT(TRACE_LEVEL_ERROR, HCA_DBG_SHIM, ("completes with ERROR status %x\n", status)); -done: + HCA_EXIT(HCA_DBG_SHIM); return status; } diff --git a/branches/WOF2-0/trunk/hw/mlx4/kernel/hca/data.c b/branches/WOF2-0/trunk/hw/mlx4/kernel/hca/data.c index 19791df0..23f42800 100644 --- a/branches/WOF2-0/trunk/hw/mlx4/kernel/hca/data.c +++ b/branches/WOF2-0/trunk/hw/mlx4/kernel/hca/data.c @@ -320,39 +320,40 @@ from_hca_cap( ca_attr_p->num_page_sizes = 1; ca_attr_p->p_page_size[0] = PAGE_SIZE; // TBD: extract an array of page sizes from HCA cap - for (port_num = 0; port_num <= (end_port(ib_dev) - start_port(ib_dev)); ++port_num) - { - // Setup port pointers - ibal_port_p = &ca_attr_p->p_port_attr[port_num]; - mthca_port_p = &hca_ports[port_num]; - - // Port Cabapilities - cl_memclr(&ibal_port_p->cap, sizeof(ib_port_cap_t)); - from_port_cap(mthca_port_p->port_cap_flags, &ibal_port_p->cap); - - // Port Atributes - ibal_port_p->port_num = (u8)(port_num + start_port(ib_dev)); - ibal_port_p->port_guid = ibal_port_p->p_gid_table[0].unicast.interface_id; - ibal_port_p->lid = cl_ntoh16(mthca_port_p->lid); - ibal_port_p->lmc = mthca_port_p->lmc; - ibal_port_p->max_vls = mthca_port_p->max_vl_num; - ibal_port_p->sm_lid = cl_ntoh16(mthca_port_p->sm_lid); - ibal_port_p->sm_sl = mthca_port_p->sm_sl; - ibal_port_p->link_state = (mthca_port_p->state != 0) ? (uint8_t)mthca_port_p->state : IB_LINK_DOWN; - ibal_port_p->num_gids = (uint16_t)mthca_port_p->gid_tbl_len; - ibal_port_p->num_pkeys = mthca_port_p->pkey_tbl_len; - ibal_port_p->pkey_ctr = (uint16_t)mthca_port_p->bad_pkey_cntr; - ibal_port_p->qkey_ctr = (uint16_t)mthca_port_p->qkey_viol_cntr; - ibal_port_p->max_msg_size = mthca_port_p->max_msg_sz; - ibal_port_p->mtu = (uint8_t)mthca_port_p->max_mtu; - ibal_port_p->active_speed = mthca_port_p->active_speed; - ibal_port_p->phys_state = mthca_port_p->phys_state; - - ibal_port_p->subnet_timeout = mthca_port_p->subnet_timeout; - // ibal_port_p->local_ack_timeout = 3; // TBD: currently ~32 usec - HCA_PRINT(TRACE_LEVEL_VERBOSE, HCA_DBG_SHIM ,("Port %d port_guid 0x%I64x\n", - ibal_port_p->port_num, cl_ntoh64(ibal_port_p->port_guid))); - } + if ( hca_ports ) + for (port_num = 0; port_num <= (end_port(ib_dev) - start_port(ib_dev)); ++port_num) + { + // Setup port pointers + ibal_port_p = &ca_attr_p->p_port_attr[port_num]; + mthca_port_p = &hca_ports[port_num]; + + // Port Cabapilities + cl_memclr(&ibal_port_p->cap, sizeof(ib_port_cap_t)); + from_port_cap(mthca_port_p->port_cap_flags, &ibal_port_p->cap); + + // Port Atributes + ibal_port_p->port_num = (u8)(port_num + start_port(ib_dev)); + ibal_port_p->port_guid = ibal_port_p->p_gid_table[0].unicast.interface_id; + ibal_port_p->lid = cl_ntoh16(mthca_port_p->lid); + ibal_port_p->lmc = mthca_port_p->lmc; + ibal_port_p->max_vls = mthca_port_p->max_vl_num; + ibal_port_p->sm_lid = cl_ntoh16(mthca_port_p->sm_lid); + ibal_port_p->sm_sl = mthca_port_p->sm_sl; + ibal_port_p->link_state = (mthca_port_p->state != 0) ? (uint8_t)mthca_port_p->state : IB_LINK_DOWN; + ibal_port_p->num_gids = (uint16_t)mthca_port_p->gid_tbl_len; + ibal_port_p->num_pkeys = mthca_port_p->pkey_tbl_len; + ibal_port_p->pkey_ctr = (uint16_t)mthca_port_p->bad_pkey_cntr; + ibal_port_p->qkey_ctr = (uint16_t)mthca_port_p->qkey_viol_cntr; + ibal_port_p->max_msg_size = mthca_port_p->max_msg_sz; + ibal_port_p->mtu = (uint8_t)mthca_port_p->max_mtu; + ibal_port_p->active_speed = mthca_port_p->active_speed; + ibal_port_p->phys_state = mthca_port_p->phys_state; + + ibal_port_p->subnet_timeout = mthca_port_p->subnet_timeout; + // ibal_port_p->local_ack_timeout = 3; // TBD: currently ~32 usec + HCA_PRINT(TRACE_LEVEL_VERBOSE, HCA_DBG_SHIM ,("Port %d port_guid 0x%I64x\n", + ibal_port_p->port_num, cl_ntoh64(ibal_port_p->port_guid))); + } } enum ib_rate to_rate(uint8_t rate) diff --git a/branches/WOF2-0/trunk/hw/mlx4/user/hca/mlx4.c b/branches/WOF2-0/trunk/hw/mlx4/user/hca/mlx4.c index 2a0f136f..7166316d 100644 --- a/branches/WOF2-0/trunk/hw/mlx4/user/hca/mlx4.c +++ b/branches/WOF2-0/trunk/hw/mlx4/user/hca/mlx4.c @@ -47,10 +47,15 @@ struct { unsigned device; } hca_table[] = { HCA(MELLANOX, 0x6340), /* MT25408 "Hermon" SDR */ - HCA(MELLANOX, 0x634a), /* MT25408 "Hermon" DDR */ - HCA(MELLANOX, 0x6354), /* MT25408 "Hermon" QDR */ - HCA(MELLANOX, 0x6732), /* MT25408 "Hermon" DDR PCIe gen2 */ - HCA(MELLANOX, 0x673c), /* MT25408 "Hermon" QDR PCIe gen2 */ + HCA(MELLANOX, 0x634a), /* MT25418 "Hermon" DDR */ + HCA(MELLANOX, 0x6732), /* MT26418 "Hermon" DDR PCIe gen2 */ + HCA(MELLANOX, 0x673c), /* MT26428 "Hermon" QDR PCIe gen2 */ + + HCA(MELLANOX, 0x6368), /* MT25448 "Hermon" Ethernet */ + HCA(MELLANOX, 0x6372), /* MT25458 "Hermon" Ethernet Yatir*/ + HCA(MELLANOX, 0x6750), /* MT26448 "Hermon" Ethernet PCIe gen2 */ + HCA(MELLANOX, 0x675A), /* MT26458 "Hermon" Ethernet Yatir PCIe gen2*/ + HCA(MELLANOX, 0x0191), /* MT25408 "Hermon" livefish mode */ }; -- 2.41.0