From patchwork Mon Aug 22 17:02:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 12950949 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12723C28D13 for ; Mon, 22 Aug 2022 17:03:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235024AbiHVRC7 (ORCPT ); Mon, 22 Aug 2022 13:02:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235765AbiHVRCx (ORCPT ); Mon, 22 Aug 2022 13:02:53 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA111419AE for ; Mon, 22 Aug 2022 10:02:51 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id q2so12643634edb.6 for ; Mon, 22 Aug 2022 10:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=3sUHWDa2F0mjoZfRKLvdJDDNPwPJAlWT4DZRT16qSQM=; b=XztyfRCjnma9UobTeTwlFQweP39vP/0lADAAgFW5EnU+P0StsbLmn3uxEXT4OHJ/TT 4/k8KgWojQSUMoL3zhYglU+P+tjNVVJamp6iX6q8l3VWjXwqgs2iJgJtA+R+BHybeH+d l2eneuAPZdjiP8sUQOTx5HxQM3n3yVvqVAniQbyMKQoBq06RTLNf4OJZWfor/TH5IlH4 CKn2nF1VyRICe+YJoCA/t7hl/actMbq/eCgmQbsI01sHu/tbtxAFP0f/ajxKe2+hXBcF JIkMj1V4p0FzXVb98H6JxQYa3KStoMBXyign0p67Vl0tYzatTHe27hTyVgsfuu2JtQx+ ediQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=3sUHWDa2F0mjoZfRKLvdJDDNPwPJAlWT4DZRT16qSQM=; b=N7N5ZvNMiiOnlDBrHUOrPtC5gHMv4+UpS6Iul2g15K9RH3QvtebFacRkU4SzfMjaAm nitxlYfrOa0Lixglu+KQl1EVlgSdLEmXmrgN2phcwbrIcsrwhD4zTGssNkZHblh3+YoT W+Zj8oCJuYbp4Y/59gIbClDz3DzvbVvCuQjCOOYZxU/BTRjJsva3+NTcw11X/v59gieS PeLumpQk9RUuso6My6bZtX3iIZgu+zmKvldo/1Z872EQctIpVSGmneF386/AdpwRv9eS /2zcg/lOwPN21GOj6nqKfdig1+7o0qre/AZk0CiuJNRzYtRSm7oSUOZI24oMLqoab9nU yDfQ== X-Gm-Message-State: ACgBeo2UTif4QOCCSF3iHxxIA7J39hAYPJWxueEOK1pA7cB1YLh5CAT5 KoLrZHFkgwE7lGlPA3xaEYP8pCArNNvJugWe X-Google-Smtp-Source: AA6agR7z2UnxY6yFEBz54DR4BAaIpXPiwjk8R8Hy0NdRePdnwZoJLBKl6dawzTVwifHYm8zmP+Offg== X-Received: by 2002:aa7:d31a:0:b0:445:f4cd:b1c3 with SMTP id p26-20020aa7d31a000000b00445f4cdb1c3mr125562edq.110.1661187770397; Mon, 22 Aug 2022 10:02:50 -0700 (PDT) Received: from localhost (host-213-179-129-39.customer.m-online.net. [213.179.129.39]) by smtp.gmail.com with ESMTPSA id bt2-20020a0564020a4200b0043d7b19abd0sm11560edb.39.2022.08.22.10.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 10:02:49 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, idosch@nvidia.com, pabeni@redhat.com, edumazet@google.com, saeedm@nvidia.com, jacob.e.keller@intel.com, vikas.gupta@broadcom.com, gospo@broadcom.com Subject: [patch net-next v2 1/4] net: devlink: extend info_get() version put to indicate a flash component Date: Mon, 22 Aug 2022 19:02:44 +0200 Message-Id: <20220822170247.974743-2-jiri@resnulli.us> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220822170247.974743-1-jiri@resnulli.us> References: <20220822170247.974743-1-jiri@resnulli.us> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Whenever the driver is called by his info_get() op, it may put multiple version names and values to the netlink message. Extend by additional helper devlink_info_version_running_put_ext() that allows to specify a version type that indicates when particular version name represents a flash component. This is going to be used in follow-up patch calling info_get() during flash update command checking if version with this the version type exists. Signed-off-by: Jiri Pirko --- v1->v2: - split from v1 patch "net: devlink: extend info_get() version put to indicate a flash component", no code changes --- include/net/devlink.h | 12 ++++++++++++ net/core/devlink.c | 23 +++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/include/net/devlink.h b/include/net/devlink.h index 119ed1ffb988..5f47d5cefaa6 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1714,6 +1714,14 @@ int devlink_info_driver_name_put(struct devlink_info_req *req, const char *name); int devlink_info_board_serial_number_put(struct devlink_info_req *req, const char *bsn); + +enum devlink_info_version_type { + DEVLINK_INFO_VERSION_TYPE_NONE, + DEVLINK_INFO_VERSION_TYPE_COMPONENT, /* May be used as flash update + * component by name. + */ +}; + int devlink_info_version_fixed_put(struct devlink_info_req *req, const char *version_name, const char *version_value); @@ -1723,6 +1731,10 @@ int devlink_info_version_stored_put(struct devlink_info_req *req, int devlink_info_version_running_put(struct devlink_info_req *req, const char *version_name, const char *version_value); +int devlink_info_version_running_put_ext(struct devlink_info_req *req, + const char *version_name, + const char *version_value, + enum devlink_info_version_type version_type); int devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg); int devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg); diff --git a/net/core/devlink.c b/net/core/devlink.c index b50bcc18b8d9..2682e968539e 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -6579,7 +6579,8 @@ EXPORT_SYMBOL_GPL(devlink_info_board_serial_number_put); static int devlink_info_version_put(struct devlink_info_req *req, int attr, const char *version_name, - const char *version_value) + const char *version_value, + enum devlink_info_version_type version_type) { struct nlattr *nest; int err; @@ -6612,7 +6613,8 @@ int devlink_info_version_fixed_put(struct devlink_info_req *req, const char *version_value) { return devlink_info_version_put(req, DEVLINK_ATTR_INFO_VERSION_FIXED, - version_name, version_value); + version_name, version_value, + DEVLINK_INFO_VERSION_TYPE_NONE); } EXPORT_SYMBOL_GPL(devlink_info_version_fixed_put); @@ -6621,7 +6623,8 @@ int devlink_info_version_stored_put(struct devlink_info_req *req, const char *version_value) { return devlink_info_version_put(req, DEVLINK_ATTR_INFO_VERSION_STORED, - version_name, version_value); + version_name, version_value, + DEVLINK_INFO_VERSION_TYPE_NONE); } EXPORT_SYMBOL_GPL(devlink_info_version_stored_put); @@ -6630,10 +6633,22 @@ int devlink_info_version_running_put(struct devlink_info_req *req, const char *version_value) { return devlink_info_version_put(req, DEVLINK_ATTR_INFO_VERSION_RUNNING, - version_name, version_value); + version_name, version_value, + DEVLINK_INFO_VERSION_TYPE_NONE); } EXPORT_SYMBOL_GPL(devlink_info_version_running_put); +int devlink_info_version_running_put_ext(struct devlink_info_req *req, + const char *version_name, + const char *version_value, + enum devlink_info_version_type version_type) +{ + return devlink_info_version_put(req, DEVLINK_ATTR_INFO_VERSION_RUNNING, + version_name, version_value, + version_type); +} +EXPORT_SYMBOL_GPL(devlink_info_version_running_put_ext); + static int devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink, enum devlink_command cmd, u32 portid, From patchwork Mon Aug 22 17:02:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 12950948 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BED8DC32774 for ; Mon, 22 Aug 2022 17:03:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236821AbiHVRC6 (ORCPT ); Mon, 22 Aug 2022 13:02:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236104AbiHVRCy (ORCPT ); Mon, 22 Aug 2022 13:02:54 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D1063ECEB for ; Mon, 22 Aug 2022 10:02:53 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id b16so14772441edd.4 for ; Mon, 22 Aug 2022 10:02:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=ULgK/+IvHR+/TIq9zz1K/UnUR2EFOOBHKxTWq4NsMkw=; b=TCdb87gTo6vazNKn32b3aFC3crRj/jxDcdk8UcqquxAw0tc7R3NP7UApfJRk3NG0oQ 5DYsmOHDIrA2hzAklkxNt9fevbvc+PbBbdLYSHjkE0gniT+NklYAGd0seiFWa70RczWB Hxg8LCkbdb9zINVvcrSLRuhkGGbyCXNfFR4edEnCYW92cBCrcLeACerISXpFWGNkPE8n eOMqgqq68DhRvRWTe9J+UNf5pduMzQ7TiaxJrUKow1dDrvEPS8wbmcJCGXTvzdzj6WDJ /4s9/wymXIY2kc5KRAzEWhyaWziUZAVXtgwz3FOoNCpHt2165ZJYRQFS5Kp81fw+dPjK lNlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=ULgK/+IvHR+/TIq9zz1K/UnUR2EFOOBHKxTWq4NsMkw=; b=kN91gwUarPKFWxq1e/bT0EWAokjrhFWaUoVFo38XVt8WmeXaWN4FHvoFFSux0YUVAY a8euEBMeX+sjldmLmwuQaBcaAxDHaK/9ZmkK/UiNHWin0ltmGcESbq+MAwwNXDtuRnEq 7erZ4Qa+/L5Jp+KMIaVI2oU0OzqAtxbRUcBEMnKfMJDv+GR1JcAlcpEhMcpgoMWbv0N4 XXwSWSyJ3sIPvcbGXz0WZrT7XlmHvBYsIe9CaaSMQbywjBFgfVfW2Gx08JIfufQKwgCC 2Mj7K6O7RnUHAfsAji2ZUPZ95Pqv5fDdf5yKH6Kj4Ha6crc5SZewxzNW0s27Gahjmkyy SNEg== X-Gm-Message-State: ACgBeo1xtdU7mtp0ntieLBg47WPo/Z+RpnSBFp0+x1fRbFgXjAOpDoZ1 P4IuTROiafiBfqo/otn0Az68NKNffHEquzGx X-Google-Smtp-Source: AA6agR4pQ6f9kMf9cGmsbht56f6+MfnvfiIQbMOKruXeSAUGet1TKk9+zA3otKKDfebrwjAQHASTAg== X-Received: by 2002:a05:6402:524a:b0:43d:aa71:33d8 with SMTP id t10-20020a056402524a00b0043daa7133d8mr104632edd.33.1661187771895; Mon, 22 Aug 2022 10:02:51 -0700 (PDT) Received: from localhost (host-213-179-129-39.customer.m-online.net. [213.179.129.39]) by smtp.gmail.com with ESMTPSA id g34-20020a056402322200b0043df40e4cfdsm14465eda.35.2022.08.22.10.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 10:02:51 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, idosch@nvidia.com, pabeni@redhat.com, edumazet@google.com, saeedm@nvidia.com, jacob.e.keller@intel.com, vikas.gupta@broadcom.com, gospo@broadcom.com Subject: [patch net-next v2 2/4] netdevsim: add version fw.mgmt info info_get() and mark as a component Date: Mon, 22 Aug 2022 19:02:45 +0200 Message-Id: <20220822170247.974743-3-jiri@resnulli.us> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220822170247.974743-1-jiri@resnulli.us> References: <20220822170247.974743-1-jiri@resnulli.us> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Fix the only component user which is netdevsim. It uses component named "fw.mgmt" in selftests. So add this version to info_get() output with version type component. Signed-off-by: Jiri Pirko --- v1->v2: - split from v1 patch "net: devlink: extend info_get() version put to indicate a flash component", no code changes --- drivers/net/netdevsim/dev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index e88f783c297e..97fc17ffff93 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -984,7 +984,14 @@ static int nsim_dev_info_get(struct devlink *devlink, struct devlink_info_req *req, struct netlink_ext_ack *extack) { - return devlink_info_driver_name_put(req, DRV_NAME); + int err; + + err = devlink_info_driver_name_put(req, DRV_NAME); + if (err) + return err; + + return devlink_info_version_running_put_ext(req, "fw.mgmt", "10.20.30", + DEVLINK_INFO_VERSION_TYPE_COMPONENT); } #define NSIM_DEV_FLASH_SIZE 500000 From patchwork Mon Aug 22 17:02:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 12950950 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6216C32772 for ; Mon, 22 Aug 2022 17:03:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236036AbiHVRDC (ORCPT ); Mon, 22 Aug 2022 13:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236816AbiHVRC4 (ORCPT ); Mon, 22 Aug 2022 13:02:56 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 560AE3F1F2 for ; Mon, 22 Aug 2022 10:02:55 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id gi31so15993621ejc.5 for ; Mon, 22 Aug 2022 10:02:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=6yGy5ggdrTF6whnWYjTmPZD20A772INL5AuSPGMVOJQ=; b=DVoTAkiZoH26qHyGdUL5kpXU9/ZKV7p+wf04j67vpQbg3GE53gTw9YDLz3rTvjp+qy JCgKqTWq/4lwL6zsf0dVNXa0Almo1IJ2ba0qzutVPRYb4JJEG65PAcjGFTeEUDCR8Bjn fDFo/ZuqhqjK5EpV68zxDQfLpyzrtpKGdjdTEUa3pmw0sZDsLNjdWYPbTHg0+n69HeqX kcr9pHxNXF9nOfFtAhUjoEiM94q0dINvYIUkUoWT198jUKLQUcVLjLAcKeOLr9Ij2tJ8 vE8ghlnWjlbEKF7+hLIfQ3dgeWNhrvirsqYRghffSqwKZDV0ECqNtXo7y7L6fjkXtBuh 3Vxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=6yGy5ggdrTF6whnWYjTmPZD20A772INL5AuSPGMVOJQ=; b=I61mjWQZZUGARjaxm6w63lZQ3k0g2qus0HfN6o3PpjigAWcLTII7AYryZyeR/CbHOu +alYZlfbBIQyO5k2sj7n2PfhHwk1YvXPz4FCeTZG7n+HyMXgLHMdVc/oprpu9sYitEQq XPNnu7SiVGL26UX/bsfJxIFDYhLbWkGTHMDVaeSPwGkQRFaSZCmstUQrtm8iInI7156W 6Pi53OZBdm/LwdiSjgZkCU+JKZfJrqUBSx+bMnGLptiXUf0EpQ3xpLpE2OjZrCB8UxmO 10BJhw//NcS06S5m8JM+wW45Jn4VWVyGtDSnBga5wSokMQ0FKdA/8efjcS7YT4KC40NV EH+g== X-Gm-Message-State: ACgBeo3K/XYbXhQZvChqu+Dw/Nu8BICF3Ree9GUYprwONiH6bCVXW8i/ 0lnV43pzgoO6B07JPgbbXRlrqyQeqTJyO2dP X-Google-Smtp-Source: AA6agR7GrXu2/tMpYAPfEyCJ0tpuxj+AaoKzjRaskjYzH/kq6mehNrjp4slVTgf2KMqGqQB7LRY1SQ== X-Received: by 2002:a17:906:9c82:b0:6df:baa2:9f75 with SMTP id fj2-20020a1709069c8200b006dfbaa29f75mr14143332ejc.762.1661187773627; Mon, 22 Aug 2022 10:02:53 -0700 (PDT) Received: from localhost (host-213-179-129-39.customer.m-online.net. [213.179.129.39]) by smtp.gmail.com with ESMTPSA id g21-20020a50d0d5000000b0043d6ece495asm4225edf.55.2022.08.22.10.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 10:02:53 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, idosch@nvidia.com, pabeni@redhat.com, edumazet@google.com, saeedm@nvidia.com, jacob.e.keller@intel.com, vikas.gupta@broadcom.com, gospo@broadcom.com Subject: [patch net-next v2 3/4] net: devlink: limit flash component name to match version returned by info_get() Date: Mon, 22 Aug 2022 19:02:46 +0200 Message-Id: <20220822170247.974743-4-jiri@resnulli.us> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220822170247.974743-1-jiri@resnulli.us> References: <20220822170247.974743-1-jiri@resnulli.us> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Limit the acceptance of component name passed to cmd_flash_update() to match one of the versions returned by info_get(), marked by version type. This makes things clearer and enforces 1:1 mapping between exposed version and accepted flash component. Check VERSION_TYPE_COMPONENT version type during cmd_flash_update() execution by calling info_get() with different "req" context. That causes info_get() to lookup the component name instead of filling-up the netlink message. Remove "UPDATE_COMPONENT" flag which becomes used. Signed-off-by: Jiri Pirko --- v1->v2: - split from v1 patch "net: devlink: extend info_get() version put to indicate a flash component", no code changes --- drivers/net/netdevsim/dev.c | 3 +- include/net/devlink.h | 3 +- net/core/devlink.c | 105 ++++++++++++++++++++++++++++++------ 3 files changed, 90 insertions(+), 21 deletions(-) diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index 97fc17ffff93..cea130490dea 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -1319,8 +1319,7 @@ nsim_dev_devlink_trap_drop_counter_get(struct devlink *devlink, static const struct devlink_ops nsim_dev_devlink_ops = { .eswitch_mode_set = nsim_devlink_eswitch_mode_set, .eswitch_mode_get = nsim_devlink_eswitch_mode_get, - .supported_flash_update_params = DEVLINK_SUPPORT_FLASH_UPDATE_COMPONENT | - DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK, + .supported_flash_update_params = DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK, .reload_actions = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT), .reload_down = nsim_dev_reload_down, .reload_up = nsim_dev_reload_up, diff --git a/include/net/devlink.h b/include/net/devlink.h index 5f47d5cefaa6..9bf4f03feca6 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -624,8 +624,7 @@ struct devlink_flash_update_params { u32 overwrite_mask; }; -#define DEVLINK_SUPPORT_FLASH_UPDATE_COMPONENT BIT(0) -#define DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK BIT(1) +#define DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK BIT(0) struct devlink_region; struct devlink_info_req; diff --git a/net/core/devlink.c b/net/core/devlink.c index 2682e968539e..17b78123ad9d 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -4742,10 +4742,76 @@ void devlink_flash_update_timeout_notify(struct devlink *devlink, } EXPORT_SYMBOL_GPL(devlink_flash_update_timeout_notify); +struct devlink_info_req { + struct sk_buff *msg; + void (*version_cb)(const char *version_name, + enum devlink_info_version_type version_type, + void *version_cb_priv); + void *version_cb_priv; +}; + +struct devlink_flash_component_lookup_ctx { + const char *lookup_name; + bool lookup_name_found; +}; + +static void +devlink_flash_component_lookup_cb(const char *version_name, + enum devlink_info_version_type version_type, + void *version_cb_priv) +{ + struct devlink_flash_component_lookup_ctx *lookup_ctx = version_cb_priv; + + if (version_type != DEVLINK_INFO_VERSION_TYPE_COMPONENT || + lookup_ctx->lookup_name_found) + return; + + lookup_ctx->lookup_name_found = + !strcmp(lookup_ctx->lookup_name, version_name); +} + +static int devlink_flash_component_get(struct devlink *devlink, + struct nlattr *nla_component, + const char **p_component, + struct netlink_ext_ack *extack) +{ + struct devlink_flash_component_lookup_ctx lookup_ctx = {}; + struct devlink_info_req req = {}; + const char *component; + int ret; + + if (!nla_component) + return 0; + + component = nla_data(nla_component); + + if (!devlink->ops->info_get) { + NL_SET_ERR_MSG_ATTR(extack, nla_component, + "component update is not supported by this device"); + return -EOPNOTSUPP; + } + + lookup_ctx.lookup_name = component; + req.version_cb = devlink_flash_component_lookup_cb; + req.version_cb_priv = &lookup_ctx; + + ret = devlink->ops->info_get(devlink, &req, NULL); + if (ret) + return ret; + + if (!lookup_ctx.lookup_name_found) { + NL_SET_ERR_MSG_ATTR(extack, nla_component, + "selected component is not supported by this device"); + return -EINVAL; + } + *p_component = component; + return 0; +} + static int devlink_nl_cmd_flash_update(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *nla_component, *nla_overwrite_mask, *nla_file_name; + struct nlattr *nla_overwrite_mask, *nla_file_name; struct devlink_flash_update_params params = {}; struct devlink *devlink = info->user_ptr[0]; const char *file_name; @@ -4758,17 +4824,13 @@ static int devlink_nl_cmd_flash_update(struct sk_buff *skb, if (!info->attrs[DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME]) return -EINVAL; - supported_params = devlink->ops->supported_flash_update_params; + ret = devlink_flash_component_get(devlink, + info->attrs[DEVLINK_ATTR_FLASH_UPDATE_COMPONENT], + ¶ms.component, info->extack); + if (ret) + return ret; - nla_component = info->attrs[DEVLINK_ATTR_FLASH_UPDATE_COMPONENT]; - if (nla_component) { - if (!(supported_params & DEVLINK_SUPPORT_FLASH_UPDATE_COMPONENT)) { - NL_SET_ERR_MSG_ATTR(info->extack, nla_component, - "component update is not supported by this device"); - return -EOPNOTSUPP; - } - params.component = nla_data(nla_component); - } + supported_params = devlink->ops->supported_flash_update_params; nla_overwrite_mask = info->attrs[DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK]; if (nla_overwrite_mask) { @@ -6553,18 +6615,18 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb, return err; } -struct devlink_info_req { - struct sk_buff *msg; -}; - int devlink_info_driver_name_put(struct devlink_info_req *req, const char *name) { + if (!req->msg) + return 0; return nla_put_string(req->msg, DEVLINK_ATTR_INFO_DRIVER_NAME, name); } EXPORT_SYMBOL_GPL(devlink_info_driver_name_put); int devlink_info_serial_number_put(struct devlink_info_req *req, const char *sn) { + if (!req->msg) + return 0; return nla_put_string(req->msg, DEVLINK_ATTR_INFO_SERIAL_NUMBER, sn); } EXPORT_SYMBOL_GPL(devlink_info_serial_number_put); @@ -6572,6 +6634,8 @@ EXPORT_SYMBOL_GPL(devlink_info_serial_number_put); int devlink_info_board_serial_number_put(struct devlink_info_req *req, const char *bsn) { + if (!req->msg) + return 0; return nla_put_string(req->msg, DEVLINK_ATTR_INFO_BOARD_SERIAL_NUMBER, bsn); } @@ -6585,6 +6649,13 @@ static int devlink_info_version_put(struct devlink_info_req *req, int attr, struct nlattr *nest; int err; + if (req->version_cb) + req->version_cb(version_name, version_type, + req->version_cb_priv); + + if (!req->msg) + return 0; + nest = nla_nest_start_noflag(req->msg, attr); if (!nest) return -EMSGSIZE; @@ -6654,7 +6725,7 @@ devlink_nl_info_fill(struct sk_buff *msg, struct devlink *devlink, enum devlink_command cmd, u32 portid, u32 seq, int flags, struct netlink_ext_ack *extack) { - struct devlink_info_req req; + struct devlink_info_req req = {}; void *hdr; int err; @@ -12321,8 +12392,8 @@ EXPORT_SYMBOL_GPL(devl_trap_policers_unregister); static void __devlink_compat_running_version(struct devlink *devlink, char *buf, size_t len) { + struct devlink_info_req req = {}; const struct nlattr *nlattr; - struct devlink_info_req req; struct sk_buff *msg; int rem, err; From patchwork Mon Aug 22 17:02:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 12950951 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2186C28D13 for ; Mon, 22 Aug 2022 17:03:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236816AbiHVRDD (ORCPT ); Mon, 22 Aug 2022 13:03:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236319AbiHVRC5 (ORCPT ); Mon, 22 Aug 2022 13:02:57 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9D39419AF for ; Mon, 22 Aug 2022 10:02:56 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id w10so2637515edc.3 for ; Mon, 22 Aug 2022 10:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=hE3TQw40VsNVsq40Dxz5mY7v5/vs4c2dK5Xb3FNaFbo=; b=w9CRBRdQdXHl9tKMqAnFGYelqQHzctwthGq055QErkagbtq3sJE9pjnUs0ZbhuSw0P IzuARJMyhEC2y2l7twxBdM+sqYPlppKNjfKUoH55g0OfuWeJco9T6HNezBfkL+4IvW7M 5etAYhaBQ1O0U4i4HGXQwGusVuE+KfDM+hjZJzCP3Q/rxXektE8BW3yevdRE1wsChRNu mEYufKVLakSEquIfoIlpQ7BSbMH8TcQJAlc2b9BIj+eAYbYehykngYd46EgfTe8sufmn SDU4G0DEtK6eJgvO0XSwlIA7pPcUqg5ee4ZFnH2Fo3testJiwdU9kL22CnMvINUh7bIF py8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=hE3TQw40VsNVsq40Dxz5mY7v5/vs4c2dK5Xb3FNaFbo=; b=QGUrwlJlfX5izfUD7mDzgjOJ7lN0BwGwfUNLQWiVPnSgc3HZQocIjkFT9lm/5zcQFm KqWaAOUnFZlbMBm7bYXjOhSjkztm12Ug6ApqxPCezGClS2J+xIg2i0vUh+r/tXqxHyps bwfUkggY/CGBemog7ebgZy/Cvd9ij45qS+kDKTTJH2/q6tOlb5torpMjuVrWNvZZ4bVS HT9TaxFlyy9gvpLYgXARQzIlsGZY3JzQKb0WR7gfyOO+n+41siq9OU9W3EXp3/b+9e/t 91W9TCcth0tT2KwklTsCaBwlCl4JiG4FPw5M54+qm2BJ4Mg1oVqrUnAaj7vAHBokGKEo MNAA== X-Gm-Message-State: ACgBeo08pMIO1OtN0oCA17aH1kgAGXMLTlRGFWGu+ZH5/OG7jD+da4iN tWGKrCrVIH1uDed7z3plTvnPXxv/PHaWEDGD X-Google-Smtp-Source: AA6agR4NI+5Spb/tn57UQRxuUDE7y8rpXEcR6EvWv3WTKlnZPmLddLMV/+n0jR+rcSWhEh0//D4NZA== X-Received: by 2002:a05:6402:206b:b0:446:ce5d:3e60 with SMTP id bd11-20020a056402206b00b00446ce5d3e60mr97523edb.139.1661187775308; Mon, 22 Aug 2022 10:02:55 -0700 (PDT) Received: from localhost (host-213-179-129-39.customer.m-online.net. [213.179.129.39]) by smtp.gmail.com with ESMTPSA id c15-20020a170906694f00b0073d6cfdc44dsm3102589ejs.115.2022.08.22.10.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 10:02:54 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, idosch@nvidia.com, pabeni@redhat.com, edumazet@google.com, saeedm@nvidia.com, jacob.e.keller@intel.com, vikas.gupta@broadcom.com, gospo@broadcom.com Subject: [patch net-next v2 4/4] net: devlink: expose the info about version representing a component Date: Mon, 22 Aug 2022 19:02:47 +0200 Message-Id: <20220822170247.974743-5-jiri@resnulli.us> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220822170247.974743-1-jiri@resnulli.us> References: <20220822170247.974743-1-jiri@resnulli.us> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko If certain version exposed by a driver is marked to be representing a component, expose this info to the user. Example: $ devlink dev info netdevsim/netdevsim10: driver netdevsim versions: running: fw.mgmt 10.20.30 flash_components: fw.mgmt Signed-off-by: Jiri Pirko --- include/uapi/linux/devlink.h | 2 ++ net/core/devlink.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index 2f24b53a87a5..7f2874189188 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -607,6 +607,8 @@ enum devlink_attr { DEVLINK_ATTR_SELFTESTS, /* nested */ + DEVLINK_ATTR_INFO_VERSION_IS_COMPONENT, /* u8 0 or 1 */ + /* add new attributes above here, update the policy in devlink.c */ __DEVLINK_ATTR_MAX, diff --git a/net/core/devlink.c b/net/core/devlink.c index 17b78123ad9d..23a5fd92ecaa 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -6670,6 +6670,11 @@ static int devlink_info_version_put(struct devlink_info_req *req, int attr, if (err) goto nla_put_failure; + err = nla_put_u8(req->msg, DEVLINK_ATTR_INFO_VERSION_IS_COMPONENT, + version_type == DEVLINK_INFO_VERSION_TYPE_COMPONENT); + if (err) + goto nla_put_failure; + nla_nest_end(req->msg, nest); return 0;