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=-8.5 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_MUTT 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 DA2CEC169C4 for ; Mon, 11 Feb 2019 16:54:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A56E121B69 for ; Mon, 11 Feb 2019 16:54:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="qW/IF47o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727123AbfBKQyk (ORCPT ); Mon, 11 Feb 2019 11:54:40 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:38932 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbfBKQyk (ORCPT ); Mon, 11 Feb 2019 11:54:40 -0500 Received: by mail-wm1-f66.google.com with SMTP id f16so18049177wmh.4 for ; Mon, 11 Feb 2019 08:54:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=y2xUfmBnXnA7bb6UgSHg5fGt3b4x11YVUQXrkFAg04g=; b=qW/IF47oOxrWLh52eEufvk4D1SCWDGZ1f8hFgvKidrz63LVkHyGHzqeDdpUnKW0vIs +xhQ+R6RnLB32wsHiHWvdAF3KNugKldeHqEY2b7NpSO6KylSI0QQnadIkVScmC7PZRqI uKr2XLwWnkONc3KEUDmrm8Hm2YL8vQkcYwjlu/lrGweSDg1u65aBQlCTUwULfUE1hgh0 vBnb8og3MjTCUtYJRs5CGsn94QrVZNpNnITRkKz4TQzw7lFfViXB+R0z+qtEsWUzQnX0 Ogluq3KgYZVvRO42xaIha0lZukO2kez6zNL0jBnerPvZIIhuY59f5OBTXxy505lBgZNI ke0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=y2xUfmBnXnA7bb6UgSHg5fGt3b4x11YVUQXrkFAg04g=; b=WbJK1nVRos7EVL386+ynpo2JidMzhhapnxe3xkSwdn2wwG9n4bc40JBeOdGpY49sbu RIcfVdk0lbxmVeA+tUlIux3EvT6QlrnMvrnbQNt4eyW4U08SCfJWMs3SfCX5mjVeX443 kwFsfCkcprmdN+poz6PyWcAEnISWnWMFTFoxXQMd1yu9d8yFGmFpD2tyx40E/1z3VOYl vaPA2Msk6diKVU0ixi6AkUu3xTyWsXB6/1MhQNEIsDQ4WTA4XardAcXyqPMMOMF4alK1 a0W8i6yDkGdvwKg3cWENetg+3fXM5GYvlA51fIcSs2MQnFQeSPQ9IZi5AwFY2NTxH+29 /CMw== X-Gm-Message-State: AHQUAua0/kQoHYB2QCAkIxFWwUHO2Nz+6gUsp1a8AhP6fXfevwUpxPyB X9MFzilkGN6itGSvG/L2w1suos14gGE= X-Google-Smtp-Source: AHgI3IZsEZSD9sVnUFiL9Lntv/adh3hWjn3JLz475CxM8klGdAc+iHlso+waA6XNfkj+JzoufxcSRA== X-Received: by 2002:a1c:b456:: with SMTP id d83mr313850wmf.115.1549904077121; Mon, 11 Feb 2019 08:54:37 -0800 (PST) Received: from localhost (jirka.pirko.cz. [84.16.102.26]) by smtp.gmail.com with ESMTPSA id s5sm9785728wmh.37.2019.02.11.08.54.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Feb 2019 08:54:36 -0800 (PST) Date: Mon, 11 Feb 2019 17:45:13 +0100 From: Jiri Pirko To: Jakub Kicinski Cc: davem@davemloft.net, netdev@vger.kernel.org, oss-drivers@netronome.com, mkubecek@suse.cz, andrew@lunn.ch Subject: Re: [RFC 1/3] devlink: add flash update command Message-ID: <20190211164513.GI2314@nanopsycho.orion> References: <20190211065923.22670-1-jakub.kicinski@netronome.com> <20190211065923.22670-2-jakub.kicinski@netronome.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190211065923.22670-2-jakub.kicinski@netronome.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Mon, Feb 11, 2019 at 07:59:20AM CET, jakub.kicinski@netronome.com wrote: >Add devlink flash update command. Advanced NICs have firmware >stored in flash and often cryptographically secured. Updating >that flash is handled by management firmware. Ethtool has a >flash update command which served us well, however, it has two >shortcomings: > - it takes rtnl_lock unnecessarily - really flash update has > nothing to do with networking, so using a networking device > as a handle is suboptimal, which leads us to the second one: > - it requires a functioning netdev - in case device enters an > error state and can't spawn a netdev (e.g. communication > with the device fails) there is no netdev to use as a handle > for flashing. > >Devlink already has the ability to report the firmware versions, >now with the ability to update the firmware/flash we will be >able to recover devices in bad state. > >To enable easy interoperability with ethtool add the target >partition ID. We may or may not add a different method of >identification, but there is no such immediate need. > >Signed-off-by: Jakub Kicinski >--- > include/net/devlink.h | 2 ++ > include/uapi/linux/devlink.h | 6 ++++++ > net/core/devlink.c | 30 ++++++++++++++++++++++++++++++ > 3 files changed, 38 insertions(+) > >diff --git a/include/net/devlink.h b/include/net/devlink.h >index 07660fe4c0e3..55b3478b1291 100644 >--- a/include/net/devlink.h >+++ b/include/net/devlink.h >@@ -529,6 +529,8 @@ struct devlink_ops { > struct netlink_ext_ack *extack); > int (*info_get)(struct devlink *devlink, struct devlink_info_req *req, > struct netlink_ext_ack *extack); >+ int (*flash_update)(struct devlink *devlink, const char *path, >+ u32 target, struct netlink_ext_ack *extack); > }; > > static inline void *devlink_priv(struct devlink *devlink) >diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h >index 72d9f7c89190..f4417283fd1b 100644 >--- a/include/uapi/linux/devlink.h >+++ b/include/uapi/linux/devlink.h >@@ -103,6 +103,8 @@ enum devlink_command { > DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET, > DEVLINK_CMD_HEALTH_REPORTER_DUMP_CLEAR, > >+ DEVLINK_CMD_FLASH_UPDATE, >+ > /* add new commands above here */ > __DEVLINK_CMD_MAX, > DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1 >@@ -326,6 +328,10 @@ enum devlink_attr { > DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS, /* u64 */ > DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD, /* u64 */ > DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER, /* u8 */ >+ >+ DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME, /* string */ >+ DEVLINK_ATTR_FLASH_UPDATE_TARGET_ID, /* u32 */ Do we need to carry this on? I mean, the ef->region is only checked in 4 drivers against ETHTOOL_FLASH_ALL_REGIONS, which is default. There is this bnxt driver which is the only one working with this value. I think that for compat, there should be some id-region mapping provided by driver which the compat layer would use to translate. I also think that this should be in sync with what is returned in DEVLINK_ATTR_INFO_VERSION_NAME. For example: $ devlink dev info pci/0000:82:00.0 pci/0000:82:00.0: driver nfp serial_number 16240145 versions: fixed: board.id AMDA0081-0001 board.rev 15 board.vendor SMA board.model hydrogen running: fw.mgmt 010181.010181.0101d4 fw.cpld 0x1030000 fw.app abm-d372b6 fw.undi 0.0.2 chip.init AMDA-0081-0001 20160318164536 stored: fw.mgmt 010181.010181.0101d4 fw.app abm-d372b6 fw.undi 0.0.2 chip.init AMDA-0081-0001 20160318164536 Now user should be able to use one of the identifiers to flash relevant fw, like: devlink dev flash pci/0000:82:00.0 XXX fw.mgmt file flash-boot.bin I'm not sure about the name of "xxx" attribute. Maybe "id": devlink dev flash pci/0000:82:00.0 id fw.mgmt file flash-boot.bin devlink dev flash pci/0000:82:00.0 id fw.cpld file some-other.bin [...]