diff mbox series

[3/4,net] qca_spi: Fix ethtool -G iface tx behavior

Message ID 20231121163004.21232-4-wahrenst@gmx.net (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series qca_spi: collection of major fixes | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/codegen success Generated files up to date
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1115 this patch: 1115
netdev/cc_maintainers warning 3 maintainers not CCed: michal.simek@amd.com broonie@kernel.org amit.kumar-mahapatra@amd.com
netdev/build_clang success Errors and warnings before: 1142 this patch: 1142
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1142 this patch: 1142
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Stefan Wahren Nov. 21, 2023, 4:30 p.m. UTC
After calling ethtool -g it was not possible to adjust the TX ring size
again. The reason for this is that the readonly setting rx_pending get
initialized and after that the range check in qcaspi_set_ringparam()
fails regardless of the provided parameter. Since there is no adjustable
RX ring at all, drop it from qcaspi_get_ringparam().

Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000")
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
 drivers/net/ethernet/qualcomm/qca_debug.c | 2 --
 1 file changed, 2 deletions(-)

--
2.34.1

Comments

Paolo Abeni Nov. 23, 2023, 11:51 a.m. UTC | #1
On Tue, 2023-11-21 at 17:30 +0100, Stefan Wahren wrote:
> After calling ethtool -g it was not possible to adjust the TX ring size
> again. 

Could you please report the exact command sequence that will fail?


> The reason for this is that the readonly setting rx_pending get
> initialized and after that the range check in qcaspi_set_ringparam()
> fails regardless of the provided parameter. Since there is no adjustable
> RX ring at all, drop it from qcaspi_get_ringparam().

> 
> Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000")
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> ---
>  drivers/net/ethernet/qualcomm/qca_debug.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/qualcomm/qca_debug.c b/drivers/net/ethernet/qualcomm/qca_debug.c
> index 6f2fa2a42770..613eb688cba2 100644
> --- a/drivers/net/ethernet/qualcomm/qca_debug.c
> +++ b/drivers/net/ethernet/qualcomm/qca_debug.c
> @@ -252,9 +252,7 @@ qcaspi_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring,
>  {
>  	struct qcaspi *qca = netdev_priv(dev);
> 
> -	ring->rx_max_pending = 4;
>  	ring->tx_max_pending = TX_RING_MAX_LEN;
> -	ring->rx_pending = 4;
>  	ring->tx_pending = qca->txr.count;
>  }

I think it's preferable update qcaspi_set_ringparam() to complete
successfully when the provided arguments don't change the rx_pending
default (4)

Cheers,

Paolo
Stefan Wahren Nov. 24, 2023, 2:17 p.m. UTC | #2
Hi Paolo,

Am 23.11.23 um 12:51 schrieb Paolo Abeni:
> On Tue, 2023-11-21 at 17:30 +0100, Stefan Wahren wrote:
>> After calling ethtool -g it was not possible to adjust the TX ring size
>> again.
> Could you please report the exact command sequence that will fail?
ethtool -g eth1
ethtool -G eth1 tx 8
>
>
>> The reason for this is that the readonly setting rx_pending get
>> initialized and after that the range check in qcaspi_set_ringparam()
>> fails regardless of the provided parameter. Since there is no adjustable
>> RX ring at all, drop it from qcaspi_get_ringparam().
>> Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000")
>> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
>> ---
>>   drivers/net/ethernet/qualcomm/qca_debug.c | 2 --
>>   1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/qualcomm/qca_debug.c b/drivers/net/ethernet/qualcomm/qca_debug.c
>> index 6f2fa2a42770..613eb688cba2 100644
>> --- a/drivers/net/ethernet/qualcomm/qca_debug.c
>> +++ b/drivers/net/ethernet/qualcomm/qca_debug.c
>> @@ -252,9 +252,7 @@ qcaspi_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring,
>>   {
>>   	struct qcaspi *qca = netdev_priv(dev);
>>
>> -	ring->rx_max_pending = 4;
>>   	ring->tx_max_pending = TX_RING_MAX_LEN;
>> -	ring->rx_pending = 4;
>>   	ring->tx_pending = qca->txr.count;
>>   }
> I think it's preferable update qcaspi_set_ringparam() to complete
> successfully when the provided arguments don't change the rx_pending
> default (4)

Sorry, i didn't get. The whole point is that there is no RX ring at all,
just a TX ring. During the time of writing this driver, i was under the
assumption that the driver needs to provide a rx_pending in
qcaspi_get_ringparam even this is no RX ring. The number 4 represent the
maximum of 4 packets which can be received at once. But it's not a ring.

Best regards

> Cheers,
>
> Paolo
>
Paolo Abeni Nov. 24, 2023, 3:49 p.m. UTC | #3
On Fri, 2023-11-24 at 15:17 +0100, Stefan Wahren wrote:
> Am 23.11.23 um 12:51 schrieb Paolo Abeni:
> > On Tue, 2023-11-21 at 17:30 +0100, Stefan Wahren wrote:
> > > After calling ethtool -g it was not possible to adjust the TX ring size
> > > again.
> > Could you please report the exact command sequence that will fail?
> ethtool -g eth1
> ethtool -G eth1 tx 8
> > 
> > 
> > > The reason for this is that the readonly setting rx_pending get
> > > initialized and after that the range check in qcaspi_set_ringparam()
> > > fails regardless of the provided parameter. Since there is no adjustable
> > > RX ring at all, drop it from qcaspi_get_ringparam().
> > > Fixes: 291ab06ecf67 ("net: qualcomm: new Ethernet over SPI driver for QCA7000")
> > > Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> > > ---
> > >   drivers/net/ethernet/qualcomm/qca_debug.c | 2 --
> > >   1 file changed, 2 deletions(-)
> > > 
> > > diff --git a/drivers/net/ethernet/qualcomm/qca_debug.c b/drivers/net/ethernet/qualcomm/qca_debug.c
> > > index 6f2fa2a42770..613eb688cba2 100644
> > > --- a/drivers/net/ethernet/qualcomm/qca_debug.c
> > > +++ b/drivers/net/ethernet/qualcomm/qca_debug.c
> > > @@ -252,9 +252,7 @@ qcaspi_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring,
> > >   {
> > >   	struct qcaspi *qca = netdev_priv(dev);
> > > 
> > > -	ring->rx_max_pending = 4;
> > >   	ring->tx_max_pending = TX_RING_MAX_LEN;
> > > -	ring->rx_pending = 4;
> > >   	ring->tx_pending = qca->txr.count;
> > >   }
> > I think it's preferable update qcaspi_set_ringparam() to complete
> > successfully when the provided arguments don't change the rx_pending
> > default (4)
> 
> Sorry, i didn't get. The whole point is that there is no RX ring at all,
> just a TX ring. 
> During the time of writing this driver, i was under the
> assumption that the driver needs to provide a rx_pending in
> qcaspi_get_ringparam even this is no RX ring. The number 4 represent the
> maximum of 4 packets which can be received at once. But it's not a ring.

Even if the H/W in charge of receiving and storing the incoming packet
is not exactly a ring but some fixed-size structure, I think it would
be better to avoid changing the exposed defaults given they are not
actually changed by this patch and they represent the current status
IMHO quite accurately.

The change I suggested is something alike the following (note that you
could possibly define a macro with a helpful name instead of the raw
number '4')

Cheers,

Paolo
---
diff --git a/drivers/net/ethernet/qualcomm/qca_debug.c b/drivers/net/ethernet/qualcomm/qca_debug.c
index 6f2fa2a42770..05c5450bff79 100644
--- a/drivers/net/ethernet/qualcomm/qca_debug.c
+++ b/drivers/net/ethernet/qualcomm/qca_debug.c
@@ -266,7 +266,7 @@ qcaspi_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring,
        const struct net_device_ops *ops = dev->netdev_ops;
        struct qcaspi *qca = netdev_priv(dev);
 
-       if ((ring->rx_pending) ||
+       if ((ring->rx_pending != 4) ||
            (ring->rx_mini_pending) ||
            (ring->rx_jumbo_pending))
                return -EINVAL;
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qualcomm/qca_debug.c b/drivers/net/ethernet/qualcomm/qca_debug.c
index 6f2fa2a42770..613eb688cba2 100644
--- a/drivers/net/ethernet/qualcomm/qca_debug.c
+++ b/drivers/net/ethernet/qualcomm/qca_debug.c
@@ -252,9 +252,7 @@  qcaspi_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring,
 {
 	struct qcaspi *qca = netdev_priv(dev);

-	ring->rx_max_pending = 4;
 	ring->tx_max_pending = TX_RING_MAX_LEN;
-	ring->rx_pending = 4;
 	ring->tx_pending = qca->txr.count;
 }