Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2669198pxk; Sun, 6 Sep 2020 09:01:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyDH6wzi2ezrI9REfQka+KrhYG2dxPVMbUPhag/cIo3Vej4nzrDIta3VrhfFyXgvup+Puf X-Received: by 2002:a17:906:2a49:: with SMTP id k9mr17734269eje.117.1599408073920; Sun, 06 Sep 2020 09:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599408073; cv=none; d=google.com; s=arc-20160816; b=tzDSN79zPWYYtQjG5DxyMy0jStjSjhIId+MiFz88Yia5jM3MR5/hxLVCp26q+gSCgS s4Ftxd/W0BKWso3ewu4aKwsCsneiolcI2rl9laVggRZyaJFeoRywChYdBtQh2hMRktmD lRUQ9hRgrlo3IYABRiAUS++U1fZlbnyY9Dx7Z/O+oQrk/7CAR/s7ndVVB9h3HuKum44p Xa2lnzMg7g6YGCz5P5v094hbIhAGXKhtfwzj8CvRfSf8AAC9zEjxEvtW2Gr2y1OxBv7d D/bWdhSDqFyZAAXVmnh6KoS/4QmScVXKLnH1wdtjMyU60/6SSpbCeB4hlhUqB8Tkn9VG Nqyw== 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=GrRz/eqbtlSmrGyXDaaMCTI6gWJzvvz6fXmQgN53lF8=; b=iMrVX+n7KXu6kOza2JjYwBVmUM41svntylurAP/KbRK370h8R69wrCNDy0SrOo6VgS hEW7vpzcPVZmIi/PubNJlU0tNpITvWC6dHEkXYyHsvFJzVVH4R37Knu1TJ00dPGJsLqd Tam5rQdq9+IVmcD2rBSt+bi1fMgdNNQWT83ETfHnCNOgEQVvMQgFlUEDSc/k2F8aK8QK chllzlEj5FIcS+FdJnuUflnBuI9DFrTsBzVx+2BycqRMYbWhsaq+gkoMnhbek23dNNRy w8IP+k8B/8n2MY0GYvDxfNWL4D2GhOSGB6HHAL8+X1W45Oa5n5LLsS5Z6Tf5skmbXzjn dKJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=OVCEDwoZ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si1811006ejt.659.2020.09.06.09.00.51; Sun, 06 Sep 2020 09:01:13 -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=@messagingengine.com header.s=fm3 header.b=OVCEDwoZ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729009AbgIFP7N (ORCPT + 99 others); Sun, 6 Sep 2020 11:59:13 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:43975 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726931AbgIFP7C (ORCPT ); Sun, 6 Sep 2020 11:59:02 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 481885C00E0; Sun, 6 Sep 2020 11:59:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sun, 06 Sep 2020 11:59:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=GrRz/e qbtlSmrGyXDaaMCTI6gWJzvvz6fXmQgN53lF8=; b=OVCEDwoZ78E5mfRCc4xRwU p17rmeNoYd5+EmZwxfREiFG1UjAcPxIVriBR8a1SQP8zera0GcpiHEc50c0khn0Z Qx3tb2y6mWmoEtBr2B7bR1TibZyyYd7uNANKpAIaN1thQPUpj6qRJ86oLxx9NuW7 ZxzTLoV3eibDCh2CaoRMvkh39+p+vpByn8PhlPq1mp8dk+CCuUygrMpiTCtwrvvc w6TpnMdK6LqgK6MJIObgvJTEYrN4t4FSFo3nAglXPRqE7R5EPaJ45M0HBpBApXCY ZYgWg000pxC0FbALeTBRMjeQx9meLQaIy/BkAVWNiu85ZrPz2/s1DZpV2O6aQYWw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudegjedgleejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefkughoucfu tghhihhmmhgvlhcuoehiughoshgthhesihguohhstghhrdhorhhgqeenucggtffrrghtth gvrhhnpedtffekkeefudffveegueejffejhfetgfeuuefgvedtieehudeuueekhfduheel teenucfkphepkeegrddvvdelrdefiedruddvkeenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehiughoshgthhesihguohhstghhrdhorhhg X-ME-Proxy: Received: from localhost (igld-84-229-36-128.inter.net.il [84.229.36.128]) by mail.messagingengine.com (Postfix) with ESMTPA id 74B6C328005D; Sun, 6 Sep 2020 11:59:00 -0400 (EDT) Date: Sun, 6 Sep 2020 18:58:58 +0300 From: Ido Schimmel To: Aya Levin Cc: "David S. Miller" , Jakub Kicinski , Jiri Pirko , netdev@vger.kernel.org, Moshe Shemesh , Eran Ben Elisha , Ido Schimmel , linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next RFC v1 3/4] devlink: Add hierarchy between traps in device level and port level Message-ID: <20200906155858.GB2431016@shredder> References: <1599060734-26617-1-git-send-email-ayal@mellanox.com> <1599060734-26617-4-git-send-email-ayal@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1599060734-26617-4-git-send-email-ayal@mellanox.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 >