From owner-svn-src-stable-10@FreeBSD.ORG Wed Jan 14 05:29:37 2015 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3A9DA35A; Wed, 14 Jan 2015 05:29:37 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 25DDD802; Wed, 14 Jan 2015 05:29:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t0E5Tb8t063346; Wed, 14 Jan 2015 05:29:37 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t0E5TahN063343; Wed, 14 Jan 2015 05:29:36 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201501140529.t0E5TahN063343@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 14 Jan 2015 05:29:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r277160 - stable/10/contrib/ofed/libmlx4/src X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jan 2015 05:29:37 -0000 Author: hselasky Date: Wed Jan 14 05:29:35 2015 New Revision: 277160 URL: https://svnweb.freebsd.org/changeset/base/277160 Log: MFC r276981: Fix support for ConnectX2 hardware. Sponsored by: Mellanox Technologies Modified: stable/10/contrib/ofed/libmlx4/src/mlx4-abi.h stable/10/contrib/ofed/libmlx4/src/mlx4.c stable/10/contrib/ofed/libmlx4/src/mlx4.h Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/ofed/libmlx4/src/mlx4-abi.h ============================================================================== --- stable/10/contrib/ofed/libmlx4/src/mlx4-abi.h Wed Jan 14 04:50:28 2015 (r277159) +++ stable/10/contrib/ofed/libmlx4/src/mlx4-abi.h Wed Jan 14 05:29:35 2015 (r277160) @@ -38,6 +38,13 @@ #define MLX4_UVERBS_MIN_ABI_VERSION 2 #define MLX4_UVERBS_MAX_ABI_VERSION 4 +struct mlx4_alloc_ucontext_resp_v3 { + struct ibv_get_context_resp ibv_resp; + __u32 qp_tab_size; + __u16 bf_reg_size; + __u16 bf_regs_per_page; +}; + struct mlx4_alloc_ucontext_resp { struct ibv_get_context_resp ibv_resp; __u32 dev_caps; Modified: stable/10/contrib/ofed/libmlx4/src/mlx4.c ============================================================================== --- stable/10/contrib/ofed/libmlx4/src/mlx4.c Wed Jan 14 04:50:28 2015 (r277159) +++ stable/10/contrib/ofed/libmlx4/src/mlx4.c Wed Jan 14 05:29:35 2015 (r277160) @@ -142,8 +142,10 @@ static struct ibv_context *mlx4_alloc_co struct mlx4_context *context; struct ibv_get_context cmd; struct mlx4_alloc_ucontext_resp resp; + struct mlx4_alloc_ucontext_resp_v3 resp_v3; int i; struct ibv_device_attr dev_attrs; + unsigned int bf_reg_size; context = calloc(1, sizeof *context); if (!context) @@ -151,11 +153,26 @@ static struct ibv_context *mlx4_alloc_co context->ibv_ctx.cmd_fd = cmd_fd; - if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd, - &resp.ibv_resp, sizeof resp)) - goto err_free; + if (to_mdev(ibdev)->driver_abi_ver > 3) { + if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd, + &resp.ibv_resp, sizeof resp)) + goto err_free; + + context->num_qps = resp.qp_tab_size; + context->num_xrc_srqs = resp.qp_tab_size; + bf_reg_size = resp.bf_reg_size; + context->cqe_size = resp.cqe_size; + } else { + if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd, + &resp_v3.ibv_resp, sizeof resp_v3)) + goto err_free; + + context->num_qps = resp_v3.qp_tab_size; + context->num_xrc_srqs = resp_v3.qp_tab_size; + bf_reg_size = resp_v3.bf_reg_size; + context->cqe_size = 32; + } - context->num_qps = resp.qp_tab_size; context->qp_table_shift = ffs(context->num_qps) - 1 - MLX4_QP_TABLE_BITS; context->qp_table_mask = (1 << context->qp_table_shift) - 1; @@ -163,7 +180,6 @@ static struct ibv_context *mlx4_alloc_co for (i = 0; i < MLX4_QP_TABLE_SIZE; ++i) context->qp_table[i].refcnt = 0; - context->num_xrc_srqs = resp.qp_tab_size; context->xrc_srq_table_shift = ffs(context->num_xrc_srqs) - 1 - MLX4_XRC_SRQ_TABLE_BITS; context->xrc_srq_table_mask = (1 << context->xrc_srq_table_shift) - 1; @@ -182,7 +198,7 @@ static struct ibv_context *mlx4_alloc_co if (context->uar == MAP_FAILED) goto err_free; - if (resp.bf_reg_size) { + if (bf_reg_size) { context->bf_page = mmap(NULL, to_mdev(ibdev)->page_size, PROT_WRITE, MAP_SHARED, cmd_fd, to_mdev(ibdev)->page_size); @@ -192,7 +208,7 @@ static struct ibv_context *mlx4_alloc_co context->bf_page = NULL; context->bf_buf_size = 0; } else { - context->bf_buf_size = resp.bf_reg_size / 2; + context->bf_buf_size = bf_reg_size / 2; context->bf_offset = 0; pthread_spin_init(&context->bf_lock, PTHREAD_PROCESS_PRIVATE); } @@ -201,7 +217,6 @@ static struct ibv_context *mlx4_alloc_co context->bf_buf_size = 0; } - context->cqe_size = resp.cqe_size; pthread_spin_init(&context->uar_lock, PTHREAD_PROCESS_PRIVATE); context->ibv_ctx.ops = mlx4_ctx_ops; @@ -294,6 +309,7 @@ found: dev->ibv_dev.ops = mlx4_dev_ops; dev->page_size = sysconf(_SC_PAGESIZE); + dev->driver_abi_ver = abi_version; return &dev->ibv_dev; } Modified: stable/10/contrib/ofed/libmlx4/src/mlx4.h ============================================================================== --- stable/10/contrib/ofed/libmlx4/src/mlx4.h Wed Jan 14 04:50:28 2015 (r277159) +++ stable/10/contrib/ofed/libmlx4/src/mlx4.h Wed Jan 14 05:29:35 2015 (r277160) @@ -162,6 +162,7 @@ enum { struct mlx4_device { struct ibv_device ibv_dev; int page_size; + int driver_abi_ver; }; struct mlx4_db_page;