netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch.org>
To: Yevhen Orlov <yevhen.orlov@plvision.eu>
Cc: netdev@vger.kernel.org, stephen@networkplumber.org,
	andrew@lunn.ch, Volodymyr Mytnyk <volodymyr.mytnyk@plvision.eu>,
	Taras Chornyi <taras.chornyi@plvision.eu>,
	Mickey Rachamim <mickeyr@marvell.com>,
	Serhiy Pshyk <serhiy.pshyk@plvision.eu>,
	Taras Chornyi <tchornyi@marvell.com>,
	Oleksandr Mazur <oleksandr.mazur@plvision.eu>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 3/6] net: marvell: prestera: Add prestera router infra
Date: Thu, 30 Dec 2021 15:48:22 +0200	[thread overview]
Message-ID: <Yc24pow5B9PaFWP2@shredder> (raw)
In-Reply-To: <20211227215233.31220-4-yevhen.orlov@plvision.eu>

On Mon, Dec 27, 2021 at 11:52:28PM +0200, Yevhen Orlov wrote:
> Add prestera_router.c, which contains code to subscribe/unsubscribe on
> kernel notifiers for router. This handle kernel notifications,
> parse structures to make key to manipulate prestera_router_hw's objects.
> 
> Also prestera_router is container for router's objects database.
> 
> Co-developed-by: Taras Chornyi <tchornyi@marvell.com>
> Signed-off-by: Taras Chornyi <tchornyi@marvell.com>
> Co-developed-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
> Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
> Signed-off-by: Yevhen Orlov <yevhen.orlov@plvision.eu>
> ---
> v1-->v2
> * No changes
> ---
>  .../net/ethernet/marvell/prestera/Makefile    |  3 +-
>  .../net/ethernet/marvell/prestera/prestera.h  | 11 ++++++++
>  .../ethernet/marvell/prestera/prestera_main.c |  6 ++++
>  .../marvell/prestera/prestera_router.c        | 28 +++++++++++++++++++
>  4 files changed, 47 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/net/ethernet/marvell/prestera/prestera_router.c
> 
> diff --git a/drivers/net/ethernet/marvell/prestera/Makefile b/drivers/net/ethernet/marvell/prestera/Makefile
> index 48dbcb2baf8f..ec69fc564a9f 100644
> --- a/drivers/net/ethernet/marvell/prestera/Makefile
> +++ b/drivers/net/ethernet/marvell/prestera/Makefile
> @@ -3,6 +3,7 @@ obj-$(CONFIG_PRESTERA)	+= prestera.o
>  prestera-objs		:= prestera_main.o prestera_hw.o prestera_dsa.o \
>  			   prestera_rxtx.o prestera_devlink.o prestera_ethtool.o \
>  			   prestera_switchdev.o prestera_acl.o prestera_flow.o \
> -			   prestera_flower.o prestera_span.o prestera_counter.o
> +			   prestera_flower.o prestera_span.o prestera_counter.o \
> +			   prestera_router.o
>  
>  obj-$(CONFIG_PRESTERA_PCI)	+= prestera_pci.o
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera.h b/drivers/net/ethernet/marvell/prestera/prestera.h
> index 636caf492531..7160da678457 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera.h
> +++ b/drivers/net/ethernet/marvell/prestera/prestera.h
> @@ -270,12 +270,20 @@ struct prestera_switch {
>  	u32 mtu_min;
>  	u32 mtu_max;
>  	u8 id;
> +	struct prestera_router *router;
>  	struct prestera_lag *lags;
>  	struct prestera_counter *counter;
>  	u8 lag_member_max;
>  	u8 lag_max;
>  };
>  
> +struct prestera_router {
> +	struct prestera_switch *sw;
> +	struct list_head vr_list;
> +	struct list_head rif_entry_list;
> +	bool aborted;

Never used

> +};
> +
>  struct prestera_rxtx_params {
>  	bool use_sdma;
>  	u32 map_addr;
> @@ -303,6 +311,9 @@ struct prestera_port *prestera_port_find_by_hwid(struct prestera_switch *sw,
>  
>  int prestera_port_autoneg_set(struct prestera_port *port, u64 link_modes);
>  
> +int prestera_router_init(struct prestera_switch *sw);
> +void prestera_router_fini(struct prestera_switch *sw);
> +
>  struct prestera_port *prestera_find_port(struct prestera_switch *sw, u32 id);
>  
>  int prestera_port_cfg_mac_read(struct prestera_port *port,
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
> index a0dbad5cb88d..242904fcd866 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
> @@ -893,6 +893,10 @@ static int prestera_switch_init(struct prestera_switch *sw)
>  	if (err)
>  		return err;
>  
> +	err = prestera_router_init(sw);
> +	if (err)
> +		goto err_router_init;
> +
>  	err = prestera_switchdev_init(sw);
>  	if (err)
>  		goto err_swdev_register;
> @@ -949,6 +953,8 @@ static int prestera_switch_init(struct prestera_switch *sw)
>  err_rxtx_register:
>  	prestera_switchdev_fini(sw);
>  err_swdev_register:
> +	prestera_router_fini(sw);

Missing a call in prestera_switch_fini(). Most likely visible with
kmemleak enabled

> +err_router_init:
>  	prestera_netdev_event_handler_unregister(sw);
>  	prestera_hw_switch_fini(sw);
>  
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_router.c b/drivers/net/ethernet/marvell/prestera/prestera_router.c
> new file mode 100644
> index 000000000000..f3980d10eb29
> --- /dev/null
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_router.c
> @@ -0,0 +1,28 @@
> +// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
> +/* Copyright (c) 2019-2021 Marvell International Ltd. All rights reserved */
> +
> +#include <linux/kernel.h>
> +#include <linux/types.h>
> +
> +#include "prestera.h"
> +
> +int prestera_router_init(struct prestera_switch *sw)
> +{
> +	struct prestera_router *router;
> +
> +	router = kzalloc(sizeof(*sw->router), GFP_KERNEL);
> +	if (!router)
> +		return -ENOMEM;
> +
> +	sw->router = router;
> +	router->sw = sw;
> +
> +	return 0;
> +}
> +
> +void prestera_router_fini(struct prestera_switch *sw)
> +{
> +	kfree(sw->router);
> +	sw->router = NULL;
> +}
> +
> -- 
> 2.17.1
> 

  reply	other threads:[~2021-12-30 13:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-27 21:52 [PATCH net-next v2 0/6] prestera: add basic router driver support Yevhen Orlov
2021-12-27 21:52 ` [PATCH net-next v2 1/6] net: marvell: prestera: add virtual router ABI Yevhen Orlov
2021-12-30 13:41   ` Ido Schimmel
2021-12-27 21:52 ` [PATCH net-next v2 2/6] net: marvell: prestera: Add router interface ABI Yevhen Orlov
2021-12-30 13:44   ` Ido Schimmel
2022-01-07  2:15     ` Yevhen Orlov
2021-12-27 21:52 ` [PATCH net-next v2 3/6] net: marvell: prestera: Add prestera router infra Yevhen Orlov
2021-12-30 13:48   ` Ido Schimmel [this message]
2021-12-27 21:52 ` [PATCH net-next v2 4/6] net: marvell: prestera: add hardware router objects accounting Yevhen Orlov
2021-12-30 14:19   ` Ido Schimmel
2021-12-27 21:52 ` [PATCH net-next v2 5/6] net: marvell: prestera: Register inetaddr stub notifiers Yevhen Orlov
2021-12-30 14:34   ` Ido Schimmel
2022-01-07  1:42     ` Yevhen Orlov
2022-01-07 13:43       ` Andrew Lunn
2022-01-11  1:00         ` Yevhen Orlov
2021-12-27 21:52 ` [PATCH net-next v2 6/6] net: marvell: prestera: Implement initial inetaddr notifiers Yevhen Orlov
2021-12-30 14:39   ` Ido Schimmel
2022-01-06  4:31     ` Yevhen Orlov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yc24pow5B9PaFWP2@shredder \
    --to=idosch@idosch.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mickeyr@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=oleksandr.mazur@plvision.eu \
    --cc=serhiy.pshyk@plvision.eu \
    --cc=stephen@networkplumber.org \
    --cc=taras.chornyi@plvision.eu \
    --cc=tchornyi@marvell.com \
    --cc=volodymyr.mytnyk@plvision.eu \
    --cc=yevhen.orlov@plvision.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).