2021-10-18 03:49:51

by Luo Jie

[permalink] [raw]
Subject: [PATCH v3 12/13] net: phy: adjust qca8081 master/slave seed value if link down

1. The master/slave seed needs to be updated when the link can't
be created.

2. The case where two qca8081 PHYs are connected each other and
master/slave seed is generated as the same value also needs
to be considered, so adding this code change into read_status
instead of link_change_notify.

Signed-off-by: Luo Jie <[email protected]>
---
drivers/net/phy/at803x.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 5d007f89e9d3..77aaf9e72781 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -1556,6 +1556,22 @@ static int qca808x_read_status(struct phy_device *phydev)
else
phydev->interface = PHY_INTERFACE_MODE_SMII;

+ /* generate seed as a lower random value to make PHY linked as SLAVE easily,
+ * except for master/slave configuration fault detected.
+ * the reason for not putting this code into the function link_change_notify is
+ * the corner case where the link partner is also the qca8081 PHY and the seed
+ * value is configured as the same value, the link can't be up and no link change
+ * occurs.
+ */
+ if (!phydev->link) {
+ if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR) {
+ qca808x_phy_ms_seed_enable(phydev, false);
+ } else {
+ qca808x_phy_ms_random_seed_set(phydev);
+ qca808x_phy_ms_seed_enable(phydev, true);
+ }
+ }
+
return 0;
}

--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


2021-10-18 22:08:40

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH v3 12/13] net: phy: adjust qca8081 master/slave seed value if link down

On Mon, Oct 18, 2021 at 11:33:32AM +0800, Luo Jie wrote:
> 1. The master/slave seed needs to be updated when the link can't
> be created.
>
> 2. The case where two qca8081 PHYs are connected each other and
> master/slave seed is generated as the same value also needs
> to be considered, so adding this code change into read_status
> instead of link_change_notify.
>
> Signed-off-by: Luo Jie <[email protected]>
> ---
> drivers/net/phy/at803x.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index 5d007f89e9d3..77aaf9e72781 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
> @@ -1556,6 +1556,22 @@ static int qca808x_read_status(struct phy_device *phydev)
> else
> phydev->interface = PHY_INTERFACE_MODE_SMII;
>
> + /* generate seed as a lower random value to make PHY linked as SLAVE easily,
> + * except for master/slave configuration fault detected.
> + * the reason for not putting this code into the function link_change_notify is
> + * the corner case where the link partner is also the qca8081 PHY and the seed
> + * value is configured as the same value, the link can't be up and no link change
> + * occurs.
> + */
> + if (!phydev->link) {
> + if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR) {
> + qca808x_phy_ms_seed_enable(phydev, false);
> + } else {
> + qca808x_phy_ms_random_seed_set(phydev);
> + qca808x_phy_ms_seed_enable(phydev, true);
> + }
> + }

Are you assuming here that the status is polled once a second, and
each poll you choose a new seed and see if it succeeds? What happens
when interrupts are used, not polling?

Andrew

2021-10-20 13:29:08

by Luo Jie

[permalink] [raw]
Subject: Re: [PATCH v3 12/13] net: phy: adjust qca8081 master/slave seed value if link down


On 10/19/2021 6:04 AM, Andrew Lunn wrote:
> On Mon, Oct 18, 2021 at 11:33:32AM +0800, Luo Jie wrote:
>> 1. The master/slave seed needs to be updated when the link can't
>> be created.
>>
>> 2. The case where two qca8081 PHYs are connected each other and
>> master/slave seed is generated as the same value also needs
>> to be considered, so adding this code change into read_status
>> instead of link_change_notify.
>>
>> Signed-off-by: Luo Jie <[email protected]>
>> ---
>> drivers/net/phy/at803x.c | 16 ++++++++++++++++
>> 1 file changed, 16 insertions(+)
>>
>> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
>> index 5d007f89e9d3..77aaf9e72781 100644
>> --- a/drivers/net/phy/at803x.c
>> +++ b/drivers/net/phy/at803x.c
>> @@ -1556,6 +1556,22 @@ static int qca808x_read_status(struct phy_device *phydev)
>> else
>> phydev->interface = PHY_INTERFACE_MODE_SMII;
>>
>> + /* generate seed as a lower random value to make PHY linked as SLAVE easily,
>> + * except for master/slave configuration fault detected.
>> + * the reason for not putting this code into the function link_change_notify is
>> + * the corner case where the link partner is also the qca8081 PHY and the seed
>> + * value is configured as the same value, the link can't be up and no link change
>> + * occurs.
>> + */
>> + if (!phydev->link) {
>> + if (phydev->master_slave_state == MASTER_SLAVE_STATE_ERR) {
>> + qca808x_phy_ms_seed_enable(phydev, false);
>> + } else {
>> + qca808x_phy_ms_random_seed_set(phydev);
>> + qca808x_phy_ms_seed_enable(phydev, true);
>> + }
>> + }
> Are you assuming here that the status is polled once a second, and
> each poll you choose a new seed and see if it succeeds? What happens
> when interrupts are used, not polling?
>
> Andrew

Hi Andrew,

yes, this code assumes that the PHY POLL is used, and choose a new
random seed value

on each poll if no link is created.

when the interrupts is used, this corner case seems can't be covered
since there is

no related interrupt occurs when the seed is configured as same value.