Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1540234pxa; Sun, 16 Aug 2020 02:12:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIcHIHUF8exiIktave8LraXRqlhDPlec0rbk4WNeahsRY+2PQl+myVGpMIxwPliBa7L9mk X-Received: by 2002:a05:6402:1606:: with SMTP id f6mr9723139edv.328.1597569138726; Sun, 16 Aug 2020 02:12:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597569138; cv=none; d=google.com; s=arc-20160816; b=CDYBU7iN1jqiIH2h04C5IXoibDRaHCIVEK3JvEOsDz/GWV4gFgGo78Y+8jJiuDUoB3 CGwLRwGgeM1YU6t/guJjU0JA4zPp6y/jbZo4RtCIOslxLFpeH6v3cCTNOwPsg74eIReI ZzxzvRl8b/2XszlPVWF5YAXrd+X6KJ9SJLyxeFOnWHDPrMXS1/mlUw1G2lZqmvyyuqjt hY9D+IhYykFLIeb6m3Gjp+UFuOxYWTECKBD4LOaIfoR+aETpxNCwJ74leg/+jBOCS9RB mrr65GjRgRDbyIR4vcbdkB/sdWv14g5C2dH1Ar+qS2gSyyj2wRx5u5+o4gZCT7q+lDcM EmDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=nxRS4sovf6GjtcJdjWXmM4G6i1tYTrf7XYtnALv+02A=; b=dGFmVikJukZjfvpEUrz9tyeGjqLDdID74g+kFNYUIsAq+LfaO5lFnXTdJsXmBYsdH8 InhXNNP8Q36BGjsXHpvUYkQiSOxBnFisfgr+oehcEHXzjPrDaNc+b+fNHeHxUis8GSS0 GlAP7dqZ+0xhBKMoCjhXniZmpjYXH4k/ONpHH5MGYMzV8O10OlUqYzTEMS21vgjq4Kxd lzb5OYD7QP3YHGkAME1USUaCk3M6NDU8kDbHl+2qeaSWdQFazjhvyAM5IQan6DBWIOCk MC+oJoXDAMoxoDAKWzlyH028OitaDRrFptG7QRER3VDnYqC/yh2I6z1wP9j8wI9kTPQx kEwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=u+OpWrD0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d8si8451479ejj.109.2020.08.16.02.11.55; Sun, 16 Aug 2020 02:12:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=u+OpWrD0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729939AbgHPC4s (ORCPT + 99 others); Sat, 15 Aug 2020 22:56:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729929AbgHPC4r (ORCPT ); Sat, 15 Aug 2020 22:56:47 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8071FC061786; Sat, 15 Aug 2020 19:56:47 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id m71so6458228pfd.1; Sat, 15 Aug 2020 19:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=nxRS4sovf6GjtcJdjWXmM4G6i1tYTrf7XYtnALv+02A=; b=u+OpWrD0xShZqRnowsZ+j9C/wDb3pI7Q2Lhmozbz+U68ef/uIpJcUza/iUSjp8zdvt B+vgWw2uhMcFfLZT9iSMKLFqBhRked1h7xYwspPP3S4Nd5xWzPv2knbmYcLe/nLOZmco 1q2OG1Rw4sHkfXzmsiUXhxhfbZSdqp6kT5ZtLjDzmEfAzfo6zQTCGLY7mgS2vRbxx/DT cqZ4BxubTiD1QmpMfX+YoxCPuPv6FLIYQRaUyktClAQ/bcYj6OzZH4ecCK5GjKM21WCi tI0adCL8Qk3NkY6E+yNskpLyAg/KhcWFfWATX1q47nHa9Ot2GFD51gEYJZDjPHR+BY0A 1/GQ== 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; bh=nxRS4sovf6GjtcJdjWXmM4G6i1tYTrf7XYtnALv+02A=; b=HcaE6qt+3g+msQqbxhB8zjY/Pg0+9bzTVqF0Y7mS0dtwOu2NtQMKqXdloa8qzyHV+G r7+BsUiMsBKc3KLe6E34xxRlBswrO1i0eBrDxkaNnG2QOre0Rx6RdCx5R7jg/nLULGvr H0aDtxP7mGCjU8KNZ+YpuvLjMMySRxtkOjFwHerybqbNkUTPGFSPRzRqEGW7YD1AfO8L igQgTSaKIr/qqhiRLQcAnygOisQG7ZgtvGpzhgiuduySBCvCy1ahCqadLzEdcnFRI4OP ecSnWSHFTwB/KDGL1zI7i/vYrkpl+0rFvIhtrWWGDsvhSm6RZZfzzqScIm1WrU17j0Ht oL8Q== X-Gm-Message-State: AOAM531CeH+i5suI4Deq1Xv4YNE188wTezrh7fcVDRL06augvawo9/Ia uQgVZzO3phT8AXqdUBrMyDI= X-Received: by 2002:a62:1ad0:: with SMTP id a199mr7068906pfa.56.1597546606564; Sat, 15 Aug 2020 19:56:46 -0700 (PDT) Received: from f3 (ae055068.dynamic.ppp.asahi-net.or.jp. [14.3.55.68]) by smtp.gmail.com with ESMTPSA id w7sm13597208pfi.164.2020.08.15.19.56.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Aug 2020 19:56:44 -0700 (PDT) Date: Sun, 16 Aug 2020 11:56:40 +0900 From: Benjamin Poirier To: Coiby Xu Cc: netdev@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Manish Chopra , GR-Linux-NIC-Dev@marvell.com, Greg Kroah-Hartman , Michal Kubecek , open list , "open list:STAGING SUBSYSTEM" Subject: Re: [RFC 1/3] Initialize devlink health dump framework for the dlge driver Message-ID: <20200816025640.GA27529@f3> References: <20200814160601.901682-1-coiby.xu@gmail.com> <20200814160601.901682-2-coiby.xu@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200814160601.901682-2-coiby.xu@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-08-15 00:05 +0800, Coiby Xu wrote: > Initialize devlink health dump framework for the dlge driver so the > coredump could be done via devlink. > > Signed-off-by: Coiby Xu > --- > drivers/staging/qlge/Makefile | 2 +- > drivers/staging/qlge/qlge.h | 9 +++++++ > drivers/staging/qlge/qlge_health.c | 43 ++++++++++++++++++++++++++++++ > drivers/staging/qlge/qlge_health.h | 2 ++ > drivers/staging/qlge/qlge_main.c | 21 +++++++++++++++ > 5 files changed, 76 insertions(+), 1 deletion(-) > create mode 100644 drivers/staging/qlge/qlge_health.c > create mode 100644 drivers/staging/qlge/qlge_health.h > > diff --git a/drivers/staging/qlge/Makefile b/drivers/staging/qlge/Makefile > index 1dc2568e820c..0a1e4c8dd546 100644 > --- a/drivers/staging/qlge/Makefile > +++ b/drivers/staging/qlge/Makefile > @@ -5,4 +5,4 @@ > > obj-$(CONFIG_QLGE) += qlge.o > > -qlge-objs := qlge_main.o qlge_dbg.o qlge_mpi.o qlge_ethtool.o > +qlge-objs := qlge_main.o qlge_dbg.o qlge_mpi.o qlge_ethtool.o qlge_health.o > diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h > index fc8c5ca8935d..055ded6dab60 100644 > --- a/drivers/staging/qlge/qlge.h > +++ b/drivers/staging/qlge/qlge.h > @@ -2061,6 +2061,14 @@ struct nic_operations { > int (*port_initialize) (struct ql_adapter *); > }; > This patch doesn't apply over the latest staging tree. I think your tree is missing commit d923bb6bf508 ("staging: qlge: qlge.h: Function definition arguments should have names.") > + > + > +struct qlge_devlink { > + struct ql_adapter *qdev; > + struct net_device *ndev; I don't have experience implementing devlink callbacks but looking at some other devlink users (mlx4, ionic, ice), all of them use devlink priv space for their main private structure. That would be struct ql_adapter in this case. Is there a good reason to stray from that pattern? > + struct devlink_health_reporter *reporter; > +}; > + > /* > * The main Adapter structure definition. > * This structure has all fields relevant to the hardware. > @@ -2078,6 +2086,7 @@ struct ql_adapter { > struct pci_dev *pdev; > struct net_device *ndev; /* Parent NET device */ > > + struct qlge_devlink *devlink; > /* Hardware information */ > u32 chip_rev_id; > u32 fw_rev_id; > diff --git a/drivers/staging/qlge/qlge_health.c b/drivers/staging/qlge/qlge_health.c > new file mode 100644 > index 000000000000..292f6b1827e1 > --- /dev/null > +++ b/drivers/staging/qlge/qlge_health.c > @@ -0,0 +1,43 @@ > +#include "qlge.h" > +#include "qlge_health.h" > + > +static int > +qlge_reporter_coredump(struct devlink_health_reporter *reporter, > + struct devlink_fmsg *fmsg, void *priv_ctx, > + struct netlink_ext_ack *extack) > +{ > + return 0; > +} > + > +static const struct devlink_health_reporter_ops qlge_reporter_ops = { > + .name = "dummy", > + .dump = qlge_reporter_coredump, > +}; I think select NET_DEVLINK should be added to drivers/staging/qlge/Kconfig > + > +int qlge_health_create_reporters(struct qlge_devlink *priv) > +{ > + int err; > + > + struct devlink_health_reporter *reporter; > + struct devlink *devlink; > + > + devlink = priv_to_devlink(priv); > + reporter = > + devlink_health_reporter_create(devlink, &qlge_reporter_ops, > + 0, > + priv); > + if (IS_ERR(reporter)) { > + netdev_warn(priv->ndev, > + "Failed to create reporter, err = %ld\n", > + PTR_ERR(reporter)); > + return PTR_ERR(reporter); > + } > + priv->reporter = reporter; > + > + if (err) > + return err; > + > + return 0; > +} > + > + Stray newlines > diff --git a/drivers/staging/qlge/qlge_health.h b/drivers/staging/qlge/qlge_health.h > new file mode 100644 > index 000000000000..07d3bafab845 > --- /dev/null > +++ b/drivers/staging/qlge/qlge_health.h > @@ -0,0 +1,2 @@ > +#include > +int qlge_health_create_reporters(struct qlge_devlink *priv); I would suggest to put this in qlge.h instead of creating a new file. > diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c > index 1650de13842f..b2be7f4b7dd6 100644 > --- a/drivers/staging/qlge/qlge_main.c > +++ b/drivers/staging/qlge/qlge_main.c > @@ -42,6 +42,7 @@ > #include > > #include "qlge.h" > +#include "qlge_health.h" > > char qlge_driver_name[] = DRV_NAME; > const char qlge_driver_version[] = DRV_VERSION; > @@ -4550,6 +4551,8 @@ static void ql_timer(struct timer_list *t) > mod_timer(&qdev->timer, jiffies + (5 * HZ)); > } > > +static const struct devlink_ops qlge_devlink_ops; > + > static int qlge_probe(struct pci_dev *pdev, > const struct pci_device_id *pci_entry) > { > @@ -4557,6 +4560,13 @@ static int qlge_probe(struct pci_dev *pdev, > struct ql_adapter *qdev = NULL; > static int cards_found; > int err = 0; > + struct devlink *devlink; > + struct qlge_devlink *qlge_dl; > + > + devlink = devlink_alloc(&qlge_devlink_ops, sizeof(struct qlge_devlink)); > + if (!devlink) > + return -ENOMEM; > + qlge_dl = devlink_priv(devlink); > > ndev = alloc_etherdev_mq(sizeof(struct ql_adapter), > min(MAX_CPUS, > @@ -4615,6 +4625,15 @@ static int qlge_probe(struct pci_dev *pdev, > free_netdev(ndev); > return err; > } > + > + err = devlink_register(devlink, &pdev->dev); > + if (err) > + devlink_free(devlink); Are you sure it's safe to continue devlink init after an error here? Again, that does not resemble usage of devlink in other drivers (ex. bnxt). > + > + qlge_health_create_reporters(qlge_dl); > + qlge_dl->qdev = qdev; > + qlge_dl->ndev = ndev; > + qdev->devlink = qlge_dl; > /* Start up the timer to trigger EEH if > * the bus goes dead > */ > @@ -4647,6 +4666,8 @@ static void qlge_remove(struct pci_dev *pdev) > unregister_netdev(ndev); > ql_release_all(pdev); > pci_disable_device(pdev); > + devlink_unregister(priv_to_devlink(qdev->devlink)); > + devlink_health_reporter_destroy(qdev->devlink->reporter); Isn't the order of those two calls mixed up? > free_netdev(ndev); > } > > -- > 2.27.0 >