Skip to content

Commit 75c05a7

Browse files
lunndavem330
authored andcommitted
net: dsa: mv88e6xxx: Fix counting of ATU violations
The ATU port vector contains a bit per port of the switch. The code wrongly used it as a port number, and incremented a port counter. This resulted in the wrong interfaces counter being incremented, and potentially going off the end of the array of ports. Fix this by using the source port ID for the violation, which really is a port number. Reported-by: Chris Healy <[email protected]> Tested-by: Chris Healy <[email protected]> Fixes: 65f60e4 ("net: dsa: mv88e6xxx: Keep ATU/VTU violation statistics") Signed-off-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9c0bda6 commit 75c05a7

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

drivers/net/dsa/mv88e6xxx/global1_atu.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
314314
{
315315
struct mv88e6xxx_chip *chip = dev_id;
316316
struct mv88e6xxx_atu_entry entry;
317+
int spid;
317318
int err;
318319
u16 val;
319320

@@ -336,6 +337,8 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
336337
if (err)
337338
goto out;
338339

340+
spid = entry.state;
341+
339342
if (val & MV88E6XXX_G1_ATU_OP_AGE_OUT_VIOLATION) {
340343
dev_err_ratelimited(chip->dev,
341344
"ATU age out violation for %pM\n",
@@ -344,23 +347,23 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
344347

345348
if (val & MV88E6XXX_G1_ATU_OP_MEMBER_VIOLATION) {
346349
dev_err_ratelimited(chip->dev,
347-
"ATU member violation for %pM portvec %x\n",
348-
entry.mac, entry.portvec);
349-
chip->ports[entry.portvec].atu_member_violation++;
350+
"ATU member violation for %pM portvec %x spid %d\n",
351+
entry.mac, entry.portvec, spid);
352+
chip->ports[spid].atu_member_violation++;
350353
}
351354

352355
if (val & MV88E6XXX_G1_ATU_OP_MISS_VIOLATION) {
353356
dev_err_ratelimited(chip->dev,
354-
"ATU miss violation for %pM portvec %x\n",
355-
entry.mac, entry.portvec);
356-
chip->ports[entry.portvec].atu_miss_violation++;
357+
"ATU miss violation for %pM portvec %x spid %d\n",
358+
entry.mac, entry.portvec, spid);
359+
chip->ports[spid].atu_miss_violation++;
357360
}
358361

359362
if (val & MV88E6XXX_G1_ATU_OP_FULL_VIOLATION) {
360363
dev_err_ratelimited(chip->dev,
361-
"ATU full violation for %pM portvec %x\n",
362-
entry.mac, entry.portvec);
363-
chip->ports[entry.portvec].atu_full_violation++;
364+
"ATU full violation for %pM portvec %x spid %d\n",
365+
entry.mac, entry.portvec, spid);
366+
chip->ports[spid].atu_full_violation++;
364367
}
365368
mutex_unlock(&chip->reg_lock);
366369

0 commit comments

Comments
 (0)