mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-04 13:21:45 +00:00
net: mscc: ocelot: better error handling in ocelot_xtr_irq_handler
The ocelot_rx_frame_word() function can return a negative error code, however this isn't being checked for consistently. Errors being ignored have not been seen in practice though. Also, some constructs can be simplified by using "goto" instead of repeated "break" statements. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d7795f8f26
commit
a94306cea5
1 changed files with 12 additions and 10 deletions
|
@ -619,12 +619,9 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)
|
||||||
for (i = 0; i < OCELOT_TAG_LEN / 4; i++) {
|
for (i = 0; i < OCELOT_TAG_LEN / 4; i++) {
|
||||||
err = ocelot_rx_frame_word(ocelot, grp, true, &ifh[i]);
|
err = ocelot_rx_frame_word(ocelot, grp, true, &ifh[i]);
|
||||||
if (err != 4)
|
if (err != 4)
|
||||||
break;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err != 4)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* At this point the IFH was read correctly, so it is safe to
|
/* At this point the IFH was read correctly, so it is safe to
|
||||||
* presume that there is no error. The err needs to be reset
|
* presume that there is no error. The err needs to be reset
|
||||||
* otherwise a frame could come in CPU queue between the while
|
* otherwise a frame could come in CPU queue between the while
|
||||||
|
@ -645,7 +642,7 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)
|
||||||
if (unlikely(!skb)) {
|
if (unlikely(!skb)) {
|
||||||
netdev_err(dev, "Unable to allocate sk_buff\n");
|
netdev_err(dev, "Unable to allocate sk_buff\n");
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
break;
|
goto out;
|
||||||
}
|
}
|
||||||
buf_len = info.len - ETH_FCS_LEN;
|
buf_len = info.len - ETH_FCS_LEN;
|
||||||
buf = (u32 *)skb_put(skb, buf_len);
|
buf = (u32 *)skb_put(skb, buf_len);
|
||||||
|
@ -653,12 +650,21 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)
|
||||||
len = 0;
|
len = 0;
|
||||||
do {
|
do {
|
||||||
sz = ocelot_rx_frame_word(ocelot, grp, false, &val);
|
sz = ocelot_rx_frame_word(ocelot, grp, false, &val);
|
||||||
|
if (sz < 0) {
|
||||||
|
err = sz;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
*buf++ = val;
|
*buf++ = val;
|
||||||
len += sz;
|
len += sz;
|
||||||
} while (len < buf_len);
|
} while (len < buf_len);
|
||||||
|
|
||||||
/* Read the FCS */
|
/* Read the FCS */
|
||||||
sz = ocelot_rx_frame_word(ocelot, grp, false, &val);
|
sz = ocelot_rx_frame_word(ocelot, grp, false, &val);
|
||||||
|
if (sz < 0) {
|
||||||
|
err = sz;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/* Update the statistics if part of the FCS was read before */
|
/* Update the statistics if part of the FCS was read before */
|
||||||
len -= ETH_FCS_LEN - sz;
|
len -= ETH_FCS_LEN - sz;
|
||||||
|
|
||||||
|
@ -667,11 +673,6 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)
|
||||||
*buf = val;
|
*buf = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sz < 0) {
|
|
||||||
err = sz;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ocelot->ptp) {
|
if (ocelot->ptp) {
|
||||||
ocelot_ptp_gettime64(&ocelot->ptp_info, &ts);
|
ocelot_ptp_gettime64(&ocelot->ptp_info, &ts);
|
||||||
|
|
||||||
|
@ -701,6 +702,7 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)
|
||||||
dev->stats.rx_packets++;
|
dev->stats.rx_packets++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
while (ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp))
|
while (ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp))
|
||||||
ocelot_read_rix(ocelot, QS_XTR_RD, grp);
|
ocelot_read_rix(ocelot, QS_XTR_RD, grp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue