Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68171C433F5 for ; Thu, 30 Dec 2021 14:39:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240048AbhL3Oj2 (ORCPT ); Thu, 30 Dec 2021 09:39:28 -0500 Received: from new1-smtp.messagingengine.com ([66.111.4.221]:46937 "EHLO new1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235691AbhL3Oj1 (ORCPT ); Thu, 30 Dec 2021 09:39:27 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id A27C95800BC; Thu, 30 Dec 2021 09:39:26 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 30 Dec 2021 09:39:26 -0500 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=fm1; bh=q2R4bf eWpVftxMmuZnfMxIctzZld7yNvMq7VilwNzDE=; b=gbpssR+Rpr0Lw3g3ByqvJJ RU0331/rriNCirksVqeJBZosBG2SQjXyR0OQtz5u/cAyYikiZjOcyzk0o2iQcpS3 0Mxn1vZYnbUfBTmpJbcqMut5gdrpqf1iPkmzoqLOfmeczOF2/7nTEMn9lGWkffLJ fs70fx80hbCrSCPjKOj8ExuMnC9ZGIfzuEIEDdFBMoH3SfN27bC+/rLtv4wfKYcm zzSftfekFf/WeWjb7skRso1fC/+rfszMhivFxYUoox61LSvZ16x+UHCIXoPY9zTV W/YstDWv0B0s9TR8Lue/meWEq2mYrV2+obGIDUIlQ7Fauahj+YLyHX+BazaoX2HQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddruddvfedgieejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefkughoucfu tghhihhmmhgvlhcuoehiughoshgthhesihguohhstghhrdhorhhgqeenucggtffrrghtth gvrhhnpeeilefghfehvdehjeevhefhvefggeeflefghfdtgffhfeejgfevhefggfejteek feenucffohhmrghinhepihhfrggtvgdruggvvhenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehiughoshgthhesihguohhstghhrdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 30 Dec 2021 09:39:25 -0500 (EST) Date: Thu, 30 Dec 2021 16:39:23 +0200 From: Ido Schimmel To: Yevhen Orlov Cc: netdev@vger.kernel.org, stephen@networkplumber.org, andrew@lunn.ch, Volodymyr Mytnyk , Taras Chornyi , Mickey Rachamim , Serhiy Pshyk , Taras Chornyi , Oleksandr Mazur , "David S. Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v2 6/6] net: marvell: prestera: Implement initial inetaddr notifiers Message-ID: References: <20211227215233.31220-1-yevhen.orlov@plvision.eu> <20211227215233.31220-7-yevhen.orlov@plvision.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211227215233.31220-7-yevhen.orlov@plvision.eu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 27, 2021 at 11:52:31PM +0200, Yevhen Orlov wrote: > Add inetaddr notifiers to support add/del IPv4 address on switchdev > port. We create TRAP on first address, added on port and delete TRAP, > when last address removed. > Currently, driver supports only regular port to became routed. > Other port type support will be added later > > Co-developed-by: Taras Chornyi > Signed-off-by: Taras Chornyi > Co-developed-by: Oleksandr Mazur > Signed-off-by: Oleksandr Mazur > Signed-off-by: Yevhen Orlov > --- > v1-->v2 > * Remove useless assigment in prestera_fix_tb_id > --- > .../marvell/prestera/prestera_router.c | 40 +++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/drivers/net/ethernet/marvell/prestera/prestera_router.c b/drivers/net/ethernet/marvell/prestera/prestera_router.c > index 0eb5f5e00e4e..483f0ba45ce0 100644 > --- a/drivers/net/ethernet/marvell/prestera/prestera_router.c > +++ b/drivers/net/ethernet/marvell/prestera/prestera_router.c > @@ -4,16 +4,31 @@ > #include > #include > #include > +#include > > #include "prestera.h" > #include "prestera_router_hw.h" > > +/* This util to be used, to convert kernel rules for default vr in hw_vr */ > +static u32 prestera_fix_tb_id(u32 tb_id) > +{ > + if (tb_id == RT_TABLE_UNSPEC || > + tb_id == RT_TABLE_LOCAL || > + tb_id == RT_TABLE_DEFAULT) > + tb_id = RT_TABLE_MAIN; > + > + return tb_id; > +} > + > static int __prestera_inetaddr_port_event(struct net_device *port_dev, > unsigned long event, > struct netlink_ext_ack *extack) > { > struct prestera_port *port = netdev_priv(port_dev); > int err; > + struct prestera_rif_entry *re; > + struct prestera_rif_entry_key re_key = {}; > + u32 kern_tb_id; Reverse xmas tree > > err = prestera_is_valid_mac_addr(port, port_dev->dev_addr); > if (err) { > @@ -21,9 +36,34 @@ static int __prestera_inetaddr_port_event(struct net_device *port_dev, > return err; > } > > + kern_tb_id = l3mdev_fib_table(port_dev); > + re_key.iface.type = PRESTERA_IF_PORT_E; > + re_key.iface.dev_port.hw_dev_num = port->dev_id; > + re_key.iface.dev_port.port_num = port->hw_id; > + re = prestera_rif_entry_find(port->sw, &re_key); > + > switch (event) { > case NETDEV_UP: > + if (re) { > + NL_SET_ERR_MSG_MOD(extack, "rif_entry already exist"); These messages are communicated to user space so use a message that is more user friendly / informative > + return -EEXIST; > + } > + re = prestera_rif_entry_create(port->sw, &re_key, > + prestera_fix_tb_id(kern_tb_id), > + port_dev->dev_addr); > + if (!re) { > + NL_SET_ERR_MSG_MOD(extack, "Can't create rif_entry"); > + return -EINVAL; > + } > + dev_hold(port_dev); What is the purpose of this dev_hold()? > + break; > case NETDEV_DOWN: > + if (!re) { > + NL_SET_ERR_MSG_MOD(extack, "rif_entry not exist"); > + return -EEXIST; > + } > + prestera_rif_entry_destroy(port->sw, re); > + dev_put(port_dev); > break; > } > > -- > 2.17.1 >