Skip to content

Commit 4f4040e

Browse files
hm-tikuba-moo
authored andcommitted
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 <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 77f0813 commit 4f4040e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

drivers/net/ethernet/ti/icssg/icssg_prueth.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,10 @@ static int prueth_emac_start(struct prueth *prueth)
148148

149149
if (prueth->is_switch_mode)
150150
firmwares = prueth->icssg_switch_firmwares;
151-
else if (prueth->is_hsr_offload_mode)
151+
else if (prueth->is_hsr_offload_mode && HSR_V1 == prueth->hsr_prp_version)
152152
firmwares = prueth->icssg_hsr_firmwares;
153+
else if (prueth->is_hsr_offload_mode && PRP_V1 == prueth->hsr_prp_version)
154+
firmwares = prueth->icssg_prp_firmwares;
153155
else
154156
firmwares = prueth->icssg_emac_firmwares;
155157

@@ -1527,6 +1529,7 @@ static int prueth_netdevice_event(struct notifier_block *unused,
15271529
struct netdev_notifier_changeupper_info *info;
15281530
struct prueth_emac *emac = netdev_priv(ndev);
15291531
struct prueth *prueth = emac->prueth;
1532+
enum hsr_version hsr_ndev_version;
15301533
int ret = NOTIFY_DONE;
15311534

15321535
if (ndev->netdev_ops != &emac_netdev_ops)
@@ -1538,6 +1541,11 @@ static int prueth_netdevice_event(struct notifier_block *unused,
15381541

15391542
if ((ndev->features & NETIF_PRUETH_HSR_OFFLOAD_FEATURES) &&
15401543
is_hsr_master(info->upper_dev)) {
1544+
hsr_get_version(info->upper_dev, &hsr_ndev_version);
1545+
if (hsr_ndev_version != HSR_V1 && hsr_ndev_version != PRP_V1)
1546+
return -EOPNOTSUPP;
1547+
prueth->hsr_prp_version = hsr_ndev_version;
1548+
15411549
if (info->linking) {
15421550
if (!prueth->hsr_dev) {
15431551
prueth->hsr_dev = info->upper_dev;
@@ -1858,6 +1866,8 @@ static int prueth_probe(struct platform_device *pdev)
18581866
prueth->icssg_switch_firmwares, "eth", "sw");
18591867
icssg_mode_firmware_names(dev, prueth->icssg_emac_firmwares,
18601868
prueth->icssg_hsr_firmwares, "eth", "hsr");
1869+
icssg_mode_firmware_names(dev, prueth->icssg_emac_firmwares,
1870+
prueth->icssg_prp_firmwares, "eth", "prp");
18611871

18621872
spin_lock_init(&prueth->vtbl_lock);
18631873
spin_lock_init(&prueth->stats_lock);

drivers/net/ethernet/ti/icssg/icssg_prueth.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/etherdevice.h>
1414
#include <linux/genalloc.h>
1515
#include <linux/if_vlan.h>
16+
#include <linux/if_hsr.h>
1617
#include <linux/interrupt.h>
1718
#include <linux/kernel.h>
1819
#include <linux/mfd/syscon.h>
@@ -290,6 +291,7 @@ struct icssg_firmwares {
290291
* @vlan_tbl: VLAN-FID table pointer
291292
* @hw_bridge_dev: pointer to HW bridge net device
292293
* @hsr_dev: pointer to the HSR net device
294+
* @hsr_prp_version: enum to store the protocol version of hsr master
293295
* @br_members: bitmask of bridge member ports
294296
* @hsr_members: bitmask of hsr member ports
295297
* @prueth_netdevice_nb: netdevice notifier block
@@ -303,6 +305,7 @@ struct icssg_firmwares {
303305
* @icssg_emac_firmwares: Firmware names for EMAC mode, indexed per MAC
304306
* @icssg_switch_firmwares: Firmware names for SWITCH mode, indexed per MAC
305307
* @icssg_hsr_firmwares: Firmware names for HSR mode, indexed per MAC
308+
* @icssg_prp_firmwares: Firmware names for PRP mode, indexed per MAC
306309
*/
307310
struct prueth {
308311
struct device *dev;
@@ -332,6 +335,7 @@ struct prueth {
332335

333336
struct net_device *hw_bridge_dev;
334337
struct net_device *hsr_dev;
338+
enum hsr_version hsr_prp_version;
335339
u8 br_members;
336340
u8 hsr_members;
337341
struct notifier_block prueth_netdevice_nb;
@@ -349,6 +353,7 @@ struct prueth {
349353
struct icssg_firmwares icssg_emac_firmwares[PRUETH_NUM_MACS];
350354
struct icssg_firmwares icssg_switch_firmwares[PRUETH_NUM_MACS];
351355
struct icssg_firmwares icssg_hsr_firmwares[PRUETH_NUM_MACS];
356+
struct icssg_firmwares icssg_prp_firmwares[PRUETH_NUM_MACS];
352357
};
353358

354359
struct emac_tx_ts_response {

0 commit comments

Comments
 (0)