From: Himanshu Mittal Date: Wed, 18 Jun 2025 17:55:36 +0000 (+0530) Subject: net: ti: icssg-prueth: Add prp offload support to ICSSG driver X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f4040ea5d3e4bebebbef9379f88085c8b99221c;p=thirdparty%2Fkernel%2Fstable.git net: ti: icssg-prueth: Add prp offload support to ICSSG driver Add support for ICSSG PRP mode which supports offloading of: - Packet duplication and PRP trailer insertion - Packet duplicate discard and PRP trailer removal Signed-off-by: Himanshu Mittal Reviewed-by: Simon Horman Link: https://patch.msgid.link/20250618175536.430568-1-h-mittal1@ti.com Signed-off-by: David S. Miller Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.c b/drivers/net/ethernet/ti/icssg/icssg_prueth.c index a1e013b0a0eb..2aa812cbab92 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.c +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.c @@ -148,8 +148,10 @@ static int prueth_emac_start(struct prueth *prueth) if (prueth->is_switch_mode) firmwares = prueth->icssg_switch_firmwares; - else if (prueth->is_hsr_offload_mode) + else if (prueth->is_hsr_offload_mode && HSR_V1 == prueth->hsr_prp_version) firmwares = prueth->icssg_hsr_firmwares; + else if (prueth->is_hsr_offload_mode && PRP_V1 == prueth->hsr_prp_version) + firmwares = prueth->icssg_prp_firmwares; else firmwares = prueth->icssg_emac_firmwares; @@ -1527,6 +1529,7 @@ static int prueth_netdevice_event(struct notifier_block *unused, struct netdev_notifier_changeupper_info *info; struct prueth_emac *emac = netdev_priv(ndev); struct prueth *prueth = emac->prueth; + enum hsr_version hsr_ndev_version; int ret = NOTIFY_DONE; if (ndev->netdev_ops != &emac_netdev_ops) @@ -1538,6 +1541,11 @@ static int prueth_netdevice_event(struct notifier_block *unused, if ((ndev->features & NETIF_PRUETH_HSR_OFFLOAD_FEATURES) && is_hsr_master(info->upper_dev)) { + hsr_get_version(info->upper_dev, &hsr_ndev_version); + if (hsr_ndev_version != HSR_V1 && hsr_ndev_version != PRP_V1) + return -EOPNOTSUPP; + prueth->hsr_prp_version = hsr_ndev_version; + if (info->linking) { if (!prueth->hsr_dev) { prueth->hsr_dev = info->upper_dev; @@ -1858,6 +1866,8 @@ static int prueth_probe(struct platform_device *pdev) prueth->icssg_switch_firmwares, "eth", "sw"); icssg_mode_firmware_names(dev, prueth->icssg_emac_firmwares, prueth->icssg_hsr_firmwares, "eth", "hsr"); + icssg_mode_firmware_names(dev, prueth->icssg_emac_firmwares, + prueth->icssg_prp_firmwares, "eth", "prp"); spin_lock_init(&prueth->vtbl_lock); spin_lock_init(&prueth->stats_lock); diff --git a/drivers/net/ethernet/ti/icssg/icssg_prueth.h b/drivers/net/ethernet/ti/icssg/icssg_prueth.h index c03e3b3626c1..9ca2e7fdefbd 100644 --- a/drivers/net/ethernet/ti/icssg/icssg_prueth.h +++ b/drivers/net/ethernet/ti/icssg/icssg_prueth.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -290,6 +291,7 @@ struct icssg_firmwares { * @vlan_tbl: VLAN-FID table pointer * @hw_bridge_dev: pointer to HW bridge net device * @hsr_dev: pointer to the HSR net device + * @hsr_prp_version: enum to store the protocol version of hsr master * @br_members: bitmask of bridge member ports * @hsr_members: bitmask of hsr member ports * @prueth_netdevice_nb: netdevice notifier block @@ -303,6 +305,7 @@ struct icssg_firmwares { * @icssg_emac_firmwares: Firmware names for EMAC mode, indexed per MAC * @icssg_switch_firmwares: Firmware names for SWITCH mode, indexed per MAC * @icssg_hsr_firmwares: Firmware names for HSR mode, indexed per MAC + * @icssg_prp_firmwares: Firmware names for PRP mode, indexed per MAC */ struct prueth { struct device *dev; @@ -332,6 +335,7 @@ struct prueth { struct net_device *hw_bridge_dev; struct net_device *hsr_dev; + enum hsr_version hsr_prp_version; u8 br_members; u8 hsr_members; struct notifier_block prueth_netdevice_nb; @@ -349,6 +353,7 @@ struct prueth { struct icssg_firmwares icssg_emac_firmwares[PRUETH_NUM_MACS]; struct icssg_firmwares icssg_switch_firmwares[PRUETH_NUM_MACS]; struct icssg_firmwares icssg_hsr_firmwares[PRUETH_NUM_MACS]; + struct icssg_firmwares icssg_prp_firmwares[PRUETH_NUM_MACS]; }; struct emac_tx_ts_response {