Skip to content

Commit

Permalink
net: ti: icssg-switch: Add switchdev based driver for ethernet switch…
Browse files Browse the repository at this point in the history
… support

ICSSG can operating in switch mode with 2 ext port and 1 host port with
VLAN/FDB/MDB and STP offloading. Add switchdev based driver to
support the same.

Driver itself will be integrated with icssg_prueth in future commits

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: MD Danish Anwar <danishanwar@ti.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
danish-ti authored and Paolo Abeni committed May 30, 2024
1 parent 487f732 commit 972383a
Show file tree
Hide file tree
Showing 4 changed files with 526 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/net/ethernet/ti/icssg/icssg_prueth.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "icssg_prueth.h"
#include "icssg_mii_rt.h"
#include "icssg_switchdev.h"
#include "../k3-cppi-desc-pool.h"

#define PRUETH_MODULE_DESCRIPTION "PRUSS ICSSG Ethernet driver"
Expand Down Expand Up @@ -833,6 +834,17 @@ static int prueth_netdev_init(struct prueth *prueth,
return ret;
}

bool prueth_dev_check(const struct net_device *ndev)
{
if (ndev->netdev_ops == &emac_netdev_ops && netif_running(ndev)) {
struct prueth_emac *emac = netdev_priv(ndev);

return emac->prueth->is_switch_mode;
}

return false;
}

static int prueth_probe(struct platform_device *pdev)
{
struct device_node *eth_node, *eth_ports_node;
Expand Down
24 changes: 24 additions & 0 deletions drivers/net/ethernet/ti/icssg/icssg_prueth.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ struct prueth_emac {

struct pruss_mem_region dram;

bool offload_fwd_mark;
int port_vlan;

struct delayed_work stats_work;
u64 stats[ICSSG_NUM_STATS];

Expand All @@ -198,10 +201,12 @@ struct prueth_emac {
* struct prueth_pdata - PRUeth platform data
* @fdqring_mode: Free desc queue mode
* @quirk_10m_link_issue: 10M link detect errata
* @switch_mode: switch firmware support
*/
struct prueth_pdata {
enum k3_ring_mode fdqring_mode;
u32 quirk_10m_link_issue:1;
u32 switch_mode:1;
};

struct icssg_firmwares {
Expand Down Expand Up @@ -233,6 +238,15 @@ struct icssg_firmwares {
* @iep0: pointer to IEP0 device
* @iep1: pointer to IEP1 device
* @vlan_tbl: VLAN-FID table pointer
* @hw_bridge_dev: pointer to HW bridge net device
* @br_members: bitmask of bridge member ports
* @prueth_netdevice_nb: netdevice notifier block
* @prueth_switchdev_nb: switchdev notifier block
* @prueth_switchdev_bl_nb: switchdev blocking notifier block
* @is_switch_mode: flag to indicate if device is in Switch mode
* @is_switchmode_supported: indicates platform support for switch mode
* @switch_id: ID for mapping switch ports to bridge
* @default_vlan: Default VLAN for host
*/
struct prueth {
struct device *dev;
Expand All @@ -258,6 +272,16 @@ struct prueth {
struct icss_iep *iep0;
struct icss_iep *iep1;
struct prueth_vlan_tbl *vlan_tbl;

struct net_device *hw_bridge_dev;
u8 br_members;
struct notifier_block prueth_netdevice_nb;
struct notifier_block prueth_switchdev_nb;
struct notifier_block prueth_switchdev_bl_nb;
bool is_switch_mode;
bool is_switchmode_supported;
unsigned char switch_id[MAX_PHYS_ITEM_ID_LEN];
int default_vlan;
};

struct emac_tx_ts_response {
Expand Down
Loading

0 comments on commit 972383a

Please sign in to comment.