Commit 75c05a74 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

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: default avatarChris Healy <Chris.Healy@zii.aero>
Tested-by: default avatarChris Healy <Chris.Healy@zii.aero>
Fixes: 65f60e45 ("net: dsa: mv88e6xxx: Keep ATU/VTU violation statistics")
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9c0bda64
...@@ -314,6 +314,7 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id) ...@@ -314,6 +314,7 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
{ {
struct mv88e6xxx_chip *chip = dev_id; struct mv88e6xxx_chip *chip = dev_id;
struct mv88e6xxx_atu_entry entry; struct mv88e6xxx_atu_entry entry;
int spid;
int err; int err;
u16 val; u16 val;
...@@ -336,6 +337,8 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id) ...@@ -336,6 +337,8 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
if (err) if (err)
goto out; goto out;
spid = entry.state;
if (val & MV88E6XXX_G1_ATU_OP_AGE_OUT_VIOLATION) { if (val & MV88E6XXX_G1_ATU_OP_AGE_OUT_VIOLATION) {
dev_err_ratelimited(chip->dev, dev_err_ratelimited(chip->dev,
"ATU age out violation for %pM\n", "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) ...@@ -344,23 +347,23 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
if (val & MV88E6XXX_G1_ATU_OP_MEMBER_VIOLATION) { if (val & MV88E6XXX_G1_ATU_OP_MEMBER_VIOLATION) {
dev_err_ratelimited(chip->dev, dev_err_ratelimited(chip->dev,
"ATU member violation for %pM portvec %x\n", "ATU member violation for %pM portvec %x spid %d\n",
entry.mac, entry.portvec); entry.mac, entry.portvec, spid);
chip->ports[entry.portvec].atu_member_violation++; chip->ports[spid].atu_member_violation++;
} }
if (val & MV88E6XXX_G1_ATU_OP_MISS_VIOLATION) { if (val & MV88E6XXX_G1_ATU_OP_MISS_VIOLATION) {
dev_err_ratelimited(chip->dev, dev_err_ratelimited(chip->dev,
"ATU miss violation for %pM portvec %x\n", "ATU miss violation for %pM portvec %x spid %d\n",
entry.mac, entry.portvec); entry.mac, entry.portvec, spid);
chip->ports[entry.portvec].atu_miss_violation++; chip->ports[spid].atu_miss_violation++;
} }
if (val & MV88E6XXX_G1_ATU_OP_FULL_VIOLATION) { if (val & MV88E6XXX_G1_ATU_OP_FULL_VIOLATION) {
dev_err_ratelimited(chip->dev, dev_err_ratelimited(chip->dev,
"ATU full violation for %pM portvec %x\n", "ATU full violation for %pM portvec %x spid %d\n",
entry.mac, entry.portvec); entry.mac, entry.portvec, spid);
chip->ports[entry.portvec].atu_full_violation++; chip->ports[spid].atu_full_violation++;
} }
mutex_unlock(&chip->reg_lock); mutex_unlock(&chip->reg_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment