From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22B9EC282C7 for ; Tue, 29 Jan 2019 03:34:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E4BE0214DA for ; Tue, 29 Jan 2019 03:34:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="zBaa/QYL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727507AbfA2Des (ORCPT ); Mon, 28 Jan 2019 22:34:48 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:38456 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727399AbfA2Dep (ORCPT ); Mon, 28 Jan 2019 22:34:45 -0500 Received: by mail-qt1-f195.google.com with SMTP id p17so20844434qtl.5 for ; Mon, 28 Jan 2019 19:34:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S99TYCOvzS6t1S/bDpNIYO6Ge99JJunfHrPj8o9g0oY=; b=zBaa/QYLnF+zC7KVJMSeEvyQjHmgAL/moLSDo9vzHQjyTaRc7DCHwI7RmfsHjueFTu p+5yjGWe1y66c6+szsfGMb31oPMgK6Yi3nQwdtOdu40BD/8l2+dIPtSRVUnPbZzWXJjW FI/tGzRBYneOfgk7Rjf+BUVGEGJPJazoT23xvbOOCUN+jIGlv+csiQBVodFK0xSEN6BR YKzJAxnNlgw5QjRi1FJhcB4wZNenXfmu5x/LtYv5zhm0u/YB2ZHVtnIiHmzfbjhurGac oxJlhMnmXt6co+APjw6fcwwVI2jaCXe4Fpycj5ijrnCiavwvT90z/tgECkViRaZH8h2a DTGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S99TYCOvzS6t1S/bDpNIYO6Ge99JJunfHrPj8o9g0oY=; b=Wq+o6hXedE9NR7LkTHidauFOxDpduaL60Weapva90xFlz9opIxSC9JjYLhHIsWyvQ3 p4i/xfHLULJMkL9pTYEliabYbZTMcV4vOSgeyJFJRkKYk0YyB4wPaaJOI2ckCioxUjV6 Ur/XLRU+G/fpVJcWuWnydqo607pgUCP+fEmIFzIhO/x4WTbOBypIPYrycVglAoAOXA+3 3/yHGQZYc757gg5YyPFCwfkjQ+lzrfJCFGfa5kKfBvOFYBGh82Lu9CBK+wZW61zPH15N 0TjN0HOsw1hkLQuhLRpBoUlsGoNtqN1WkiWGADurzRPCHhpsbB73aCVt28Q55zflxGq7 +COg== X-Gm-Message-State: AJcUuke88eHBnk7oKoSOFy40Kah72IdDQEr5yOXDUh1A3j+sChIHjpzu I60wrCopzr9tZ6vksBJa261Zrw== X-Google-Smtp-Source: ALg8bN4LNOK0ADkIfEjqfSTOWc4C+Wto9udjr1kI40OOoWzzdbSJFeMMciR8arzaM0rkIQzBF2YgHg== X-Received: by 2002:ac8:2276:: with SMTP id p51mr24712538qtp.200.1548732884688; Mon, 28 Jan 2019 19:34:44 -0800 (PST) Received: from jkicinski-Precision-T1700.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id z18sm70505153qkz.96.2019.01.28.19.34.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jan 2019 19:34:44 -0800 (PST) From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, oss-drivers@netronome.com, jiri@resnulli.us, andrew@lunn.ch, f.fainelli@gmail.com, mkubecek@suse.cz, eugenem@fb.com, jonathan.lemon@gmail.com, Jakub Kicinski Subject: [PATCH net-next 4/7] nfp: devlink: report fixed versions Date: Mon, 28 Jan 2019 19:34:17 -0800 Message-Id: <20190129033420.27235-5-jakub.kicinski@netronome.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190129033420.27235-1-jakub.kicinski@netronome.com> References: <20190129033420.27235-1-jakub.kicinski@netronome.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Report information about the hardware. RFCv2: - add defines for board IDs which are likely to be reusable for other drivers (Jiri). Signed-off-by: Jakub Kicinski --- .../net/ethernet/netronome/nfp/nfp_devlink.c | 37 ++++++++++++++++++- include/net/devlink.h | 5 +++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c index cb3ef7e46614..9857fa663adf 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c @@ -172,6 +172,41 @@ static int nfp_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode, return ret; } +static const struct nfp_devlink_versions_simple { + const char *key; + const char *hwinfo; +} nfp_devlink_versions_hwinfo[] = { + { DEVLINK_VERSION_GENERIC_BOARD_ID, "assembly.partno", }, + { DEVLINK_VERSION_GENERIC_BOARD_REV, "assembly.revision", }, + { "board.vendor", /* fab */ "assembly.vendor", }, + { "board.model", /* code name */ "assembly.model", }, +}; + +static int +nfp_devlink_versions_get_hwinfo(struct nfp_pf *pf, struct devlink_info_req *req) +{ + unsigned int i; + int err; + + for (i = 0; i < ARRAY_SIZE(nfp_devlink_versions_hwinfo); i++) { + const struct nfp_devlink_versions_simple *info; + const char *val; + + info = &nfp_devlink_versions_hwinfo[i]; + + val = nfp_hwinfo_lookup(pf->hwinfo, info->hwinfo); + if (!val) + continue; + + err = devlink_info_report_version(req, DEVLINK_VERSION_FIXED, + info->key, val); + if (err) + return err; + } + + return 0; +} + static int nfp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, struct netlink_ext_ack *extack) @@ -191,7 +226,7 @@ nfp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, return err; } - return 0; + return nfp_devlink_versions_get_hwinfo(pf, req); } const struct devlink_ops nfp_devlink_ops = { diff --git a/include/net/devlink.h b/include/net/devlink.h index f53ace3ac4b3..dc08301028a9 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -419,6 +419,11 @@ enum devlink_param_generic_id { .validate = _validate, \ } +/* Part number, identifier of board design */ +#define DEVLINK_VERSION_GENERIC_BOARD_ID "board.id" +/* Revision of board design */ +#define DEVLINK_VERSION_GENERIC_BOARD_REV "board.rev" + enum devlink_version_type { DEVLINK_VERSION_FIXED, DEVLINK_VERSION_STORED, -- 2.19.2