Skip to content

Commit a5b78b6

Browse files
Roger QuadrosNipaLocal
authored andcommitted
net: ti: prueth: Adds support for network filters for traffic control supported by PRU-ICSS
Driver updates to enable/disable network filters and traffic control features supported by the firmware running on PRU-ICSS. Control of the following features are now supported: 1. Promiscuous mode 2. Network Storm prevention 3. Multicast filtering and 4. VLAN filtering Firmware running on PRU-ICSS will go through all these filter checks prior to sending the rx packets to the host. Ethtool or dev ioctl can be used to enable/disable these features from the user space. Signed-off-by: Roger Quadros <[email protected]> Signed-off-by: Andrew F. Davis <[email protected]> Signed-off-by: Basharath Hussain Khaja <[email protected]> Signed-off-by: Parvathi Pudi <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 98eef06 commit a5b78b6

File tree

7 files changed

+744
-2
lines changed

7 files changed

+744
-2
lines changed

drivers/net/ethernet/ti/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55

66
obj-$(CONFIG_TI_PRUETH) += icssm-prueth.o
7-
icssm-prueth-y := icssm/icssm_prueth.o icssm/icssm_ethtool.o
7+
icssm-prueth-y := icssm/icssm_prueth.o icssm/icssm_ethtool.o icssm/icssm_prueth_dos.o
88

99
obj-$(CONFIG_TI_CPSW) += cpsw-common.o
1010
obj-$(CONFIG_TI_DAVINCI_EMAC) += cpsw-common.o

drivers/net/ethernet/ti/icssm/icssm_ethtool.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/if_bridge.h>
99
#include <linux/if_vlan.h>
1010
#include "icssm_prueth.h"
11+
#include "icssm_vlan_mcast_filter_mmap.h"
1112
#include "../icssg/icss_iep.h"
1213

1314
/* set PRU firmware statistics */
@@ -18,6 +19,11 @@ void icssm_emac_set_stats(struct prueth_emac *emac,
1819

1920
dram = emac->prueth->mem[emac->dram].va;
2021
memcpy_toio(dram + STATISTICS_OFFSET, pstats, STAT_SIZE);
22+
23+
writel(pstats->vlan_dropped, dram +
24+
ICSS_EMAC_FW_VLAN_FILTER_DROP_CNT_OFFSET);
25+
writel(pstats->multicast_dropped, dram +
26+
ICSS_EMAC_FW_MULTICAST_FILTER_DROP_CNT_OFFSET);
2127
}
2228

2329
/* get statistics maintained by the PRU firmware into @pstats */
@@ -28,6 +34,11 @@ void icssm_emac_get_stats(struct prueth_emac *emac,
2834

2935
dram = emac->prueth->mem[emac->dram].va;
3036
memcpy_fromio(pstats, dram + STATISTICS_OFFSET, STAT_SIZE);
37+
38+
pstats->vlan_dropped =
39+
readl(dram + ICSS_EMAC_FW_VLAN_FILTER_DROP_CNT_OFFSET);
40+
pstats->multicast_dropped =
41+
readl(dram + ICSS_EMAC_FW_MULTICAST_FILTER_DROP_CNT_OFFSET);
3142
}
3243

3344
/**
@@ -162,13 +173,40 @@ static void icssm_emac_get_ethtool_stats(struct net_device *ndev,
162173
}
163174
}
164175

176+
static int icssm_emac_get_regs_len(struct net_device *ndev)
177+
{
178+
struct prueth_emac *emac = netdev_priv(ndev);
179+
struct prueth *prueth = emac->prueth;
180+
181+
/* VLAN Table at the end of the memory map, after MultiCast
182+
* filter region. So VLAN table base +
183+
* size will give the entire size of reg dump in case of
184+
* Dual-EMAC firmware.
185+
*/
186+
if (PRUETH_IS_EMAC(prueth)) {
187+
return ICSS_EMAC_FW_VLAN_FLTR_TBL_BASE_ADDR +
188+
ICSS_EMAC_FW_VLAN_FILTER_TABLE_SIZE_BYTES;
189+
}
190+
191+
return 0;
192+
}
193+
165194
static void icssm_emac_get_regs(struct net_device *ndev,
166195
struct ethtool_regs *regs, void *p)
167196
{
168197
struct prueth_emac *emac = netdev_priv(ndev);
169198
struct prueth *prueth = emac->prueth;
199+
void __iomem *ram;
200+
u8 *reg = p;
170201

171202
regs->version = PRUETH_REG_DUMP_GET_VER(prueth);
203+
204+
/* Dump firmware's VLAN and MC tables */
205+
if (PRUETH_IS_EMAC(prueth)) {
206+
ram = prueth->mem[emac->dram].va;
207+
memcpy_fromio(reg, ram, icssm_emac_get_regs_len(ndev));
208+
return;
209+
}
172210
}
173211

174212
static const struct ethtool_rmon_hist_range icssm_emac_rmon_ranges[] = {
@@ -252,6 +290,7 @@ const struct ethtool_ops emac_ethtool_ops = {
252290
.get_sset_count = icssm_emac_get_sset_count,
253291
.get_strings = icssm_emac_get_strings,
254292
.get_ethtool_stats = icssm_emac_get_ethtool_stats,
293+
.get_regs_len = icssm_emac_get_regs_len,
255294
.get_regs = icssm_emac_get_regs,
256295
.get_rmon_stats = icssm_emac_get_rmon_stats,
257296
.get_eth_mac_stats = icssm_emac_get_eth_mac_stats,

0 commit comments

Comments
 (0)