From owner-svn-src-stable@freebsd.org Wed Dec 12 11:43:53 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 602F31339AED; Wed, 12 Dec 2018 11:43:53 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 078D78B16C; Wed, 12 Dec 2018 11:43:53 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D3F8177C0; Wed, 12 Dec 2018 11:43:52 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBCBhqqe057535; Wed, 12 Dec 2018 11:43:52 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBCBhq2W057534; Wed, 12 Dec 2018 11:43:52 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201812121143.wBCBhq2W057534@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Wed, 12 Dec 2018 11:43:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r341905 - in stable/12/sys/dev/mlx4: . mlx4_core X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/12/sys/dev/mlx4: . mlx4_core X-SVN-Commit-Revision: 341905 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 078D78B16C X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-0.71 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.71)[-0.709,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Dec 2018 11:43:53 -0000 Author: hselasky Date: Wed Dec 12 11:43:52 2018 New Revision: 341905 URL: https://svnweb.freebsd.org/changeset/base/341905 Log: MFC r341545: mlx4: Add board identifier and firmware version to sysctl In last mlx4 update (r325841) we lost the sysctl to show the firmware version for mlx4 devices. Add both board identifier and firmware version under: sys.device.mlx4_core0.hw sysctl node. Sponsored by: Mellanox Technologies Modified: stable/12/sys/dev/mlx4/device.h stable/12/sys/dev/mlx4/mlx4_core/mlx4_main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/mlx4/device.h ============================================================================== --- stable/12/sys/dev/mlx4/device.h Wed Dec 12 11:43:49 2018 (r341904) +++ stable/12/sys/dev/mlx4/device.h Wed Dec 12 11:43:52 2018 (r341905) @@ -877,6 +877,8 @@ struct mlx4_dev { u64 regid_allmulti_array[MLX4_MAX_PORTS + 1]; struct mlx4_vf_dev *dev_vfs; u8 uar_page_shift; + struct sysctl_ctx_list hw_ctx; + char fw_str[64]; }; struct mlx4_clock_params { Modified: stable/12/sys/dev/mlx4/mlx4_core/mlx4_main.c ============================================================================== --- stable/12/sys/dev/mlx4/mlx4_core/mlx4_main.c Wed Dec 12 11:43:49 2018 (r341904) +++ stable/12/sys/dev/mlx4/mlx4_core/mlx4_main.c Wed Dec 12 11:43:52 2018 (r341905) @@ -1893,6 +1893,7 @@ static void unmap_internal_clock(struct mlx4_dev *dev) static void mlx4_close_hca(struct mlx4_dev *dev) { + sysctl_ctx_free(&dev->hw_ctx); unmap_internal_clock(dev); unmap_bf_area(dev); if (mlx4_is_slave(dev)) @@ -3745,10 +3746,14 @@ err_disable_pdev: static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) { - struct mlx4_priv *priv; - struct mlx4_dev *dev; - int ret; + struct sysctl_ctx_list *ctx; + struct sysctl_oid *node; + struct sysctl_oid_list *node_list; + struct mlx4_priv *priv; + struct mlx4_dev *dev; + int ret; + printk_once(KERN_INFO "%s", mlx4_version); priv = kzalloc(sizeof(*priv), GFP_KERNEL); @@ -3773,8 +3778,28 @@ static int mlx4_init_one(struct pci_dev *pdev, const s if (ret) { kfree(dev->persist); kfree(priv); + return ret; } else { pci_save_state(pdev->dev.bsddev); + } + + snprintf(dev->fw_str, sizeof(dev->fw_str), "%d.%d.%d", + (int) (dev->caps.fw_ver >> 32), + (int) (dev->caps.fw_ver >> 16) & 0xffff, + (int) (dev->caps.fw_ver & 0xffff)); + + ctx = &dev->hw_ctx; + sysctl_ctx_init(ctx); + node = SYSCTL_ADD_NODE(ctx,SYSCTL_CHILDREN(pdev->dev.kobj.oidp), + OID_AUTO, "hw" , CTLFLAG_RD, 0, "mlx4 dev hw information"); + if (node != NULL) { + node_list = SYSCTL_CHILDREN(node); + SYSCTL_ADD_STRING(ctx, node_list, OID_AUTO, + "fw_version", CTLFLAG_RD, dev->fw_str, 0, + "Device firmware version"); + SYSCTL_ADD_STRING(ctx, node_list, OID_AUTO, + "board_id", CTLFLAG_RD, dev->board_id, 0, + "Device board identifier"); } return ret;