From patchwork Fri Jan 8 16:31:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12006999 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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,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 22888C4332E for ; Fri, 8 Jan 2021 16:34:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED0F2239A1 for ; Fri, 8 Jan 2021 16:34:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728405AbhAHQdo (ORCPT ); Fri, 8 Jan 2021 11:33:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728004AbhAHQdk (ORCPT ); Fri, 8 Jan 2021 11:33:40 -0500 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 2339DC0612A4 for ; Fri, 8 Jan 2021 08:32:34 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id b2so11821204edm.3 for ; Fri, 08 Jan 2021 08:32:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GH9gv6pTMkTE9mhPswpSQp2Heu44uVPpot5nMAmR7P0=; b=hf237byPxJemxTx+qUcMiGiJ/nAL/NYA+RHj55v5JIwHza2Cuj8hmwrQEPlpYKAkol fIxvL4QZOnw/8Nr2NP6t2H7xlrTiUOL+iF5VSfd3Xy5kymSW6ay2A+tE9GZK/bhQRlDk 0HiBUvYwYF/Vhyp9XeRFLG3+gRq6XaEsTsn+fTzkmi2lhWTeGnDJXWP76Kx6GjlQtqnX DOUeo6Gly/sHqODjaliIXNINEuP4AHSgG/v6RM/HSvgcBDx0u6iTwFkINX+V9BvuKdJs hBMIcxDsSCn3gAJdWH6EeewioTwJJ814CHiR4rY3uR6litC57Z7uvIzePvMLKxHgVQFX SaMQ== 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=GH9gv6pTMkTE9mhPswpSQp2Heu44uVPpot5nMAmR7P0=; b=umNl773kxx+3GqjAkilr6ugfso94begnPltcJO0/Nhv4LI77zx+Bth9K8lBcdCGXEy xUnB9G0Knr81mdRXneIaIftcOtzpown/08Ps/3ilDpOYzUIumkMDCvqQ0L4RMhwys8xv rr1Bqf2uptysGIeN9/I7wt/vxwvLitzlXcg2M7lzLEhVRAHGtMMMx6uaTgIK5bSIZFCd Eipu/NkXcQ8NpEmnr8soQqlLqtZiWo+HQh3CxqsHgLf3BzpVL9dtY7KB2ivZI/MpR9Df Uhmm06YuJARDJ4XBv0Eh2jnnIMgq+1p0qDUoe3tIMYHF1jDP3GjhHokZdBi38+kpVVO7 TjGA== X-Gm-Message-State: AOAM533SmuZnycsq96HrbCYNSppy0DMC2w4ceChJfCC+n/vdkjOcmaOo 2WgtxpMcKAKLCpbVgCuvz7k= X-Google-Smtp-Source: ABdhPJz9+sP8888Z24A3rhxykJEiaSo9T0ig7QSsSh8qIuKywvxcpoXKfRN472oFxvrcUF8LCifEIw== X-Received: by 2002:aa7:cf85:: with SMTP id z5mr5829379edx.274.1610123552862; Fri, 08 Jan 2021 08:32:32 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id x6sm3957737edl.67.2021.01.08.08.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 08:32:31 -0800 (PST) From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Cong Wang , Stephen Hemminger , Eric Dumazet , George McCollister , Oleksij Rempel , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , Arnd Bergmann , Taehee Yoo , Jiri Pirko , Florian Westphal , Nikolay Aleksandrov , Pravin B Shelar , Sridhar Samudrala , Saeed Mahameed Subject: [PATCH v5 net-next 09/16] scsi: fcoe: propagate errors from dev_get_stats Date: Fri, 8 Jan 2021 18:31:52 +0200 Message-Id: <20210108163159.358043-10-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210108163159.358043-1-olteanv@gmail.com> References: <20210108163159.358043-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vladimir Oltean The FCoE callback for the Link Error Status Block retrieves the FCS error count using dev_get_stats. This function can now return errors. Propagate these all the way to the sysfs device attributes. Signed-off-by: Vladimir Oltean --- Changes in v5: None. Changes in v4: Patch is new (Eric's suggestion). drivers/scsi/fcoe/fcoe_sysfs.c | 9 +++++++-- drivers/scsi/fcoe/fcoe_transport.c | 24 +++++++++++++++--------- drivers/scsi/libfc/fc_rport.c | 5 ++++- include/scsi/fcoe_sysfs.h | 12 ++++++------ include/scsi/libfc.h | 2 +- include/scsi/libfcoe.h | 8 ++++---- 6 files changed, 37 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c index af658aa38fed..a197e66ffa8a 100644 --- a/drivers/scsi/fcoe/fcoe_sysfs.c +++ b/drivers/scsi/fcoe/fcoe_sysfs.c @@ -139,8 +139,13 @@ static ssize_t show_fcoe_ctlr_device_##field(struct device *dev, \ char *buf) \ { \ struct fcoe_ctlr_device *ctlr = dev_to_ctlr(dev); \ - if (ctlr->f->get_fcoe_ctlr_##field) \ - ctlr->f->get_fcoe_ctlr_##field(ctlr); \ + int err; \ + \ + if (ctlr->f->get_fcoe_ctlr_##field) { \ + err = ctlr->f->get_fcoe_ctlr_##field(ctlr); \ + if (err) \ + return err; \ + } \ return snprintf(buf, sz, format_string, \ cast fcoe_ctlr_##field(ctlr)); \ } diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c index 213ee9efb044..5d19650e9bc1 100644 --- a/drivers/scsi/fcoe/fcoe_transport.c +++ b/drivers/scsi/fcoe/fcoe_transport.c @@ -166,15 +166,16 @@ EXPORT_SYMBOL_GPL(fcoe_link_speed_update); * Note, the Link Error Status Block (LESB) for FCoE is defined in FC-BB-6 * Clause 7.11 in v1.04. */ -void __fcoe_get_lesb(struct fc_lport *lport, - struct fc_els_lesb *fc_lesb, - struct net_device *netdev) +int __fcoe_get_lesb(struct fc_lport *lport, + struct fc_els_lesb *fc_lesb, + struct net_device *netdev) { struct rtnl_link_stats64 dev_stats; unsigned int cpu; u32 lfc, vlfc, mdac; struct fc_stats *stats; struct fcoe_fc_els_lesb *lesb; + int err; lfc = 0; vlfc = 0; @@ -190,8 +191,14 @@ void __fcoe_get_lesb(struct fc_lport *lport, lesb->lesb_link_fail = htonl(lfc); lesb->lesb_vlink_fail = htonl(vlfc); lesb->lesb_miss_fka = htonl(mdac); - dev_get_stats(netdev, &dev_stats); + + err = dev_get_stats(netdev, &dev_stats); + if (err) + return err; + lesb->lesb_fcs_error = htonl(dev_stats.rx_crc_errors); + + return 0; } EXPORT_SYMBOL_GPL(__fcoe_get_lesb); @@ -200,12 +207,11 @@ EXPORT_SYMBOL_GPL(__fcoe_get_lesb); * @lport: the local port * @fc_lesb: the link error status block */ -void fcoe_get_lesb(struct fc_lport *lport, - struct fc_els_lesb *fc_lesb) +int fcoe_get_lesb(struct fc_lport *lport, struct fc_els_lesb *fc_lesb) { struct net_device *netdev = fcoe_get_netdev(lport); - __fcoe_get_lesb(lport, fc_lesb, netdev); + return __fcoe_get_lesb(lport, fc_lesb, netdev); } EXPORT_SYMBOL_GPL(fcoe_get_lesb); @@ -215,14 +221,14 @@ EXPORT_SYMBOL_GPL(fcoe_get_lesb); * @ctlr_dev: The given fcoe controller device * */ -void fcoe_ctlr_get_lesb(struct fcoe_ctlr_device *ctlr_dev) +int fcoe_ctlr_get_lesb(struct fcoe_ctlr_device *ctlr_dev) { struct fcoe_ctlr *fip = fcoe_ctlr_device_priv(ctlr_dev); struct net_device *netdev = fcoe_get_netdev(fip->lp); struct fc_els_lesb *fc_lesb; fc_lesb = (struct fc_els_lesb *)(&ctlr_dev->lesb); - __fcoe_get_lesb(fip->lp, fc_lesb, netdev); + return __fcoe_get_lesb(fip->lp, fc_lesb, netdev); } EXPORT_SYMBOL_GPL(fcoe_ctlr_get_lesb); diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index 56003208d2e7..cb299fef7a78 100644 --- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c @@ -1633,6 +1633,7 @@ static void fc_rport_recv_rls_req(struct fc_rport_priv *rdata, struct fc_els_lesb *lesb; struct fc_seq_els_data rjt_data; struct fc_host_statistics *hst; + int err; lockdep_assert_held(&rdata->rp_mutex); @@ -1659,7 +1660,9 @@ static void fc_rport_recv_rls_req(struct fc_rport_priv *rdata, lesb = &rsp->rls_lesb; if (lport->tt.get_lesb) { /* get LESB from LLD if it supports it */ - lport->tt.get_lesb(lport, lesb); + err = lport->tt.get_lesb(lport, lesb); + if (err) + goto out_rjt; } else { fc_get_host_stats(lport->host); hst = &lport->host_stats; diff --git a/include/scsi/fcoe_sysfs.h b/include/scsi/fcoe_sysfs.h index 4b1216de3f22..076b593f2625 100644 --- a/include/scsi/fcoe_sysfs.h +++ b/include/scsi/fcoe_sysfs.h @@ -16,12 +16,12 @@ struct fcoe_ctlr_device; struct fcoe_fcf_device; struct fcoe_sysfs_function_template { - void (*get_fcoe_ctlr_link_fail)(struct fcoe_ctlr_device *); - void (*get_fcoe_ctlr_vlink_fail)(struct fcoe_ctlr_device *); - void (*get_fcoe_ctlr_miss_fka)(struct fcoe_ctlr_device *); - void (*get_fcoe_ctlr_symb_err)(struct fcoe_ctlr_device *); - void (*get_fcoe_ctlr_err_block)(struct fcoe_ctlr_device *); - void (*get_fcoe_ctlr_fcs_error)(struct fcoe_ctlr_device *); + int (*get_fcoe_ctlr_link_fail)(struct fcoe_ctlr_device *); + int (*get_fcoe_ctlr_vlink_fail)(struct fcoe_ctlr_device *); + int (*get_fcoe_ctlr_miss_fka)(struct fcoe_ctlr_device *); + int (*get_fcoe_ctlr_symb_err)(struct fcoe_ctlr_device *); + int (*get_fcoe_ctlr_err_block)(struct fcoe_ctlr_device *); + int (*get_fcoe_ctlr_fcs_error)(struct fcoe_ctlr_device *); void (*set_fcoe_ctlr_mode)(struct fcoe_ctlr_device *); int (*set_fcoe_ctlr_enabled)(struct fcoe_ctlr_device *); void (*get_fcoe_fcf_selected)(struct fcoe_fcf_device *); diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 9b87e1a1c646..510654796db5 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -501,7 +501,7 @@ struct libfc_function_template { * * STATUS: OPTIONAL */ - void (*get_lesb)(struct fc_lport *, struct fc_els_lesb *lesb); + int (*get_lesb)(struct fc_lport *, struct fc_els_lesb *lesb); /* * Reset an exchange manager, completing all sequences and exchanges. diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h index 2568cb0627ec..a42cbe847ce6 100644 --- a/include/scsi/libfcoe.h +++ b/include/scsi/libfcoe.h @@ -255,13 +255,13 @@ int fcoe_libfc_config(struct fc_lport *, struct fcoe_ctlr *, u32 fcoe_fc_crc(struct fc_frame *fp); int fcoe_start_io(struct sk_buff *skb); int fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type); -void __fcoe_get_lesb(struct fc_lport *lport, struct fc_els_lesb *fc_lesb, - struct net_device *netdev); +int __fcoe_get_lesb(struct fc_lport *lport, struct fc_els_lesb *fc_lesb, + struct net_device *netdev); void fcoe_wwn_to_str(u64 wwn, char *buf, int len); int fcoe_validate_vport_create(struct fc_vport *vport); int fcoe_link_speed_update(struct fc_lport *); -void fcoe_get_lesb(struct fc_lport *, struct fc_els_lesb *); -void fcoe_ctlr_get_lesb(struct fcoe_ctlr_device *ctlr_dev); +int fcoe_get_lesb(struct fc_lport *, struct fc_els_lesb *); +int fcoe_ctlr_get_lesb(struct fcoe_ctlr_device *ctlr_dev); /** * is_fip_mode() - returns true if FIP mode selected.