Skip to content

Commit 026b907

Browse files
lategoodbyedavem330
authored andcommitted
net: qca_spi: Add available buffer space verification
Interferences on the SPI line could distort the response of available buffer space. So at least we should check that the response doesn't exceed the maximum available buffer space. In error case increase a new error counter and retry it later. This behavior avoids buffer errors in the QCA7000, which results in an unnecessary chip reset including packet loss. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5025425 commit 026b907

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

drivers/net/ethernet/qualcomm/qca_debug.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ static const char qcaspi_gstrings_stats[][ETH_GSTRING_LEN] = {
6161
"Transmit ring full",
6262
"SPI errors",
6363
"Write verify errors",
64+
"Buffer available errors",
6465
};
6566

6667
#ifdef CONFIG_DEBUG_FS

drivers/net/ethernet/qualcomm/qca_spi.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,14 @@ qcaspi_transmit(struct qcaspi *qca)
289289

290290
qcaspi_read_register(qca, SPI_REG_WRBUF_SPC_AVA, &available);
291291

292+
if (available > QCASPI_HW_BUF_LEN) {
293+
/* This could only happen by interferences on the SPI line.
294+
* So retry later ...
295+
*/
296+
qca->stats.buf_avail_err++;
297+
return -1;
298+
}
299+
292300
while (qca->txr.skb[qca->txr.head]) {
293301
pkt_len = qca->txr.skb[qca->txr.head]->len + QCASPI_HW_PKT_LEN;
294302

@@ -355,7 +363,13 @@ qcaspi_receive(struct qcaspi *qca)
355363
netdev_dbg(net_dev, "qcaspi_receive: SPI_REG_RDBUF_BYTE_AVA: Value: %08x\n",
356364
available);
357365

358-
if (available == 0) {
366+
if (available > QCASPI_HW_BUF_LEN) {
367+
/* This could only happen by interferences on the SPI line.
368+
* So retry later ...
369+
*/
370+
qca->stats.buf_avail_err++;
371+
return -1;
372+
} else if (available == 0) {
359373
netdev_dbg(net_dev, "qcaspi_receive called without any data being available!\n");
360374
return -1;
361375
}

drivers/net/ethernet/qualcomm/qca_spi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ struct qcaspi_stats {
7474
u64 ring_full;
7575
u64 spi_err;
7676
u64 write_verify_failed;
77+
u64 buf_avail_err;
7778
};
7879

7980
struct qcaspi {

0 commit comments

Comments
 (0)