Skip to content

Commit

Permalink
net: prueth: fix disabling storm prevention
Browse files Browse the repository at this point in the history
Storm prevention feature was not being disabled because value was only
being written to memory for firmware to read if storm prevention was
enabled. Fix writes disabled status to memory once, when storm
prevention is disabled through sysfs. Additionally, the correct DRAM was
not being set during initializtion so both ports were defaulting to
DRAM0. Added initialization to set correct DRAM per port.

Signed-off-by: Aaron Kramer <[email protected]>
  • Loading branch information
Aaron Kramer committed Dec 9, 2019
1 parent 5f8c1c6 commit 6990349
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 11 additions & 0 deletions drivers/net/ethernet/ti/prueth.c
Original file line number Diff line number Diff line change
Expand Up @@ -5000,6 +5000,17 @@ static int prueth_netdev_init(struct prueth *prueth,
emac->ndev = ndev;
emac->port_id = port;

switch (port) {
case PRUETH_PORT_MII0:
emac->dram = PRUETH_MEM_DRAM0;
break;
case PRUETH_PORT_MII1:
emac->dram = PRUETH_MEM_DRAM1;
break;
default:
return -EINVAL;
}

if (PRUETH_HAS_PTP(prueth) && !PRUETH_IS_EMAC(prueth))
tx_int = "hsrprp_ptp_tx";
else
Expand Down
7 changes: 5 additions & 2 deletions drivers/net/ethernet/ti/prueth_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ static ssize_t nsp_credit_store(struct device *dev,
const char *buffer, size_t count)
{
struct prueth_emac *emac = nsp_credit_to_emac(attr);
void __iomem *dram = emac->prueth->mem[emac->dram].va;
u32 val;

if (kstrtou32(buffer, 0, &val))
return -EINVAL;

if (val)
if (val) {
emac->nsp_credit =
(val << PRUETH_NSP_CREDIT_SHIFT) | PRUETH_NSP_ENABLE;
else
} else {
emac->nsp_credit = PRUETH_NSP_DISABLE;
writel(emac->nsp_credit, dram + STORM_PREVENTION_OFFSET);
}

return count;
}
Expand Down

0 comments on commit 6990349

Please sign in to comment.