* Re: [PATCH rdma-rc] RDMA/mlx5: Fix missed RST2INIT and INIT2INIT steps during ECE handshake
From: Jason Gunthorpe @ 2020-06-18 13:01 UTC (permalink / raw)
To: Leon Romanovsky
Cc: Doug Ledford, Leon Romanovsky, linux-rdma, Mark Zhang, netdev,
Saeed Mahameed
In-Reply-To: <20200616104536.2426384-1-leon@kernel.org>
On Tue, Jun 16, 2020 at 01:45:36PM +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@mellanox.com>
>
> Missed step during ECE handshake left userspace application with less
> options for the ECE handshake with a need to do workarounds.
>
> Fixes: 50aec2c3135e ("RDMA/mlx5: Return ECE data after modify QP")
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> ---
> drivers/infiniband/hw/mlx5/qpc.c | 8 ++++++++
> include/linux/mlx5/mlx5_ifc.h | 10 ++++++----
> 2 files changed, 14 insertions(+), 4 deletions(-)
Applied to for-rc, thanks
Jason
^ permalink raw reply
* Re: [PATCH net] geneve: allow changing DF behavior after creation
From: Sabrina Dubroca @ 2020-06-18 13:03 UTC (permalink / raw)
To: Stefano Brivio; +Cc: netdev
In-Reply-To: <20200618122629.54a66950@redhat.com>
2020-06-18, 12:26:29 +0200, Stefano Brivio wrote:
> On Thu, 18 Jun 2020 12:13:22 +0200
> Sabrina Dubroca <sd@queasysnail.net> wrote:
>
> > Currently, trying to change the DF parameter of a geneve device does
> > nothing:
> >
> > # ip -d link show geneve1
> > 14: geneve1: <snip>
> > link/ether <snip>
> > geneve id 1 remote 10.0.0.1 ttl auto df set dstport 6081 <snip>
> > # ip link set geneve1 type geneve id 1 df unset
> > # ip -d link show geneve1
> > 14: geneve1: <snip>
> > link/ether <snip>
> > geneve id 1 remote 10.0.0.1 ttl auto df set dstport 6081 <snip>
> >
> > We just need to update the value in geneve_changelink.
> >
> > Fixes: a025fb5f49ad ("geneve: Allow configuration of DF behaviour")
> > Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> > ---
> > drivers/net/geneve.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
> > index 75266580b586..4661ef865807 100644
> > --- a/drivers/net/geneve.c
> > +++ b/drivers/net/geneve.c
> > @@ -1649,6 +1649,7 @@ static int geneve_changelink(struct net_device *dev, struct nlattr *tb[],
> > geneve->collect_md = metadata;
> > geneve->use_udp6_rx_checksums = use_udp6_rx_checksums;
> > geneve->ttl_inherit = ttl_inherit;
> > + geneve->df = df;
>
> I introduced this bug as I didn't notice the asymmetry with VXLAN,
> where vxlan_nl2conf() takes care of this for both new links and link
> changes.
Yeah, I didn't notice either :/
> Here, this block is duplicated in geneve_configure(), which,
> somewhat surprisingly given the name, is not called from
> geneve_changelink(). Did you consider factoring out (at least) this
> block to have it shared?
Then I'd have to introduce another lovely function with an absurdly
long argument list. I'd rather clean that up in all of geneve and
introduce something like struct vxlan_config, but it's a bit much for
net. I'll do that once this fix finds its way into net-next.
>
> Either way,
>
> Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Thanks.
--
Sabrina
^ permalink raw reply
* Re: [net 1/3] e1000e: Do not wake up the system via WOL if device wakeup is disabled
From: Sasha Levin @ 2020-06-18 13:18 UTC (permalink / raw)
To: Sasha Levin, Jeff Kirsher, Chen Yu, davem; +Cc: Chen Yu, netdev, Stable, stable
In-Reply-To: <20200616225354.2744572-2-jeffrey.t.kirsher@intel.com>
Hi
[This is an automated email]
This commit has been processed because it contains a "Fixes:" tag
fixing commit: bc7f75fa9788 ("[E1000E]: New pci-express e1000 driver (currently for ICH9 devices only)").
The bot has tested the following trees: v5.7.2, v5.4.46, v4.19.128, v4.14.184, v4.9.227, v4.4.227.
v5.7.2: Build OK!
v5.4.46: Build OK!
v4.19.128: Build OK!
v4.14.184: Build OK!
v4.9.227: Failed to apply! Possible dependencies:
c8744f44aeaee ("e1000e: Add Support for CannonLake")
v4.4.227: Failed to apply! Possible dependencies:
16ecba59bc333 ("e1000e: Do not read ICR in Other interrupt")
18dd239207038 ("e1000e: use BIT() macro for bit defines")
74f31299a41e7 ("e1000e: Increase PHY PLL clock gate timing")
c8744f44aeaee ("e1000e: Add Support for CannonLake")
f3ed935de059b ("e1000e: initial support for i219-LM (3)")
NOTE: The patch will not be queued to stable trees until it is upstream.
How should we proceed with this patch?
--
Thanks
Sasha
^ permalink raw reply
* [PATCH -next] macvlan: Fix memleak in macvlan_changelink_sources
From: Zheng Bin @ 2020-06-18 13:26 UTC (permalink / raw)
To: davem, kuba, michael-dev, netdev, linux-kernel; +Cc: zhengbin13, yi.zhang
macvlan_changelink_sources
if (addr)
ret = macvlan_hash_add_source(vlan, addr)
nla_for_each_attr(nla, head, len, rem)
ret = macvlan_hash_add_source(vlan, addr)
-->If fail, need to free previous malloc memory
Fixes: 79cf79abce71 ("macvlan: add source mode")
Signed-off-by: Zheng Bin <zhengbin13@huawei.com>
---
drivers/net/macvlan.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 6a6cc9f75307..0017c5d28a27 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -1379,8 +1379,10 @@ static int macvlan_changelink_sources(struct macvlan_dev *vlan, u32 mode,
addr = nla_data(nla);
ret = macvlan_hash_add_source(vlan, addr);
- if (ret)
+ if (ret) {
+ macvlan_flush_sources(vlan->port, vlan);
return ret;
+ }
}
} else {
return -EINVAL;
--
2.25.4
^ permalink raw reply related
* Re: [PATCH v5 3/3] net: phy: mscc: handle the clkout control on some phy variants
From: Andrew Lunn @ 2020-06-18 13:28 UTC (permalink / raw)
To: Heiko Stuebner
Cc: davem, kuba, robh+dt, f.fainelli, hkallweit1, linux, netdev,
devicetree, linux-kernel, christoph.muellner, Heiko Stuebner
In-Reply-To: <20200618121139.1703762-4-heiko@sntech.de>
On Thu, Jun 18, 2020 at 02:11:39PM +0200, Heiko Stuebner wrote:
> From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
>
> At least VSC8530/8531/8540/8541 contain a clock output that can emit
> a predefined rate of 25, 50 or 125MHz.
>
> This may then feed back into the network interface as source clock.
> So expose a clock-provider from the phy using the common clock framework
> to allow setting the rate.
>
> Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
> ---
> drivers/net/phy/mscc/mscc.h | 13 +++
> drivers/net/phy/mscc/mscc_main.c | 182 +++++++++++++++++++++++++++++--
> 2 files changed, 187 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/phy/mscc/mscc.h b/drivers/net/phy/mscc/mscc.h
> index fbcee5fce7b2..94883dab5cc1 100644
> --- a/drivers/net/phy/mscc/mscc.h
> +++ b/drivers/net/phy/mscc/mscc.h
> @@ -218,6 +218,13 @@ enum rgmii_clock_delay {
> #define INT_MEM_DATA_M 0x00ff
> #define INT_MEM_DATA(x) (INT_MEM_DATA_M & (x))
>
> +#define MSCC_CLKOUT_CNTL 13
> +#define CLKOUT_ENABLE BIT(15)
> +#define CLKOUT_FREQ_MASK GENMASK(14, 13)
> +#define CLKOUT_FREQ_25M (0x0 << 13)
> +#define CLKOUT_FREQ_50M (0x1 << 13)
> +#define CLKOUT_FREQ_125M (0x2 << 13)
> +
> #define MSCC_PHY_PROC_CMD 18
> #define PROC_CMD_NCOMPLETED 0x8000
> #define PROC_CMD_FAILED 0x4000
> @@ -360,6 +367,12 @@ struct vsc8531_private {
> */
> unsigned int base_addr;
>
> +#ifdef CONFIG_COMMON_CLK
> + struct clk_hw clkout_hw;
> +#endif
> + u32 clkout_rate;
> + int clkout_enabled;
> +
> #if IS_ENABLED(CONFIG_MACSEC)
> /* MACsec fields:
> * - One SecY per device (enforced at the s/w implementation level)
> diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c
> index 5d2777522fb4..727a9dd58403 100644
> --- a/drivers/net/phy/mscc/mscc_main.c
> +++ b/drivers/net/phy/mscc/mscc_main.c
> @@ -7,6 +7,7 @@
> * Copyright (c) 2016 Microsemi Corporation
> */
>
> +#include <linux/clk-provider.h>
> #include <linux/firmware.h>
> #include <linux/jiffies.h>
> #include <linux/kernel.h>
> @@ -431,7 +432,6 @@ static int vsc85xx_dt_led_mode_get(struct phy_device *phydev,
>
> return led_mode;
> }
> -
> #else
> static int vsc85xx_edge_rate_magic_get(struct phy_device *phydev)
> {
> @@ -1508,6 +1508,43 @@ static int vsc85xx_config_init(struct phy_device *phydev)
> return 0;
> }
>
> +static int vsc8531_config_init(struct phy_device *phydev)
> +{
> + struct vsc8531_private *vsc8531 = phydev->priv;
> + u16 val;
> + int rc;
> +
> + rc = vsc85xx_config_init(phydev);
> + if (rc)
> + return rc;
> +
> +#ifdef CONFIG_COMMON_CLK
> + switch (vsc8531->clkout_rate) {
> + case 25000000:
> + val = CLKOUT_FREQ_25M;
> + break;
> + case 50000000:
> + val = CLKOUT_FREQ_50M;
> + break;
> + case 125000000:
> + val = CLKOUT_FREQ_125M;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + if (vsc8531->clkout_enabled)
> + val |= CLKOUT_ENABLE;
> +
> + rc = phy_write_paged(phydev, MSCC_PHY_PAGE_EXTENDED_GPIO,
> + MSCC_CLKOUT_CNTL, val);
> + if (rc)
> + return rc;
> +#endif
> +
> + return 0;
> +}
> +
> +static int vsc8531_clkout_prepare(struct clk_hw *hw)
> +{
> + struct vsc8531_private *vsc8531 = clkout_hw_to_vsc8531(hw);
> +
> + vsc8531->clkout_enabled = true;
> + return 0;
> +}
> +
> +static void vsc8531_clkout_unprepare(struct clk_hw *hw)
> +{
> + struct vsc8531_private *vsc8531 = clkout_hw_to_vsc8531(hw);
> +
> + vsc8531->clkout_enabled = false;
> +}
> +
> +static const struct clk_ops vsc8531_clkout_ops = {
> + .prepare = vsc8531_clkout_prepare,
> + .unprepare = vsc8531_clkout_unprepare,
> + .is_prepared = vsc8531_clkout_is_prepared,
> + .recalc_rate = vsc8531_clkout_recalc_rate,
> + .round_rate = vsc8531_clkout_round_rate,
> + .set_rate = vsc8531_clkout_set_rate,
I'm not sure this is the expected behaviour. The clk itself should
only start ticking when the enable callback is called. But this code
will enable the clock when config_init() is called. I think you should
implement the enable and disable methods.
Andrew
^ permalink raw reply
* [PATCH][next] tipc: Use struct_size() helper
From: Gustavo A. R. Silva @ 2020-06-18 13:35 UTC (permalink / raw)
To: Jon Maloy, Ying Xue, David S. Miller, Jakub Kicinski
Cc: netdev, tipc-discussion, linux-kernel, Gustavo A. R. Silva
Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.
This code was detected with the help of Coccinelle and, audited and
fixed manually.
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
net/tipc/link.c | 8 ++++----
net/tipc/msg.h | 6 ++----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/net/tipc/link.c b/net/tipc/link.c
index ee3b8d0576b8..9a33752f0263 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1385,12 +1385,12 @@ u16 tipc_get_gap_ack_blks(struct tipc_gap_ack_blks **ga, struct tipc_link *l,
p = (struct tipc_gap_ack_blks *)msg_data(hdr);
sz = ntohs(p->len);
/* Sanity check */
- if (sz == tipc_gap_ack_blks_sz(p->ugack_cnt + p->bgack_cnt)) {
+ if (sz == struct_size(p, gacks, p->ugack_cnt + p->bgack_cnt)) {
/* Good, check if the desired type exists */
if ((uc && p->ugack_cnt) || (!uc && p->bgack_cnt))
goto ok;
/* Backward compatible: peer might not support bc, but uc? */
- } else if (uc && sz == tipc_gap_ack_blks_sz(p->ugack_cnt)) {
+ } else if (uc && sz == struct_size(p, gacks, p->ugack_cnt)) {
if (p->ugack_cnt) {
p->bgack_cnt = 0;
goto ok;
@@ -1472,7 +1472,7 @@ static u16 tipc_build_gap_ack_blks(struct tipc_link *l, struct tipc_msg *hdr)
__tipc_build_gap_ack_blks(ga, l, ga->bgack_cnt) : 0;
/* Total len */
- len = tipc_gap_ack_blks_sz(ga->bgack_cnt + ga->ugack_cnt);
+ len = struct_size(ga, gacks, ga->bgack_cnt + ga->ugack_cnt);
ga->len = htons(len);
return len;
}
@@ -1521,7 +1521,7 @@ static int tipc_link_advance_transmq(struct tipc_link *l, struct tipc_link *r,
gacks = &ga->gacks[ga->bgack_cnt];
} else if (ga) {
/* Copy the Gap ACKs, bc part, for later renewal if needed */
- this_ga = kmemdup(ga, tipc_gap_ack_blks_sz(ga->bgack_cnt),
+ this_ga = kmemdup(ga, struct_size(ga, gacks, ga->bgack_cnt),
GFP_ATOMIC);
if (likely(this_ga)) {
this_ga->start_index = 0;
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index 58660d56bc83..c0d161bc7a50 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -189,11 +189,9 @@ struct tipc_gap_ack_blks {
struct tipc_gap_ack gacks[];
};
-#define tipc_gap_ack_blks_sz(n) (sizeof(struct tipc_gap_ack_blks) + \
- sizeof(struct tipc_gap_ack) * (n))
-
#define MAX_GAP_ACK_BLKS 128
-#define MAX_GAP_ACK_BLKS_SZ tipc_gap_ack_blks_sz(MAX_GAP_ACK_BLKS)
+#define MAX_GAP_ACK_BLKS_SZ (sizeof(struct tipc_gap_ack_blks) + \
+ sizeof(struct tipc_gap_ack) * MAX_GAP_ACK_BLKS)
static inline struct tipc_msg *buf_msg(struct sk_buff *skb)
{
--
2.27.0
^ permalink raw reply related
* Re: [PATCH v5 3/3] net: phy: mscc: handle the clkout control on some phy variants
From: Russell King - ARM Linux admin @ 2020-06-18 13:41 UTC (permalink / raw)
To: Andrew Lunn
Cc: Heiko Stuebner, davem, kuba, robh+dt, f.fainelli, hkallweit1,
netdev, devicetree, linux-kernel, christoph.muellner,
Heiko Stuebner
In-Reply-To: <20200618132822.GN249144@lunn.ch>
On Thu, Jun 18, 2020 at 03:28:22PM +0200, Andrew Lunn wrote:
> On Thu, Jun 18, 2020 at 02:11:39PM +0200, Heiko Stuebner wrote:
> > From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
> >
> > At least VSC8530/8531/8540/8541 contain a clock output that can emit
> > a predefined rate of 25, 50 or 125MHz.
> >
> > This may then feed back into the network interface as source clock.
> > So expose a clock-provider from the phy using the common clock framework
> > to allow setting the rate.
> >
> > Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
> > ---
> > drivers/net/phy/mscc/mscc.h | 13 +++
> > drivers/net/phy/mscc/mscc_main.c | 182 +++++++++++++++++++++++++++++--
> > 2 files changed, 187 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/phy/mscc/mscc.h b/drivers/net/phy/mscc/mscc.h
> > index fbcee5fce7b2..94883dab5cc1 100644
> > --- a/drivers/net/phy/mscc/mscc.h
> > +++ b/drivers/net/phy/mscc/mscc.h
> > @@ -218,6 +218,13 @@ enum rgmii_clock_delay {
> > #define INT_MEM_DATA_M 0x00ff
> > #define INT_MEM_DATA(x) (INT_MEM_DATA_M & (x))
> >
> > +#define MSCC_CLKOUT_CNTL 13
> > +#define CLKOUT_ENABLE BIT(15)
> > +#define CLKOUT_FREQ_MASK GENMASK(14, 13)
> > +#define CLKOUT_FREQ_25M (0x0 << 13)
> > +#define CLKOUT_FREQ_50M (0x1 << 13)
> > +#define CLKOUT_FREQ_125M (0x2 << 13)
> > +
> > #define MSCC_PHY_PROC_CMD 18
> > #define PROC_CMD_NCOMPLETED 0x8000
> > #define PROC_CMD_FAILED 0x4000
> > @@ -360,6 +367,12 @@ struct vsc8531_private {
> > */
> > unsigned int base_addr;
> >
> > +#ifdef CONFIG_COMMON_CLK
> > + struct clk_hw clkout_hw;
> > +#endif
> > + u32 clkout_rate;
> > + int clkout_enabled;
> > +
> > #if IS_ENABLED(CONFIG_MACSEC)
> > /* MACsec fields:
> > * - One SecY per device (enforced at the s/w implementation level)
> > diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c
> > index 5d2777522fb4..727a9dd58403 100644
> > --- a/drivers/net/phy/mscc/mscc_main.c
> > +++ b/drivers/net/phy/mscc/mscc_main.c
> > @@ -7,6 +7,7 @@
> > * Copyright (c) 2016 Microsemi Corporation
> > */
> >
> > +#include <linux/clk-provider.h>
> > #include <linux/firmware.h>
> > #include <linux/jiffies.h>
> > #include <linux/kernel.h>
> > @@ -431,7 +432,6 @@ static int vsc85xx_dt_led_mode_get(struct phy_device *phydev,
> >
> > return led_mode;
> > }
> > -
> > #else
> > static int vsc85xx_edge_rate_magic_get(struct phy_device *phydev)
> > {
> > @@ -1508,6 +1508,43 @@ static int vsc85xx_config_init(struct phy_device *phydev)
> > return 0;
> > }
> >
> > +static int vsc8531_config_init(struct phy_device *phydev)
> > +{
> > + struct vsc8531_private *vsc8531 = phydev->priv;
> > + u16 val;
> > + int rc;
> > +
> > + rc = vsc85xx_config_init(phydev);
> > + if (rc)
> > + return rc;
> > +
> > +#ifdef CONFIG_COMMON_CLK
> > + switch (vsc8531->clkout_rate) {
> > + case 25000000:
> > + val = CLKOUT_FREQ_25M;
> > + break;
> > + case 50000000:
> > + val = CLKOUT_FREQ_50M;
> > + break;
> > + case 125000000:
> > + val = CLKOUT_FREQ_125M;
> > + break;
> > + default:
> > + return -EINVAL;
> > + }
> > +
> > + if (vsc8531->clkout_enabled)
> > + val |= CLKOUT_ENABLE;
> > +
> > + rc = phy_write_paged(phydev, MSCC_PHY_PAGE_EXTENDED_GPIO,
> > + MSCC_CLKOUT_CNTL, val);
> > + if (rc)
> > + return rc;
> > +#endif
> > +
> > + return 0;
> > +}
> > +
>
> > +static int vsc8531_clkout_prepare(struct clk_hw *hw)
> > +{
> > + struct vsc8531_private *vsc8531 = clkout_hw_to_vsc8531(hw);
> > +
> > + vsc8531->clkout_enabled = true;
> > + return 0;
> > +}
> > +
> > +static void vsc8531_clkout_unprepare(struct clk_hw *hw)
> > +{
> > + struct vsc8531_private *vsc8531 = clkout_hw_to_vsc8531(hw);
> > +
> > + vsc8531->clkout_enabled = false;
> > +}
> > +
>
> > +static const struct clk_ops vsc8531_clkout_ops = {
> > + .prepare = vsc8531_clkout_prepare,
> > + .unprepare = vsc8531_clkout_unprepare,
> > + .is_prepared = vsc8531_clkout_is_prepared,
> > + .recalc_rate = vsc8531_clkout_recalc_rate,
> > + .round_rate = vsc8531_clkout_round_rate,
> > + .set_rate = vsc8531_clkout_set_rate,
>
> I'm not sure this is the expected behaviour. The clk itself should
> only start ticking when the enable callback is called. But this code
> will enable the clock when config_init() is called. I think you should
> implement the enable and disable methods.
That is actually incorrect. The whole "prepare" vs "enable" difference
is that prepare can schedule, enable isn't permitted. So, if you need
to sleep to enable the clock, then enabling the clock in the prepare
callback is the right thing to do.
However, the above driver just sets a flag, which only gets used when
the PHY's config_init method is called; that really doesn't seem to be
sane - the clock is available from the point that the PHY has been
probed, and it'll be expected that once the clock is published, it can
be made functional.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply
* Re: [PATCH net-next v7 2/6] net: phy: Add a helper to return the index for of the internal delay
From: Dan Murphy @ 2020-06-18 13:41 UTC (permalink / raw)
To: Andrew Lunn
Cc: f.fainelli, hkallweit1, davem, robh, netdev, linux-kernel,
devicetree
In-Reply-To: <20200618015147.GH249144@lunn.ch>
Andrew
On 6/17/20 8:51 PM, Andrew Lunn wrote:
> On Wed, Jun 17, 2020 at 01:20:15PM -0500, Dan Murphy wrote:
>> Add a helper function that will return the index in the array for the
>> passed in internal delay value. The helper requires the array, size and
>> delay value.
>>
>> The helper will then return the index for the exact match or return the
>> index for the index to the closest smaller value.
>>
>> Signed-off-by: Dan Murphy <dmurphy@ti.com>
>> ---
>> drivers/net/phy/phy_device.c | 68 ++++++++++++++++++++++++++++++++++++
>> include/linux/phy.h | 4 +++
>> 2 files changed, 72 insertions(+)
>>
>> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
>> index 04946de74fa0..611d4e68e3c6 100644
>> --- a/drivers/net/phy/phy_device.c
>> +++ b/drivers/net/phy/phy_device.c
>> @@ -31,6 +31,7 @@
>> #include <linux/mdio.h>
>> #include <linux/io.h>
>> #include <linux/uaccess.h>
>> +#include <linux/property.h>
>>
>> MODULE_DESCRIPTION("PHY library");
>> MODULE_AUTHOR("Andy Fleming");
>> @@ -2657,6 +2658,73 @@ void phy_get_pause(struct phy_device *phydev, bool *tx_pause, bool *rx_pause)
>> }
>> EXPORT_SYMBOL(phy_get_pause);
>>
>> +/**
>> + * phy_get_delay_index - returns the index of the internal delay
>> + * @phydev: phy_device struct
>> + * @dev: pointer to the devices device struct
>> + * @delay_values: array of delays the PHY supports
>> + * @size: the size of the delay array
>> + * @is_rx: boolean to indicate to get the rx internal delay
>> + *
>> + * Returns the index within the array of internal delay passed in.
>> + * Or if size == 0 then the delay read from the firmware is returned.
>> + * The array must be in ascending order.
>> + * Return errno if the delay is invalid or cannot be found.
>> + */
>> +s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev,
>> + const int *delay_values, int size, bool is_rx)
>> +{
>> + int ret;
>> + int i;
>> + s32 delay;
>> +
>> + if (is_rx)
>> + ret = device_property_read_u32(dev, "rx-internal-delay-ps",
>> + &delay);
>> + else
>> + ret = device_property_read_u32(dev, "tx-internal-delay-ps",
>> + &delay);
>> + if (ret) {
>> + phydev_err(phydev, "internal delay not defined\n");
> This is an optional property. So printing an error message seems heavy
> handed.
I will change this to phydev_info
> Maybe it would be better to default to 0 if the property is not found,
> and continue with the lookup in the table to find what value should be
> written for a 0ps delay?
If the property is not found what would we look up? The property
missing to me indicates that the phy is not adding the delay for that path.
If these properties are not present then the delay should not be set by
the device driver.
This is why I return -EINVAL. Maybe I should return -ENODATA instead.
Dan
>
> Andrew
^ permalink raw reply
* Re: [RFC PATCH 1/9] net: dsa: Add tag handling for Hirschmann Hellcreek switches
From: Andrew Lunn @ 2020-06-18 13:42 UTC (permalink / raw)
To: Kurt Kanzenbach
Cc: Vivien Didelot, Florian Fainelli, David S. Miller, Jakub Kicinski,
netdev, Rob Herring, devicetree, Sebastian Andrzej Siewior,
Richard Cochran, Kamil Alkhouri, ilias.apalodimas
In-Reply-To: <20200618064029.32168-2-kurt@linutronix.de>
On Thu, Jun 18, 2020 at 08:40:21AM +0200, Kurt Kanzenbach wrote:
> The Hirschmann Hellcreek TSN switches have a special tagging protocol for frames
> exchanged between the CPU port and the master interface. The format is a one
> byte trailer indicating the destination or origin port.
>
> It's quite similar to the Micrel KSZ tagging. That's why the implementation is
> based on that code.
>
> Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
> include/net/dsa.h | 2 +
> net/dsa/Kconfig | 6 +++
> net/dsa/Makefile | 1 +
> net/dsa/tag_hellcreek.c | 101 ++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 110 insertions(+)
> create mode 100644 net/dsa/tag_hellcreek.c
>
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index 50389772c597..2784c4851d92 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -44,6 +44,7 @@ struct phylink_link_state;
> #define DSA_TAG_PROTO_KSZ8795_VALUE 14
> #define DSA_TAG_PROTO_OCELOT_VALUE 15
> #define DSA_TAG_PROTO_AR9331_VALUE 16
> +#define DSA_TAG_PROTO_HELLCREEK_VALUE 17
>
> enum dsa_tag_protocol {
> DSA_TAG_PROTO_NONE = DSA_TAG_PROTO_NONE_VALUE,
> @@ -63,6 +64,7 @@ enum dsa_tag_protocol {
> DSA_TAG_PROTO_KSZ8795 = DSA_TAG_PROTO_KSZ8795_VALUE,
> DSA_TAG_PROTO_OCELOT = DSA_TAG_PROTO_OCELOT_VALUE,
> DSA_TAG_PROTO_AR9331 = DSA_TAG_PROTO_AR9331_VALUE,
> + DSA_TAG_PROTO_HELLCREEK = DSA_TAG_PROTO_HELLCREEK_VALUE,
> };
>
> struct packet_type;
> diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
> index d5bc6ac599ef..edc0c3ab6a4e 100644
> --- a/net/dsa/Kconfig
> +++ b/net/dsa/Kconfig
> @@ -121,4 +121,10 @@ config NET_DSA_TAG_TRAILER
> Say Y or M if you want to enable support for tagging frames at
> with a trailed. e.g. Marvell 88E6060.
>
> +config NET_DSA_TAG_HELLCREEK
> + tristate "Tag driver for Hirschmann Hellcreek TSN switches"
> + help
> + Say Y or M if you want to enable support for tagging frames
> + for the Hirschmann Hellcreek TSN switches.
> +
Hi Kurt
This file is roughly in alphabetic order based on the tristate
string. Please move this before "Tag driver for Lantiq / Intel GSWIP
switches" to keep with the sorting.
Otherwise this looks good.
Andrew
^ permalink raw reply
* Re: [PATCH net-next v7 1/6] dt-bindings: net: Add tx and rx internal delays
From: Dan Murphy @ 2020-06-18 13:44 UTC (permalink / raw)
To: Andrew Lunn
Cc: f.fainelli, hkallweit1, davem, robh, netdev, linux-kernel,
devicetree
In-Reply-To: <20200618020101.GJ249144@lunn.ch>
Andrew
On 6/17/20 9:01 PM, Andrew Lunn wrote:
> On Wed, Jun 17, 2020 at 01:20:14PM -0500, Dan Murphy wrote:
>> tx-internal-delays and rx-internal-delays are a common setting for RGMII
>> capable devices.
>>
>> These properties are used when the phy-mode or phy-controller is set to
>> rgmii-id, rgmii-rxid or rgmii-txid. These modes indicate to the
>> controller that the PHY will add the internal delay for the connection.
>>
>> Signed-off-by: Dan Murphy <dmurphy@ti.com>
>> ---
>> .../devicetree/bindings/net/ethernet-phy.yaml | 11 +++++++++++
>> 1 file changed, 11 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/net/ethernet-phy.yaml b/Documentation/devicetree/bindings/net/ethernet-phy.yaml
>> index 9b1f1147ca36..b2887476fe6a 100644
>> --- a/Documentation/devicetree/bindings/net/ethernet-phy.yaml
>> +++ b/Documentation/devicetree/bindings/net/ethernet-phy.yaml
>> @@ -162,6 +162,17 @@ properties:
>> description:
>> Specifies a reference to a node representing a SFP cage.
>>
>> +
>> + rx-internal-delay-ps:
>> + description: |
>> + RGMII Receive PHY Clock Delay defined in pico seconds. This is used for
>> + PHY's that have configurable RX internal delays.
>> +
>> + tx-internal-delay-ps:
>> + description: |
>> + RGMII Transmit PHY Clock Delay defined in pico seconds. This is used for
>> + PHY's that have configurable TX internal delays.
>> +
> So in a later patch you have:
>
> default: 2000
>
> That seems to apply that these values only apply when the phy mode
> indicates a delay is needed. It would be good to document that here,
> when each of these properties will be used. Also, that they default to
> 2000 when not present.
The default of 2000ps is for the DP83869 only. The DP83822 fixed delay
is 3500ps.
So indicating that the default here is 2000ps for all devices is not
correct.
But I can add a note that if these properties are present then the delay
is added by the PHY.
Dan
> Andrew
^ permalink raw reply
* [PATCH 0/9] Clause 45 PHY probing improvements
From: Russell King - ARM Linux admin @ 2020-06-18 13:45 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Florian Fainelli, Jakub Kicinski, Jeremy Linton, netdev
Hi,
Last time this series was posted back in May, Florian reviewed the
patches, which was the only feedback I received. I'm now posting
them without the RFC tag.
This series aims to improve the probing for Clause 45 PHYs.
The first four patches clean up get_phy_device() and called functions,
updating the kernel doc, adding information about the various error
return values.
We then provide better kerneldoc for get_phy_device(), describing what
is going on, and more importantly what the various return codes mean.
Patch 6 adds support for probing MMDs >= 8 to check for their presence.
Patch 7 changes get_phy_c45_ids() to only set the returned
devices_in_package if we successfully find a PHY.
Patch 8 splits the use of "devices in package" from the "mmds present".
Patch 9 expands our ID reading to cover the other MMDs.
drivers/net/phy/phy-c45.c | 4 +-
drivers/net/phy/phy_device.c | 159 ++++++++++++++++++++++++++++---------------
drivers/net/phy/phylink.c | 8 +--
include/linux/phy.h | 8 ++-
4 files changed, 117 insertions(+), 62 deletions(-)
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply
* [PATCH net-next 1/9] net: phy: clean up cortina workaround
From: Russell King @ 2020-06-18 13:45 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
Cc: Jeremy Linton, David S. Miller, Jakub Kicinski, netdev
In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk>
Move the Cortina PHY workaround out of the "devices in package" loop;
it doesn't need to be in there as the control flow will terminate the
loop once we enter the workaround irrespective of the workaround's
outcome. The workaround is triggered by the ID being mostly 1's, which
will in any case terminate the loop.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/phy_device.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 04946de74fa0..c71dc2624c4b 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -720,23 +720,21 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
phy_reg = get_phy_c45_devs_in_pkg(bus, addr, i, devs);
if (phy_reg < 0)
return -EIO;
+ }
+
+ if ((*devs & 0x1fffffff) == 0x1fffffff) {
+ /* If mostly Fs, there is no device there, then let's probe
+ * MMD 0, as some 10G PHYs have zero Devices In package,
+ * e.g. Cortina CS4315/CS4340 PHY.
+ */
+ phy_reg = get_phy_c45_devs_in_pkg(bus, addr, 0, devs);
+ if (phy_reg < 0)
+ return -EIO;
+ /* no device there, let's get out of here */
if ((*devs & 0x1fffffff) == 0x1fffffff) {
- /* If mostly Fs, there is no device there,
- * then let's continue to probe more, as some
- * 10G PHYs have zero Devices In package,
- * e.g. Cortina CS4315/CS4340 PHY.
- */
- phy_reg = get_phy_c45_devs_in_pkg(bus, addr, 0, devs);
- if (phy_reg < 0)
- return -EIO;
- /* no device there, let's get out of here */
- if ((*devs & 0x1fffffff) == 0x1fffffff) {
- *phy_id = 0xffffffff;
- return 0;
- } else {
- break;
- }
+ *phy_id = 0xffffffff;
+ return 0;
}
}
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 2/9] net: phy: clean up PHY ID reading
From: Russell King @ 2020-06-18 13:45 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
Cc: Jeremy Linton, David S. Miller, Jakub Kicinski, netdev
In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk>
Rearrange the code to read the PHY IDs, so we don't call get_phy_id()
only to immediately call get_phy_c45_ids(). Move that logic into
get_phy_device(), which results in better readability.
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/phy_device.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index c71dc2624c4b..a351eabe772f 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -758,29 +758,18 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
}
/**
- * get_phy_id - reads the specified addr for its ID.
+ * get_phy_c22_id - reads the specified addr for its clause 22 ID.
* @bus: the target MII bus
* @addr: PHY address on the MII bus
* @phy_id: where to store the ID retrieved.
- * @is_c45: If true the PHY uses the 802.3 clause 45 protocol
- * @c45_ids: where to store the c45 ID information.
- *
- * Description: In the case of a 802.3-c22 PHY, reads the ID registers
- * of the PHY at @addr on the @bus, stores it in @phy_id and returns
- * zero on success.
- *
- * In the case of a 802.3-c45 PHY, get_phy_c45_ids() is invoked, and
- * its return value is in turn returned.
*
+ * Read the 802.3 clause 22 PHY ID from the PHY at @addr on the @bus.
+ * Return the PHY ID read from the PHY in @phy_id on successful access.
*/
-static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
- bool is_c45, struct phy_c45_device_ids *c45_ids)
+static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)
{
int phy_reg;
- if (is_c45)
- return get_phy_c45_ids(bus, addr, phy_id, c45_ids);
-
/* Grab the bits from PHYIR1, and put them in the upper half */
phy_reg = mdiobus_read(bus, addr, MII_PHYSID1);
if (phy_reg < 0) {
@@ -819,7 +808,11 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
c45_ids.devices_in_package = 0;
memset(c45_ids.device_ids, 0xff, sizeof(c45_ids.device_ids));
- r = get_phy_id(bus, addr, &phy_id, is_c45, &c45_ids);
+ if (is_c45)
+ r = get_phy_c45_ids(bus, addr, &phy_id, &c45_ids);
+ else
+ r = get_phy_c22_id(bus, addr, &phy_id);
+
if (r)
return ERR_PTR(r);
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 3/9] net: phy: clean up get_phy_c45_ids() failure handling
From: Russell King @ 2020-06-18 13:45 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
Cc: Jeremy Linton, David S. Miller, Jakub Kicinski, netdev
In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk>
When we decide that a PHY is not present, we do not need to go through
the hoops of setting *phy_id to 0xffffffff, and then return zero to
make get_phy_device() fail - we can return -ENODEV which will have the
same effect.
Doing so means we no longer have to pass a pointer to phy_id in, and
we can then clean up the clause 22 path in a similar way.
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/phy_device.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index a351eabe772f..e8dc9fcf188e 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -697,16 +697,16 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr,
* get_phy_c45_ids - reads the specified addr for its 802.3-c45 IDs.
* @bus: the target MII bus
* @addr: PHY address on the MII bus
- * @phy_id: where to store the ID retrieved.
* @c45_ids: where to store the c45 ID information.
*
- * If the PHY devices-in-package appears to be valid, it and the
- * corresponding identifiers are stored in @c45_ids, zero is stored
- * in @phy_id. Otherwise 0xffffffff is stored in @phy_id. Returns
- * zero on success.
+ * Read the PHY "devices in package". If this appears to be valid, read
+ * the PHY identifiers for each device. Return the "devices in package"
+ * and identifiers in @c45_ids.
*
+ * Returns zero on success, %-EIO on bus access error, or %-ENODEV if
+ * the "devices in package" is invalid.
*/
-static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
+static int get_phy_c45_ids(struct mii_bus *bus, int addr,
struct phy_c45_device_ids *c45_ids)
{
const int num_ids = ARRAY_SIZE(c45_ids->device_ids);
@@ -732,10 +732,8 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
return -EIO;
/* no device there, let's get out of here */
- if ((*devs & 0x1fffffff) == 0x1fffffff) {
- *phy_id = 0xffffffff;
- return 0;
- }
+ if ((*devs & 0x1fffffff) == 0x1fffffff)
+ return -ENODEV;
}
/* Now probe Device Identifiers for each device present. */
@@ -753,7 +751,7 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id,
return -EIO;
c45_ids->device_ids[i] |= phy_reg;
}
- *phy_id = 0;
+
return 0;
}
@@ -809,7 +807,7 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
memset(c45_ids.device_ids, 0xff, sizeof(c45_ids.device_ids));
if (is_c45)
- r = get_phy_c45_ids(bus, addr, &phy_id, &c45_ids);
+ r = get_phy_c45_ids(bus, addr, &c45_ids);
else
r = get_phy_c22_id(bus, addr, &phy_id);
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 4/9] net: phy: clean up get_phy_c22_id() invalid ID handling
From: Russell King @ 2020-06-18 13:45 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
Cc: Jeremy Linton, David S. Miller, Jakub Kicinski, netdev
In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk>
Move the ID check from get_phy_device() into get_phy_c22_id(), which
simplifies get_phy_device(). The ID reading functions are now
responsible for indicating whether they found a PHY or not via their
return code - they must return -ENODEV when a PHY is not present.
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/phy_device.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index e8dc9fcf188e..0e802c6add09 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -761,8 +761,10 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,
* @addr: PHY address on the MII bus
* @phy_id: where to store the ID retrieved.
*
- * Read the 802.3 clause 22 PHY ID from the PHY at @addr on the @bus.
- * Return the PHY ID read from the PHY in @phy_id on successful access.
+ * Read the 802.3 clause 22 PHY ID from the PHY at @addr on the @bus,
+ * placing it in @phy_id. Return zero on successful read and the ID is
+ * valid, %-EIO on bus access error, or %-ENODEV if no device responds
+ * or invalid ID.
*/
static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)
{
@@ -784,6 +786,10 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)
*phy_id |= phy_reg;
+ /* If the phy_id is mostly Fs, there is no device there */
+ if ((*phy_id & 0x1fffffff) == 0x1fffffff)
+ return -ENODEV;
+
return 0;
}
@@ -814,10 +820,6 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
if (r)
return ERR_PTR(r);
- /* If the phy_id is mostly Fs, there is no device there */
- if ((phy_id & 0x1fffffff) == 0x1fffffff)
- return ERR_PTR(-ENODEV);
-
return phy_device_create(bus, addr, phy_id, is_c45, &c45_ids);
}
EXPORT_SYMBOL(get_phy_device);
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 5/9] net: phy: reword get_phy_device() kerneldoc
From: Russell King @ 2020-06-18 13:45 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
Cc: Jeremy Linton, David S. Miller, Jakub Kicinski, netdev
In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk>
Reword the get_phy_device() kerneldoc to be more explicit about how
we probe for the PHY, and what the various return conditions signify.
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/phy_device.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 0e802c6add09..09096c3ceb86 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -800,8 +800,17 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id)
* @addr: PHY address on the MII bus
* @is_c45: If true the PHY uses the 802.3 clause 45 protocol
*
- * Description: Reads the ID registers of the PHY at @addr on the
- * @bus, then allocates and returns the phy_device to represent it.
+ * Probe for a PHY at @addr on @bus.
+ *
+ * When probing for a clause 22 PHY, then read the ID registers. If we find
+ * a valid ID, allocate and return a &struct phy_device.
+ *
+ * When probing for a clause 45 PHY, read the "devices in package" registers.
+ * If the "devices in package" appears valid, read the ID registers for each
+ * MMD, allocate and return a &struct phy_device.
+ *
+ * Returns an allocated &struct phy_device on success, %-ENODEV if there is
+ * no PHY present, or %-EIO on bus access error.
*/
struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
{
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 6/9] net: phy: add support for probing MMDs >= 8 for devices-in-package
From: Russell King @ 2020-06-18 13:45 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
Cc: Jeremy Linton, David S. Miller, Jakub Kicinski, netdev
In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk>
Add support for probing MMDs above 7 for a valid devices-in-package
specifier, but only probe the vendor MMDs for this if they also report
that there the device is present in status register 2. This avoids
issues where the MMD is implemented, but does not provide IEEE 802.3
compliant registers (such as the MV88X3310 PHY.)
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/phy_device.c | 40 ++++++++++++++++++++++++++++++++++--
include/linux/phy.h | 2 ++
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 09096c3ceb86..8d9af2772853 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -661,6 +661,28 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
}
EXPORT_SYMBOL(phy_device_create);
+/* phy_c45_probe_present - checks to see if a MMD is present in the package
+ * @bus: the target MII bus
+ * @prtad: PHY package address on the MII bus
+ * @devad: PHY device (MMD) address
+ *
+ * Read the MDIO_STAT2 register, and check whether a device is responding
+ * at this address.
+ *
+ * Returns: negative error number on bus access error, zero if no device
+ * is responding, or positive if a device is present.
+ */
+static int phy_c45_probe_present(struct mii_bus *bus, int prtad, int devad)
+{
+ int stat2;
+
+ stat2 = mdiobus_c45_read(bus, prtad, devad, MDIO_STAT2);
+ if (stat2 < 0)
+ return stat2;
+
+ return (stat2 & MDIO_STAT2_DEVPRST) == MDIO_STAT2_DEVPRST_VAL;
+}
+
/* get_phy_c45_devs_in_pkg - reads a MMD's devices in package registers.
* @bus: the target MII bus
* @addr: PHY address on the MII bus
@@ -711,12 +733,26 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,
{
const int num_ids = ARRAY_SIZE(c45_ids->device_ids);
u32 *devs = &c45_ids->devices_in_package;
- int i, phy_reg;
+ int i, ret, phy_reg;
/* Find first non-zero Devices In package. Device zero is reserved
* for 802.3 c45 complied PHYs, so don't probe it at first.
*/
- for (i = 1; i < num_ids && *devs == 0; i++) {
+ for (i = 1; i < MDIO_MMD_NUM && *devs == 0; i++) {
+ if (i == MDIO_MMD_VEND1 || i == MDIO_MMD_VEND2) {
+ /* Check that there is a device present at this
+ * address before reading the devices-in-package
+ * register to avoid reading garbage from the PHY.
+ * Some PHYs (88x3310) vendor space is not IEEE802.3
+ * compliant.
+ */
+ ret = phy_c45_probe_present(bus, addr, i);
+ if (ret < 0)
+ return -EIO;
+
+ if (!ret)
+ continue;
+ }
phy_reg = get_phy_c45_devs_in_pkg(bus, addr, i, devs);
if (phy_reg < 0)
return -EIO;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 8c05d0fb5c00..abe318387331 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -388,6 +388,8 @@ enum phy_state {
PHY_CABLETEST,
};
+#define MDIO_MMD_NUM 32
+
/**
* struct phy_c45_device_ids - 802.3-c45 Device Identifiers
* @devices_in_package: Bit vector of devices present.
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 7/9] net: phy: set devices_in_package only after validation
From: Russell King @ 2020-06-18 13:46 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
Cc: Jeremy Linton, David S. Miller, Jakub Kicinski, netdev
In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk>
Only set the devices_in_package to a non-zero value if we find a valid
value for this field, so we avoid leaving it set to e.g. 0x1fffffff.
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/phy_device.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 8d9af2772853..8e11e3d3a801 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -732,13 +732,13 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,
struct phy_c45_device_ids *c45_ids)
{
const int num_ids = ARRAY_SIZE(c45_ids->device_ids);
- u32 *devs = &c45_ids->devices_in_package;
+ u32 devs_in_pkg = 0;
int i, ret, phy_reg;
/* Find first non-zero Devices In package. Device zero is reserved
* for 802.3 c45 complied PHYs, so don't probe it at first.
*/
- for (i = 1; i < MDIO_MMD_NUM && *devs == 0; i++) {
+ for (i = 1; i < MDIO_MMD_NUM && devs_in_pkg == 0; i++) {
if (i == MDIO_MMD_VEND1 || i == MDIO_MMD_VEND2) {
/* Check that there is a device present at this
* address before reading the devices-in-package
@@ -753,28 +753,28 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,
if (!ret)
continue;
}
- phy_reg = get_phy_c45_devs_in_pkg(bus, addr, i, devs);
+ phy_reg = get_phy_c45_devs_in_pkg(bus, addr, i, &devs_in_pkg);
if (phy_reg < 0)
return -EIO;
}
- if ((*devs & 0x1fffffff) == 0x1fffffff) {
+ if ((devs_in_pkg & 0x1fffffff) == 0x1fffffff) {
/* If mostly Fs, there is no device there, then let's probe
* MMD 0, as some 10G PHYs have zero Devices In package,
* e.g. Cortina CS4315/CS4340 PHY.
*/
- phy_reg = get_phy_c45_devs_in_pkg(bus, addr, 0, devs);
+ phy_reg = get_phy_c45_devs_in_pkg(bus, addr, 0, &devs_in_pkg);
if (phy_reg < 0)
return -EIO;
/* no device there, let's get out of here */
- if ((*devs & 0x1fffffff) == 0x1fffffff)
+ if ((devs_in_pkg & 0x1fffffff) == 0x1fffffff)
return -ENODEV;
}
/* Now probe Device Identifiers for each device present. */
for (i = 1; i < num_ids; i++) {
- if (!(c45_ids->devices_in_package & (1 << i)))
+ if (!(devs_in_pkg & (1 << i)))
continue;
phy_reg = mdiobus_c45_read(bus, addr, i, MII_PHYSID1);
@@ -788,6 +788,8 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,
c45_ids->device_ids[i] |= phy_reg;
}
+ c45_ids->devices_in_package = devs_in_pkg;
+
return 0;
}
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 8/9] net: phy: split devices_in_package
From: Russell King @ 2020-06-18 13:46 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
Cc: Jeremy Linton, David S. Miller, Jakub Kicinski, netdev
In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk>
We have two competing requirements for the devices_in_package field.
We want to use it as a bit array indicating which MMDs are present, but
we also want to know if the Clause 22 registers are present.
Since "devices in package" is a term used in the 802.3 specification,
keep this as the as-specified values read from the PHY, and introduce
a new member "mmds_present" to indicate which MMDs are actually
present in the PHY, derived from the "devices in package" value.
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/phy-c45.c | 4 ++--
drivers/net/phy/phy_device.c | 6 +++---
drivers/net/phy/phylink.c | 8 ++++----
include/linux/phy.h | 4 +++-
4 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index defe09d94422..bd11e62bfdfe 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -219,7 +219,7 @@ int genphy_c45_read_link(struct phy_device *phydev)
int val, devad;
bool link = true;
- if (phydev->c45_ids.devices_in_package & MDIO_DEVS_AN) {
+ if (phydev->c45_ids.mmds_present & MDIO_DEVS_AN) {
val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_CTRL1);
if (val < 0)
return val;
@@ -409,7 +409,7 @@ int genphy_c45_pma_read_abilities(struct phy_device *phydev)
int val;
linkmode_clear_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phydev->supported);
- if (phydev->c45_ids.devices_in_package & MDIO_DEVS_AN) {
+ if (phydev->c45_ids.mmds_present & MDIO_DEVS_AN) {
val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1);
if (val < 0)
return val;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 8e11e3d3a801..c1f81c4d0bb3 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -709,9 +709,6 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr,
return -EIO;
*devices_in_package |= phy_reg;
- /* Bit 0 doesn't represent a device, it indicates c22 regs presence */
- *devices_in_package &= ~BIT(0);
-
return 0;
}
@@ -789,6 +786,8 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,
}
c45_ids->devices_in_package = devs_in_pkg;
+ /* Bit 0 doesn't represent a device, it indicates c22 regs presence */
+ c45_ids->mmds_present = devs_in_pkg & ~BIT(0);
return 0;
}
@@ -857,6 +856,7 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45)
int r;
c45_ids.devices_in_package = 0;
+ c45_ids.mmds_present = 0;
memset(c45_ids.device_ids, 0xff, sizeof(c45_ids.device_ids));
if (is_c45)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 0ab65fb75258..7ce787c227b3 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1638,11 +1638,11 @@ static int phylink_phy_read(struct phylink *pl, unsigned int phy_id,
case MII_BMSR:
case MII_PHYSID1:
case MII_PHYSID2:
- devad = __ffs(phydev->c45_ids.devices_in_package);
+ devad = __ffs(phydev->c45_ids.mmds_present);
break;
case MII_ADVERTISE:
case MII_LPA:
- if (!(phydev->c45_ids.devices_in_package & MDIO_DEVS_AN))
+ if (!(phydev->c45_ids.mmds_present & MDIO_DEVS_AN))
return -EINVAL;
devad = MDIO_MMD_AN;
if (reg == MII_ADVERTISE)
@@ -1678,11 +1678,11 @@ static int phylink_phy_write(struct phylink *pl, unsigned int phy_id,
case MII_BMSR:
case MII_PHYSID1:
case MII_PHYSID2:
- devad = __ffs(phydev->c45_ids.devices_in_package);
+ devad = __ffs(phydev->c45_ids.mmds_present);
break;
case MII_ADVERTISE:
case MII_LPA:
- if (!(phydev->c45_ids.devices_in_package & MDIO_DEVS_AN))
+ if (!(phydev->c45_ids.mmds_present & MDIO_DEVS_AN))
return -EINVAL;
devad = MDIO_MMD_AN;
if (reg == MII_ADVERTISE)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index abe318387331..19d9e040ad84 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -392,11 +392,13 @@ enum phy_state {
/**
* struct phy_c45_device_ids - 802.3-c45 Device Identifiers
- * @devices_in_package: Bit vector of devices present.
+ * @devices_in_package: IEEE 802.3 devices in package register value.
+ * @mmds_present: bit vector of MMDs present.
* @device_ids: The device identifer for each present device.
*/
struct phy_c45_device_ids {
u32 devices_in_package;
+ u32 mmds_present;
u32 device_ids[8];
};
--
2.20.1
^ permalink raw reply related
* [PATCH net-next 9/9] net: phy: read MMD ID from all present MMDs
From: Russell King @ 2020-06-18 13:46 UTC (permalink / raw)
To: Andrew Lunn, Florian Fainelli, Heiner Kallweit
Cc: Jeremy Linton, David S. Miller, Jakub Kicinski, netdev
In-Reply-To: <20200618134500.GB1551@shell.armlinux.org.uk>
Expand the device_ids[] array to allow all MMD IDs to be read rather
than just the first 8 MMDs, but only read the ID if the MDIO_STAT2
register reports that a device really is present here for these new
devices to maintain compatibility with our current behaviour. Note
that only a limited number of devices have MDIO_STAT2.
88X3310 PHY vendor MMDs do are marked as present in the
devices_in_package, but do not contain IEE 802.3 compatible register
sets in their lower space. This avoids reading incorrect values as MMD
identifiers.
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/phy_device.c | 13 +++++++++++++
include/linux/phy.h | 2 +-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index c1f81c4d0bb3..29ef4456ac25 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -774,6 +774,19 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr,
if (!(devs_in_pkg & (1 << i)))
continue;
+ if (i == MDIO_MMD_VEND1 || i == MDIO_MMD_VEND2) {
+ /* Probe the "Device Present" bits for the vendor MMDs
+ * to ignore these if they do not contain IEEE 802.3
+ * registers.
+ */
+ ret = phy_c45_probe_present(bus, addr, i);
+ if (ret < 0)
+ return ret;
+
+ if (!ret)
+ continue;
+ }
+
phy_reg = mdiobus_c45_read(bus, addr, i, MII_PHYSID1);
if (phy_reg < 0)
return -EIO;
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 19d9e040ad84..9248dd2ce4ca 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -399,7 +399,7 @@ enum phy_state {
struct phy_c45_device_ids {
u32 devices_in_package;
u32 mmds_present;
- u32 device_ids[8];
+ u32 device_ids[MDIO_MMD_NUM];
};
struct macsec_context;
--
2.20.1
^ permalink raw reply related
* Re: [RFC PATCH 9/9] dt-bindings: net: dsa: Add documentation for Hellcreek switches
From: Andrew Lunn @ 2020-06-18 13:47 UTC (permalink / raw)
To: Kurt Kanzenbach
Cc: Vivien Didelot, Florian Fainelli, David S. Miller, Jakub Kicinski,
netdev, Rob Herring, devicetree, Sebastian Andrzej Siewior,
Richard Cochran, Kamil Alkhouri, ilias.apalodimas
In-Reply-To: <20200618064029.32168-10-kurt@linutronix.de>
> +Ethernet switch connected memory mapped to the host, CPU port wired to gmac0:
> +
> +soc {
> + switch0: switch@0xff240000 {
> + compatible = "hirschmann,hellcreek";
> + status = "okay";
> + reg = <0xff240000 0x1000 /* TSN base */
> + 0xff250000 0x1000>; /* PTP base */
> + dsa,member = <0 0>;
> +
> + ports {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + port@0 {
> + reg = <0>;
> + label = "cpu";
> + ethernet = <&gmac0>;
> + };
> +
> + port@2 {
> + reg = <2>;
> + label = "lan0";
> + phy-handle = <&phy1>;
> + };
> +
> + port@3 {
> + reg = <3>;
> + label = "lan1";
> + phy-handle = <&phy2>;
> + };
> + };
> + };
> +};
> +
> +&gmac0 {
> + status = "okay";
> + phy-mode = "mii";
> +
> + fixed-link {
> + speed = <100>;
> + full-duplex;
Hi Kurt
The switch is 100/100Mbps right? The MAC is only Fast ethernet. Do you
need some properties in the port@0 node to tell the switch to only use
100Mbps? I would expect it to default to 1G. Not looked at the code
yet...
Andrew
^ permalink raw reply
* Re: [PATCH v1 1/3] net: phy: Allow mdio buses to auto-probe c45 devices
From: Calvin Johnson @ 2020-06-18 14:00 UTC (permalink / raw)
To: Russell King - ARM Linux admin
Cc: Jeremy Linton, Jon, Cristi Sovaiala, Ioana Ciornei, Andrew Lunn,
Andy Shevchenko, Florian Fainelli, Madalin Bucur, netdev,
linux.cj
In-Reply-To: <20200617174451.GT1551@shell.armlinux.org.uk>
On Wed, Jun 17, 2020 at 06:44:51PM +0100, Russell King - ARM Linux admin wrote:
> On Wed, Jun 17, 2020 at 10:45:33PM +0530, Calvin Johnson wrote:
> > From: Jeremy Linton <jeremy.linton@arm.com>
> >
> > The mdiobus_scan logic is currently hardcoded to only
> > work with c22 devices. This works fairly well in most
> > cases, but its possible a c45 device doesn't respond
> > despite being a standard phy. If the parent hardware
> > is capable, it makes sense to scan for c22 devices before
> > falling back to c45.
> >
> > As we want this to reflect the capabilities of the STA,
> > lets add a field to the mii_bus structure to represent
> > the capability. That way devices can opt into the extended
> > scanning. Existing users should continue to default to c22
> > only scanning as long as they are zero'ing the structure
> > before use.
> >
> > Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> > Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
>
> I know that we've hashed this out quite a bit already, but I would like
> to point out that include/linux/mdio.h contains:
>
> * struct mdio_if_info - Ethernet controller MDIO interface
> * @mode_support: MDIO modes supported. If %MDIO_SUPPORTS_C22 is set then
> * MII register access will be passed through with @devad =
> * %MDIO_DEVAD_NONE. If %MDIO_EMULATE_C22 is set then access to
> * commonly used clause 22 registers will be translated into
> * clause 45 registers.
>
> #define MDIO_SUPPORTS_C22 1
> #define MDIO_SUPPORTS_C45 2
> #define MDIO_EMULATE_C22 4
>
> While this structure is not applicable to phylib or mii_bus, it may be
> worth considering that there already exist definitions for identifying
> the properties of the underlying bus.
Can we reuse these or go ahead with the new MDIOBUS_C22?
>
> > ---
> >
> > drivers/net/phy/mdio_bus.c | 17 +++++++++++++++--
> > include/linux/phy.h | 7 +++++++
> > 2 files changed, 22 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> > index 6ceee82b2839..e6c179b89907 100644
> > --- a/drivers/net/phy/mdio_bus.c
> > +++ b/drivers/net/phy/mdio_bus.c
> > @@ -739,10 +739,23 @@ EXPORT_SYMBOL(mdiobus_free);
> > */
> > struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr)
> > {
> > - struct phy_device *phydev;
> > + struct phy_device *phydev = ERR_PTR(-ENODEV);
> > int err;
> >
> > - phydev = get_phy_device(bus, addr, false);
> > + switch (bus->probe_capabilities) {
> > + case MDIOBUS_C22:
> > + phydev = get_phy_device(bus, addr, false);
> > + break;
> > + case MDIOBUS_C45:
> > + phydev = get_phy_device(bus, addr, true);
> > + break;
> > + case MDIOBUS_C22_C45:
> > + phydev = get_phy_device(bus, addr, false);
> > + if (IS_ERR(phydev))
> > + phydev = get_phy_device(bus, addr, true);
> > + break;
> > + }
> > +
> > if (IS_ERR(phydev))
> > return phydev;
> >
> > diff --git a/include/linux/phy.h b/include/linux/phy.h
> > index 9248dd2ce4ca..50e5312b2304 100644
> > --- a/include/linux/phy.h
> > +++ b/include/linux/phy.h
> > @@ -298,6 +298,13 @@ struct mii_bus {
> > /* RESET GPIO descriptor pointer */
> > struct gpio_desc *reset_gpiod;
> >
> > + /* bus capabilities, used for probing */
> > + enum {
> > + MDIOBUS_C22 = 0,
> > + MDIOBUS_C45,
> > + MDIOBUS_C22_C45,
> > + } probe_capabilities;
>
> I think it would be better to reserve "0" to mean that no capabilities
> have been declared. We hae the situation where we have mii_bus that
> exist which do support C45, but as they stand, probe_capabilities will
> be zero, and with your definitions above, that means MDIOBUS_C22.
>
> It seems this could lock in some potential issues later down the line
> if we want to use this elsewhere.
I'll change it to :
enum {
MDIOBUS_C22 = 1,
MDIOBUS_C45,
MDIOBUS_C22_C45,
} probe_capabilities;
Thanks
Calvin
^ permalink raw reply
* Re: [PATCH net-next 4/5] net: phy: add Lynx PCS MDIO module
From: Russell King - ARM Linux admin @ 2020-06-18 14:06 UTC (permalink / raw)
To: Ioana Ciornei
Cc: netdev, davem, vladimir.oltean, claudiu.manoil,
alexandru.marginean, michael, andrew, f.fainelli
In-Reply-To: <20200618120837.27089-5-ioana.ciornei@nxp.com>
On Thu, Jun 18, 2020 at 03:08:36PM +0300, Ioana Ciornei wrote:
> Add a Lynx PCS MDIO module which exposes the necessary operations to
> drive the PCS using PHYLINK.
>
> The majority of the code is extracted from the Felix DSA driver, which
> will be also modified in a later patch, and exposed as a separate module
> for code reusability purposes.
>
> At the moment, USXGMII (only with in-band AN and speeds up to 2500),
> SGMII, QSGMII and 2500Base-X (only w/o in-band AN) are supported by the
> Lynx PCS MDIO module since these were also supported by Felix.
>
> The module can only be enabled by the drivers in need and not user
> selectable.
Is this the same PCS found in the LX2160A? It looks very similar.
> +/* 2500Base-X is SerDes protocol 7 on Felix and 6 on ENETC. It is a SerDes lane
> + * clocked at 3.125 GHz which encodes symbols with 8b/10b and does not have
> + * auto-negotiation of any link parameters. Electrically it is compatible with
> + * a single lane of XAUI.
> + * The hardware reference manual wants to call this mode SGMII, but it isn't
> + * really, since the fundamental features of SGMII:
> + * - Downgrading the link speed by duplicating symbols
> + * - Auto-negotiation
> + * are not there.
I welcome that others are waking up to the industry wide obfuscation of
terminology surrounding "SGMII" and "1000base-X", and calling it out
where it is blatently incorrectly described in documentation.
> + * The speed is configured at 1000 in the IF_MODE because the clock frequency
> + * is actually given by a PLL configured in the Reset Configuration Word (RCW).
> + * Since there is no difference between fixed speed SGMII w/o AN and 802.3z w/o
> + * AN, we call this PHY interface type 2500Base-X. In case a PHY negotiates a
> + * lower link speed on line side, the system-side interface remains fixed at
> + * 2500 Mbps and we do rate adaptation through pause frames.
We have systems that do have AN with 2500base-X however - which is what
you want when you couple two potentially remote systems over a fibre
cable. The AN in 802.3z (1000base-X) is used to negotiate:
- duplex
- pause mode
although in practice, half-duplex is not supported by lots of hardware,
which leaves just pause mode. It is useful to have pause mode
negotiation remain present, whether it's 1000base-X or 2500base-X, but
obviously within the hardware boundaries.
I suspect the hardware is capable of supporting 802.3z AN when operating
at 2500base-X, but not the SGMII symbol duplication for slower speeds.
> +struct mdio_lynx_pcs *mdio_lynx_pcs_create(struct mdio_device *mdio_dev)
> +{
> + struct mdio_lynx_pcs *pcs;
> +
> + if (WARN_ON(!mdio_dev))
> + return NULL;
> +
> + pcs = kzalloc(sizeof(*pcs), GFP_KERNEL);
> + if (!pcs)
> + return NULL;
> +
> + pcs->dev = mdio_dev;
> + pcs->an_restart = lynx_pcs_an_restart;
> + pcs->get_state = lynx_pcs_get_state;
> + pcs->link_up = lynx_pcs_link_up;
> + pcs->config = lynx_pcs_config;
We really should not have these private structure interfaces. Private
structure-based driver specific interfaces really don't constitute a
sane approach to interface design.
Would it work if there was a "struct mdio_device" add to the
phylink_config structure, and then you could have the phylink_pcs_ops
embedded into this driver?
If not, then we need some kind of mdio_pcs_device that offers this
kind of functionality.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply
* [PATCH] iavf: fix error return code in iavf_init_get_resources()
From: Wei Yongjun @ 2020-06-18 14:19 UTC (permalink / raw)
To: Jeff Kirsher, Jakub Kicinski
Cc: Wei Yongjun, intel-wired-lan, netdev, kernel-janitors
Fix to return negative error code -ENOMEM from the error handling
case instead of 0, as done elsewhere in this function.
Fixes: b66c7bc1cd4d ("iavf: Refactor init state machine")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
drivers/net/ethernet/intel/iavf/iavf_main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index fa82768e5eda..bc83e2d99944 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -1863,8 +1863,10 @@ static int iavf_init_get_resources(struct iavf_adapter *adapter)
adapter->rss_key = kzalloc(adapter->rss_key_size, GFP_KERNEL);
adapter->rss_lut = kzalloc(adapter->rss_lut_size, GFP_KERNEL);
- if (!adapter->rss_key || !adapter->rss_lut)
+ if (!adapter->rss_key || !adapter->rss_lut) {
+ err = -ENOMEM;
goto err_mem;
+ }
if (RSS_AQ(adapter))
adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_RSS;
else
^ permalink raw reply related
* [PATCH][next] taprio: Use struct_size() in kzalloc()
From: Gustavo A. R. Silva @ 2020-06-18 14:46 UTC (permalink / raw)
To: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
Jakub Kicinski
Cc: netdev, linux-kernel, Gustavo A. R. Silva
Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes. Also, remove unnecessary
variable _size_.
This code was detected with the help of Coccinelle and, audited and
fixed manually.
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
net/sched/sch_taprio.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index b1eb12d33b9a..e981992634dd 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1108,11 +1108,10 @@ static void setup_txtime(struct taprio_sched *q,
static struct tc_taprio_qopt_offload *taprio_offload_alloc(int num_entries)
{
- size_t size = sizeof(struct tc_taprio_sched_entry) * num_entries +
- sizeof(struct __tc_taprio_qopt_offload);
struct __tc_taprio_qopt_offload *__offload;
- __offload = kzalloc(size, GFP_KERNEL);
+ __offload = kzalloc(struct_size(__offload, offload.entries, num_entries),
+ GFP_KERNEL);
if (!__offload)
return NULL;
--
2.27.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox