Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3321969pxk; Mon, 7 Sep 2020 09:29:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwcqWjP3sBfEJQs23+qR2PzwLb8lWNRN6K/pQoCiQj/vdwtzSTur8kUD5su+c7YsDbEya0 X-Received: by 2002:a17:906:48d6:: with SMTP id d22mr22318958ejt.462.1599496166045; Mon, 07 Sep 2020 09:29:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599496166; cv=none; d=google.com; s=arc-20160816; b=yujgXKu6bAgu6R7d2Gavm9bQbTjzKhFWeGgHfF8DPlFKKlrP+ulFYtJfxVC0ZFY8t3 WzP//AxV4Ai6mfPx4pCpBfaqPa6mJMqncy4D8f0Hg6D8QI2vXttfC4t+rgI1v9OBN+98 xW0ruDex9XcWM/faR7KXby3R59VQU6SPe0pCXI6T4K8GrCv6IfRAIFTyec4XB1boQFqS +hbJsgK0SL5ZLJ3MeyUx/RAfDHUURm8480mQZYAk/UJRg4YSHAFOYXHJiNGfMlv5mgTP 3BWq1vnqfkm0IiAN1hvam8B4mk9gcDeW2MetrJuuWfbN5IMfUGC0yDDd11pPi7oq8VP0 vbUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=zWN2HLHNzNDC/aRGR6xUqOC8/KSE1ZfTowseUrpuvXE=; b=VLnMOVOR2WIfbfk9DspnRgx4xeSmnm4oJvoyYBEIIHVFnOW6EJ+DXF1zZEuY4O4mPg FkcmtWeYscx7jApk041zMh2lHasR4cJAlo2aEGGPMmlMDSQ6yn30/5IEJwIo/MC51TdS 7XseiXpuW+uwUR27voiQF1Yu/r9rCxr1HMC21tdHRf5wIxOIW0A4IzgHrHU3HnHDeKwD gjW8co1UPPORlADsakUtPrg8NGeEpANOxqoaBQ/qiez58n83OQ6PuM3grf+uzGWM5n2J /jFVykDtDRUiNX6t7Hn0Y2MOjQ4WyjSuXfiHzQZ3z5L1RE0/H9i5osDm7mbDRATy28di 7P1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=SzMIKPjH; 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=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g11si9700956edy.476.2020.09.07.09.29.03; Mon, 07 Sep 2020 09:29:26 -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=@nvidia.com header.s=n1 header.b=SzMIKPjH; 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=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730380AbgIGQ1Q (ORCPT + 99 others); Mon, 7 Sep 2020 12:27:16 -0400 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:11311 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729863AbgIGQ1F (ORCPT ); Mon, 7 Sep 2020 12:27:05 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 07 Sep 2020 09:26:45 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 07 Sep 2020 09:26:59 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 07 Sep 2020 09:26:59 -0700 Received: from [172.27.13.12] (172.20.13.39) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 7 Sep 2020 16:26:50 +0000 Subject: Re: [PATCH net-next RFC v1 3/4] devlink: Add hierarchy between traps in device level and port level To: Ido Schimmel , Aya Levin CC: "David S. Miller" , Jakub Kicinski , Jiri Pirko , , Moshe Shemesh , Eran Ben Elisha , Ido Schimmel , References: <1599060734-26617-1-git-send-email-ayal@mellanox.com> <1599060734-26617-4-git-send-email-ayal@mellanox.com> <20200906155858.GB2431016@shredder> From: Aya Levin Message-ID: Date: Mon, 7 Sep 2020 19:26:48 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200906155858.GB2431016@shredder> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1599496005; bh=zWN2HLHNzNDC/aRGR6xUqOC8/KSE1ZfTowseUrpuvXE=; h=X-PGP-Universal:Subject:To:CC:References:From:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:Content-Type:Content-Language: Content-Transfer-Encoding:X-Originating-IP:X-ClientProxiedBy; b=SzMIKPjHuDMvng3v+lrgs1iZyZwrlI9C5LxvELAbZBBD93qzkwtYgIoVM0f0DJ4uU Uwl9YQ3J1+LpDJl4MjqqjQ2pLTvWMmKf0n3N7PTC7VEVT/cVdf6g65UrKZogiILUvh 3n6BjCyHWBwi0efHltOGCYj+yppTSvtWYHsHSHqC5Yf0FD5zVv6oO/J9g1RfO17RTn 2BuGKt9/NrgBwYPRUN8s3m1HIOuB4bkRh6ShgrSYXKv6IWlzfS8KIhrZPU+vbBs0s4 oQvGb66djDNCgXdTAKe9V2hqrg5MgkOdtoR2bNwhq/uF4NYVd8j0gRiYFzm49XNFH1 LIbitXgUobRYQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/6/2020 6:58 PM, Ido Schimmel wrote: > On Wed, Sep 02, 2020 at 06:32:13PM +0300, Aya Levin wrote: >> Managing large scale port's traps may be complicated. This patch >> introduces a shortcut: when setting a trap on a device and this trap is >> not registered on this device, the action will take place on all related >> ports that did register this trap. > > I'm not really a fan of this and I'm not sure there is precedent for > something similar. Also, it's an optimization, so I wouldn't put it as > part of the first submission before you gather some operational > experience with the initial interface. I thought it was a nice idea but I agree that this is an optimization and can be dropped from preliminary submission > > In addition, I find it very unintuitive for users. When I do 'devlink > trap show' I will not see anything. I will only see the traps when I > issue 'devlink port trap show', yet 'devlink trap set ...' is expected > to work. > > Lets assume that this is a valid change, it would be better implemented > with my suggestion from the previous patch: When devlink sees that a > trap is registered on all the ports it can auto-register a new > per-device trap and user space gets the appropriate notification. > >> >> Signed-off-by: Aya Levin >> --- >> net/core/devlink.c | 43 +++++++++++++++++++++++++++++++++---------- >> 1 file changed, 33 insertions(+), 10 deletions(-) >> >> diff --git a/net/core/devlink.c b/net/core/devlink.c >> index b13e1b40bf1c..dea5482b2517 100644 >> --- a/net/core/devlink.c >> +++ b/net/core/devlink.c >> @@ -6501,23 +6501,46 @@ static int devlink_nl_cmd_trap_set_doit(struct sk_buff *skb, >> struct devlink *devlink = info->user_ptr[0]; >> struct devlink_trap_mngr *trap_mngr; >> struct devlink_trap_item *trap_item; >> + struct devlink_port *devlink_port; >> int err; >> >> - trap_mngr = devlink_trap_get_trap_mngr_from_info(devlink, info); >> - if (list_empty(&trap_mngr->trap_list)) >> - return -EOPNOTSUPP; >> + devlink_port = devlink_port_get_from_attrs(devlink, info->attrs); >> + if (IS_ERR(devlink_port)) { >> + trap_mngr = &devlink->trap_mngr; >> + if (list_empty(&trap_mngr->trap_list)) >> + goto loop_over_ports; >> >> - trap_item = devlink_trap_item_get_from_info(trap_mngr, info); >> - if (!trap_item) { >> - NL_SET_ERR_MSG_MOD(extack, "Device did not register this trap"); >> - return -ENOENT; >> + trap_item = devlink_trap_item_get_from_info(trap_mngr, info); >> + if (!trap_item) >> + goto loop_over_ports; >> + } else { >> + trap_mngr = &devlink_port->trap_mngr; >> + if (list_empty(&trap_mngr->trap_list)) >> + return -EOPNOTSUPP; >> + >> + trap_item = devlink_trap_item_get_from_info(trap_mngr, info); >> + if (!trap_item) { >> + NL_SET_ERR_MSG_MOD(extack, "Port did not register this trap"); >> + return -ENOENT; >> + } >> } >> return devlink_trap_action_set(devlink, trap_mngr, trap_item, info); >> >> - err = devlink_trap_action_set(devlink, trap_mngr, trap_item, info); >> - if (err) >> - return err; >> +loop_over_ports: >> + if (list_empty(&devlink->port_list)) >> + return -EOPNOTSUPP; >> + list_for_each_entry(devlink_port, &devlink->port_list, list) { >> + trap_mngr = &devlink_port->trap_mngr; >> + if (list_empty(&trap_mngr->trap_list)) >> + continue; >> >> + trap_item = devlink_trap_item_get_from_info(trap_mngr, info); >> + if (!trap_item) >> + continue; >> + err = devlink_trap_action_set(devlink, trap_mngr, trap_item, info); >> + if (err) >> + return err; >> + } >> return 0; >> } >> >> -- >> 2.14.1 >>