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 35149C61CE4 for ; Sun, 20 Jan 2019 11:47:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 031B72084F for ; Sun, 20 Jan 2019 11:47:17 +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="Hw7gKV0U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730517AbfATLrQ (ORCPT ); Sun, 20 Jan 2019 06:47:16 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:35566 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730473AbfATLrP (ORCPT ); Sun, 20 Jan 2019 06:47:15 -0500 Received: by mail-wm1-f65.google.com with SMTP id t200so8348308wmt.0 for ; Sun, 20 Jan 2019 03:47:13 -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=jAfjmsaOOx6d+21Kv9ameDE1LmoBjRJcsSqK3WuRuxA=; b=Hw7gKV0Up+rlwrGB2O17D3TYtxt7hk9ObE76B7kkdPyzCWL9ggebiJpPFNvC0cjjbz Dt1x2i4cTAlRQUQ7H5PdYv9DttOY+FqSeMNVC5vAvZzL6ez4qg2psNlyh25p296h63QJ GuSpyWf+mgw89aPNjp49VloIEPc3bgueXVJijgsqIZrXs5NxOrg6ozIzFlBTxBs8GgOH wFxqywlT0MLOwLoiRowBxb5M5ASKXvSgvEGMmiXVsNUBQkXg04R81XYbAmXDCmSKZlrG 690fZd+EHnqCATFQvXKqgmmQoAzmmDtSDPjxNEl29KD7B4DuYHW1eyDtkoTdbGEX3oMw fsng== 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=jAfjmsaOOx6d+21Kv9ameDE1LmoBjRJcsSqK3WuRuxA=; b=sNqDXl6tw3QL2G6LYnQeRVsyzMOZLo7sIPaiDzc7sfOaQCARuuSTH+2I+ENjPtijPV EC9xP0j6DSVdL65AFL3AWo/ioOiMwye58D24OoXDIf2GgpJ4J2kqzETshTjqwGuGGZh0 mDOM8wwBX4Rv/yeuSw5KktffgTBlnlXlMX7Bxxy3l/FATevrMwIijVBM0CKvkWeEWtaT yEtZGpV92Kz65eS1XCkCsNUInMyvwa4LgjiGVyht9Ht0wkgjkZ13gm5ECN+k0keAWwJC X6iUHyEtCk+ftm772Id7ORoR/YEcsvfwfepvUn/qyy1zSniHoSRZ8hH3zOghhVK++F3W zz8g== X-Gm-Message-State: AJcUukfBQQDNTJFY2hWFTHLlkhdJ6W0SdUVHVCqZW4G14nCwR4XMMmcP Kc2udcHNlnyJDgPhEedC6W6oB//5Kmg= X-Google-Smtp-Source: ALg8bN6ShGF0rgDDRpZB/H+yzitLCPy9nSUIRLrtBaPQchJUdfzwiFMd2udzMo36Ig4XjXSYSBEIIA== X-Received: by 2002:a7b:cf30:: with SMTP id m16mr22444092wmg.22.1547984833234; Sun, 20 Jan 2019 03:47:13 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id p139sm94359293wmd.31.2019.01.20.03.47.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Jan 2019 03:47:12 -0800 (PST) Date: Sun, 20 Jan 2019 12:38:29 +0100 From: Jiri Pirko To: Eran Ben Elisha Cc: netdev@vger.kernel.org, Jiri Pirko , "David S. Miller" , Ariel Almog , Aya Levin , Moshe Shemesh Subject: Re: [PATCH net-next v2 07/11] devlink: Add health diagnose command Message-ID: <20190120113829.GK2730@nanopsycho> References: <1547762360-7075-1-git-send-email-eranbe@mellanox.com> <1547762360-7075-8-git-send-email-eranbe@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1547762360-7075-8-git-send-email-eranbe@mellanox.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Thu, Jan 17, 2019 at 10:59:16PM CET, eranbe@mellanox.com wrote: >Add devlink health diagnose command, in order to run a diagnose >operation over a specific reporter. > >It is expected from driver's callback for diagnose command to fill it >via the buffer descriptors API. Devlink will parse it and convert it to >netlink nla API in order to pass it to the user. > >Signed-off-by: Eran Ben Elisha >Reviewed-by: Moshe Shemesh >--- > include/uapi/linux/devlink.h | 1 + > net/core/devlink.c | 51 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 52 insertions(+) > >diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h >index 1c186fd77343..51b4d7612cf8 100644 >--- a/include/uapi/linux/devlink.h >+++ b/include/uapi/linux/devlink.h >@@ -92,6 +92,7 @@ enum devlink_command { > DEVLINK_CMD_HEALTH_REPORTER_GET, > DEVLINK_CMD_HEALTH_REPORTER_SET, > DEVLINK_CMD_HEALTH_REPORTER_RECOVER, >+ DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE, > > /* add new commands above here */ > __DEVLINK_CMD_MAX, >diff --git a/net/core/devlink.c b/net/core/devlink.c >index b224d0d31c0c..57252ca31e1e 100644 >--- a/net/core/devlink.c >+++ b/net/core/devlink.c >@@ -4500,6 +4500,50 @@ static int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb, > return devlink_health_reporter_recover(reporter, NULL); > } > >+static int devlink_nl_cmd_health_reporter_diagnose_doit(struct sk_buff *skb, >+ struct genl_info *info) >+{ >+ struct devlink *devlink = info->user_ptr[0]; >+ struct devlink_health_reporter *reporter; >+ u64 num_of_buffers; >+ int err; >+ >+ reporter = devlink_health_reporter_get_from_info(devlink, info); >+ if (!reporter) >+ return -EINVAL; >+ >+ if (!reporter->ops->diagnose) >+ return -EOPNOTSUPP; >+ >+ num_of_buffers = >+ DEVLINK_HEALTH_SIZE_TO_BUFFERS(reporter->ops->diagnose_size); This is odd. You need to convert to number of "buffers" the magic value the driver provided. And then couple lines below.... >+ >+ mutex_lock(&reporter->diagnose_lock); >+ devlink_health_buffers_reset(reporter->diagnose_buffers_array, >+ num_of_buffers); >+ >+ err = reporter->ops->diagnose(reporter, >+ reporter->diagnose_buffers_array, >+ DEVLINK_HEALTH_BUFFER_SIZE, >+ num_of_buffers); ....you call the driver with "buffers array", buffer size and number of buffers. It should be just: struct devlink_msg_ctx msg_ctx; err = reporter->ops->diagnose(reporter, &msg_ctx); and then; err = devlink_health_buffer_snd(info, devlink_cmd_health_reporter_diagnose, 0, &msg_ctx); >+ if (err) >+ goto out; >+ >+ err = devlink_health_buffer_snd(info, >+ devlink_cmd_health_reporter_diagnose, >+ 0, reporter->diagnose_buffers_array, >+ num_of_buffers); >+ if (err) >+ goto out; >+ >+ mutex_unlock(&reporter->diagnose_lock); >+ return 0; >+ >+out: >+ mutex_unlock(&reporter->diagnose_lock); >+ return err; >+} >+ > static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = { > [DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING }, > [DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING }, >@@ -4770,6 +4814,13 @@ static const struct genl_ops devlink_nl_ops[] = { > .flags = GENL_ADMIN_PERM, > .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, > }, >+ { >+ .cmd = DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE, >+ .doit = devlink_nl_cmd_health_reporter_diagnose_doit, >+ .policy = devlink_nl_policy, >+ .flags = GENL_ADMIN_PERM, >+ .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, >+ }, > }; > > static struct genl_family devlink_nl_family __ro_after_init = { >-- >2.17.1 >