From patchwork Thu Sep 17 03:02:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 1365784 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=pensando.io Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=pensando.io header.i=@pensando.io header.a=rsa-sha256 header.s=google header.b=YiBK8n1I; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BsMNT1Yl9z9sTQ for ; Thu, 17 Sep 2020 13:08:09 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726097AbgIQDIE (ORCPT ); Wed, 16 Sep 2020 23:08:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726002AbgIQDIB (ORCPT ); Wed, 16 Sep 2020 23:08:01 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8581BC061356 for ; Wed, 16 Sep 2020 20:02:14 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id u9so350736plk.4 for ; Wed, 16 Sep 2020 20:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GeBC5SZMySgUGL1jC0oi+rfcsEQ+xVNDU0XKznJ0qkE=; b=YiBK8n1I/wuCAWLRBCit/H6omZv+YnIT9D9O1n0D+HxrANZzRmuekWyBYyyUQ5lmVE t7RylX6BaazSSIqntMaac8OsqP/UytuLnI1hp9EDmq3NEnLtrMSuzz23cUXKlG4KY8wk cDh5S0hgpL9q7HO3hQ15wV5UdUsN9/dATNgyZg53ffiZrkwMvOhKzOGqpdtujxddnQZL QaTjbm3li/aoDSk+qI2qirJPWm5wI19ZhUYoHISY2cmOGk1DFjy4uQ2fC5po44fqlsII ENAmBgq6LyVDbFTwITgYeW1brfwmnLnpVVDvpgNkGMoAo/3p1PJiABqtocLMd2u5LHx/ JQ6Q== 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; bh=GeBC5SZMySgUGL1jC0oi+rfcsEQ+xVNDU0XKznJ0qkE=; b=eNugT3pZruzAxKTv7ZOtNetZPWJN43QwyNYPjHRqeWoZjAPG5+JafF/kdTSsfC6SK8 WJpiMidqr6SbIjpGgcIGbDK1iyQwDai/e6rrRGHNt1+Dok13mBwCyagGwL3vQVs1Lulp 9ZZ68VHUMI58LXuvXkrPkI4Cr//Lh915Zeerglj0Z/WGA+Bhw6Mm8mBlDr7aZX9QLfK+ DoZZA8DiMDZEYXBsttC4gqPLUFXfM3sYF9sSG6HRgqvIpE3+Mevl0RlZ+ZfIZFlHPPaM IBpR3cdT6k3+RjbMBOmBnY0ps/U/9SMwVjHgGCsEIKlDDpuCViXIdYRamfcrsoHlMjOy w5CA== X-Gm-Message-State: AOAM531BSn7b3t7cm6DYpYtzDvJ5veOgFheBCwbSXWjAPMJ2pMHbP7lK TjsGke6JI11+Yl5jmsCjVWNU7S19hXTBAQ== X-Google-Smtp-Source: ABdhPJzUILzsHNzgD3kGHIk+m/0yoppn46ogLqS4DxmvumP+WhEnm8jzrcbKJbRZCMHomCDwmNO0gw== X-Received: by 2002:a17:90a:e98d:: with SMTP id v13mr6399048pjy.79.1600311733772; Wed, 16 Sep 2020 20:02:13 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id b2sm12072498pfp.3.2020.09.16.20.02.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 20:02:12 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net Cc: Shannon Nelson Subject: [PATCH v4 net-next 1/5] devlink: add timeout information to status_notify Date: Wed, 16 Sep 2020 20:02:00 -0700 Message-Id: <20200917030204.50098-2-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200917030204.50098-1-snelson@pensando.io> References: <20200917030204.50098-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add a timeout element to the DEVLINK_CMD_FLASH_UPDATE_STATUS netlink message for use by a userland utility to show that a particular firmware flash activity may take a long but bounded time to finish. Also add a handy helper for drivers to make use of the new timeout value. UI usage hints: - if non-zero, add timeout display to the end of the status line [component] status_msg ( Xm Ys : Am Bs ) using the timeout value for Am Bs and updating the Xm Ys every second - if the timeout expires while awaiting the next update, display something like [component] status_msg ( timeout reached : Am Bs ) - if new status notify messages are received, remove the timeout and start over Signed-off-by: Shannon Nelson Reviewed-by: Jakub Kicinski Reviewed-by: Jacob Keller --- include/net/devlink.h | 4 ++++ include/uapi/linux/devlink.h | 3 +++ net/core/devlink.c | 29 +++++++++++++++++++++++------ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/include/net/devlink.h b/include/net/devlink.h index eaec0a8cc5ef..f206accf80ad 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1400,6 +1400,10 @@ void devlink_flash_update_status_notify(struct devlink *devlink, const char *component, unsigned long done, unsigned long total); +void devlink_flash_update_timeout_notify(struct devlink *devlink, + const char *status_msg, + const char *component, + unsigned long timeout); int devlink_traps_register(struct devlink *devlink, const struct devlink_trap *traps, diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index 40d35145c879..4a6e213cfa04 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -460,6 +460,9 @@ enum devlink_attr { DEVLINK_ATTR_PORT_EXTERNAL, /* u8 */ DEVLINK_ATTR_PORT_CONTROLLER_NUMBER, /* u32 */ + + DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT, /* u64 */ + /* 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 19037f114307..01f855e53e06 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -3024,7 +3024,9 @@ static int devlink_nl_flash_update_fill(struct sk_buff *msg, enum devlink_command cmd, const char *status_msg, const char *component, - unsigned long done, unsigned long total) + unsigned long done, + unsigned long total, + unsigned long timeout) { void *hdr; @@ -3052,6 +3054,9 @@ static int devlink_nl_flash_update_fill(struct sk_buff *msg, if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL, total, DEVLINK_ATTR_PAD)) goto nla_put_failure; + if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT, + timeout, DEVLINK_ATTR_PAD)) + goto nla_put_failure; out: genlmsg_end(msg, hdr); @@ -3067,7 +3072,8 @@ static void __devlink_flash_update_notify(struct devlink *devlink, const char *status_msg, const char *component, unsigned long done, - unsigned long total) + unsigned long total, + unsigned long timeout) { struct sk_buff *msg; int err; @@ -3081,7 +3087,7 @@ static void __devlink_flash_update_notify(struct devlink *devlink, return; err = devlink_nl_flash_update_fill(msg, devlink, cmd, status_msg, - component, done, total); + component, done, total, timeout); if (err) goto out_free_msg; @@ -3097,7 +3103,7 @@ void devlink_flash_update_begin_notify(struct devlink *devlink) { __devlink_flash_update_notify(devlink, DEVLINK_CMD_FLASH_UPDATE, - NULL, NULL, 0, 0); + NULL, NULL, 0, 0, 0); } EXPORT_SYMBOL_GPL(devlink_flash_update_begin_notify); @@ -3105,7 +3111,7 @@ void devlink_flash_update_end_notify(struct devlink *devlink) { __devlink_flash_update_notify(devlink, DEVLINK_CMD_FLASH_UPDATE_END, - NULL, NULL, 0, 0); + NULL, NULL, 0, 0, 0); } EXPORT_SYMBOL_GPL(devlink_flash_update_end_notify); @@ -3117,10 +3123,21 @@ void devlink_flash_update_status_notify(struct devlink *devlink, { __devlink_flash_update_notify(devlink, DEVLINK_CMD_FLASH_UPDATE_STATUS, - status_msg, component, done, total); + status_msg, component, done, total, 0); } EXPORT_SYMBOL_GPL(devlink_flash_update_status_notify); +void devlink_flash_update_timeout_notify(struct devlink *devlink, + const char *status_msg, + const char *component, + unsigned long timeout) +{ + __devlink_flash_update_notify(devlink, + DEVLINK_CMD_FLASH_UPDATE_STATUS, + status_msg, component, 0, 0, timeout); +} +EXPORT_SYMBOL_GPL(devlink_flash_update_timeout_notify); + static int devlink_nl_cmd_flash_update(struct sk_buff *skb, struct genl_info *info) { From patchwork Thu Sep 17 03:02:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 1365788 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=pensando.io Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=pensando.io header.i=@pensando.io header.a=rsa-sha256 header.s=google header.b=hZF/z7Tl; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BsMNn4YlWz9sTQ for ; Thu, 17 Sep 2020 13:08:25 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726170AbgIQDIY (ORCPT ); Wed, 16 Sep 2020 23:08:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725858AbgIQDII (ORCPT ); Wed, 16 Sep 2020 23:08:08 -0400 X-Greylist: delayed 413 seconds by postgrey-1.27 at vger.kernel.org; Wed, 16 Sep 2020 23:08:02 EDT Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56E88C0612F2 for ; Wed, 16 Sep 2020 20:02:16 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id y6so336966plt.9 for ; Wed, 16 Sep 2020 20:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2w1n/UNGFvfdJeXM8PGLXzwznjiLAcdbCmfR6hGUsw8=; b=hZF/z7Tl0eMRaWzsy4eIiwjv/kZhVvAZpIwAHKKEYUtmTJMgnPhgUC1CX2lmWnyG9A NROG6SziuqWRfYZuToN2Z31wpe4OPPz0PD1iDhoj4kR4WZlTeB12tdFo4n8eKQjvoeKq SDBSX2Wv4fAiH7aueMZXQ/ORpmKZxNPek/PQUR2Sgrgb7wUXmoUFWzTqGKPCmjYbwAi3 J2OjzVneXLJ68zpICuCmgSEyWaPMGFgbqX+zwui0sEg4U45TdGhy/8M+F7Z9iPyPAIkG q45rF0QzMCO0dPUsZplpXJUVKzlPdeRgpMD32zGeLDuRwtuUvGNUB6zQ4PMxXBXGUOsS VFQg== 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; bh=2w1n/UNGFvfdJeXM8PGLXzwznjiLAcdbCmfR6hGUsw8=; b=ujJWelgoMM6geyS/FWPFfHEkGNZ2O8yRmONooz16vIXNX6IW9dRfjAi8O9TbooJxjO GndjbN2kmCmj0four1cz4rAtOF6XbF1O1/VgCL9LcrqeInMrjVWZU3F10xwSQJZ2VkCc 3i95WYGNHRK/flLGAk/+E8E2u+E5y/dX2gWIU0/CQs7SOwu7FPatXRV+4cGou05DK1+K x7QkAtAWNAJbvfsRvfBVX2v/KF5byxBEVVfd0jZ9f2BwJiO+aklwwJDqGYpvCVuCAaqg d+3dSibxWBijWNXRsv6C+0PYFR4OPI3UVj8zmBi8DPFvfsZUEJ0cJVhk/mKzcKwKGO3o HPqA== X-Gm-Message-State: AOAM531lqUX+JZHcqHZpyutal62u0o4o/WustH0UHGOkwm4wvoyYtOL1 eqhUyxlYvl5cCHx8I1MPbHSGpY6Vnm0u3w== X-Google-Smtp-Source: ABdhPJzEVKJuTOL8H3mvy8bcGG/ZgVwCneZdvVt2ShMBoREXHRezxYYV452zH29S+Fn/KvJWcpxj4g== X-Received: by 2002:a17:90b:707:: with SMTP id s7mr6629847pjz.25.1600311734801; Wed, 16 Sep 2020 20:02:14 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id b2sm12072498pfp.3.2020.09.16.20.02.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 20:02:14 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net Cc: Shannon Nelson Subject: [PATCH v4 net-next 2/5] devlink: collect flash notify params into a struct Date: Wed, 16 Sep 2020 20:02:01 -0700 Message-Id: <20200917030204.50098-3-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200917030204.50098-1-snelson@pensando.io> References: <20200917030204.50098-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The dev flash status notify function parameter lists are getting rather long, so add a struct to be filled and passed rather than continuously changing the function signatures. Signed-off-by: Shannon Nelson Reviewed-by: Jacob Keller --- include/net/devlink.h | 21 ++++++++++++ net/core/devlink.c | 80 +++++++++++++++++++++++-------------------- 2 files changed, 63 insertions(+), 38 deletions(-) diff --git a/include/net/devlink.h b/include/net/devlink.h index f206accf80ad..9ab2014885cb 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -391,6 +391,27 @@ struct devlink_param_gset_ctx { enum devlink_param_cmode cmode; }; +/** + * struct devlink_flash_notify - devlink dev flash notify data + * @cmd: devlink notify command code + * @status_msg: current status string + * @component: firmware component being updated + * @done: amount of work completed of total amount + * @total: amount of work expected to be done + * @timeout: expected max timeout in seconds + * + * These are values to be given to userland to be displayed in order + * to show current activity in a firmware update process. + */ +struct devlink_flash_notify { + enum devlink_command cmd; + const char *status_msg; + const char *component; + unsigned long done; + unsigned long total; + unsigned long timeout; +}; + /** * struct devlink_param - devlink configuration parameter data * @name: name of the parameter diff --git a/net/core/devlink.c b/net/core/devlink.c index 01f855e53e06..816f27a18b16 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -3021,41 +3021,36 @@ static int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info) static int devlink_nl_flash_update_fill(struct sk_buff *msg, struct devlink *devlink, - enum devlink_command cmd, - const char *status_msg, - const char *component, - unsigned long done, - unsigned long total, - unsigned long timeout) + struct devlink_flash_notify *params) { void *hdr; - hdr = genlmsg_put(msg, 0, 0, &devlink_nl_family, 0, cmd); + hdr = genlmsg_put(msg, 0, 0, &devlink_nl_family, 0, params->cmd); if (!hdr) return -EMSGSIZE; if (devlink_nl_put_handle(msg, devlink)) goto nla_put_failure; - if (cmd != DEVLINK_CMD_FLASH_UPDATE_STATUS) + if (params->cmd != DEVLINK_CMD_FLASH_UPDATE_STATUS) goto out; - if (status_msg && + if (params->status_msg && nla_put_string(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_MSG, - status_msg)) + params->status_msg)) goto nla_put_failure; - if (component && + if (params->component && nla_put_string(msg, DEVLINK_ATTR_FLASH_UPDATE_COMPONENT, - component)) + params->component)) goto nla_put_failure; if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_DONE, - done, DEVLINK_ATTR_PAD)) + params->done, DEVLINK_ATTR_PAD)) goto nla_put_failure; if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL, - total, DEVLINK_ATTR_PAD)) + params->total, DEVLINK_ATTR_PAD)) goto nla_put_failure; if (nla_put_u64_64bit(msg, DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT, - timeout, DEVLINK_ATTR_PAD)) + params->timeout, DEVLINK_ATTR_PAD)) goto nla_put_failure; out: @@ -3068,26 +3063,20 @@ static int devlink_nl_flash_update_fill(struct sk_buff *msg, } static void __devlink_flash_update_notify(struct devlink *devlink, - enum devlink_command cmd, - const char *status_msg, - const char *component, - unsigned long done, - unsigned long total, - unsigned long timeout) + struct devlink_flash_notify *params) { struct sk_buff *msg; int err; - WARN_ON(cmd != DEVLINK_CMD_FLASH_UPDATE && - cmd != DEVLINK_CMD_FLASH_UPDATE_END && - cmd != DEVLINK_CMD_FLASH_UPDATE_STATUS); + WARN_ON(params->cmd != DEVLINK_CMD_FLASH_UPDATE && + params->cmd != DEVLINK_CMD_FLASH_UPDATE_END && + params->cmd != DEVLINK_CMD_FLASH_UPDATE_STATUS); msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); if (!msg) return; - err = devlink_nl_flash_update_fill(msg, devlink, cmd, status_msg, - component, done, total, timeout); + err = devlink_nl_flash_update_fill(msg, devlink, params); if (err) goto out_free_msg; @@ -3101,17 +3090,21 @@ static void __devlink_flash_update_notify(struct devlink *devlink, void devlink_flash_update_begin_notify(struct devlink *devlink) { - __devlink_flash_update_notify(devlink, - DEVLINK_CMD_FLASH_UPDATE, - NULL, NULL, 0, 0, 0); + struct devlink_flash_notify params = { + .cmd = DEVLINK_CMD_FLASH_UPDATE, + }; + + __devlink_flash_update_notify(devlink, ¶ms); } EXPORT_SYMBOL_GPL(devlink_flash_update_begin_notify); void devlink_flash_update_end_notify(struct devlink *devlink) { - __devlink_flash_update_notify(devlink, - DEVLINK_CMD_FLASH_UPDATE_END, - NULL, NULL, 0, 0, 0); + struct devlink_flash_notify params = { + .cmd = DEVLINK_CMD_FLASH_UPDATE_END, + }; + + __devlink_flash_update_notify(devlink, ¶ms); } EXPORT_SYMBOL_GPL(devlink_flash_update_end_notify); @@ -3121,9 +3114,15 @@ void devlink_flash_update_status_notify(struct devlink *devlink, unsigned long done, unsigned long total) { - __devlink_flash_update_notify(devlink, - DEVLINK_CMD_FLASH_UPDATE_STATUS, - status_msg, component, done, total, 0); + struct devlink_flash_notify params = { + .cmd = DEVLINK_CMD_FLASH_UPDATE_STATUS, + .status_msg = status_msg, + .component = component, + .done = done, + .total = total, + }; + + __devlink_flash_update_notify(devlink, ¶ms); } EXPORT_SYMBOL_GPL(devlink_flash_update_status_notify); @@ -3132,9 +3131,14 @@ void devlink_flash_update_timeout_notify(struct devlink *devlink, const char *component, unsigned long timeout) { - __devlink_flash_update_notify(devlink, - DEVLINK_CMD_FLASH_UPDATE_STATUS, - status_msg, component, 0, 0, timeout); + struct devlink_flash_notify params = { + .cmd = DEVLINK_CMD_FLASH_UPDATE_STATUS, + .status_msg = status_msg, + .component = component, + .timeout = timeout, + }; + + __devlink_flash_update_notify(devlink, ¶ms); } EXPORT_SYMBOL_GPL(devlink_flash_update_timeout_notify); From patchwork Thu Sep 17 03:02:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 1365789 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=pensando.io Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=pensando.io header.i=@pensando.io header.a=rsa-sha256 header.s=google header.b=I0u4Yv3s; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BsMNs40c9z9sTS for ; Thu, 17 Sep 2020 13:08:29 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726142AbgIQDIS (ORCPT ); Wed, 16 Sep 2020 23:08:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbgIQDIG (ORCPT ); Wed, 16 Sep 2020 23:08:06 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47674C06121C for ; Wed, 16 Sep 2020 20:02:17 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id m15so340552pls.8 for ; Wed, 16 Sep 2020 20:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VESNo/2OJz/Sp8yXsIXxgqMsPsVudyZ4n86jws0CmLQ=; b=I0u4Yv3szXahKg0W+sFtoLebtewtNlyhaxlEq9HLv7hSB8tsmN0TE/8EUfMpRgr1Z3 CTCo+PNo/lE/R+8LC8m9YtZapBxaocjFMxtCdIULm06QVIm3vp3SX+fDD0kiQot6bN4I WyztwDXU02+5t+/XDgov3Cz7Wfmbq05LSLBAMPHukMgK9n6xNzneOuwrtMNDtxKTER+/ UPbrIzsezIIV11ZsLKi6kPokpVKGw2qRDHuP68Sgmt1KIGENCdW04maJu8jyOVeb4hbT 5Nm3X6tn3ByMv0wsafuKPVU4KDb8SEgVTX5E4+hs0hLksZ0YeqzhN9Ydr9yqpNDGjnu8 V1Jg== 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; bh=VESNo/2OJz/Sp8yXsIXxgqMsPsVudyZ4n86jws0CmLQ=; b=G8teCIPuycDuzcW+YpuZd6aMV6y3quvVTIg1NkqZoz/B33I7FU3AnSsH/aklJoFFZB kInKDttZvCy5VPROwRRleM2UnGzaGQskc+TU5b9sX1k6qnNeOk+ZGKTDs/LAxH01IrR4 7h8SvMPWuUXLwHSCOIoFHmCc9kHLiLBhjVoOXmBCDdBej8Jn66viq4kmGaSuX9QiF4zP Y/V9CVUH/qU7+7frBRq/9YH70WsWQe3RBP6h0lW96IDZM9Q89RkCzB5tdWgOSxlRl8Wa KUo8CAKqrK8ImfBgKNEi9nsxXCVjalEhbBdo33+44/nP9TSzu5zk40vJ1hDUQoZp9oD+ 8pRw== X-Gm-Message-State: AOAM530g2SY/9mKQIo0j50huYFV7vQdwZS0W5MwL4vpkJ/jT6Z1uD3wM m7lHSDWbhuKQVRucx+mdkkumkeg7hR1jYQ== X-Google-Smtp-Source: ABdhPJywVSoyUI4zFpbVqd0YKnaDv+DCfvMmSY9ShVyhQpk8zLvaIeS8tibkKxNmI81mZ1GEAELMgw== X-Received: by 2002:a17:902:8602:b029:d1:e5e7:be65 with SMTP id f2-20020a1709028602b02900d1e5e7be65mr8999996plo.63.1600311736590; Wed, 16 Sep 2020 20:02:16 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id b2sm12072498pfp.3.2020.09.16.20.02.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 20:02:15 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net Cc: Shannon Nelson Subject: [PATCH v4 net-next 3/5] netdevsim: devlink flash timeout message Date: Wed, 16 Sep 2020 20:02:02 -0700 Message-Id: <20200917030204.50098-4-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200917030204.50098-1-snelson@pensando.io> References: <20200917030204.50098-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add a simple devlink flash timeout message to exercise the message mechanism. Signed-off-by: Shannon Nelson --- drivers/net/netdevsim/dev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index 32f339fedb21..4123550e3f6e 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -768,6 +768,8 @@ static int nsim_dev_flash_update(struct devlink *devlink, const char *file_name, component, NSIM_DEV_FLASH_SIZE, NSIM_DEV_FLASH_SIZE); + devlink_flash_update_timeout_notify(devlink, "Flash timeout", + component, 81); devlink_flash_update_status_notify(devlink, "Flashing done", component, 0, 0); devlink_flash_update_end_notify(devlink); From patchwork Thu Sep 17 03:02:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 1365786 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=pensando.io Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=pensando.io header.i=@pensando.io header.a=rsa-sha256 header.s=google header.b=wsTifUWu; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BsMNc4VMnz9sTQ for ; Thu, 17 Sep 2020 13:08:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726115AbgIQDIQ (ORCPT ); Wed, 16 Sep 2020 23:08:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbgIQDIE (ORCPT ); Wed, 16 Sep 2020 23:08:04 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3E4EC06121D for ; Wed, 16 Sep 2020 20:02:18 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id m15so340572pls.8 for ; Wed, 16 Sep 2020 20:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d5lh7dSTzYL1z77vtX8o0KhR/tEcPbvx+ghe0OFpwQg=; b=wsTifUWu0NhwLe+lG9x2ehjsCZyuf8lLDqq8vfkeMN60reKzcSGlXKw2kxapndmT8U s5eiWE4Q0GfPETJ1mkIOrofSoLxTk1PmRuyu/lUMGfvTQel4VsmpkmOe8S5XjUSNeB6r uaJ76nkKrSluPtYaW0YBfXRJWCyIS+NaALoL6A4heq4V1yGSKKjwN0GVqyY0hY8CGwm/ UuqwmGwnPFGwt2qHV8nImJalUKoerPNh1I/UaFFZiSYKiKB5uBT591LIu/Q/Tsti7drr JoJNk4d9YNshT8cEXhBJbsrXuahaibEHByG5bvZ0EojEzQGAQF+vkzU2Ki/2AZ/my74c pXkw== 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; bh=d5lh7dSTzYL1z77vtX8o0KhR/tEcPbvx+ghe0OFpwQg=; b=CbTWS6rnQL5UpGNeupehsxkZdgMyYByBXWp2U1XxVfOzBEZrw+6EiwT6tJLlii7bWT kyIRkVtzFYVNfUQpQzaNAiwd1DY1P02P/SLHvRg0rSJHJvUwASd8wrg/rGYGluWoUx8W Ql96+o4vsaG+Kag2scaw3YNys16CEUGGq/qY1XbaEVIwDiwuWlNlnnFxFNoc3PBrNHxT jrENMcXkoSYcYfDVxXwvupitX6NqCbbg10JqHeMoWu/NwPzIw2/AnirAIdANk+TCr2Fd aP583WSHP0NwYPYFQHT2bJMAyBviCQPVU8JzVyRLs8wWsefXiiA7gZYATBNZ97wyZygR vBxg== X-Gm-Message-State: AOAM533NEas1eJ2eGoaNP30evW8iTjNsnmtxcRfsateaBfxwt2i2LoTg YL94EYR4e50v6wMNVhs5ghmMgnje/tHDWQ== X-Google-Smtp-Source: ABdhPJwh3MtBCIEPyKg9g/9L5osMGFnR0YSL/Cp0E9jidMgQNI4Y8ihdVs1Dgmdu+rQ4IJzfkMANtg== X-Received: by 2002:a17:902:8545:b029:d1:f2e3:8dd4 with SMTP id d5-20020a1709028545b02900d1f2e38dd4mr4421493plo.65.1600311737947; Wed, 16 Sep 2020 20:02:17 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id b2sm12072498pfp.3.2020.09.16.20.02.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 20:02:17 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net Cc: Shannon Nelson Subject: [PATCH v4 net-next 4/5] ionic: update the fw update api Date: Wed, 16 Sep 2020 20:02:03 -0700 Message-Id: <20200917030204.50098-5-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200917030204.50098-1-snelson@pensando.io> References: <20200917030204.50098-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add the rest of the firmware api bits needed to support the driver running a firmware update. Signed-off-by: Shannon Nelson --- .../net/ethernet/pensando/ionic/ionic_if.h | 33 ++++++++++++++----- .../net/ethernet/pensando/ionic/ionic_main.c | 4 +++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_if.h b/drivers/net/ethernet/pensando/ionic/ionic_if.h index acc94b244cf3..5bb56a27a50d 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_if.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_if.h @@ -63,8 +63,10 @@ enum ionic_cmd_opcode { IONIC_CMD_QOS_RESET = 245, /* Firmware commands */ - IONIC_CMD_FW_DOWNLOAD = 254, - IONIC_CMD_FW_CONTROL = 255, + IONIC_CMD_FW_DOWNLOAD = 252, + IONIC_CMD_FW_CONTROL = 253, + IONIC_CMD_FW_DOWNLOAD_V1 = 254, + IONIC_CMD_FW_CONTROL_V1 = 255, }; /** @@ -2069,14 +2071,23 @@ typedef struct ionic_admin_comp ionic_fw_download_comp; /** * enum ionic_fw_control_oper - FW control operations - * @IONIC_FW_RESET: Reset firmware - * @IONIC_FW_INSTALL: Install firmware - * @IONIC_FW_ACTIVATE: Activate firmware + * @IONIC_FW_RESET: Reset firmware + * @IONIC_FW_INSTALL: Install firmware + * @IONIC_FW_ACTIVATE: Activate firmware + * @IONIC_FW_INSTALL_ASYNC: Install firmware asynchronously + * @IONIC_FW_INSTALL_STATUS: Firmware installation status + * @IONIC_FW_ACTIVATE_ASYNC: Activate firmware asynchronously + * @IONIC_FW_ACTIVATE_STATUS: Firmware activate status */ enum ionic_fw_control_oper { - IONIC_FW_RESET = 0, - IONIC_FW_INSTALL = 1, - IONIC_FW_ACTIVATE = 2, + IONIC_FW_RESET = 0, + IONIC_FW_INSTALL = 1, + IONIC_FW_ACTIVATE = 2, + IONIC_FW_INSTALL_ASYNC = 3, + IONIC_FW_INSTALL_STATUS = 4, + IONIC_FW_ACTIVATE_ASYNC = 5, + IONIC_FW_ACTIVATE_STATUS = 6, + IONIC_FW_UPDATE_CLEANUP = 7, }; /** @@ -2689,6 +2700,9 @@ union ionic_dev_cmd { struct ionic_q_identify_cmd q_identify; struct ionic_q_init_cmd q_init; struct ionic_q_control_cmd q_control; + + struct ionic_fw_download_cmd fw_download; + struct ionic_fw_control_cmd fw_control; }; union ionic_dev_cmd_comp { @@ -2722,6 +2736,9 @@ union ionic_dev_cmd_comp { struct ionic_q_identify_comp q_identify; struct ionic_q_init_comp q_init; + + ionic_fw_download_comp fw_download; + struct ionic_fw_control_comp fw_control; }; /** diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c index cfb90bf605fe..99e9dd15a303 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c @@ -170,6 +170,10 @@ static const char *ionic_opcode_to_str(enum ionic_cmd_opcode opcode) return "IONIC_CMD_FW_DOWNLOAD"; case IONIC_CMD_FW_CONTROL: return "IONIC_CMD_FW_CONTROL"; + case IONIC_CMD_FW_DOWNLOAD_V1: + return "IONIC_CMD_FW_DOWNLOAD_V1"; + case IONIC_CMD_FW_CONTROL_V1: + return "IONIC_CMD_FW_CONTROL_V1"; case IONIC_CMD_VF_GETATTR: return "IONIC_CMD_VF_GETATTR"; case IONIC_CMD_VF_SETATTR: From patchwork Thu Sep 17 03:02:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Nelson X-Patchwork-Id: 1365785 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=pensando.io Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=pensando.io header.i=@pensando.io header.a=rsa-sha256 header.s=google header.b=us5wky7n; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BsMNV0bL9z9sTS for ; Thu, 17 Sep 2020 13:08:10 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726055AbgIQDII (ORCPT ); Wed, 16 Sep 2020 23:08:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726007AbgIQDIB (ORCPT ); Wed, 16 Sep 2020 23:08:01 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24BDBC06121E for ; Wed, 16 Sep 2020 20:02:20 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id x123so297719pfc.7 for ; Wed, 16 Sep 2020 20:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z/biRr2gfnCnTs7yX/rFy/CA+d7qiqpvAKA568Ikjq4=; b=us5wky7nYPlCS8JnVe2CS4s/1mqlw1Nr8VM0vA3Xws4Zk/UxdMjn64QVifi/54Nc3U 2YhAR9jOeYAa2sA+nKWfZ+y2RvnVE462HtIBQBoHBJ2zUJ8NF2BswZ0jE3+a6AtiOAC/ MDKkM6unjTANPh8RmTcu2BrC1e5eHjhKyxjOt2eNtHd3OZYSmHs9eOh2RTaejlD7dGOG rK1eG86f8c/J8htDhGDx1sdXcDAuSopb2e0cAes3q4tkFPQ5XGYwpwNy70GCl7W8lJXg vrVDfw/s96zjJgAACX22n6m0zF6oH9+bAJPw5DcfPH60XqfwfXRnAIfRe2dAo0UN2y7k V4jw== 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; bh=Z/biRr2gfnCnTs7yX/rFy/CA+d7qiqpvAKA568Ikjq4=; b=QFQIqUz6LJqcwvO/9W6j1jTygMghq68Z/U8KnS1DksD6eOtMnwoqA4pFmftmlJFPBo SJ8664aRcBC+NFSEjiXqLq+ekpCM4mn2SuW4T3imxroV4G9MNHjVi5zJKSQDR6GWuMKC dW3L7Hz2JZiQcxNTHMKQ3HCSx4QEoysAYsP/wXVN09gjez/k2Zo0hTX2CDxSh21bVNPa eEdXw0bZArrXUqgVHJIoX7EXDC7XSXYXpvb8Pr25lnA6lnQmc4QQLKtplNLKxcyIJvZq jitNWzFOkuhyYtFYbOX2TDRg4v6Uiwmt3jG2Il4zNcaBNOJh1fGfHaBAY390RTwc8bIB 0uqg== X-Gm-Message-State: AOAM530fQUmR5SPlcRHzqslyFXWoM5UY2UgeogZyzifL2eZ52SAlDefu QK1gssdfYrE1OZ26HzpjJ3qpAA6s+yu6PQ== X-Google-Smtp-Source: ABdhPJxKAQri0T7+B6WmE9pFKT09Z3BH5zILZE2KW8E4M6owbLMak7cnpQ0sH45Mn9kFhh4Qorc2uA== X-Received: by 2002:a63:d841:: with SMTP id k1mr4213641pgj.59.1600311739133; Wed, 16 Sep 2020 20:02:19 -0700 (PDT) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id b2sm12072498pfp.3.2020.09.16.20.02.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2020 20:02:18 -0700 (PDT) From: Shannon Nelson To: netdev@vger.kernel.org, davem@davemloft.net Cc: Shannon Nelson Subject: [PATCH v4 net-next 5/5] ionic: add devlink firmware update Date: Wed, 16 Sep 2020 20:02:04 -0700 Message-Id: <20200917030204.50098-6-snelson@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200917030204.50098-1-snelson@pensando.io> References: <20200917030204.50098-1-snelson@pensando.io> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add support for firmware update through the devlink interface. This update copies the firmware object into the device, asks the current firmware to install it, then asks the firmware to select the new firmware for the next boot-up. The install and select steps are launched as asynchronous requests, which are then followed up with status request commands. These status request commands will be answered with an EAGAIN return value and will try again until the request has completed or reached the timeout specified. Signed-off-by: Shannon Nelson Acked-by: Jakub Kicinski --- drivers/net/ethernet/pensando/ionic/Makefile | 2 +- .../ethernet/pensando/ionic/ionic_devlink.c | 14 ++ .../ethernet/pensando/ionic/ionic_devlink.h | 3 + .../net/ethernet/pensando/ionic/ionic_fw.c | 206 ++++++++++++++++++ .../net/ethernet/pensando/ionic/ionic_main.c | 23 +- 5 files changed, 239 insertions(+), 9 deletions(-) create mode 100644 drivers/net/ethernet/pensando/ionic/ionic_fw.c diff --git a/drivers/net/ethernet/pensando/ionic/Makefile b/drivers/net/ethernet/pensando/ionic/Makefile index 29f304d75261..8d3c2d3cb10d 100644 --- a/drivers/net/ethernet/pensando/ionic/Makefile +++ b/drivers/net/ethernet/pensando/ionic/Makefile @@ -5,4 +5,4 @@ obj-$(CONFIG_IONIC) := ionic.o ionic-y := ionic_main.o ionic_bus_pci.o ionic_devlink.o ionic_dev.o \ ionic_debugfs.o ionic_lif.o ionic_rx_filter.o ionic_ethtool.o \ - ionic_txrx.o ionic_stats.o + ionic_txrx.o ionic_stats.o ionic_fw.o diff --git a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c index 8d9fb2e19cca..5348f05ebc32 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c @@ -9,6 +9,19 @@ #include "ionic_lif.h" #include "ionic_devlink.h" +static int ionic_dl_flash_update(struct devlink *dl, + const char *fwname, + const char *component, + struct netlink_ext_ack *extack) +{ + struct ionic *ionic = devlink_priv(dl); + + if (component) + return -EOPNOTSUPP; + + return ionic_firmware_update(ionic->lif, fwname, extack); +} + static int ionic_dl_info_get(struct devlink *dl, struct devlink_info_req *req, struct netlink_ext_ack *extack) { @@ -48,6 +61,7 @@ static int ionic_dl_info_get(struct devlink *dl, struct devlink_info_req *req, static const struct devlink_ops ionic_dl_ops = { .info_get = ionic_dl_info_get, + .flash_update = ionic_dl_flash_update, }; struct ionic *ionic_devlink_alloc(struct device *dev) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_devlink.h b/drivers/net/ethernet/pensando/ionic/ionic_devlink.h index 0690172fc57a..5c01a9e306d8 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_devlink.h +++ b/drivers/net/ethernet/pensando/ionic/ionic_devlink.h @@ -6,6 +6,9 @@ #include +int ionic_firmware_update(struct ionic_lif *lif, const char *fw_name, + struct netlink_ext_ack *extack); + struct ionic *ionic_devlink_alloc(struct device *dev); void ionic_devlink_free(struct ionic *ionic); int ionic_devlink_register(struct ionic *ionic); diff --git a/drivers/net/ethernet/pensando/ionic/ionic_fw.c b/drivers/net/ethernet/pensando/ionic/ionic_fw.c new file mode 100644 index 000000000000..f492ae406a60 --- /dev/null +++ b/drivers/net/ethernet/pensando/ionic/ionic_fw.c @@ -0,0 +1,206 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2020 Pensando Systems, Inc */ + +#include +#include +#include +#include + +#include "ionic.h" +#include "ionic_dev.h" +#include "ionic_lif.h" +#include "ionic_devlink.h" + +/* The worst case wait for the install activity is about 25 minutes when + * installing a new CPLD, which is very seldom. Normal is about 30-35 + * seconds. Since the driver can't tell if a CPLD update will happen we + * set the timeout for the ugly case. + */ +#define IONIC_FW_INSTALL_TIMEOUT (25 * 60) +#define IONIC_FW_SELECT_TIMEOUT 30 + +/* Number of periodic log updates during fw file download */ +#define IONIC_FW_INTERVAL_FRACTION 32 + +static void ionic_dev_cmd_firmware_download(struct ionic_dev *idev, u64 addr, + u32 offset, u32 length) +{ + union ionic_dev_cmd cmd = { + .fw_download.opcode = IONIC_CMD_FW_DOWNLOAD, + .fw_download.offset = offset, + .fw_download.addr = addr, + .fw_download.length = length + }; + + ionic_dev_cmd_go(idev, &cmd); +} + +static void ionic_dev_cmd_firmware_install(struct ionic_dev *idev) +{ + union ionic_dev_cmd cmd = { + .fw_control.opcode = IONIC_CMD_FW_CONTROL, + .fw_control.oper = IONIC_FW_INSTALL_ASYNC + }; + + ionic_dev_cmd_go(idev, &cmd); +} + +static void ionic_dev_cmd_firmware_activate(struct ionic_dev *idev, u8 slot) +{ + union ionic_dev_cmd cmd = { + .fw_control.opcode = IONIC_CMD_FW_CONTROL, + .fw_control.oper = IONIC_FW_ACTIVATE_ASYNC, + .fw_control.slot = slot + }; + + ionic_dev_cmd_go(idev, &cmd); +} + +static int ionic_fw_status_long_wait(struct ionic *ionic, + const char *label, + unsigned long timeout, + u8 fw_cmd, + struct netlink_ext_ack *extack) +{ + union ionic_dev_cmd cmd = { + .fw_control.opcode = IONIC_CMD_FW_CONTROL, + .fw_control.oper = fw_cmd, + }; + unsigned long start_time; + unsigned long end_time; + int err; + + start_time = jiffies; + end_time = start_time + (timeout * HZ); + do { + mutex_lock(&ionic->dev_cmd_lock); + ionic_dev_cmd_go(&ionic->idev, &cmd); + err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT); + mutex_unlock(&ionic->dev_cmd_lock); + + msleep(20); + } while (time_before(jiffies, end_time) && (err == -EAGAIN || err == -ETIMEDOUT)); + + if (err == -EAGAIN || err == -ETIMEDOUT) { + NL_SET_ERR_MSG_MOD(extack, "Firmware wait timed out"); + dev_err(ionic->dev, "DEV_CMD firmware wait %s timed out\n", label); + } else if (err) { + NL_SET_ERR_MSG_MOD(extack, "Firmware wait failed"); + } + + return err; +} + +int ionic_firmware_update(struct ionic_lif *lif, const char *fw_name, + struct netlink_ext_ack *extack) +{ + struct ionic_dev *idev = &lif->ionic->idev; + struct net_device *netdev = lif->netdev; + struct ionic *ionic = lif->ionic; + union ionic_dev_cmd_comp comp; + u32 buf_sz, copy_sz, offset; + const struct firmware *fw; + struct devlink *dl; + int next_interval; + int err = 0; + u8 fw_slot; + + netdev_info(netdev, "Installing firmware %s\n", fw_name); + + dl = priv_to_devlink(ionic); + devlink_flash_update_begin_notify(dl); + devlink_flash_update_status_notify(dl, "Preparing to flash", NULL, 0, 0); + + err = request_firmware(&fw, fw_name, ionic->dev); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Unable to find firmware file"); + goto err_out; + } + + buf_sz = sizeof(idev->dev_cmd_regs->data); + + netdev_dbg(netdev, + "downloading firmware - size %d part_sz %d nparts %lu\n", + (int)fw->size, buf_sz, DIV_ROUND_UP(fw->size, buf_sz)); + + offset = 0; + next_interval = 0; + while (offset < fw->size) { + if (offset >= next_interval) { + devlink_flash_update_status_notify(dl, "Downloading", NULL, + offset, fw->size); + next_interval = offset + (fw->size / IONIC_FW_INTERVAL_FRACTION); + } + + copy_sz = min_t(unsigned int, buf_sz, fw->size - offset); + mutex_lock(&ionic->dev_cmd_lock); + memcpy_toio(&idev->dev_cmd_regs->data, fw->data + offset, copy_sz); + ionic_dev_cmd_firmware_download(idev, + offsetof(union ionic_dev_cmd_regs, data), + offset, copy_sz); + err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT); + mutex_unlock(&ionic->dev_cmd_lock); + if (err) { + netdev_err(netdev, + "download failed offset 0x%x addr 0x%lx len 0x%x\n", + offset, offsetof(union ionic_dev_cmd_regs, data), + copy_sz); + NL_SET_ERR_MSG_MOD(extack, "Segment download failed"); + goto err_out; + } + offset += copy_sz; + } + devlink_flash_update_status_notify(dl, "Downloading", NULL, + fw->size, fw->size); + + devlink_flash_update_timeout_notify(dl, "Installing", NULL, + IONIC_FW_INSTALL_TIMEOUT); + + mutex_lock(&ionic->dev_cmd_lock); + ionic_dev_cmd_firmware_install(idev); + err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT); + ionic_dev_cmd_comp(idev, (union ionic_dev_cmd_comp *)&comp); + fw_slot = comp.fw_control.slot; + mutex_unlock(&ionic->dev_cmd_lock); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Failed to start firmware install"); + goto err_out; + } + + err = ionic_fw_status_long_wait(ionic, "Installing", + IONIC_FW_INSTALL_TIMEOUT, + IONIC_FW_INSTALL_STATUS, + extack); + if (err) + goto err_out; + + devlink_flash_update_timeout_notify(dl, "Selecting", NULL, + IONIC_FW_SELECT_TIMEOUT); + + mutex_lock(&ionic->dev_cmd_lock); + ionic_dev_cmd_firmware_activate(idev, fw_slot); + err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT); + mutex_unlock(&ionic->dev_cmd_lock); + if (err) { + NL_SET_ERR_MSG_MOD(extack, "Failed to start firmware select"); + goto err_out; + } + + err = ionic_fw_status_long_wait(ionic, "Selecting", + IONIC_FW_SELECT_TIMEOUT, + IONIC_FW_ACTIVATE_STATUS, + extack); + if (err) + goto err_out; + + netdev_info(netdev, "Firmware update completed\n"); + +err_out: + if (err) + devlink_flash_update_status_notify(dl, "Flash failed", NULL, 0, 0); + else + devlink_flash_update_status_notify(dl, "Flash done", NULL, 0, 0); + release_firmware(fw); + devlink_flash_update_end_notify(dl); + return err; +} diff --git a/drivers/net/ethernet/pensando/ionic/ionic_main.c b/drivers/net/ethernet/pensando/ionic/ionic_main.c index 99e9dd15a303..e339216949a6 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_main.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_main.c @@ -335,17 +335,22 @@ int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds) */ max_wait = jiffies + (max_seconds * HZ); try_again: + opcode = idev->dev_cmd_regs->cmd.cmd.opcode; start_time = jiffies; do { done = ionic_dev_cmd_done(idev); if (done) break; - msleep(5); - hb = ionic_heartbeat_check(ionic); + usleep_range(100, 200); + + /* Don't check the heartbeat on FW_CONTROL commands as they are + * notorious for interrupting the firmware's heartbeat update. + */ + if (opcode != IONIC_CMD_FW_CONTROL) + hb = ionic_heartbeat_check(ionic); } while (!done && !hb && time_before(jiffies, max_wait)); duration = jiffies - start_time; - opcode = idev->dev_cmd_regs->cmd.cmd.opcode; dev_dbg(ionic->dev, "DEVCMD %s (%d) done=%d took %ld secs (%ld jiffies)\n", ionic_opcode_to_str(opcode), opcode, done, duration / HZ, duration); @@ -369,8 +374,9 @@ int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds) err = ionic_dev_cmd_status(&ionic->idev); if (err) { - if (err == IONIC_RC_EAGAIN && !time_after(jiffies, max_wait)) { - dev_err(ionic->dev, "DEV_CMD %s (%d) error, %s (%d) retrying...\n", + if (err == IONIC_RC_EAGAIN && + time_before(jiffies, (max_wait - HZ))) { + dev_dbg(ionic->dev, "DEV_CMD %s (%d), %s (%d) retrying...\n", ionic_opcode_to_str(opcode), opcode, ionic_error_to_str(err), err); @@ -380,9 +386,10 @@ int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds) goto try_again; } - dev_err(ionic->dev, "DEV_CMD %s (%d) error, %s (%d) failed\n", - ionic_opcode_to_str(opcode), opcode, - ionic_error_to_str(err), err); + if (!(opcode == IONIC_CMD_FW_CONTROL && err == IONIC_RC_EAGAIN)) + dev_err(ionic->dev, "DEV_CMD %s (%d) error, %s (%d) failed\n", + ionic_opcode_to_str(opcode), opcode, + ionic_error_to_str(err), err); return ionic_error_to_errno(err); }