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: 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> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
0f07bd6bcb
Коммит
69204174cc
|
@ -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 @@ err_handlers_register:
|
|||
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);
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
// 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;
|
||||
}
|
Загрузка…
Ссылка в новой задаче