Skip to content

Commit

Permalink
net: marvell: prestera: Add Switchdev driver implementation
Browse files Browse the repository at this point in the history
The following features are supported:

    - VLAN-aware bridge offloading
    - VLAN-unaware bridge offloading
    - FDB offloading (learning, ageing)
    - Switchport configuration

Currently there are some limitations like:

    - Only 1 VLAN-aware bridge instance supported
    - FDB ageing timeout parameter is set globally per device

Co-developed-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Signed-off-by: Serhiy Boiko <serhiy.boiko@plvision.eu>
Co-developed-by: Serhiy Pshyk <serhiy.pshyk@plvision.eu>
Signed-off-by: Serhiy Pshyk <serhiy.pshyk@plvision.eu>
Co-developed-by: Taras Chornyi <taras.chornyi@plvision.eu>
Signed-off-by: Taras Chornyi <taras.chornyi@plvision.eu>
Signed-off-by: Vadym Kochan <vadym.kochan@plvision.eu>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
vkochan-plv authored and davem330 committed Sep 17, 2020
1 parent a97d3c6 commit e1189d9
Show file tree
Hide file tree
Showing 7 changed files with 1,807 additions and 4 deletions.
3 changes: 2 additions & 1 deletion drivers/net/ethernet/marvell/prestera/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
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_rxtx.o prestera_devlink.o prestera_ethtool.o \
prestera_switchdev.o

obj-$(CONFIG_PRESTERA_PCI) += prestera_pci.o
31 changes: 31 additions & 0 deletions drivers/net/ethernet/marvell/prestera/prestera.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#define PRESTERA_DRV_NAME "prestera"

#define PRESTERA_DEFAULT_VID 1

struct prestera_fw_rev {
u16 maj;
u16 min;
Expand Down Expand Up @@ -66,11 +68,13 @@ struct prestera_port {
u32 hw_id;
u32 dev_id;
u16 fp_id;
u16 pvid;
bool autoneg;
u64 adver_link_modes;
u8 adver_fec;
struct prestera_port_caps caps;
struct list_head list;
struct list_head vlans_list;
struct {
struct prestera_port_stats stats;
struct delayed_work caching_dw;
Expand Down Expand Up @@ -100,6 +104,7 @@ enum prestera_event_type {
PRESTERA_EVENT_TYPE_UNSPEC,

PRESTERA_EVENT_TYPE_PORT,
PRESTERA_EVENT_TYPE_FDB,
PRESTERA_EVENT_TYPE_RXTX,

PRESTERA_EVENT_TYPE_MAX
Expand All @@ -122,19 +127,37 @@ struct prestera_port_event {
} data;
};

enum prestera_fdb_event_id {
PRESTERA_FDB_EVENT_UNSPEC,
PRESTERA_FDB_EVENT_LEARNED,
PRESTERA_FDB_EVENT_AGED,
};

struct prestera_fdb_event {
u32 port_id;
u32 vid;
union {
u8 mac[ETH_ALEN];
} data;
};

struct prestera_event {
u16 id;
union {
struct prestera_port_event port_evt;
struct prestera_fdb_event fdb_evt;
};
};

struct prestera_switchdev;
struct prestera_rxtx;

struct prestera_switch {
struct prestera_device *dev;
struct prestera_switchdev *swdev;
struct prestera_rxtx *rxtx;
struct list_head event_handlers;
struct notifier_block netdev_nb;
char base_mac[ETH_ALEN];
struct list_head port_list;
rwlock_t port_list_lock;
Expand Down Expand Up @@ -172,4 +195,12 @@ struct prestera_port *prestera_port_find_by_hwid(struct prestera_switch *sw,
int prestera_port_autoneg_set(struct prestera_port *port, bool enable,
u64 adver_link_modes, u8 adver_fec);

struct prestera_port *prestera_find_port(struct prestera_switch *sw, u32 id);

struct prestera_port *prestera_port_dev_lower_find(struct net_device *dev);

int prestera_port_pvid_set(struct prestera_port *port, u16 vid);

bool prestera_netdev_check(const struct net_device *dev);

#endif /* _PRESTERA_H_ */
Loading

0 comments on commit e1189d9

Please sign in to comment.