Commit 69204174 authored by Yevhen Orlov's avatar Yevhen Orlov Committed by David S. Miller

net: marvell: prestera: Add prestera router infra

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: default avatarTaras Chornyi <tchornyi@marvell.com>
Signed-off-by: default avatarTaras Chornyi <tchornyi@marvell.com>
Co-developed-by: default avatarOleksandr Mazur <oleksandr.mazur@plvision.eu>
Signed-off-by: default avatarOleksandr Mazur <oleksandr.mazur@plvision.eu>
Signed-off-by: default avatarYevhen Orlov <yevhen.orlov@plvision.eu>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0f07bd6b
......@@ -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
......@@ -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;
};
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,
......
......@@ -902,6 +902,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;
......@@ -958,6 +962,8 @@ static int prestera_switch_init(struct prestera_switch *sw)
err_rxtx_register:
prestera_switchdev_fini(sw);
err_swdev_register:
prestera_router_fini(sw);
err_router_init:
prestera_netdev_event_handler_unregister(sw);
prestera_hw_switch_fini(sw);
......
// 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;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment