[PATCH 1/1] net/ipv6: add sysctl option accept_ra_min_hop_limit
Please apply the following patch to v4.1.x. By ommit 6fd99094de2b ("ipv6: Don't reduce hop limit for an interface") that have been added in the 4.0-rc7, it no longer comply with RFC4861. This problem has been fixed in the commit 8013d1d7eafb ("net/ipv6: add sysctl option accept_ra_min_hop_limit") in 4.3-rc1, but 4.1.x is still. [ Upstream 8013d1d7eafb0589ca766db6b74026f76b7f5cb4 ] Commit 6fd99094de2b ("ipv6: Don't reduce hop limit for an interface") disabled accept hop limit from RA if it is smaller than the current hop limit for security stuff. But this behavior kind of break the RFC definition. RFC 4861, 6.3.4. Processing Received Router Advertisements A Router Advertisement field (e.g., Cur Hop Limit, Reachable Time, and Retrans Timer) may contain a value denoting that it is unspecified. In such cases, the parameter should be ignored and the host should continue using whatever value it is already using. If the received Cur Hop Limit value is non-zero, the host SHOULD set its CurHopLimit variable to the received value. So add sysctl option accept_ra_min_hop_limit to let user choose the minimum hop limit value they can accept from RA. And set default to 1 to meet RFC standards. Signed-off-by: Hangbin Liu Acked-by: YOSHIFUJI Hideaki Signed-off-by: David S. Miller --- Documentation/networking/ip-sysctl.txt | 8 include/linux/ipv6.h | 1 + include/uapi/linux/ipv6.h | 1 + net/ipv6/addrconf.c| 10 ++ net/ipv6/ndisc.c | 16 +++- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt index 071fb18..07fad3d 100644 --- a/Documentation/networking/ip-sysctl.txt +++ b/Documentation/networking/ip-sysctl.txt @@ -1321,6 +1321,14 @@ accept_ra_from_local - BOOLEAN disabled if accept_ra_from_local is disabled on a specific interface. +accept_ra_min_hop_limit - INTEGER + Minimum hop limit Information in Router Advertisement. + + Hop limit Information in Router Advertisement less than this + variable shall be ignored. + + Default: 1 + accept_ra_pinfo - BOOLEAN Learn Prefix Information in Router Advertisement. diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index e4b4649..01c2592 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -29,6 +29,7 @@ struct ipv6_devconf { __s32 max_desync_factor; __s32 max_addresses; __s32 accept_ra_defrtr; + __s32 accept_ra_min_hop_limit; __s32 accept_ra_pinfo; #ifdef CONFIG_IPV6_ROUTER_PREF __s32 accept_ra_rtr_pref; diff --git a/include/uapi/linux/ipv6.h b/include/uapi/linux/ipv6.h index 5efa54a..68094e33 100644 --- a/include/uapi/linux/ipv6.h +++ b/include/uapi/linux/ipv6.h @@ -171,6 +171,7 @@ enum { DEVCONF_USE_OPTIMISTIC, DEVCONF_ACCEPT_RA_MTU, DEVCONF_STABLE_SECRET, + DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT, DEVCONF_MAX }; diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index fd3aa61..366d010 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -195,6 +195,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = { .max_addresses = IPV6_MAX_ADDRESSES, .accept_ra_defrtr = 1, .accept_ra_from_local = 0, + .accept_ra_min_hop_limit= 1, .accept_ra_pinfo= 1, #ifdef CONFIG_IPV6_ROUTER_PREF .accept_ra_rtr_pref = 1, @@ -236,6 +237,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = { .max_addresses = IPV6_MAX_ADDRESSES, .accept_ra_defrtr = 1, .accept_ra_from_local = 0, + .accept_ra_min_hop_limit= 1, .accept_ra_pinfo= 1, #ifdef CONFIG_IPV6_ROUTER_PREF .accept_ra_rtr_pref = 1, @@ -4559,6 +4561,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor; array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses; array[DEVCONF_ACCEPT_RA_DEFRTR] = cnf->accept_ra_defrtr; + array[DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT] = cnf->accept_ra_min_hop_limit; array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo; #ifdef CONFIG_IPV6_ROUTER_PREF array[DEVCONF_ACCEPT_RA_RTR_PREF] = cnf->accept_ra_rtr_pref; @@ -5455,6 +5458,13 @@ static struct addrconf_sysctl_table .proc_handler = proc_dointvec, }, { + .procname = "accept_ra_min_hop_limit", + .data = &ipv6_devconf.accept_ra_min_hop_limit, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, +
[PATCH v3 net-next] net: ethernet: cadence-macb: Add disabled usrio caps
On some platforms, the macb integration does not use the USRIO register to configure the (R)MII port and clocks. When the register is not implemented and the MACB error signal is connected to the bus error, reading or writing to the USRIO register can trigger some Imprecise External Aborts on ARM platforms. Signed-off-by: Neil Armstrong --- drivers/net/ethernet/cadence/macb.c | 27 +++ drivers/net/ethernet/cadence/macb.h | 1 + 2 files changed, 16 insertions(+), 12 deletions(-) Nicolas, I post only the first patch of the previous set posted here : http://lkml.kernel.org/r/1449582726-6148-1-git-send-email-narmstr...@baylibre.com to hopefully make it into the 4.5 merge time, I'll post the vendor prefix once this patch will hit mainline. Regards, Neil diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index 8b45bc9..fa53bc3 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c @@ -2124,7 +2124,8 @@ static void macb_get_regs(struct net_device *dev, struct ethtool_regs *regs, regs_buff[10] = macb_tx_dma(&bp->queues[0], tail); regs_buff[11] = macb_tx_dma(&bp->queues[0], head); - regs_buff[12] = macb_or_gem_readl(bp, USRIO); + if (!(bp->caps & MACB_CAPS_USRIO_DISABLED)) + regs_buff[12] = macb_or_gem_readl(bp, USRIO); if (macb_is_gem(bp)) { regs_buff[13] = gem_readl(bp, DMACFG); } @@ -2403,19 +2404,21 @@ static int macb_init(struct platform_device *pdev) dev->hw_features &= ~NETIF_F_SG; dev->features = dev->hw_features; - val = 0; - if (bp->phy_interface == PHY_INTERFACE_MODE_RGMII) - val = GEM_BIT(RGMII); - else if (bp->phy_interface == PHY_INTERFACE_MODE_RMII && -(bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII)) - val = MACB_BIT(RMII); - else if (!(bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII)) - val = MACB_BIT(MII); + if (!(bp->caps & MACB_CAPS_USRIO_DISABLED)) { + val = 0; + if (bp->phy_interface == PHY_INTERFACE_MODE_RGMII) + val = GEM_BIT(RGMII); + else if (bp->phy_interface == PHY_INTERFACE_MODE_RMII && +(bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII)) + val = MACB_BIT(RMII); + else if (!(bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII)) + val = MACB_BIT(MII); - if (bp->caps & MACB_CAPS_USRIO_HAS_CLKEN) - val |= MACB_BIT(CLKEN); + if (bp->caps & MACB_CAPS_USRIO_HAS_CLKEN) + val |= MACB_BIT(CLKEN); - macb_or_gem_writel(bp, USRIO, val); + macb_or_gem_writel(bp, USRIO, val); + } /* Set MII management clock divider */ val = macb_mdc_clk_div(bp); diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h index 5c03e81..0d4ecfc 100644 --- a/drivers/net/ethernet/cadence/macb.h +++ b/drivers/net/ethernet/cadence/macb.h @@ -400,6 +400,7 @@ #define MACB_CAPS_USRIO_HAS_CLKEN 0x0002 #define MACB_CAPS_USRIO_DEFAULT_IS_MII 0x0004 #define MACB_CAPS_NO_GIGABIT_HALF 0x0008 +#define MACB_CAPS_USRIO_DISABLED 0x0010 #define MACB_CAPS_FIFO_MODE0x1000 #define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x2000 #define MACB_CAPS_SG_DISABLED 0x4000 -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram
On Wed, Dec 30, 2015 at 11:30 PM, Cong Wang wrote: > On Wed, Dec 30, 2015 at 6:30 AM, Jacob Siverskog > wrote: >> On Wed, Dec 30, 2015 at 2:26 PM, Eric Dumazet wrote: >>> How often can you trigger this bug ? >> >> Ok. I don't have a good repro to trigger it unfortunately, I've seen it just >> a >> few times when bringing up/down network interfaces. Does the trace >> give any clue? >> > > A little bit. You need to help people to narrow down the problem > because there are too many places using skb->next and skb->prev. > > Since you mentioned it seems related to network interface flip, > what network interfaces are you using? What's is your TC setup? > > Thanks. The system contains only one physical network interface (TI WL1837, wl18xx module). The state prior to the crash was as follows: - One virtual network interface active (as STA, associated with access point) - Bluetooth (BLE only) active (same physical chip, co-existence, btwilink/st_drv modules) Actions made around the time of the crash: - Bluetooth disabled - One additional virtual network interface brought up (also as STA) I believe the crash occurred between these two actions. I just saw that there are some interesting events in the log prior to the crash: kernel: Bluetooth: Unable to push skb to HCI core(-6) kernel: (stc): proto stack 4's ->recv failed kernel: (stc): remove_channel_from_table: id 3 kernel: (stc): remove_channel_from_table: id 2 kernel: (stc): remove_channel_from_table: id 4 kernel: (stc): all chnl_ids unregistered kernel: (stk) :ldisc_install = 0(stc): st_tty_close The first print is from btwilink.c. However, I can't see the connection between Bluetooth (BLE) and UDP/IPv6 (we're not using 6LoWPAN or anything similar). Thanks, Jacob -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 net-next] net: ethernet: cadence-macb: Add disabled usrio caps
Le 04/01/2016 10:01, Neil Armstrong a écrit : > On some platforms, the macb integration does not use the USRIO > register to configure the (R)MII port and clocks. > When the register is not implemented and the MACB error signal > is connected to the bus error, reading or writing to the USRIO > register can trigger some Imprecise External Aborts on ARM platforms. > > Signed-off-by: Neil Armstrong > --- > drivers/net/ethernet/cadence/macb.c | 27 +++ > drivers/net/ethernet/cadence/macb.h | 1 + > 2 files changed, 16 insertions(+), 12 deletions(-) > > Nicolas, > I post only the first patch of the previous set posted here : > http://lkml.kernel.org/r/1449582726-6148-1-git-send-email-narmstr...@baylibre.com > to hopefully make it into the 4.5 merge time, > I'll post the vendor prefix once this patch will hit mainline. Okay, but I don't see how you will activate this capability (or I lost track of it). So, before I can accept one solution, can you please repost the whole solution as a v4. Thanks. Bye, > > Regards, > Neil > > diff --git a/drivers/net/ethernet/cadence/macb.c > b/drivers/net/ethernet/cadence/macb.c > index 8b45bc9..fa53bc3 100644 > --- a/drivers/net/ethernet/cadence/macb.c > +++ b/drivers/net/ethernet/cadence/macb.c > @@ -2124,7 +2124,8 @@ static void macb_get_regs(struct net_device *dev, > struct ethtool_regs *regs, > regs_buff[10] = macb_tx_dma(&bp->queues[0], tail); > regs_buff[11] = macb_tx_dma(&bp->queues[0], head); > > - regs_buff[12] = macb_or_gem_readl(bp, USRIO); > + if (!(bp->caps & MACB_CAPS_USRIO_DISABLED)) > + regs_buff[12] = macb_or_gem_readl(bp, USRIO); > if (macb_is_gem(bp)) { > regs_buff[13] = gem_readl(bp, DMACFG); > } > @@ -2403,19 +2404,21 @@ static int macb_init(struct platform_device *pdev) > dev->hw_features &= ~NETIF_F_SG; > dev->features = dev->hw_features; > > - val = 0; > - if (bp->phy_interface == PHY_INTERFACE_MODE_RGMII) > - val = GEM_BIT(RGMII); > - else if (bp->phy_interface == PHY_INTERFACE_MODE_RMII && > - (bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII)) > - val = MACB_BIT(RMII); > - else if (!(bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII)) > - val = MACB_BIT(MII); > + if (!(bp->caps & MACB_CAPS_USRIO_DISABLED)) { > + val = 0; > + if (bp->phy_interface == PHY_INTERFACE_MODE_RGMII) > + val = GEM_BIT(RGMII); > + else if (bp->phy_interface == PHY_INTERFACE_MODE_RMII && > + (bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII)) > + val = MACB_BIT(RMII); > + else if (!(bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII)) > + val = MACB_BIT(MII); > > - if (bp->caps & MACB_CAPS_USRIO_HAS_CLKEN) > - val |= MACB_BIT(CLKEN); > + if (bp->caps & MACB_CAPS_USRIO_HAS_CLKEN) > + val |= MACB_BIT(CLKEN); > > - macb_or_gem_writel(bp, USRIO, val); > + macb_or_gem_writel(bp, USRIO, val); > + } > > /* Set MII management clock divider */ > val = macb_mdc_clk_div(bp); > diff --git a/drivers/net/ethernet/cadence/macb.h > b/drivers/net/ethernet/cadence/macb.h > index 5c03e81..0d4ecfc 100644 > --- a/drivers/net/ethernet/cadence/macb.h > +++ b/drivers/net/ethernet/cadence/macb.h > @@ -400,6 +400,7 @@ > #define MACB_CAPS_USRIO_HAS_CLKEN0x0002 > #define MACB_CAPS_USRIO_DEFAULT_IS_MII 0x0004 > #define MACB_CAPS_NO_GIGABIT_HALF0x0008 > +#define MACB_CAPS_USRIO_DISABLED 0x0010 > #define MACB_CAPS_FIFO_MODE 0x1000 > #define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x2000 > #define MACB_CAPS_SG_DISABLED0x4000 > -- Nicolas Ferre -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
These patches are labour intensive to review because you can't just do it in the email client. Also you were not able to review it properly yourself and introduced a bug. I am often remove initializers but it's normally because I am changing something else which makes it worthwhile. This patch is the correct thing but it's not "worthwhile". It is not a good use of my time. Please stop sending cleanup patches, Markus. Just send fixes. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] net-iwlegacy: Refactoring for il_eeprom_init()
On Fri, Jan 01, 2016 at 09:30:10PM +0100, SF Markus Elfring wrote: > From: Markus Elfring > Date: Fri, 1 Jan 2016 20:54:25 +0100 > > Return directly if a memory allocation failed at the beginning. > > Signed-off-by: Markus Elfring Acked-by: Stanislaw Gruszka -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] iwlegacy: 4965-mac: constify il_sensitivity_ranges structure
On Wed, Dec 30, 2015 at 12:20:49PM +0100, Julia Lawall wrote: > The il_sensitivity_ranges is never modified, so declare it as const. > > Done with the help of Coccinelle. > > Signed-off-by: Julia Lawall Acked-by: Stanislaw Gruszka -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
Btw, GCC misses a lot of uninitialized variable bugs. I have a Smatch check which sometimes catches the bugs that GCC misses but you should not rely on the tools here. These patches need to be reviewed manually. And the "goto err" before the initialization makes everything more complicated (that's actually what caused the bug in this patch, in fact). regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
The original code is fine. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch net-next 0/4] mlxsw: couple of fixes
From: Jiri Pirko Couple of fixes from Ido. Ido Schimmel (4): mlxsw: spectrum: Initialize PVID only once mlxsw: spectrum: Return NOTIFY_BAD on bridge failure mlxsw: spectrum: Set bridge status in appropriate functions mlxsw: spectrum: Change bridge port attributes only when bridged drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 37 -- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 3 ++ 2 files changed, 23 insertions(+), 17 deletions(-) -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch net-next 2/4] mlxsw: spectrum: Return NOTIFY_BAD on bridge failure
From: Ido Schimmel It is possible for us to fail when joining or leaving a bridge, so let the user know about that by returning NOTIFY_BAD, as already done for LAG join/leave and 802.1D bridges. Signed-off-by: Ido Schimmel Signed-off-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index 6cc1125..eb719f3 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -2357,16 +2357,20 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *dev, } else if (netif_is_bridge_master(upper_dev)) { if (info->linking) { err = mlxsw_sp_port_bridge_join(mlxsw_sp_port); - if (err) + if (err) { netdev_err(dev, "Failed to join bridge\n"); + return NOTIFY_BAD; + } mlxsw_sp_master_bridge_inc(mlxsw_sp, upper_dev); mlxsw_sp_port->bridged = 1; } else { err = mlxsw_sp_port_bridge_leave(mlxsw_sp_port); - if (err) - netdev_err(dev, "Failed to leave bridge\n"); mlxsw_sp_port->bridged = 0; mlxsw_sp_master_bridge_dec(mlxsw_sp, upper_dev); + if (err) { + netdev_err(dev, "Failed to leave bridge\n"); + return NOTIFY_BAD; + } } } else if (netif_is_lag_master(upper_dev)) { if (info->linking) { -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch net-next 3/4] mlxsw: spectrum: Set bridge status in appropriate functions
From: Ido Schimmel Set the bridge status of physical ports in the appropriate functions, to be consistent with LAG join/leave and vPorts joining/leaving bridge. Also, remove the error messages in these two functions, as we already emit errors in both the single functions they call. Signed-off-by: Ido Schimmel Signed-off-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 15 +-- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index eb719f3..ed2eb7b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -1989,8 +1989,8 @@ static int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port) * own VLANs. */ err = mlxsw_sp_port_kill_vid(dev, 0, 1); - if (err) - netdev_err(dev, "Failed to remove VID 1\n"); + if (!err) + mlxsw_sp_port->bridged = 1; return err; } @@ -1998,16 +1998,13 @@ static int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port) static int mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port) { struct net_device *dev = mlxsw_sp_port->dev; - int err; + + mlxsw_sp_port->bridged = 0; /* Add implicit VLAN interface in the device, so that untagged * packets will be classified to the default vFID. */ - err = mlxsw_sp_port_add_vid(dev, 0, 1); - if (err) - netdev_err(dev, "Failed to add VID 1\n"); - - return err; + return mlxsw_sp_port_add_vid(dev, 0, 1); } static bool mlxsw_sp_master_bridge_check(struct mlxsw_sp *mlxsw_sp, @@ -2362,10 +2359,8 @@ static int mlxsw_sp_netdevice_port_upper_event(struct net_device *dev, return NOTIFY_BAD; } mlxsw_sp_master_bridge_inc(mlxsw_sp, upper_dev); - mlxsw_sp_port->bridged = 1; } else { err = mlxsw_sp_port_bridge_leave(mlxsw_sp_port); - mlxsw_sp_port->bridged = 0; mlxsw_sp_master_bridge_dec(mlxsw_sp, upper_dev); if (err) { netdev_err(dev, "Failed to leave bridge\n"); -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch net-next 1/4] mlxsw: spectrum: Initialize PVID only once
From: Ido Schimmel We set PVID to 1 in mlxsw_sp_port_vlan_init(), so we can remove this statement. Signed-off-by: Ido Schimmel Signed-off-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index c588c65..6cc1125 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -1367,7 +1367,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port) mlxsw_sp_port->learning = 1; mlxsw_sp_port->learning_sync = 1; mlxsw_sp_port->uc_flood = 1; - mlxsw_sp_port->pvid = 1; bytes = DIV_ROUND_UP(VLAN_N_VID, BITS_PER_BYTE); mlxsw_sp_port->active_vlans = kzalloc(bytes, GFP_KERNEL); if (!mlxsw_sp_port->active_vlans) { -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 net-next 0/3] Add new capability and macb DT variant
The first patch introduces a new capability bit to disable usage of the USRIO register on platform not implementing it thus avoiding some external imprecise aborts on ARM based platforms. The two last patchs adds a new macb variant compatible name using the capability, the NPx name is temporary and must be fixed when the first patch hits mainline. Only the first patch should be merged right now until the compatible name is fixed. v1: http://lkml.kernel.org/r/1449485914-12883-1-git-send-email-narmstr...@baylibre.com v2: http://lkml.kernel.org/r/1449582726-6148-1-git-send-email-narmstr...@baylibre.com v3: http://lkml.kernel.org/r/1451898103-21868-1-git-send-email-narmstr...@baylibre.com v4: as nicolas suggested, use a new macb config and a new product/vendor prefix Neil Armstrong (3): net: ethernet: cadence-macb: Add disabled usrio caps net: macb: Add NPx macb config using USRIO_DISABLED cap dt-bindings: net: macb: Add NPx macb variant Documentation/devicetree/bindings/net/macb.txt | 1 + drivers/net/ethernet/cadence/macb.c| 33 -- drivers/net/ethernet/cadence/macb.h| 1 + 3 files changed, 23 insertions(+), 12 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch net-next 4/4] mlxsw: spectrum: Change bridge port attributes only when bridged
From: Ido Schimmel Bridge port attributes are offloaded to hardware when invoked with SELF flag set, but it really makes no sense to reflect them when port is not bridged. Allow a user to change these attribute only when port is bridged and initialize them correctly when joining or leaving a bridge. Signed-off-by: Ido Schimmel Signed-off-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 17 +++-- .../net/ethernet/mellanox/mlxsw/spectrum_switchdev.c| 3 +++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index ed2eb7b..74ff011 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -1364,9 +1364,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port) mlxsw_sp_port->dev = dev; mlxsw_sp_port->mlxsw_sp = mlxsw_sp; mlxsw_sp_port->local_port = local_port; - mlxsw_sp_port->learning = 1; - mlxsw_sp_port->learning_sync = 1; - mlxsw_sp_port->uc_flood = 1; bytes = DIV_ROUND_UP(VLAN_N_VID, BITS_PER_BYTE); mlxsw_sp_port->active_vlans = kzalloc(bytes, GFP_KERNEL); if (!mlxsw_sp_port->active_vlans) { @@ -1989,16 +1986,24 @@ static int mlxsw_sp_port_bridge_join(struct mlxsw_sp_port *mlxsw_sp_port) * own VLANs. */ err = mlxsw_sp_port_kill_vid(dev, 0, 1); - if (!err) - mlxsw_sp_port->bridged = 1; + if (err) + return err; - return err; + mlxsw_sp_port->learning = 1; + mlxsw_sp_port->learning_sync = 1; + mlxsw_sp_port->uc_flood = 1; + mlxsw_sp_port->bridged = 1; + + return 0; } static int mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port) { struct net_device *dev = mlxsw_sp_port->dev; + mlxsw_sp_port->learning = 0; + mlxsw_sp_port->learning_sync = 0; + mlxsw_sp_port->uc_flood = 0; mlxsw_sp_port->bridged = 0; /* Add implicit VLAN interface in the device, so that untagged diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c index 9476ff9..6215954 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -252,6 +252,9 @@ static int mlxsw_sp_port_attr_br_flags_set(struct mlxsw_sp_port *mlxsw_sp_port, bool set; int err; + if (!mlxsw_sp_port->bridged) + return -EINVAL; + if (switchdev_trans_ph_prepare(trans)) return 0; -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 net-next 2/3] net: macb: Add NPx macb config using USRIO_DISABLED cap
Declare a new SoC variant for NPx SoCs having USRIO_DISABLED as capability bit. Signed-off-by: Neil Armstrong --- drivers/net/ethernet/cadence/macb.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index fa53bc3..a9e27a7 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c @@ -2781,6 +2781,11 @@ static const struct macb_config emac_config = { .init = at91ether_init, }; +static const struct macb_config npx_config = { + .caps = MACB_CAPS_USRIO_DISABLED, + .clk_init = macb_clk_init, + .init = macb_init, +}; static const struct macb_config zynqmp_config = { .caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO, @@ -2801,6 +2806,7 @@ static const struct of_device_id macb_dt_ids[] = { { .compatible = "cdns,at32ap7000-macb" }, { .compatible = "cdns,at91sam9260-macb", .data = &at91sam9260_config }, { .compatible = "cdns,macb" }, + { .compatible = "cdns,npx-macb", .data = &npx_config }, { .compatible = "cdns,pc302-gem", .data = &pc302gem_config }, { .compatible = "cdns,gem", .data = &pc302gem_config }, { .compatible = "atmel,sama5d2-gem", .data = &sama5d2_config }, -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 net-next 1/3] net: ethernet: cadence-macb: Add disabled usrio caps
On some platforms, the macb integration does not use the USRIO register to configure the (R)MII port and clocks. When the register is not implemented and the MACB error signal is connected to the bus error, reading or writing to the USRIO register can trigger some Imprecise External Aborts on ARM platforms. Signed-off-by: Neil Armstrong --- drivers/net/ethernet/cadence/macb.c | 27 +++ drivers/net/ethernet/cadence/macb.h | 1 + 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c index 8b45bc9..fa53bc3 100644 --- a/drivers/net/ethernet/cadence/macb.c +++ b/drivers/net/ethernet/cadence/macb.c @@ -2124,7 +2124,8 @@ static void macb_get_regs(struct net_device *dev, struct ethtool_regs *regs, regs_buff[10] = macb_tx_dma(&bp->queues[0], tail); regs_buff[11] = macb_tx_dma(&bp->queues[0], head); - regs_buff[12] = macb_or_gem_readl(bp, USRIO); + if (!(bp->caps & MACB_CAPS_USRIO_DISABLED)) + regs_buff[12] = macb_or_gem_readl(bp, USRIO); if (macb_is_gem(bp)) { regs_buff[13] = gem_readl(bp, DMACFG); } @@ -2403,19 +2404,21 @@ static int macb_init(struct platform_device *pdev) dev->hw_features &= ~NETIF_F_SG; dev->features = dev->hw_features; - val = 0; - if (bp->phy_interface == PHY_INTERFACE_MODE_RGMII) - val = GEM_BIT(RGMII); - else if (bp->phy_interface == PHY_INTERFACE_MODE_RMII && -(bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII)) - val = MACB_BIT(RMII); - else if (!(bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII)) - val = MACB_BIT(MII); + if (!(bp->caps & MACB_CAPS_USRIO_DISABLED)) { + val = 0; + if (bp->phy_interface == PHY_INTERFACE_MODE_RGMII) + val = GEM_BIT(RGMII); + else if (bp->phy_interface == PHY_INTERFACE_MODE_RMII && +(bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII)) + val = MACB_BIT(RMII); + else if (!(bp->caps & MACB_CAPS_USRIO_DEFAULT_IS_MII)) + val = MACB_BIT(MII); - if (bp->caps & MACB_CAPS_USRIO_HAS_CLKEN) - val |= MACB_BIT(CLKEN); + if (bp->caps & MACB_CAPS_USRIO_HAS_CLKEN) + val |= MACB_BIT(CLKEN); - macb_or_gem_writel(bp, USRIO, val); + macb_or_gem_writel(bp, USRIO, val); + } /* Set MII management clock divider */ val = macb_mdc_clk_div(bp); diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h index 5c03e81..0d4ecfc 100644 --- a/drivers/net/ethernet/cadence/macb.h +++ b/drivers/net/ethernet/cadence/macb.h @@ -400,6 +400,7 @@ #define MACB_CAPS_USRIO_HAS_CLKEN 0x0002 #define MACB_CAPS_USRIO_DEFAULT_IS_MII 0x0004 #define MACB_CAPS_NO_GIGABIT_HALF 0x0008 +#define MACB_CAPS_USRIO_DISABLED 0x0010 #define MACB_CAPS_FIFO_MODE0x1000 #define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x2000 #define MACB_CAPS_SG_DISABLED 0x4000 -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 net-next 3/3] dt-bindings: net: macb: Add NPx macb variant
Add NPx macb variant for NPx SoCs. Signed-off-by: Neil Armstrong --- Documentation/devicetree/bindings/net/macb.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/net/macb.txt b/Documentation/devicetree/bindings/net/macb.txt index 38c8e84..638cdde 100644 --- a/Documentation/devicetree/bindings/net/macb.txt +++ b/Documentation/devicetree/bindings/net/macb.txt @@ -4,6 +4,7 @@ Required properties: - compatible: Should be "cdns,[-]{macb|gem}" Use "cdns,at91sam9260-macb" for Atmel at91sam9 SoCs or the 10/100Mbit IP available on sama5d3 SoCs. + Use "cdns,npx-macb" for NPX SoCs devices. Use "cdns,at32ap7000-macb" for other 10/100 usage or use the generic form: "cdns,macb". Use "cdns,pc302-gem" for Picochip picoXcell pc302 and later devices based on the Cadence GEM, or the generic form: "cdns,gem". -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH iproute2 4/4] man: iplink: document new addrgenmodes
Cc: Hannes Frederic Sowa Signed-off-by: Bjørn Mork --- man/man8/ip-link.8.in | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in index ac6f4813a329..189a8f15fa03 100644 --- a/man/man8/ip-link.8.in +++ b/man/man8/ip-link.8.in @@ -150,7 +150,7 @@ ip-link \- network device configuration .br .B nomaster " |" .br -.B addrgenmode { eui64 | none } +.B addrgenmode { eui64 | none | stable_secret | random } .br .B link-netnsid ID .BR " }" @@ -1029,8 +1029,20 @@ set master device of the device (enslave device). unset master device of the device (release device). .TP -.BR "addrgenmode eui64 " or " addrgenmode none" -set IPv6 address generation mode +.BI addrgenmode " eui64|none|stable_secret|random" +set the IPv6 address generation mode + +.I eui64 +- use a Modified EUI-64 format interface identifier + +.I none +- disable automatic address generation + +.I stable_secret +- generate the interface identifier based on a preset /proc/sys/net/ipv6/conf/{default,DEVICE}/stable_secret + +.I random +- like stable_secret, but auto-generate a new random secret if none is set .TP .BR "link-netnsid " -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH iproute2 2/4] iplink: support setting addrgenmode stable_secret
It is possible to switch to another addrgenmode after setting a valid secret. Allow switching back without reconfiguring the secret for completeness. Cc: Hannes Frederic Sowa Signed-off-by: Bjørn Mork --- ip/iplink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ip/iplink.c b/ip/iplink.c index f30de86d1858..e824082f7d81 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -84,7 +84,7 @@ void iplink_usage(void) fprintf(stderr, " [ state { auto | enable | disable} ] ]\n"); fprintf(stderr, " [ master DEVICE ]\n"); fprintf(stderr, " [ nomaster ]\n"); - fprintf(stderr, " [ addrgenmode { eui64 | none } ]\n"); + fprintf(stderr, " [ addrgenmode { eui64 | none | stable_secret } ]\n"); fprintf(stderr, " [ protodown { on | off } ]\n"); fprintf(stderr, " ip link show [ DEVICE | group GROUP ] [up] [master DEV] [type TYPE]\n"); @@ -176,6 +176,8 @@ static int get_addr_gen_mode(const char *mode) return IN6_ADDR_GEN_MODE_EUI64; if (strcasecmp(mode, "none") == 0) return IN6_ADDR_GEN_MODE_NONE; + if (strcasecmp(mode, "stable_secret") == 0) + return IN6_ADDR_GEN_MODE_STABLE_PRIVACY; return -1; } -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH iproute2 0/4] addrgenmode updates for net-next
This adds support for the new "random" addrgenmode in net-next and improves the support for the "stable_secret" mode. Bjørn Mork (4): include: update kernel headers iplink: support setting addrgenmode stable_secret iplink: support show and set of "addrgenmode random" man: iplink: document new addrgenmodes include/linux/if_link.h | 1 + ip/ipaddress.c | 3 +++ ip/iplink.c | 6 +- man/man8/ip-link.8.in | 18 +++--- 4 files changed, 24 insertions(+), 4 deletions(-) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH iproute2 3/4] iplink: support show and set of "addrgenmode random"
"random" is a new IPv6 addrgenmode, enabling "stable_secret" type addresses with an auto-generated secret. $ ip link set eth0 addrgenmode random $ ip -d link show dev eth0 2: eth0: mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether 00:21:86:a3:25:7d brd ff:ff:ff:ff:ff:ff promiscuity 0 addrgenmode random Cc: Hannes Frederic Sowa Signed-off-by: Bjørn Mork --- ip/ipaddress.c | 3 +++ ip/iplink.c| 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ip/ipaddress.c b/ip/ipaddress.c index a495a391a0ec..9d254d27bc1b 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -296,6 +296,9 @@ static void print_af_spec(FILE *fp, struct rtattr *af_spec_attr) case IN6_ADDR_GEN_MODE_STABLE_PRIVACY: fprintf(fp, "addrgenmode stable_secret "); break; + case IN6_ADDR_GEN_MODE_RANDOM: + fprintf(fp, "addrgenmode random "); + break; default: fprintf(fp, "addrgenmode %#.2hhx ", mode); break; diff --git a/ip/iplink.c b/ip/iplink.c index e824082f7d81..75b21540c6b5 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -84,7 +84,7 @@ void iplink_usage(void) fprintf(stderr, " [ state { auto | enable | disable} ] ]\n"); fprintf(stderr, " [ master DEVICE ]\n"); fprintf(stderr, " [ nomaster ]\n"); - fprintf(stderr, " [ addrgenmode { eui64 | none | stable_secret } ]\n"); + fprintf(stderr, " [ addrgenmode { eui64 | none | stable_secret | random } ]\n"); fprintf(stderr, " [ protodown { on | off } ]\n"); fprintf(stderr, " ip link show [ DEVICE | group GROUP ] [up] [master DEV] [type TYPE]\n"); @@ -178,6 +178,8 @@ static int get_addr_gen_mode(const char *mode) return IN6_ADDR_GEN_MODE_NONE; if (strcasecmp(mode, "stable_secret") == 0) return IN6_ADDR_GEN_MODE_STABLE_PRIVACY; + if (strcasecmp(mode, "random") == 0) + return IN6_ADDR_GEN_MODE_RANDOM; return -1; } -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH iproute2 1/4] include: update kernel headers
Import current if_link.h from net-next Signed-off-by: Bjørn Mork --- include/linux/if_link.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/if_link.h b/include/linux/if_link.h index c9ad487d04f0..d91f2c97d946 100644 --- a/include/linux/if_link.h +++ b/include/linux/if_link.h @@ -216,6 +216,7 @@ enum in6_addr_gen_mode { IN6_ADDR_GEN_MODE_EUI64, IN6_ADDR_GEN_MODE_NONE, IN6_ADDR_GEN_MODE_STABLE_PRIVACY, + IN6_ADDR_GEN_MODE_RANDOM, }; /* Bridge section */ -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
On 03-01-16 16:18, Rafał Miłecki wrote: > On 3 January 2016 at 10:36, Arend van Spriel wrote: >> On 02-01-16 12:21, SF Markus Elfring wrote: Did you look at the resulting assembly code for different target architectures? >>> >>> Not yet. - Which execution system variants would you recommend for >>> further comparisons? >> >> Guess x86{,_64} and arm would be good candidates, ie. CISC vs. RISC. > > Oh, don't forget about MIPS with its fancy branches handling. You know > about it, don't you? You are asking me, right ;-) ? I have come across my share of MIPS platforms here at Broadcom, but I still try to avoid them as much as possible. > I'm against this patch as well. and counting... :-p Regards, Arend -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 net-next 2/3] net: macb: Add NPx macb config using USRIO_DISABLED cap
Le 04/01/2016 10:42, Neil Armstrong a écrit : > Declare a new SoC variant for NPx SoCs having USRIO_DISABLED as > capability bit. > > Signed-off-by: Neil Armstrong > --- > drivers/net/ethernet/cadence/macb.c | 6 ++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/net/ethernet/cadence/macb.c > b/drivers/net/ethernet/cadence/macb.c > index fa53bc3..a9e27a7 100644 > --- a/drivers/net/ethernet/cadence/macb.c > +++ b/drivers/net/ethernet/cadence/macb.c > @@ -2781,6 +2781,11 @@ static const struct macb_config emac_config = { > .init = at91ether_init, > }; > > +static const struct macb_config npx_config = { > + .caps = MACB_CAPS_USRIO_DISABLED, > + .clk_init = macb_clk_init, > + .init = macb_init, > +}; > > static const struct macb_config zynqmp_config = { > .caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO, > @@ -2801,6 +2806,7 @@ static const struct of_device_id macb_dt_ids[] = { > { .compatible = "cdns,at32ap7000-macb" }, > { .compatible = "cdns,at91sam9260-macb", .data = &at91sam9260_config }, > { .compatible = "cdns,macb" }, > + { .compatible = "cdns,npx-macb", .data = &npx_config }, I can accept that, but I think that you'd better make your device tree compatibility string *not* generic. Name it by the first NPx SoC or perfectly compatible SoC family that has this configuration and you'll be able to make the NP(x+1) compatible with it. It has proven to be much more future proof and even if in the early days of DT on ARM we accepted some binding with generic strings like this one below, It has proven to be a mistake. > { .compatible = "cdns,gem", .data = &pc302gem_config }, > { .compatible = "atmel,sama5d2-gem", .data = &sama5d2_config }, > -- Nicolas Ferre -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
> These patches are labour intensive to review because you can't just do > it in the email client. Thanks for your general interest. > Also you were not able to review it properly yourself and introduced > a bug. I admit that it can happen during my software development that I overlook implementation details somehow. > I am often remove initializers but it's normally because I am changing > something else which makes it worthwhile. It is nice to hear that you are also occasionally looking for similar update candidates. > This patch is the correct thing but it's not "worthwhile". I find this view interesting. > Please stop sending cleanup patches, Markus. Just send fixes. How often will source code clean-up fix something? May I resend a consistent patch series for the source file "drivers/net/wireless/rsi/rsi_91x_pkt.c" in the near future? Regards, Markus -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
I think the original code is fine. Wei. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
On 4 January 2016 at 11:05, Arend van Spriel wrote: > On 03-01-16 16:18, Rafał Miłecki wrote: >> On 3 January 2016 at 10:36, Arend van Spriel wrote: >>> On 02-01-16 12:21, SF Markus Elfring wrote: > Did you look at the resulting assembly code for different target > architectures? Not yet. - Which execution system variants would you recommend for further comparisons? >>> >>> Guess x86{,_64} and arm would be good candidates, ie. CISC vs. RISC. >> >> Oh, don't forget about MIPS with its fancy branches handling. You know >> about it, don't you? > > You are asking me, right ;-) ? I have come across my share of MIPS > platforms here at Broadcom, but I still try to avoid them as much as > possible. I was more thinking about author on this patch. But it's indeed an interesting thing, just to know, how MIPS CPU handles branches ;) -- Rafał -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
On Mon, Jan 04, 2016 at 11:44:15AM +0100, SF Markus Elfring wrote: > > Please stop sending cleanup patches, Markus. Just send fixes. > > How often will source code clean-up fix something? > > > May I resend a consistent patch series for the source file > "drivers/net/wireless/rsi/rsi_91x_pkt.c" in the near future? If you were sending checkpatch.pl fixes that would be easier to deal with but you are sending hundreds of "controversial" cleanups. They are controversial in the sense that they don't fix anything against official kernel style and they go against the author's original intention. I tend to agree that useless initializers are bad and disable GCCs uninitialized variable warnings but just because I agree with you doesn't make it official kernel style. It's slightly rude to go against the author's intention. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH net-next 3/3] macsec: introduce IEEE 802.1AE driver
Sabrina Dubroca wrote: [ Sorry for long delay ] > 2015-12-29, 02:14:06 +0100, Florian Westphal wrote: > > > + tx_sa->next_pn++; > > > + if (tx_sa->next_pn == 0) { > > > + pr_notice("PN wrapped, transitionning to !oper\n"); > > > > Is that _notice intentional? > > I'm only asking because it seems we printk unconditionally in response > > to network traffic & I don't get what operator should do in response to > > that message. > > The operator should install a new tx_sa, or MKA should have already > installed a new one and switched to it. > I can remove this message, or make it a pr_debug. Ok, I'll leave it up to you since I don't know what makes more sense. Basically just do whatever you think is right ;) AFAIU this should not really happen in practice, right? If so, pr_debug might be appropriate. > > > +static void macsec_encrypt_done(struct crypto_async_request *base, int > > > err) > > > +{ > > > + struct sk_buff *skb = base->data; > > > + struct net_device *dev = skb->dev; > > > + struct macsec_dev *macsec = macsec_priv(dev); > > > + struct macsec_tx_sa *sa = macsec_skb_cb(skb)->tx_sa; > > > + int len, ret; > > > + > > > + aead_request_free(macsec_skb_cb(skb)->req); > > > + > > > + rcu_read_lock_bh(); > > > + macsec_encrypt_finish(skb, dev); > > > + macsec_count_tx(skb, &macsec->secy.tx_sc, macsec_skb_cb(skb)->tx_sa); > > > + len = skb->len; > > > + ret = dev_queue_xmit(skb); > > > + count_tx(dev, ret, len); > > > + rcu_read_unlock_bh(); > > > > What was the rcu_read_lock_bh protecting? > > this_cpu_ptr in macsec_count_tx and count_tx. Separate get_cpu_ptr in > both functions seem a bit wasteful, and dev_queue_xmit will also > disable bh. > > I could turn that into a preempt_disable with a comment (something > like "covers multiple accesses to pcpu variables"). Or I could get > rid of it, and use get/put_cpu_ptr in macsec_count_tx/count_tx. > Note that macsec_count_tx/count_tx (and count_rx below) are also > called from the normal packet processing path, where we already run > under rcu_read_lock_bh anyway, so avoiding the overhead of an extra > get_cpu_ptr seems preferable. Ah, I see. In that case it seems preferrable to local_bh_dis/enable here. What do you think? (comment is still good to have wrt. pcpu and packet processing path detail, I missed the latter). > > > + spin_unlock(&rx_sa->lock); > > > + pr_debug("packet_number too small: %u < %u\n", pn, lowest_pn); > > > + u64_stats_update_begin(&rxsc_stats->syncp); > > > + rxsc_stats->stats.InPktsLate++; > > > + u64_stats_update_end(&rxsc_stats->syncp); > > > + goto drop; > > > + } > > > > I don't understand why this seems to perform replay check twice? > > This is part of the specification (802.1AE-2006 figure 10-5). > The first check is done before attempting to decrypt the packet, then > once again after decrypting. I see. Could you add a short comment? ("re-check post decryption as per $ref $figure" or something like that should suffice). > > > + if (secy->validate_frames != MACSEC_VALIDATE_DISABLED) { > > > + u64_stats_update_begin(&rxsc_stats->syncp); > > > + if (hdr->tci_an & MACSEC_TCI_E) > > > + rxsc_stats->stats.InOctetsDecrypted += skb->len; > > > + else > > > + rxsc_stats->stats.InOctetsValidated += skb->len; > > > + u64_stats_update_end(&rxsc_stats->syncp); > > > + } [..] > > Do you think its feasible to rearrange the above so that > > rx_sa->lock/unlock (next_pn test and increment) are grouped more closesly? > > Not if we want to follow the order of the checks in the specification. Ok, thanks for explaining. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
>> May I resend a consistent patch series for the source file >> "drivers/net/wireless/rsi/rsi_91x_pkt.c" in the near future? > > If you were sending checkpatch.pl fixes that would be easier to deal with Does this feedback mean that you would accept any more suggestions around source code updates which are derived from recommendations of this script? > but you are sending hundreds of "controversial" cleanups. It depends on the time range you look at for my proposals. > They are controversial in the sense that they don't fix anything > against official kernel style I find that I suggested also few changes that fit to this aspect. > and they go against the author's original intention. Can it occasionally help to reconsider the "first approach"? > I tend to agree that useless initializers are bad Would any more software developers like to share their opinions on this detail? > and disable GCCs uninitialized variable warnings I hope that this software area can be also improved. > but just because I agree with you doesn't make it official kernel style. That is fine. - Will it become useful to clarify any extensions to a document like "CodingStyle"? > It's slightly rude to go against the author's intention. I just dare to propose further special changes. Regards, Markus -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH (net-next.git) 08/18] stmmac: merge get_rx_owner into rx_status routine.
From: Fabrice Gasnier The RDES0 register can be read several times while doing RX of a packet. This patch slightly improves RX path performance by reading rdes0 once for two operation: check rx owner, get rx status bits. Signed-off-by: Fabrice Gasnier Acked-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/common.h | 10 +- drivers/net/ethernet/stmicro/stmmac/enh_desc.c|9 +++-- drivers/net/ethernet/stmicro/stmmac/norm_desc.c |9 +++-- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |9 + 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 586a336..bc780dc 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -234,10 +234,11 @@ struct stmmac_extra_stats { /* Rx IPC status */ enum rx_frame_status { - good_frame = 0, - discard_frame = 1, - csum_none = 2, - llc_snap = 4, + good_frame = 0x0, + discard_frame = 0x1, + csum_none = 0x2, + llc_snap = 0x4, + dma_own = 0x8, }; enum dma_irq_status { @@ -352,7 +353,6 @@ struct stmmac_desc_ops { /* Get the buffer size from the descriptor */ int (*get_tx_len) (struct dma_desc *p); /* Handle extra events on specific interrupts hw dependent */ - int (*get_rx_owner) (struct dma_desc *p); void (*set_rx_owner) (struct dma_desc *p); /* Get the receive frame size */ int (*get_rx_frame_len) (struct dma_desc *p, int rx_coe_type); diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c index 716b807..1a2fce9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c @@ -186,6 +186,9 @@ static int enh_desc_get_rx_status(void *data, struct stmmac_extra_stats *x, unsigned int rdes0 = p->des0; int ret = good_frame; + if (unlikely(rdes0 & RDES0_OWN)) + return dma_own; + if (unlikely(rdes0 & RDES0_ERROR_SUMMARY)) { if (unlikely(rdes0 & RDES0_DESCRIPTOR_ERROR)) { x->rx_desc++; @@ -272,11 +275,6 @@ static int enh_desc_get_tx_owner(struct dma_desc *p) return (p->des0 & ETDES0_OWN) >> 31; } -static int enh_desc_get_rx_owner(struct dma_desc *p) -{ - return (p->des0 & RDES0_OWN) >> 31; -} - static void enh_desc_set_tx_owner(struct dma_desc *p) { p->des0 |= ETDES0_OWN; @@ -402,7 +400,6 @@ const struct stmmac_desc_ops enh_desc_ops = { .init_rx_desc = enh_desc_init_rx_desc, .init_tx_desc = enh_desc_init_tx_desc, .get_tx_owner = enh_desc_get_tx_owner, - .get_rx_owner = enh_desc_get_rx_owner, .release_tx_desc = enh_desc_release_tx_desc, .prepare_tx_desc = enh_desc_prepare_tx_desc, .clear_tx_ic = enh_desc_clear_tx_ic, diff --git a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c index 460c573..5a91932 100644 --- a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c @@ -82,6 +82,9 @@ static int ndesc_get_rx_status(void *data, struct stmmac_extra_stats *x, unsigned int rdes0 = p->des0; struct net_device_stats *stats = (struct net_device_stats *)data; + if (unlikely(rdes0 & RDES0_OWN)) + return dma_own; + if (unlikely(!(rdes0 & RDES0_LAST_DESCRIPTOR))) { pr_warn("%s: Oversized frame spanned multiple buffers\n", __func__); @@ -155,11 +158,6 @@ static int ndesc_get_tx_owner(struct dma_desc *p) return (p->des0 & TDES0_OWN) >> 31; } -static int ndesc_get_rx_owner(struct dma_desc *p) -{ - return (p->des0 & RDES0_OWN) >> 31; -} - static void ndesc_set_tx_owner(struct dma_desc *p) { p->des0 |= TDES0_OWN; @@ -277,7 +275,6 @@ const struct stmmac_desc_ops ndesc_ops = { .init_rx_desc = ndesc_init_rx_desc, .init_tx_desc = ndesc_init_tx_desc, .get_tx_owner = ndesc_get_tx_owner, - .get_rx_owner = ndesc_get_rx_owner, .release_tx_desc = ndesc_release_tx_desc, .prepare_tx_desc = ndesc_prepare_tx_desc, .clear_tx_ic = ndesc_clear_tx_ic, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 9094aa6..1a31a1c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2224,7 +2224,11 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit) else p = priv->dma_rx + entry; - if (priv->hw->desc->get_rx_owner(p)) + /* read the status of the incoming frame */ + status = priv->hw->desc->rx_status(&priv->dev->stats, +
[PATCHv2 (net-next.git) 00/18] stmmac: enhance driver performances and update the version
This is a subset of patches to rework the driver in order to improve its performances and make it more robust under stress conditions. All patches have been ported on STi mainstream kernel branch and tested on ARM STiH4xx platforms and newer ones. This series also updates the driver version and prepares it to include further development to support new chips. In detail, these patches are: o to rework and improve the internal DMA bus settings Fine tuning is mandatory on some platforms for both performance and stability issues. o to rework and optimize the descriptor management. This will help a lot on performance side and preparing the inclusion on the GMAC4. o to add a set of optimizations for both xmit and rx functions. These will help a lot on performance side and making the driver more robust in case of low memory conditions and under some stress test, performed for example on IP-STB. Below some throughput figures obtained on some boxes before and after the patches. nuttcp (mbps) iperf (Mbps) -- tcp udp tcp udp tx rx tx rx tx rx tx rx -- old 680 800 480 506760 800 600 700 new 830 880 540 630840 880 700 800 == V2: as required, the rx_copybreak is now managed by using ethtool. == Fabrice Gasnier (3): stmmac: merge get_rx_owner into rx_status routine. stmmac: optimize tx clean function stmmac: fix phy init when attached to a phy Giuseppe Cavallaro (15): stmmac: share reset function between dwmac100 and dwmac1000 stmmac: rework DMA bus setting and introduce new platform AXI structure stmmac: change descriptor layout stmmac: remove modulo in stmmac_xmit() stmmac: add length field to dma data stmmac: add last_segment field to dma data stmmac: add is_jumbo field to dma data stmmac: optimize tx desc management stmmac: set dirty index out of the loop stmmac: first frame prep at the end of xmit routine stmmac: perf, remove modulo in stmmac_rx() stmmac: do not poll phy handler when attach a switch stmmac: do not perform zero-copy for rx frames stmmac: tune rx copy via threshold. stmmac: update version to Oct_2015 Documentation/devicetree/bindings/net/stmmac.txt | 54 +++- drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 35 ++- drivers/net/ethernet/stmicro/stmmac/common.h | 34 ++- drivers/net/ethernet/stmicro/stmmac/descs.h| 330 +--- drivers/net/ethernet/stmicro/stmmac/descs_com.h| 77 ++--- drivers/net/ethernet/stmicro/stmmac/dwmac100.h |1 - drivers/net/ethernet/stmicro/stmmac/dwmac1000.h|3 +- .../net/ethernet/stmicro/stmmac/dwmac1000_dma.c| 111 --- drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c | 22 +-- drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h| 39 +++- drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c| 21 ++ drivers/net/ethernet/stmicro/stmmac/enh_desc.c | 226 -- drivers/net/ethernet/stmicro/stmmac/norm_desc.c| 150 + drivers/net/ethernet/stmicro/stmmac/ring_mode.c| 32 ++- drivers/net/ethernet/stmicro/stmmac/stmmac.h |7 +- .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 41 +++- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 338 +-- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c |4 +- .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 42 +++- include/linux/stmmac.h | 17 +- 20 files changed, 967 insertions(+), 617 deletions(-) -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH (net-next.git) 01/18] stmmac: share reset function between dwmac100 and dwmac1000
This patch is to share the same reset procedure between dwmac100 and dwmac1000 chips. This will also help on enhancing the driver and support new chips. Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/common.h |3 +- drivers/net/ethernet/stmicro/stmmac/dwmac100.h |1 - drivers/net/ethernet/stmicro/stmmac/dwmac1000.h|1 - .../net/ethernet/stmicro/stmmac/dwmac1000_dma.c| 22 +++ drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c | 22 ++- drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h|5 drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c| 21 +++ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 ++-- 8 files changed, 46 insertions(+), 43 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 1e19c8f..bac0e44 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -376,7 +376,8 @@ extern const struct stmmac_desc_ops ndesc_ops; /* Specific DMA helpers */ struct stmmac_dma_ops { /* DMA core initialization */ - int (*init) (void __iomem *ioaddr, int pbl, int fb, int mb, + int (*reset)(void __iomem *ioaddr); + void (*init)(void __iomem *ioaddr, int pbl, int fb, int mb, int burst_len, u32 dma_tx, u32 dma_rx, int atds); /* Dump DMA registers */ void (*dump_regs) (void __iomem *ioaddr); diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100.h b/drivers/net/ethernet/stmicro/stmmac/dwmac100.h index 2ec6aea..1657acf 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac100.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100.h @@ -95,7 +95,6 @@ #define DMA_BUS_MODE_DSL_MASK 0x007c /* Descriptor Skip Length */ #define DMA_BUS_MODE_DSL_SHIFT 2 /* (in DWORDS) */ #define DMA_BUS_MODE_BAR_BUS 0x0002 /* Bar-Bus Arbitration */ -#define DMA_BUS_MODE_SFT_RESET 0x0001 /* Software Reset */ #define DMA_BUS_MODE_DEFAULT 0x /* DMA Control register defines */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h index 8831a05..9d36ae7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h @@ -221,7 +221,6 @@ enum inter_frame_gap { /*--- DMA BLOCK defines ---*/ /* DMA Bus Mode register defines */ -#define DMA_BUS_MODE_SFT_RESET 0x0001 /* Software Reset */ #define DMA_BUS_MODE_DA0x0002 /* Arbitration scheme */ #define DMA_BUS_MODE_DSL_MASK 0x007c /* Descriptor Skip Length */ #define DMA_BUS_MODE_DSL_SHIFT 2 /* (in DWORDS) */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c index 0e8937c..5f0aea5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c @@ -30,23 +30,10 @@ #include "dwmac1000.h" #include "dwmac_dma.h" -static int dwmac1000_dma_init(void __iomem *ioaddr, int pbl, int fb, int mb, - int burst_len, u32 dma_tx, u32 dma_rx, int atds) +static void dwmac1000_dma_init(void __iomem *ioaddr, int pbl, int fb, int mb, + int burst_len, u32 dma_tx, u32 dma_rx, int atds) { - u32 value = readl(ioaddr + DMA_BUS_MODE); - int limit; - - /* DMA SW reset */ - value |= DMA_BUS_MODE_SFT_RESET; - writel(value, ioaddr + DMA_BUS_MODE); - limit = 10; - while (limit--) { - if (!(readl(ioaddr + DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET)) - break; - mdelay(10); - } - if (limit < 0) - return -EBUSY; + u32 value; /* * Set the DMA PBL (Programmable Burst Length) mode @@ -102,8 +89,6 @@ static int dwmac1000_dma_init(void __iomem *ioaddr, int pbl, int fb, int mb, */ writel(dma_tx, ioaddr + DMA_TX_BASE_ADDR); writel(dma_rx, ioaddr + DMA_RCV_BASE_ADDR); - - return 0; } static u32 dwmac1000_configure_fc(u32 csr6, int rxfifosz) @@ -205,6 +190,7 @@ static void dwmac1000_rx_watchdog(void __iomem *ioaddr, u32 riwt) } const struct stmmac_dma_ops dwmac1000_dma_ops = { + .reset = dwmac_dma_reset, .init = dwmac1000_dma_init, .dump_regs = dwmac1000_dump_dma_regs, .dma_mode = dwmac1000_dma_operation_mode, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c index 9d0971c..c40582a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c @@ -32,24 +32,9 @@ #include "dwmac100.h" #include "dwmac_dma.h" -static int dwmac100_dma_init(void __iomem *ioaddr, int pbl
[PATCH (net-next.git) 02/18] stmmac: rework DMA bus setting and introduce new platform AXI structure
This patch restructures the DMA bus settings and this is done by introducing a new platform structure used for programming the AXI Bus Mode Register inside the DMA module. This structure can be populated from device-tree as documented in the binding txt file. After initializing the DMA, the AXI register can be optionally tuned for platform drivers based. This patch also reworks some parameters to make coherent the DMA configuration now that AXI register is introduced. For example, the burst_len is managed by using the mentioned axi support above; so the snps,burst-len parameter has been removed. It makes sense to provide the AAL parameter from DT to Address-Aligned Beats inside the Register0 and review the PBL settings when initialize the engine. Signed-off-by: Giuseppe Cavallaro --- Documentation/devicetree/bindings/net/stmmac.txt | 54 +++ drivers/net/ethernet/stmicro/stmmac/common.h |5 +- drivers/net/ethernet/stmicro/stmmac/dwmac1000.h|2 +- .../net/ethernet/stmicro/stmmac/dwmac1000_dma.c| 99 +-- drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c |2 +- drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h| 34 +++- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 ++- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c |4 +- .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 42 - include/linux/stmmac.h | 17 +++- 10 files changed, 209 insertions(+), 62 deletions(-) diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt index e862a92..6605d19 100644 --- a/Documentation/devicetree/bindings/net/stmmac.txt +++ b/Documentation/devicetree/bindings/net/stmmac.txt @@ -17,7 +17,25 @@ Required properties: The 1st cell is reset pre-delay in micro seconds. The 2nd cell is reset pulse in micro seconds. The 3rd cell is reset post-delay in micro seconds. + +Optional properties: +- resets: Should contain a phandle to the STMMAC reset signal, if any +- reset-names: Should contain the reset signal name "stmmaceth", if a + reset phandle is given +- max-frame-size: See ethernet.txt file in the same directory +- clocks: If present, the first clock should be the GMAC main clock and + the second clock should be peripheral's register interface clock. Further + clocks may be specified in derived bindings. +- clock-names: One name for each entry in the clocks property, the + first one should be "stmmaceth" and the second one should be "pclk". +- clk_ptp_ref: this is the PTP reference clock; in case of the PTP is + available this clock is used for programming the Timestamp Addend Register. + If not passed then the system clock will be used and this is fine on some + platforms. +- tx-fifo-depth: See ethernet.txt file in the same directory +- rx-fifo-depth: See ethernet.txt file in the same directory - snps,pbl Programmable Burst Length +- snps,aal Address-Aligned Beats - snps,fixed-burst Program the DMA to use the fixed burst mode - snps,mixed-burst Program the DMA to use the mixed burst mode - snps,force_thresh_dma_mode Force DMA to use the threshold mode for @@ -29,27 +47,28 @@ Required properties: supported by this device instance - snps,perfect-filter-entries: Number of perfect filter entries supported by this device instance - -Optional properties: -- resets: Should contain a phandle to the STMMAC reset signal, if any -- reset-names: Should contain the reset signal name "stmmaceth", if a - reset phandle is given -- max-frame-size: See ethernet.txt file in the same directory -- clocks: If present, the first clock should be the GMAC main clock - The optional second clock should be peripheral's register interface clock. - The third optional clock should be the ptp reference clock. - Further clocks may be specified in derived bindings. -- clock-names: One name for each entry in the clocks property. - The first one should be "stmmaceth". - The optional second one should be "pclk". - The optional third one should be "clk_ptp_ref". -- snps,burst_len: The AXI burst lenth value of the AXI BUS MODE register. -- tx-fifo-depth: See ethernet.txt file in the same directory -- rx-fifo-depth: See ethernet.txt file in the same directory +- AXI BUS Mode parameters: below the list of all the parameters to program the + AXI register inside the DMA module: + - snps,lpi_en: enable Low Power Interface + - snps,xit_frm: unlock on WoL + - snps,wr_osr_lmt: max write oustanding req. limit + - snps,rd_osr_lmt: max read oustanding req. limit + - snps,kbbe: do not cross 1KiB boundary. + - snps,axi_all: align address + - snps,blen: this is a vector of supported burst length. + - snps,fb: fixed-burst + - snps,mb: mixed-burst + - snps,rb: rebuild
[PATCH (net-next.git) 18/18] stmmac: update version to Oct_2015
This patch just updates the driver to the version fully tested on STi platforms. This version is Oct_2015. Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/stmmac.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index 9c62b86..cc404f4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -24,7 +24,7 @@ #define __STMMAC_H__ #define STMMAC_RESOURCE_NAME "stmmaceth" -#define DRV_MODULE_VERSION "March_2013" +#define DRV_MODULE_VERSION "Oct_2015" #include #include -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH (net-next.git) 17/18] stmmac: tune rx copy via threshold.
There is a threshold now used to also limit the skb allocation when use zero-copy. This is to avoid that there are incoherence in the ring due to a failure on skb allocation under very aggressive testing and under low memory conditions. Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/stmmac.h |1 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 26 +++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index c94ae65..9c62b86 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -77,6 +77,7 @@ struct stmmac_priv { unsigned int dma_rx_size; unsigned int dma_buf_sz; unsigned int rx_copybreak; + unsigned int rx_zeroc_thresh; u32 rx_riwt; int hwts_rx_en; dma_addr_t *rx_skbuff_dma; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index b431046..71bda4e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -201,6 +201,7 @@ static void print_pkt(unsigned char *buf, int len) /* minimum number of free TX descriptors required to wake up TX process */ #define STMMAC_TX_THRESH(x)(x->dma_tx_size/4) +#define STMMAC_RX_THRESH(x)(x->dma_rx_size / 4) static inline u32 stmmac_tx_avail(struct stmmac_priv *priv) { @@ -2173,6 +2174,14 @@ static void stmmac_rx_vlan(struct net_device *dev, struct sk_buff *skb) } +static inline int stmmac_rx_threshold_count(struct stmmac_priv *priv) +{ + if (priv->rx_zeroc_thresh < STMMAC_RX_THRESH(priv)) + return 0; + + return 1; +} + /** * stmmac_rx_refill - refill used skb preallocated buffers * @priv: driver private structure @@ -2198,8 +2207,15 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv) struct sk_buff *skb; skb = netdev_alloc_skb_ip_align(priv->dev, bfsize); - if (unlikely(!skb)) + if (unlikely(!skb)) { + /* so for a while no zero-copy! */ + priv->rx_zeroc_thresh = STMMAC_RX_THRESH(priv); + if (unlikely(net_ratelimit())) + dev_err(priv->device, + "fail to alloc skb entry %d\n", + entry); break; + } priv->rx_skbuff[entry] = skb; priv->rx_skbuff_dma[entry] = @@ -2215,9 +2231,13 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv) priv->hw->mode->refill_desc3(priv, p); + if (priv->rx_zeroc_thresh > 0) + priv->rx_zeroc_thresh--; + if (netif_msg_rx_status(priv)) pr_debug("\trefill entry #%d\n", entry); } + wmb(); priv->hw->desc->set_rx_owner(p); wmb(); @@ -2322,7 +2342,8 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit) frame_len, status); } - if (unlikely(frame_len < priv->rx_copybreak)) { + if (unlikely((frame_len < priv->rx_copybreak) || +stmmac_rx_threshold_count(priv))) { skb = netdev_alloc_skb_ip_align(priv->dev, frame_len); if (unlikely(!skb)) { @@ -2357,6 +2378,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit) } prefetch(skb->data - NET_IP_ALIGN); priv->rx_skbuff[entry] = NULL; + priv->rx_zeroc_thresh++; skb_put(skb, frame_len); dma_unmap_single(priv->device, -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH (net-next.git) 15/18] stmmac: fix phy init when attached to a phy
From: Fabrice Gasnier phy_bus_name can be NULL when "fixed-link" property isn't used. Then, since "stmmac: do not poll phy handler when attach a switch", phy_bus_name ptr needs to be checked before strcmp is called. Signed-off-by: Fabrice Gasnier Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 76ca54c..879cf77 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -883,8 +883,9 @@ static int stmmac_init_phy(struct net_device *dev) } /* If attached to a switch, there is no reason to poll phy handler */ - if (!strcmp(priv->plat->phy_bus_name, "fixed")) - phydev->irq = PHY_IGNORE_INTERRUPT; + if (priv->plat->phy_bus_name) + if (!strcmp(priv->plat->phy_bus_name, "fixed")) + phydev->irq = PHY_IGNORE_INTERRUPT; pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)" " Link = %d\n", dev->name, phydev->phy_id, phydev->link); -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH (net-next.git) 05/18] stmmac: add length field to dma data
Currently, the code pulls out the length field when unmapping a buffer directly from the descriptor. This will result in an uncached read to a dma_alloc_coherent() region. There is no need to do this, so this patch simply puts the value directly into a data structure which will hit the cache. Signed-off-by: Fabrice Gasnier Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/chain_mode.c |3 +++ drivers/net/ethernet/stmicro/stmmac/ring_mode.c |5 + drivers/net/ethernet/stmicro/stmmac/stmmac.h |1 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c index 399a7ed..688795e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c @@ -50,6 +50,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) if (dma_mapping_error(priv->device, desc->des2)) return -1; priv->tx_skbuff_dma[entry].buf = desc->des2; + priv->tx_skbuff_dma[entry].len = bmax; priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum, STMMAC_CHAIN_MODE); while (len != 0) { @@ -65,6 +66,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) if (dma_mapping_error(priv->device, desc->des2)) return -1; priv->tx_skbuff_dma[entry].buf = desc->des2; + priv->tx_skbuff_dma[entry].len = bmax; priv->hw->desc->prepare_tx_desc(desc, 0, bmax, csum, STMMAC_CHAIN_MODE); priv->hw->desc->set_tx_owner(desc); @@ -77,6 +79,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) if (dma_mapping_error(priv->device, desc->des2)) return -1; priv->tx_skbuff_dma[entry].buf = desc->des2; + priv->tx_skbuff_dma[entry].len = len; priv->hw->desc->prepare_tx_desc(desc, 0, len, csum, STMMAC_CHAIN_MODE); priv->hw->desc->set_tx_owner(desc); diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c index 2560855..3300029 100644 --- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c @@ -57,6 +57,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) return -1; priv->tx_skbuff_dma[entry].buf = desc->des2; + priv->tx_skbuff_dma[entry].len = bmax; + desc->des3 = desc->des2 + BUF_SIZE_4KiB; priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum, STMMAC_RING_MODE); @@ -75,6 +77,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) if (dma_mapping_error(priv->device, desc->des2)) return -1; priv->tx_skbuff_dma[entry].buf = desc->des2; + priv->tx_skbuff_dma[entry].len = len; + desc->des3 = desc->des2 + BUF_SIZE_4KiB; priv->hw->desc->prepare_tx_desc(desc, 0, len, csum, STMMAC_RING_MODE); @@ -86,6 +90,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) if (dma_mapping_error(priv->device, desc->des2)) return -1; priv->tx_skbuff_dma[entry].buf = desc->des2; + priv->tx_skbuff_dma[entry].len = nopaged_len; desc->des3 = desc->des2 + BUF_SIZE_4KiB; priv->hw->desc->prepare_tx_desc(desc, 1, nopaged_len, csum, STMMAC_RING_MODE); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index 1f3b33a..8517a04 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -45,6 +45,7 @@ struct stmmac_resources { struct stmmac_tx_info { dma_addr_t buf; bool map_as_page; + unsigned len; }; struct stmmac_priv { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 4c73c09..004e567 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1107,6 +1107,7 @@ static int init_dma_desc_rings(struct net_device *dev, gfp_t flags) p->des2 = 0; priv->tx_skbuff_dma[i].buf = 0; priv->tx_skbuff_dma[i].map_as_page = false; +
[PATCH (net-next.git) 10/18] stmmac: optimize tx clean function
From: Fabrice Gasnier This patch "inline" get_tx_owner and get_ls routines. It Results in a unique read to tdes0, instead of three, to check TX_OWN and LS bits, and other status bits. It helps improve driver TX path by removing two uncached read/writes inside TX clean loop for enhanced descriptors but not for normal ones because the des1 must be read in any case. Signed-off-by: Fabrice Gasnier Acked-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/common.h |8 ++ drivers/net/ethernet/stmicro/stmmac/enh_desc.c| 12 +++- drivers/net/ethernet/stmicro/stmmac/norm_desc.c | 13 - drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 27 ++--- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 536aa06..c377ece 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -241,6 +241,14 @@ enum rx_frame_status { dma_own = 0x8, }; +/* Tx status */ +enum tx_frame_status { + tx_done = 0x0, + tx_not_ls = 0x1, + tx_err = 0x2, + tx_dma_own = 0x4, +}; + enum dma_irq_status { tx_hard_error = 0x1, tx_hard_error_bump_tc = 0x2, diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c index 1c9a520..b672e51 100644 --- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c @@ -31,7 +31,15 @@ static int enh_desc_get_tx_status(void *data, struct stmmac_extra_stats *x, { struct net_device_stats *stats = (struct net_device_stats *)data; unsigned int tdes0 = p->des0; - int ret = 0; + int ret = tx_done; + + /* Get tx owner first */ + if (unlikely(tdes0 & ETDES0_OWN)) + return tx_dma_own; + + /* Verify tx error by looking at the last segment. */ + if (likely(!(tdes0 & ETDES0_LAST_SEGMENT))) + return tx_not_ls; if (unlikely(tdes0 & ETDES0_ERROR_SUMMARY)) { if (unlikely(tdes0 & ETDES0_JABBER_TIMEOUT)) @@ -71,7 +79,7 @@ static int enh_desc_get_tx_status(void *data, struct stmmac_extra_stats *x, dwmac_dma_flush_tx_fifo(ioaddr); } - ret = -1; + ret = tx_err; } if (unlikely(tdes0 & ETDES0_DEFERRED)) diff --git a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c index df2603e..9ccae3c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c @@ -31,7 +31,16 @@ static int ndesc_get_tx_status(void *data, struct stmmac_extra_stats *x, { struct net_device_stats *stats = (struct net_device_stats *)data; unsigned int tdes0 = p->des0; - int ret = 0; + unsigned int tdes1 = p->des1; + int ret = tx_done; + + /* Get tx owner first */ + if (unlikely(tdes0 & TDES0_OWN)) + return tx_dma_own; + + /* Verify tx error by looking at the last segment. */ + if (likely(!(tdes1 & TDES1_LAST_SEGMENT))) + return tx_not_ls; if (unlikely(tdes0 & TDES0_ERROR_SUMMARY)) { if (unlikely(tdes0 & TDES0_UNDERFLOW_ERROR)) { @@ -54,7 +63,7 @@ static int ndesc_get_tx_status(void *data, struct stmmac_extra_stats *x, collisions = (tdes0 & TDES0_COLLISION_COUNT_MASK) >> 3; stats->collisions += collisions; } - ret = -1; + ret = tx_err; } if (tdes0 & TDES0_VLAN_FRAME) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index c2d923e..230ded2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1330,32 +1330,31 @@ static void stmmac_tx_clean(struct stmmac_priv *priv) priv->xstats.tx_clean++; while (entry != priv->cur_tx) { - int last; struct sk_buff *skb = priv->tx_skbuff[entry]; struct dma_desc *p; + int status; if (priv->extend_desc) p = (struct dma_desc *)(priv->dma_etx + entry); else p = priv->dma_tx + entry; - /* Check if the descriptor is owned by the DMA. */ - if (priv->hw->desc->get_tx_owner(p)) - break; - - /* Verify tx error by looking at the last segment. */ - last = priv->tx_skbuff_dma[entry].last_segment; - if (likely(last)) { - int tx_error = - priv->hw->desc->tx_status(&priv->dev->stats, + status = priv->hw->desc->tx_status(&priv-
Re: [Linux-v4.4-LTS] ppp: Backport of rtnetlink device handling
On Mon, Jan 04, 2016 at 08:47:30AM +0100, Sedat Dilek wrote: > Hi Guillaume, > > which patches do I need to backport "ppp: rtnetlink device handling" > to Linux v4.4 which will be a LongTerm-Supported (LTS) Linux-kernel > [0]? > Quite frankly, backporting this series doesn't look like a good idea. It only provides a new ABI for creating ppp devices and your control plane most likely hasn't been updated to use it. So it won't bring any benefit. > I tried [1] and [2] on top of recent net-next Git tree which will be > in Linux v4.5. > Currently, your patches are not included in net-next.git#master. > Indeed, and that's why no control plane should rely on them (yet). > In the thread "[net-next] ppp: rtnetlink device handling" [4] you > explained the benefits and use-case etc. > > Checking with git-log shows me these commits... > > $ git log --oneline --no-merges v4.4-rc8.. drivers/net/ppp net/l2tp > 19e8c5713e78 l2tp: rely on ppp layer for skb scrubbing > 645eee4eba45 ppp: implement rtnetlink device handling > 3a9bce0ae138 ppp: define reusable device creation functions > 69d9728d00c7 ppp: declare ppp devices as enumerated interfaces > 94dbffe16eb1 ppp: define "ppp" device type > 681b4d88ad8e pppox: use standard module auto-loading feature > a8acce6aa584 ppp: remove PPPOX_ZOMBIE socket state > 8734e485fed5 ppp: don't set sk_state to PPPOX_ZOMBIE in pppoe_disc_rcv() > > ...is that sufficient for a backport? > Applying the series directly on v4.4-rc8 should work (with a few conflicts, but other patches are unrelated). But still, you probably don't want to maintain backports unless strictly required. BTW, this one has no chance to hit any -stable tree anyway. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH (net-next.git) 07/18] stmmac: add is_jumbo field to dma data
Optimize tx_clean by avoiding a des3 read in stmmac_clean_desc3(). In ring mode, TX, des3 seems only used when xmit a jumbo frame. In case of normal descriptors, it may also be used for time stamping. Clean it in the above two case, without reading it. Signed-off-by: Fabrice Gasnier Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/chain_mode.c |3 ++- drivers/net/ethernet/stmicro/stmmac/ring_mode.c | 11 ++- drivers/net/ethernet/stmicro/stmmac/stmmac.h |1 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c index e985459..d6d56ee 100644 --- a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c @@ -154,7 +154,8 @@ static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p) struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr; unsigned int entry = priv->dirty_tx; - if (priv->tx_skbuff_dma[entry].last_segment && !priv->extend_desc) + if (priv->tx_skbuff_dma[entry].last_segment && !priv->extend_desc && + priv->hwts_tx_en) /* NOTE: Device will overwrite des3 with timestamp value if * 1588-2002 time stamping is enabled, hence reinitialize it * to keep explicit chaining in the descriptor. diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c index 3300029..ffab4d7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c @@ -58,6 +58,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) priv->tx_skbuff_dma[entry].buf = desc->des2; priv->tx_skbuff_dma[entry].len = bmax; + priv->tx_skbuff_dma[entry].is_jumbo = true; desc->des3 = desc->des2 + BUF_SIZE_4KiB; priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum, @@ -78,6 +79,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) return -1; priv->tx_skbuff_dma[entry].buf = desc->des2; priv->tx_skbuff_dma[entry].len = len; + priv->tx_skbuff_dma[entry].is_jumbo = true; desc->des3 = desc->des2 + BUF_SIZE_4KiB; priv->hw->desc->prepare_tx_desc(desc, 0, len, csum, @@ -91,6 +93,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) return -1; priv->tx_skbuff_dma[entry].buf = desc->des2; priv->tx_skbuff_dma[entry].len = nopaged_len; + priv->tx_skbuff_dma[entry].is_jumbo = true; desc->des3 = desc->des2 + BUF_SIZE_4KiB; priv->hw->desc->prepare_tx_desc(desc, 1, nopaged_len, csum, STMMAC_RING_MODE); @@ -128,7 +131,13 @@ static void stmmac_init_desc3(struct dma_desc *p) static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p) { - if (unlikely(p->des3)) + struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr; + unsigned int entry = priv->dirty_tx; + + /* des3 is only used for jumbo frames tx or time stamping */ + if (unlikely(priv->tx_skbuff_dma[entry].is_jumbo || +(priv->tx_skbuff_dma[entry].last_segment && + !priv->extend_desc && priv->hwts_tx_en))) p->des3 = 0; } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index f15c493..b73e8d8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -47,6 +47,7 @@ struct stmmac_tx_info { bool map_as_page; unsigned len; bool last_segment; + bool is_jumbo; }; struct stmmac_priv { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index cb24779..9094aa6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1378,6 +1378,7 @@ static void stmmac_tx_clean(struct stmmac_priv *priv) } priv->hw->mode->clean_desc3(priv, p); priv->tx_skbuff_dma[entry].last_segment = false; + priv->tx_skbuff_dma[entry].is_jumbo = false; if (likely(skb != NULL)) { pkts_compl++; -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH (net-next.git) 12/18] stmmac: first frame prep at the end of xmit routine
This patch is to fill the first descriptor just before granting the DMA engine so at the end of the xmit. The patch takes care about the algorithm adopted to mitigate the interrupts, then it fixes the last segment in case of no fragments. Moreover, this new implementation does not pass any "ter" field when prepare the descriptors because this is not necessary. The patch also details the memory barrier in the xmit. As final results, this patch guarantees the same performances but fixing a case if small datagram are sent. In fact, this kind of test is impacted if no coalesce is done. Signed-off-by: Fabrice Gasnier Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/common.h |7 +- drivers/net/ethernet/stmicro/stmmac/enh_desc.c | 25 +++-- drivers/net/ethernet/stmicro/stmmac/norm_desc.c| 24 ++-- drivers/net/ethernet/stmicro/stmmac/ring_mode.c|2 - .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c |2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 114 +++ 6 files changed, 95 insertions(+), 79 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index c377ece..01d2408 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -96,7 +96,7 @@ struct stmmac_extra_stats { unsigned long napi_poll; unsigned long tx_normal_irq_n; unsigned long tx_clean; - unsigned long tx_reset_ic_bit; + unsigned long tx_set_ic_bit; unsigned long irq_receive_pmt_irq_n; /* MMC info */ unsigned long mmc_tx_irq_n; @@ -342,8 +342,7 @@ struct stmmac_desc_ops { /* Invoked by the xmit function to prepare the tx descriptor */ void (*prepare_tx_desc) (struct dma_desc *p, int is_fs, int len, -int csum_flag, int mode, int tx_own, -bool ls_ic); +int csum_flag, int mode, int tx_own, bool ls); /* Set/get the owner of the descriptor */ void (*set_tx_owner) (struct dma_desc *p); int (*get_tx_owner) (struct dma_desc *p); @@ -351,7 +350,7 @@ struct stmmac_desc_ops { void (*release_tx_desc) (struct dma_desc *p, int mode); /* Clear interrupt on tx frame completion. When this bit is * set an interrupt happens as soon as the frame is transmitted */ - void (*clear_tx_ic) (struct dma_desc *p); + void (*set_tx_ic)(struct dma_desc *p); /* Last tx segment reports the transmit status */ int (*get_tx_ls) (struct dma_desc *p); /* Return the transmit status looking at the TDES1 */ diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c index b672e51..76e1c15 100644 --- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c @@ -311,10 +311,15 @@ static void enh_desc_release_tx_desc(struct dma_desc *p, int mode) static void enh_desc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len, int csum_flag, int mode, int tx_own, -bool ls_ic) +bool ls) { unsigned int tdes0 = p->des0; + if (mode == STMMAC_CHAIN_MODE) + enh_set_tx_desc_len_on_chain(p, len); + else + enh_set_tx_desc_len_on_ring(p, len); + if (is_fs) tdes0 |= ETDES0_FIRST_SEGMENT; else @@ -325,6 +330,10 @@ static void enh_desc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len, else tdes0 &= ~(TX_CIC_FULL << ETDES0_CHECKSUM_INSERTION_SHIFT); + if (ls) + tdes0 |= ETDES0_LAST_SEGMENT; + + /* Finally set the OWN bit. Later the DMA will start! */ if (tx_own) tdes0 |= ETDES0_OWN; @@ -335,20 +344,12 @@ static void enh_desc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len, */ wmb(); - if (ls_ic) - tdes0 |= ETDES0_LAST_SEGMENT | ETDES0_INTERRUPT; - p->des0 = tdes0; - - if (mode == STMMAC_CHAIN_MODE) - enh_set_tx_desc_len_on_chain(p, len); - else - enh_set_tx_desc_len_on_ring(p, len); } -static void enh_desc_clear_tx_ic(struct dma_desc *p) +static void enh_desc_set_tx_ic(struct dma_desc *p) { - p->des0 &= ~ETDES0_INTERRUPT; + p->des0 |= ETDES0_INTERRUPT; } static int enh_desc_get_rx_frame_len(struct dma_desc *p, int rx_coe_type) @@ -419,7 +420,7 @@ const struct stmmac_desc_ops enh_desc_ops = { .get_tx_owner = enh_desc_get_tx_owner, .release_tx_desc = enh_desc_release_tx_desc, .prepare_tx_desc = enh_desc_prepare_tx_desc, - .clear_tx_ic = enh_desc_clear_tx_ic, + .set_tx_ic = enh_desc_set_tx_ic, .get_tx_ls = enh_desc_g
[PATCH (net-next.git) 09/18] stmmac: optimize tx desc management
This patch is to optimize the way to manage the TDES inside the xmit function. When prepare the frame, some settings (e.g. OWN bit) can be merged. This has been reworked to improve the tx performances. Signed-off-by: Fabrice Gasnier Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 13 +++ drivers/net/ethernet/stmicro/stmmac/common.h |5 +-- drivers/net/ethernet/stmicro/stmmac/enh_desc.c| 22 ++-- drivers/net/ethernet/stmicro/stmmac/norm_desc.c | 15 +++-- drivers/net/ethernet/stmicro/stmmac/ring_mode.c |7 ++--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 16 +- 6 files changed, 42 insertions(+), 36 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c index d6d56ee..c9310ef 100644 --- a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c @@ -51,7 +51,9 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) return -1; priv->tx_skbuff_dma[entry].buf = desc->des2; priv->tx_skbuff_dma[entry].len = bmax; - priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum, STMMAC_CHAIN_MODE); + /* do not close the descriptor and do not set own bit */ + priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum, STMMAC_CHAIN_MODE, + 0, false); while (len != 0) { priv->tx_skbuff[entry] = NULL; @@ -68,8 +70,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) priv->tx_skbuff_dma[entry].buf = desc->des2; priv->tx_skbuff_dma[entry].len = bmax; priv->hw->desc->prepare_tx_desc(desc, 0, bmax, csum, - STMMAC_CHAIN_MODE); - priv->hw->desc->set_tx_owner(desc); + STMMAC_CHAIN_MODE, 1, + false); len -= bmax; i++; } else { @@ -80,9 +82,10 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) return -1; priv->tx_skbuff_dma[entry].buf = desc->des2; priv->tx_skbuff_dma[entry].len = len; + /* last descriptor can be set now */ priv->hw->desc->prepare_tx_desc(desc, 0, len, csum, - STMMAC_CHAIN_MODE); - priv->hw->desc->set_tx_owner(desc); + STMMAC_CHAIN_MODE, 1, + true); len = 0; } } diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index bc780dc..536aa06 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -334,12 +334,11 @@ struct stmmac_desc_ops { /* Invoked by the xmit function to prepare the tx descriptor */ void (*prepare_tx_desc) (struct dma_desc *p, int is_fs, int len, -int csum_flag, int mode); +int csum_flag, int mode, int tx_own, +bool ls_ic); /* Set/get the owner of the descriptor */ void (*set_tx_owner) (struct dma_desc *p); int (*get_tx_owner) (struct dma_desc *p); - /* Invoked by the xmit function to close the tx descriptor */ - void (*close_tx_desc) (struct dma_desc *p); /* Clean the tx descriptor as soon as the tx irq is received */ void (*release_tx_desc) (struct dma_desc *p, int mode); /* Clear interrupt on tx frame completion. When this bit is diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c index 1a2fce9..1c9a520 100644 --- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c @@ -302,7 +302,8 @@ static void enh_desc_release_tx_desc(struct dma_desc *p, int mode) } static void enh_desc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len, -int csum_flag, int mode) +int csum_flag, int mode, int tx_own, +bool ls_ic) { unsigned int tdes0 = p->des0; @@ -316,6 +317,19 @@ static void enh_desc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len, else tdes0 &= ~(TX_CIC_FULL << ETDES0_CHECKSUM_INSERTION_SHIFT); + if (tx_own) + tdes0 |= ETDES0_OWN; + + if (is_fs & tx_own) + /* When
[PATCHv2 (net-next.git) 16/18] stmmac: do not perform zero-copy for rx frames
This patch is to allow this driver to copy tiny frames during the reception process. This is giving more stability while stressing the driver on STi embedded systems. Signed-off-by: Giuseppe Cavallaro --- V2: rx_copybreak tunable by using ethtool drivers/net/ethernet/stmicro/stmmac/stmmac.h |1 + .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 39 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 61 +++- 3 files changed, 86 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index b73e8d8..c94ae65 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -76,6 +76,7 @@ struct stmmac_priv { unsigned int dirty_rx; unsigned int dma_rx_size; unsigned int dma_buf_sz; + unsigned int rx_copybreak; u32 rx_riwt; int hwts_rx_en; dma_addr_t *rx_skbuff_dma; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index c803d4c..3c7928e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -781,6 +781,43 @@ static int stmmac_get_ts_info(struct net_device *dev, return ethtool_op_get_ts_info(dev, info); } +static int stmmac_get_tunable(struct net_device *dev, + const struct ethtool_tunable *tuna, void *data) +{ + struct stmmac_priv *priv = netdev_priv(dev); + int ret = 0; + + switch (tuna->id) { + case ETHTOOL_RX_COPYBREAK: + *(u32 *)data = priv->rx_copybreak; + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +static int stmmac_set_tunable(struct net_device *dev, + const struct ethtool_tunable *tuna, + const void *data) +{ + struct stmmac_priv *priv = netdev_priv(dev); + int ret = 0; + + switch (tuna->id) { + case ETHTOOL_RX_COPYBREAK: + priv->rx_copybreak = *(u32 *)data; + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + static const struct ethtool_ops stmmac_ethtool_ops = { .begin = stmmac_check_if_running, .get_drvinfo = stmmac_ethtool_getdrvinfo, @@ -803,6 +840,8 @@ static const struct ethtool_ops stmmac_ethtool_ops = { .get_ts_info = stmmac_get_ts_info, .get_coalesce = stmmac_get_coalesce, .set_coalesce = stmmac_set_coalesce, + .get_tunable = stmmac_get_tunable, + .set_tunable = stmmac_set_tunable, }; void stmmac_set_ethtool_ops(struct net_device *netdev) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 879cf77..b431046 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -99,6 +99,8 @@ static int buf_sz = DEFAULT_BUFSIZE; module_param(buf_sz, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(buf_sz, "DMA buffer size"); +#defineSTMMAC_RX_COPYBREAK 256 + static const u32 default_msg_level = (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN | NETIF_MSG_TIMER); @@ -1842,6 +1844,7 @@ static int stmmac_open(struct net_device *dev) priv->dma_tx_size = STMMAC_ALIGN(dma_txsize); priv->dma_rx_size = STMMAC_ALIGN(dma_rxsize); priv->dma_buf_sz = STMMAC_ALIGN(buf_sz); + priv->rx_copybreak = STMMAC_RX_COPYBREAK; ret = alloc_dma_desc_resources(priv); if (ret < 0) { @@ -2195,8 +2198,7 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv) struct sk_buff *skb; skb = netdev_alloc_skb_ip_align(priv->dev, bfsize); - - if (unlikely(skb == NULL)) + if (unlikely(!skb)) break; priv->rx_skbuff[entry] = skb; @@ -2319,23 +2321,52 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit) pr_debug("\tframe size %d, COE: %d\n", frame_len, status); } - skb = priv->rx_skbuff[entry]; - if (unlikely(!skb)) { - pr_err("%s: Inconsistent Rx descriptor chain\n", - priv->dev->name); - priv->dev->stats.rx_dropped++; - break; + + if (unlikely(frame_len < priv->rx_copybreak)) { + skb =
[PATCH (net-next.git) 14/18] stmmac: do not poll phy handler when attach a switch
This patch avoids to call the stmmac_adjust_link when the driver is connected to a switch by using the FIXED_PHY support. Prior this patch the phydev->irq was set as PHY_POLL so periodically the phy handler was invoked spending useless time because the link cannot actually change. Note that the stmmac_adjust_link will be called just one time and this guarantees that the ST glue logic will be setup according to the mode and speed fixed. Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 4a75f79..76ca54c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -881,6 +881,11 @@ static int stmmac_init_phy(struct net_device *dev) phy_disconnect(phydev); return -ENODEV; } + + /* If attached to a switch, there is no reason to poll phy handler */ + if (!strcmp(priv->plat->phy_bus_name, "fixed")) + phydev->irq = PHY_IGNORE_INTERRUPT; + pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)" " Link = %d\n", dev->name, phydev->phy_id, phydev->link); -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH (net-next.git) 11/18] stmmac: set dirty index out of the loop
The dirty index can be updated out of the loop where all the tx resources are claimed. This will help on performances too. Also a useless debug printk has been removed from the main loop. Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |5 + 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 230ded2..daa732f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1357,9 +1357,6 @@ static void stmmac_tx_clean(struct stmmac_priv *priv) } stmmac_get_tx_hwtstamp(priv, entry, skb); } - if (netif_msg_tx_done(priv)) - pr_debug("%s: curr %d, dirty %d\n", __func__, -priv->cur_tx, priv->dirty_tx); if (likely(priv->tx_skbuff_dma[entry].buf)) { if (priv->tx_skbuff_dma[entry].map_as_page) @@ -1390,8 +1387,8 @@ static void stmmac_tx_clean(struct stmmac_priv *priv) if (++entry >= txsize) entry = 0; - priv->dirty_tx = entry; } + priv->dirty_tx = entry; netdev_completed_queue(priv->dev, pkts_compl, bytes_compl); -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH (net-next.git) 03/18] stmmac: change descriptor layout
This patch completely changes the descriptor layout to improve the whole performances due to the single read usage of the descriptors in critical paths. Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/descs.h | 330 ++- drivers/net/ethernet/stmicro/stmmac/descs_com.h | 77 +++--- drivers/net/ethernet/stmicro/stmmac/enh_desc.c | 190 +++-- drivers/net/ethernet/stmicro/stmmac/norm_desc.c | 121 + 4 files changed, 355 insertions(+), 363 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/descs.h b/drivers/net/ethernet/stmicro/stmmac/descs.h index 799c292..2e4c171 100644 --- a/drivers/net/ethernet/stmicro/stmmac/descs.h +++ b/drivers/net/ethernet/stmicro/stmmac/descs.h @@ -1,6 +1,6 @@ /*** - Header File to describe the DMA descriptors. - Enhanced descriptors have been in case of DWMAC1000 Cores. + Header File to describe the DMA descriptors and related definitions. + This is for DWMAC100 and 1000 cores. This program is free software; you can redistribute it and/or modify it under the terms and conditions of the GNU General Public License, @@ -24,198 +24,164 @@ #ifndef __DESCS_H__ #define __DESCS_H__ +#include + +/* Normal receive descriptor defines */ + +/* RDES0 */ +#defineRDES0_PAYLOAD_CSUM_ERR BIT(0) +#defineRDES0_CRC_ERROR BIT(1) +#defineRDES0_DRIBBLING BIT(2) +#defineRDES0_MII_ERROR BIT(3) +#defineRDES0_RECEIVE_WATCHDOG BIT(4) +#defineRDES0_FRAME_TYPEBIT(5) +#defineRDES0_COLLISION BIT(6) +#defineRDES0_IPC_CSUM_ERRORBIT(7) +#defineRDES0_LAST_DESCRIPTOR BIT(8) +#defineRDES0_FIRST_DESCRIPTOR BIT(9) +#defineRDES0_VLAN_TAG BIT(10) +#defineRDES0_OVERFLOW_ERRORBIT(11) +#defineRDES0_LENGTH_ERROR BIT(12) +#defineRDES0_SA_FILTER_FAILBIT(13) +#defineRDES0_DESCRIPTOR_ERROR BIT(14) +#defineRDES0_ERROR_SUMMARY BIT(15) +#defineRDES0_FRAME_LEN_MASKGENMASK(29, 16) +#define RDES0_FRAME_LEN_SHIFT 16 +#defineRDES0_DA_FILTER_FAILBIT(30) +#defineRDES0_OWN BIT(31) + /* RDES1 */ +#defineRDES1_BUFFER1_SIZE_MASK GENMASK(10, 0) +#defineRDES1_BUFFER2_SIZE_MASK GENMASK(21, 11) +#defineRDES1_BUFFER2_SIZE_SHIFT11 +#defineRDES1_SECOND_ADDRESS_CHAINEDBIT(24) +#defineRDES1_END_RING BIT(25) +#defineRDES1_DISABLE_ICBIT(31) + +/* Enhanced receive descriptor defines */ + +/* RDES0 (similar to normal RDES) */ +#define ERDES0_RX_MAC_ADDR BIT(0) + +/* RDES1: completely differ from normal desc definitions */ +#defineERDES1_BUFFER1_SIZE_MASKGENMASK(12, 0) +#defineERDES1_SECOND_ADDRESS_CHAINED BIT(14) +#defineERDES1_END_RING BIT(15) +#defineERDES1_BUFFER2_SIZE_MASKGENMASK(28, 16) +#define ERDES1_BUFFER2_SIZE_SHIFT 16 +#defineERDES1_DISABLE_IC BIT(31) + +/* Normal transmit descriptor defines */ +/* TDES0 */ +#defineTDES0_DEFERRED BIT(0) +#defineTDES0_UNDERFLOW_ERROR BIT(1) +#defineTDES0_EXCESSIVE_DEFERRALBIT(2) +#defineTDES0_COLLISION_COUNT_MASK GENMASK(6, 3) +#defineTDES0_VLAN_FRAMEBIT(7) +#defineTDES0_EXCESSIVE_COLLISIONS BIT(8) +#defineTDES0_LATE_COLLISIONBIT(9) +#defineTDES0_NO_CARRIERBIT(10) +#defineTDES0_LOSS_CARRIER BIT(11) +#defineTDES0_PAYLOAD_ERROR BIT(12) +#defineTDES0_FRAME_FLUSHED BIT(13) +#defineTDES0_JABBER_TIMEOUTBIT(14) +#defineTDES0_ERROR_SUMMARY BIT(15) +#defineTDES0_IP_HEADER_ERROR BIT(16) +#defineTDES0_TIME_STAMP_STATUS BIT(17) +#defineTDES0_OWN BIT(31) +/* TDES1 */ +#defineTDES1_BUFFER1_SIZE_MASK GENMASK(10, 0) +#defineTDES1_BUFFER2_SIZE_MASK GENMASK(21, 11) +#defineTDES1_BUFFER2_SIZE_SHIFT11 +#defineTDES1_TIME_STAMP_ENABLE BIT(22) +#defineTDES1_DISABLE_PADDING BIT(23) +#defineTDES1_SECOND_ADDRESS_CHAINEDBIT(24) +#defineTDES1_END_RING BIT(25) +#defineTDES1_CRC_DISABLE BIT(26) +#defineTDES1_CHECKSUM_INSERTION_MASK GENMASK(28, 27) +#defineTDES1_CHECKSUM_INSERTION_SHIFT 27 +#defineTDES1_FIRST_SEGMENT BIT(29) +#defineTDES1_LAST_SEGMENT BIT(30) +#defineTDES1_INTERRUPT BIT(31) + +/* Enhanced transmit descriptor defines */ +/* TDES0 */ +#define
[PATCH (net-next.git) 13/18] stmmac: perf, remove modulo in stmmac_rx()
The indexes into the ring buffer are always incremented, and the entry is accessed via doing a modulo to find the "real" index. Modulo is an expensive operation. This patch replaces the modulo with a simple if clamp. It helps improve stmmac RX path as it's being called inside RX loop. Signed-off-by: Fabrice Gasnier Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 28 ++--- 1 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 5bb2804..4a75f79 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -212,6 +212,18 @@ static inline u32 stmmac_tx_avail(struct stmmac_priv *priv) return avail; } +static inline u32 stmmac_rx_dirty(struct stmmac_priv *priv) +{ + unsigned dirty; + + if (priv->dirty_rx <= priv->cur_rx) + dirty = priv->cur_rx - priv->dirty_rx; + else + dirty = priv->dma_rx_size - priv->dirty_rx + priv->cur_rx; + + return dirty; +} + /** * stmmac_hw_fix_mac_speed - callback for speed selection * @priv: driver private structure @@ -2162,9 +2174,10 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv) { unsigned int rxsize = priv->dma_rx_size; int bfsize = priv->dma_buf_sz; + unsigned int entry = priv->dirty_rx; + int dirty = stmmac_rx_dirty(priv); - for (; priv->cur_rx - priv->dirty_rx > 0; priv->dirty_rx++) { - unsigned int entry = priv->dirty_rx % rxsize; + while (dirty-- > 0) { struct dma_desc *p; if (priv->extend_desc) @@ -2200,6 +2213,10 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv) wmb(); priv->hw->desc->set_rx_owner(p); wmb(); + + if (unlikely(++priv->dirty_rx >= rxsize)) + priv->dirty_rx = 0; + entry = priv->dirty_rx; } } @@ -2213,7 +2230,7 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv) static int stmmac_rx(struct stmmac_priv *priv, int limit) { unsigned int rxsize = priv->dma_rx_size; - unsigned int entry = priv->cur_rx % rxsize; + unsigned int entry = priv->cur_rx; unsigned int next_entry; unsigned int count = 0; int coe = priv->hw->rx_csum; @@ -2243,7 +2260,10 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit) count++; - next_entry = (++priv->cur_rx) % rxsize; + if (unlikely(++priv->cur_rx >= rxsize)) + priv->cur_rx = 0; + next_entry = priv->cur_rx; + if (priv->extend_desc) prefetch(priv->dma_erx + next_entry); else -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH (net-next.git) 04/18] stmmac: remove modulo in stmmac_xmit()
The indexes into the ring buffer are always incremented, and the entry is accessed via doing a modulo to find the "real" index. I have changed this for 3 reasons: * It is inefficient, modulo is an expensive operation. * It is also broken when the counter wraps. * It makes my head hurt trying to cope with huge numbers This patch replaces the modulo with a simple if clamp. Signed-off-by: David McKay Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 15 ++ drivers/net/ethernet/stmicro/stmmac/ring_mode.c |7 +++- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 31 +++- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c index cf28dab..399a7ed 100644 --- a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c @@ -32,7 +32,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) { struct stmmac_priv *priv = (struct stmmac_priv *)p; unsigned int txsize = priv->dma_tx_size; - unsigned int entry = priv->cur_tx % txsize; + unsigned int entry = priv->cur_tx; struct dma_desc *desc = priv->dma_tx + entry; unsigned int nopaged_len = skb_headlen(skb); unsigned int bmax; @@ -54,7 +54,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) while (len != 0) { priv->tx_skbuff[entry] = NULL; - entry = (++priv->cur_tx) % txsize; + if (++entry >= txsize) + entry = 0; desc = priv->dma_tx + entry; if (len > bmax) { @@ -82,6 +83,9 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) len = 0; } } + + priv->cur_tx = entry; + return entry; } @@ -151,10 +155,9 @@ static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p) * 1588-2002 time stamping is enabled, hence reinitialize it * to keep explicit chaining in the descriptor. */ - p->des3 = (unsigned int)(priv->dma_tx_phy + -(((priv->dirty_tx + 1) % - priv->dma_tx_size) * - sizeof(struct dma_desc))); + p->des3 = (unsigned int)((priv->dma_tx_phy + + priv->dirty_tx + 1) * + sizeof(struct dma_desc)); } const struct stmmac_mode_ops chain_mode_ops = { diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c index 5dd50c6..2560855 100644 --- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c @@ -32,7 +32,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) { struct stmmac_priv *priv = (struct stmmac_priv *)p; unsigned int txsize = priv->dma_tx_size; - unsigned int entry = priv->cur_tx % txsize; + unsigned int entry = priv->cur_tx; struct dma_desc *desc; unsigned int nopaged_len = skb_headlen(skb); unsigned int bmax, len; @@ -62,7 +62,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) STMMAC_RING_MODE); wmb(); priv->tx_skbuff[entry] = NULL; - entry = (++priv->cur_tx) % txsize; + if (++entry >= txsize) + entry = 0; if (priv->extend_desc) desc = (struct dma_desc *)(priv->dma_etx + entry); @@ -90,6 +91,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) STMMAC_RING_MODE); } + priv->cur_tx = entry; + return entry; } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 89c2626..4c73c09 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -202,7 +202,14 @@ static void print_pkt(unsigned char *buf, int len) static inline u32 stmmac_tx_avail(struct stmmac_priv *priv) { - return priv->dirty_tx + priv->dma_tx_size - priv->cur_tx - 1; + unsigned avail; + + if (priv->dirty_tx > priv->cur_tx) + avail = priv->dirty_tx - priv->cur_tx - 1; + else + avail = priv->dma_tx_size - priv->cur_tx + priv->dirty_tx - 1; + + return avail; } /** @@ -1312,16 +1319,16 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv) */ static void stmmac_tx_clean(struct stmmac_priv *priv) { - unsigned int txsize = priv->dma_tx_size;
[PATCH (net-next.git) 06/18] stmmac: add last_segment field to dma data
last_segment field is read twice from dma descriptors in stmmac_clean(). Add last_segment to dma data so that this flag is from priv structure in cache instead of memory. It avoids reading twice from memory for each loop in stmmac_clean(). Signed-off-by: Fabrice Gasnier Signed-off-by: Giuseppe Cavallaro --- drivers/net/ethernet/stmicro/stmmac/chain_mode.c |3 ++- drivers/net/ethernet/stmicro/stmmac/stmmac.h |1 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |5 - 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c index 688795e..e985459 100644 --- a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c @@ -152,8 +152,9 @@ static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p) static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p) { struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr; + unsigned int entry = priv->dirty_tx; - if (priv->hw->desc->get_tx_ls(p) && !priv->extend_desc) + if (priv->tx_skbuff_dma[entry].last_segment && !priv->extend_desc) /* NOTE: Device will overwrite des3 with timestamp value if * 1588-2002 time stamping is enabled, hence reinitialize it * to keep explicit chaining in the descriptor. diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index 8517a04..f15c493 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -46,6 +46,7 @@ struct stmmac_tx_info { dma_addr_t buf; bool map_as_page; unsigned len; + bool last_segment; }; struct stmmac_priv { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 004e567..cb24779 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1108,6 +1108,7 @@ static int init_dma_desc_rings(struct net_device *dev, gfp_t flags) priv->tx_skbuff_dma[i].buf = 0; priv->tx_skbuff_dma[i].map_as_page = false; priv->tx_skbuff_dma[i].len = 0; + priv->tx_skbuff_dma[i].last_segment = false; priv->tx_skbuff[i] = NULL; } @@ -1343,7 +1344,7 @@ static void stmmac_tx_clean(struct stmmac_priv *priv) break; /* Verify tx error by looking at the last segment. */ - last = priv->hw->desc->get_tx_ls(p); + last = priv->tx_skbuff_dma[entry].last_segment; if (likely(last)) { int tx_error = priv->hw->desc->tx_status(&priv->dev->stats, @@ -1376,6 +1377,7 @@ static void stmmac_tx_clean(struct stmmac_priv *priv) priv->tx_skbuff_dma[entry].map_as_page = false; } priv->hw->mode->clean_desc3(priv, p); + priv->tx_skbuff_dma[entry].last_segment = false; if (likely(skb != NULL)) { pkts_compl++; @@ -2052,6 +2054,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) /* Finalize the latest segment. */ priv->hw->desc->close_tx_desc(desc); + priv->tx_skbuff_dma[entry].last_segment = true; wmb(); /* According to the coalesce parameter the IC bit for the latest -- 1.7.4.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
Dan Carpenter writes: > Please stop sending cleanup patches, Markus. Just send fixes. Thanks for your continued but unwarranted belief in AI. Do you mind if I remind you of https://lkml.org/lkml/2014/11/3/162 ? I am sure there are lots and lots of other examples. There is no reason to believe this will ever stop. He just goes into Eliza mode. Bjørn -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch v2] qlcnic: fix a timeout loop
Le 15/12/2015 14:56, Dan Carpenter a écrit : The problem here is that at the end of the loop we test for if idc->vnic_wait_limit is zero, but since idc->vnic_wait_limit-- is a post-op, it actually ends up set to (u8)-1. I have fixed this by moving the decrement inside the loop. Fixes: 486a5bc77a4a ('qlcnic: Add support for 83xx suspend and resume.') Signed-off-by: Dan Carpenter --- v2: different color on the bikeshed diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c index be7d7a6..b1a452f 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c @@ -246,7 +246,8 @@ int qlcnic_83xx_check_vnic_state(struct qlcnic_adapter *adapter) u32 state; state = QLCRDX(ahw, QLC_83XX_VNIC_STATE); - while (state != QLCNIC_DEV_NPAR_OPER && idc->vnic_wait_limit--) { + while (state != QLCNIC_DEV_NPAR_OPER && idc->vnic_wait_limit) { + idc->vnic_wait_limit--; msleep(1000); state = QLCRDX(ahw, QLC_83XX_VNIC_STATE); } -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Hi everybody, & Happy new year. We're seeing very sporadic & rare kernel oops due to qlcnic, even with latests kernels. I only have 1 trace, which can be seen here https://paste2.org/4m8EGEG1 Others kernel oops (not recorded) showed different stack trace, but in the end, problem was always in qlcnic_xmit_frame Any chance this bug is corrected by this very patch or is this a totally different problem ? Cheers, Yann. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
On Mon, Jan 04, 2016 at 02:17:40PM +0100, Bjørn Mork wrote: > Dan Carpenter writes: > > > Please stop sending cleanup patches, Markus. Just send fixes. > > Thanks for your continued but unwarranted belief in AI. > I always tell people that I am very mechanical and you can rely on me to send predictable responses... > Do you mind if I remind you of https://lkml.org/lkml/2014/11/3/162 ? > I am sure there are lots and lots of other examples. There is no reason > to believe this will ever stop. He just goes into Eliza mode. Yup. I feel some sense of responsibility for any patches where kernel-janitors is on the CC but I'm having a hard time dealing with all of Markus's patches. Normally you just respond to the first patch and people change the later patches but, as you put it, Markus just goes into ELIZA mode. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] mac802154: constify ieee802154_llsec_ops structure
Hi, On Wed, Dec 23, 2015 at 10:36:32PM +0100, Julia Lawall wrote: > The ieee802154_llsec_ops structure is never modified, so declare it as > const. > > Done with the help of Coccinelle. > > Signed-off-by: Julia Lawall > Acked-by: Alexander Aring Marcel, can you please apply this on bluetooth-next? Thank you. - Alex -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram
On Mon, 2016-01-04 at 10:10 +0100, Jacob Siverskog wrote: > On Wed, Dec 30, 2015 at 11:30 PM, Cong Wang wrote: > > On Wed, Dec 30, 2015 at 6:30 AM, Jacob Siverskog > > wrote: > >> On Wed, Dec 30, 2015 at 2:26 PM, Eric Dumazet wrote: > >>> How often can you trigger this bug ? > >> > >> Ok. I don't have a good repro to trigger it unfortunately, I've seen it > >> just a > >> few times when bringing up/down network interfaces. Does the trace > >> give any clue? > >> > > > > A little bit. You need to help people to narrow down the problem > > because there are too many places using skb->next and skb->prev. > > > > Since you mentioned it seems related to network interface flip, > > what network interfaces are you using? What's is your TC setup? > > > > Thanks. > > The system contains only one physical network interface (TI WL1837, > wl18xx module). > The state prior to the crash was as follows: > - One virtual network interface active (as STA, associated with access point) > - Bluetooth (BLE only) active (same physical chip, co-existence, > btwilink/st_drv modules) > > Actions made around the time of the crash: > - Bluetooth disabled > - One additional virtual network interface brought up (also as STA) > > I believe the crash occurred between these two actions. I just saw > that there are some interesting events in the log prior to the crash: > kernel: Bluetooth: Unable to push skb to HCI core(-6) > kernel: (stc): proto stack 4's ->recv failed > kernel: (stc): remove_channel_from_table: id 3 > kernel: (stc): remove_channel_from_table: id 2 > kernel: (stc): remove_channel_from_table: id 4 > kernel: (stc): all chnl_ids unregistered > kernel: (stk) :ldisc_install = 0(stc): st_tty_close > > The first print is from btwilink.c. However, I can't see the > connection between Bluetooth (BLE) and UDP/IPv6 (we're not using > 6LoWPAN or anything similar). > > Thanks, Jacob Definitely these details are useful ;) Could you try : diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c index 6e3af8b42cdd..0c99a74fb895 100644 --- a/drivers/misc/ti-st/st_core.c +++ b/drivers/misc/ti-st/st_core.c @@ -912,7 +912,9 @@ void st_core_exit(struct st_data_s *st_gdata) skb_queue_purge(&st_gdata->txq); skb_queue_purge(&st_gdata->tx_waitq); kfree_skb(st_gdata->rx_skb); + st_gdata->rx_skb = NULL; kfree_skb(st_gdata->tx_skb); + st_gdata->tx_skb = NULL; /* TTY ldisc cleanup */ err = tty_unregister_ldisc(N_TI_WL); if (err) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 02/12] net: sched: free per cpu bstats
On 12/30/2015 06:51 PM, John Fastabend wrote: When a qdisc is using per cpu stats only the bstats are being freed. This also free's the qstats. Signed-off-by: John Fastabend Seems like a bug fix, current code seems to free this only in error path in qdisc_create(). Should this go to -net as an individual one? Thanks, Daniel -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: commit e34d65696d2e broke stmmac ethernet on socfpga
On 01/01/2016 02:49 AM, Romain Perier wrote: > Hi all, > > Same here on rockchip. > See "[PATCH] stmmac: Don't exit mdio registration when mdio subnode is > not found in the DTS" > > Regards, > Romain > > 2015-12-18 18:45 GMT+01:00 Dinh Nguyen : >> Hi, >> >> It appears that commit e34d65696d2e 'stmmac: create of compatible mdio >> bus for >> stmmac driver' is causing this error on the SoCFPGA platform: >> >> [1.767246] libphy: PHY stmmac-0: not found >> [1.772106] eth0: Could not attach to PHY >> [1.776129] stmmac_open: Cannot attach to PHY (error: -19) >> [1.781590] IP-Config: Failed to open eth0 >> [1.785681] IP-Config: No network devices available >> >> Doing a revert of this commit fixes the issue. Will try to debug further. >> There error is here: [0.663275] socfpga-dwmac ff702000.ethernet eth0: NO MDIO subnode It appears that his commit requires an update to DTS files, which will subsequently break legacy DTS. Also, this commit is only in linux-next. Dinh -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-next 1/3] nfp: free buffers before changing MTU
For freeing DMA buffers we depend on nfp_net.fl_bufsz having the same value as during allocation therefore in .ndo_change_mtu we must first free the buffers and then change the setting. Signed-off-by: Jakub Kicinski Reviewed-by: Rolf Neugebauer --- drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 43c618bafdb6..2826166547fd 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -1920,17 +1920,17 @@ static int nfp_net_change_mtu(struct net_device *netdev, int new_mtu) return -EINVAL; } + if (netif_running(netdev)) + nfp_net_netdev_close(netdev); + netdev->mtu = new_mtu; /* Freelist buffer size rounded up to the nearest 1K */ tmp = new_mtu + ETH_HLEN + VLAN_HLEN + NFP_NET_MAX_PREPEND; nn->fl_bufsz = roundup(tmp, 1024); - /* restart if running */ - if (netif_running(netdev)) { - nfp_net_netdev_close(netdev); + if (netif_running(netdev)) nfp_net_netdev_open(netdev); - } return 0; } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-next 0/3] nfp: MTU changes and other fixes
Hi! Three small fixes around RX buffer sizing. First one corrects the length used for unmapping DMA buffers when MTU is changed, second makes sure buffers are big enough to meet FW's expectations. Third change corrects packet length validation on RX. Jakub Kicinski (3): nfp: free buffers before changing MTU nfp: correct RX buffer length calculation nfp: fix RX buffer length validation .../net/ethernet/netronome/nfp/nfp_net_common.c| 37 +- 1 file changed, 15 insertions(+), 22 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-next 3/3] nfp: fix RX buffer length validation
Meaning of data_len and meta_len RX WB descriptor fields depend slightly on whether rx_offset is dynamic or not. For dynamic offsets data_len includes mata_len. This makes the code harder to follow, in fact our RX buffer length check is incorrect - we are comparing allocation length to data_len while we should also account for meta_len. Let's adjust the values of data_len and meta_len to their natural meaning and simplify the logic. Signed-off-by: Jakub Kicinski Reviewed-by: Rolf Neugebauer --- drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 19 --- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index bfc522474820..ee4b99373e33 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -1259,22 +1259,19 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget) meta_len = rxd->rxd.meta_len_dd & PCIE_DESC_RX_META_LEN_MASK; data_len = le16_to_cpu(rxd->rxd.data_len); + /* For dynamic offset data_len includes meta_len, adjust */ + if (nn->rx_offset == NFP_NET_CFG_RX_OFFSET_DYNAMIC) + data_len -= meta_len; + else + meta_len = nn->rx_offset; - if (WARN_ON_ONCE(data_len > nn->fl_bufsz)) { + if (WARN_ON_ONCE(meta_len + data_len > nn->fl_bufsz)) { dev_kfree_skb_any(skb); continue; } - if (nn->rx_offset == NFP_NET_CFG_RX_OFFSET_DYNAMIC) { - /* The packet data starts after the metadata */ - skb_reserve(skb, meta_len); - } else { - /* The packet data starts at a fixed offset */ - skb_reserve(skb, nn->rx_offset); - } - - /* Adjust the SKB for the dynamic meta data pre-pended */ - skb_put(skb, data_len - meta_len); + skb_reserve(skb, meta_len); + skb_put(skb, data_len); nfp_net_set_hash(nn->netdev, skb, rxd); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH net-next 2/3] nfp: correct RX buffer length calculation
When calculating the RX buffer length we need to account for up to 2 VLAN tags and up to 8 MPLS labels. Rounding up to 1k is an relic of a distant past and can be removed. While at it also remove trivial print statement. Signed-off-by: Jakub Kicinski Reviewed-by: Rolf Neugebauer --- drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 2826166547fd..bfc522474820 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -61,6 +61,7 @@ #include +#include #include #include "nfp_net_ctrl.h" @@ -1911,9 +1912,6 @@ static void nfp_net_set_rx_mode(struct net_device *netdev) static int nfp_net_change_mtu(struct net_device *netdev, int new_mtu) { struct nfp_net *nn = netdev_priv(netdev); - u32 tmp; - - nn_dbg(nn, "New MTU = %d\n", new_mtu); if (new_mtu < 68 || new_mtu > nn->max_mtu) { nn_err(nn, "New MTU (%d) is not valid\n", new_mtu); @@ -1924,10 +1922,8 @@ static int nfp_net_change_mtu(struct net_device *netdev, int new_mtu) nfp_net_netdev_close(netdev); netdev->mtu = new_mtu; - - /* Freelist buffer size rounded up to the nearest 1K */ - tmp = new_mtu + ETH_HLEN + VLAN_HLEN + NFP_NET_MAX_PREPEND; - nn->fl_bufsz = roundup(tmp, 1024); + nn->fl_bufsz = NFP_NET_MAX_PREPEND + ETH_HLEN + VLAN_HLEN * 2 + + MPLS_HLEN * 8 + new_mtu; if (netif_running(netdev)) nfp_net_netdev_open(netdev); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram
Eric Dumazet writes: > On Mon, 2016-01-04 at 10:10 +0100, Jacob Siverskog wrote: [...] >> I believe the crash occurred between these two actions. I just saw >> that there are some interesting events in the log prior to the crash: >> kernel: Bluetooth: Unable to push skb to HCI core(-6) >> kernel: (stc): proto stack 4's ->recv failed >> kernel: (stc): remove_channel_from_table: id 3 >> kernel: (stc): remove_channel_from_table: id 2 >> kernel: (stc): remove_channel_from_table: id 4 >> kernel: (stc): all chnl_ids unregistered >> kernel: (stk) :ldisc_install = 0(stc): st_tty_close >> >> The first print is from btwilink.c. However, I can't see the >> connection between Bluetooth (BLE) and UDP/IPv6 (we're not using >> 6LoWPAN or anything similar). >> >> Thanks, Jacob > > Definitely these details are useful ;) > > Could you try : > > diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c > index 6e3af8b42cdd..0c99a74fb895 100644 > --- a/drivers/misc/ti-st/st_core.c > +++ b/drivers/misc/ti-st/st_core.c > @@ -912,7 +912,9 @@ void st_core_exit(struct st_data_s *st_gdata) > skb_queue_purge(&st_gdata->txq); > skb_queue_purge(&st_gdata->tx_waitq); > kfree_skb(st_gdata->rx_skb); > + st_gdata->rx_skb = NULL; > kfree_skb(st_gdata->tx_skb); > + st_gdata->tx_skb = NULL; > /* TTY ldisc cleanup */ > err = tty_unregister_ldisc(N_TI_WL); > if (err) Hmm ... the code continues with err = tty_unregister_ldisc(N_TI_WL); if (err) pr_err("unable to un-register ldisc %ld", err); /* free the global data pointer */ kfree(st_gdata); So who would ever see that the rx_skb and tx_skb pointers were cleared prior to freeing the data structure containing them? -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 net-next 3/4] soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF
On Tue, Dec 29, 2015 at 6:50 PM, Alexei Starovoitov wrote: > On Tue, Dec 29, 2015 at 12:29:09PM -0500, Craig Gallek wrote: >> From: Craig Gallek >> +static struct sock *run_bpf(struct sock_reuseport *reuse, u16 socks, >> + struct bpf_prog *prog, struct sk_buff *skb, >> + int hdr_len) >> +{ >> + struct sk_buff *nskb = NULL; >> + u32 index; >> + >> + if (skb_shared(skb)) { >> + nskb = skb_clone(skb, GFP_ATOMIC); >> + if (!nskb) >> + return NULL; >> + skb = nskb; >> + } >> + >> + /* temporarily advance data past protocol header */ >> + if (!pskb_may_pull(skb, hdr_len) || !skb_pull_inline(skb, hdr_len)) { > > pskb_pull() would be cleaner. ACK -> v3 >> + consume_skb(nskb); >> + return NULL; >> + } >> + index = bpf_prog_run_save_cb(prog, skb); >> + __skb_push(skb, hdr_len); > > This indeed matches what normal bpf filters see with udp sockets, so > I guess that's fine. > Acked-by: Alexei Starovoitov Thanks for the review! -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 net-next 3/4] soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF
On Sat, Jan 2, 2016 at 4:28 PM, Daniel Borkmann wrote: > On 12/29/2015 06:29 PM, Craig Gallek wrote: >> >> From: Craig Gallek >> >> Expose socket options for setting a classic or extended BPF program >> for use when selecting sockets in an SO_REUSEPORT group. These options >> can be used on the first socket to belong to a group before bind or >> on any socket in the group after bind. >> >> This change includes refactoring of the existing sk_filter code to >> allow reuse of the existing BPF filter validation checks. >> >> Signed-off-by: Craig Gallek > > [...] >> >> diff --git a/include/linux/filter.h b/include/linux/filter.h >> index 4165e9a..3561d3a 100644 >> --- a/include/linux/filter.h >> +++ b/include/linux/filter.h >> @@ -447,6 +447,8 @@ void bpf_prog_destroy(struct bpf_prog *fp); >> >> int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk); >> int sk_attach_bpf(u32 ufd, struct sock *sk); >> +int reuseport_attach_filter(struct sock_fprog *fprog, struct sock *sk); >> +int reuseport_attach_bpf(u32 ufd, struct sock *sk); > > > Maybe for consistency this should be sk_* prefixed as well due to its > relation to sockets?) ACK -> v3 > You currently don't charge the BPF program against the optmem limits, but > just > test if the size of a given program would surpass the current > sysctl_optmem_max. > Ok, after all, this would block anything beyond 2560 insns by default. Is > there > a reason it's not charged for real? Due to the sysctl_optmem_max default > being > too small? > > Btw, in case of an eBPF fd, we already charged it to the user's > RLIMIT_MEMLOCK, > not sure if blocking it here after program already got an fd makes much > sense. > I'm fine if you want to leave it for now and refine this later, though. I considered a couple options, but I wasn't able to come up with a straight forward policy. Which socket should the filter memory be charged to? If it's only one of them, you run the risk of under accounting when that socket leaves the group. If you charge all of them you end up over-accounting and introduce all kinds of partial failure paths. Another alternative would be to mirror one of the sk memory properties (omem?) in the sock_reuseport structure. That is, have an accounting variable similar to sk_omem_alloc (with a max of sysctl_optmem_max) which is changed each time the reuseport bpf program is manipulated. I'd definitely be interested in ideas for a follow-on patch if you have any. > Nit: return bpf_prepare_filter(prog, NULL); ACK -> v3 > Rest of BPF bits look good to me. Thank you! -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 net-next 0/4] Faster SO_REUSEPORT
From: Craig Gallek This series contains two optimizations for the SO_REUSEPORT feature: Faster lookup when selecting a socket for an incoming packet and the ability to select the socket from the group using a BPF program. This series only includes the UDP path. I plan to submit a follow-up including the TCP path if the implementation in this series is acceptable. Changes in v3: - skb_pull_inline -> pskb_pull (per Alexei Starovoitov) - reuseport_attach* -> sk_reuseport_attach* and simple return statement syntax change (per Daniel Borkmann) Changes in v2: - Fix ARM build; remove unnecessary include. - Handle case where protocol header is not in linear section (per Alexei Starovoitov). Craig Gallek (4): soreuseport: define reuseport groups soreuseport: fast reuseport UDP socket selection soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF soreuseport: BPF selection functional test arch/alpha/include/uapi/asm/socket.h| 3 + arch/avr32/include/uapi/asm/socket.h| 3 + arch/frv/include/uapi/asm/socket.h | 3 + arch/ia64/include/uapi/asm/socket.h | 3 + arch/m32r/include/uapi/asm/socket.h | 3 + arch/mips/include/uapi/asm/socket.h | 3 + arch/mn10300/include/uapi/asm/socket.h | 3 + arch/parisc/include/uapi/asm/socket.h | 3 + arch/powerpc/include/uapi/asm/socket.h | 3 + arch/s390/include/uapi/asm/socket.h | 3 + arch/sparc/include/uapi/asm/socket.h| 3 + arch/xtensa/include/uapi/asm/socket.h | 3 + include/linux/filter.h | 2 + include/net/addrconf.h | 3 +- include/net/sock.h | 2 + include/net/sock_reuseport.h| 28 ++ include/net/udp.h | 7 +- include/uapi/asm-generic/socket.h | 3 + net/core/Makefile | 2 +- net/core/filter.c | 121 +-- net/core/sock.c | 29 ++ net/core/sock_reuseport.c | 251 +++ net/ipv4/udp.c | 127 ++-- net/ipv4/udp_diag.c | 4 +- net/ipv6/inet6_connection_sock.c| 4 +- net/ipv6/udp.c | 56 +++- tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile| 2 +- tools/testing/selftests/net/reuseport_bpf.c | 467 29 files changed, 1076 insertions(+), 69 deletions(-) create mode 100644 include/net/sock_reuseport.h create mode 100644 net/core/sock_reuseport.c create mode 100644 tools/testing/selftests/net/reuseport_bpf.c -- 2.6.0.rc2.230.g3dd15c0 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 net-next 1/4] soreuseport: define reuseport groups
From: Craig Gallek struct sock_reuseport is an optional shared structure referenced by each socket belonging to a reuseport group. When a socket is bound to an address/port not yet in use and the reuseport flag has been set, the structure will be allocated and attached to the newly bound socket. When subsequent calls to bind are made for the same address/port, the shared structure will be updated to include the new socket and the newly bound socket will reference the group structure. Usually, when an incoming packet was destined for a reuseport group, all sockets in the same group needed to be considered before a dispatching decision was made. With this structure, an appropriate socket can be found after looking up just one socket in the group. This shared structure will also allow for more complicated decisions to be made when selecting a socket (eg a BPF filter). This work is based off a similar implementation written by Ying Cai for implementing policy-based reuseport selection. Signed-off-by: Craig Gallek --- include/net/sock.h | 2 + include/net/sock_reuseport.h | 20 + net/core/Makefile| 2 +- net/core/sock_reuseport.c| 173 +++ 4 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 include/net/sock_reuseport.h create mode 100644 net/core/sock_reuseport.c diff --git a/include/net/sock.h b/include/net/sock.h index 3794cdd..e830c10 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -318,6 +318,7 @@ struct cg_proto; *@sk_error_report: callback to indicate errors (e.g. %MSG_ERRQUEUE) *@sk_backlog_rcv: callback to process the backlog *@sk_destruct: called at sock freeing time, i.e. when all refcnt == 0 + *@sk_reuseport_cb: reuseport group container */ struct sock { /* @@ -453,6 +454,7 @@ struct sock { int (*sk_backlog_rcv)(struct sock *sk, struct sk_buff *skb); void(*sk_destruct)(struct sock *sk); + struct sock_reuseport __rcu *sk_reuseport_cb; }; #define __sk_user_data(sk) ((*((void __rcu **)&(sk)->sk_user_data))) diff --git a/include/net/sock_reuseport.h b/include/net/sock_reuseport.h new file mode 100644 index 000..67d1eb8 --- /dev/null +++ b/include/net/sock_reuseport.h @@ -0,0 +1,20 @@ +#ifndef _SOCK_REUSEPORT_H +#define _SOCK_REUSEPORT_H + +#include +#include + +struct sock_reuseport { + struct rcu_head rcu; + + u16 max_socks; /* length of socks */ + u16 num_socks; /* elements in socks */ + struct sock *socks[0]; /* array of sock pointers */ +}; + +extern int reuseport_alloc(struct sock *sk); +extern int reuseport_add_sock(struct sock *sk, const struct sock *sk2); +extern void reuseport_detach_sock(struct sock *sk); +extern struct sock *reuseport_select_sock(struct sock *sk, u32 hash); + +#endif /* _SOCK_REUSEPORT_H */ diff --git a/net/core/Makefile b/net/core/Makefile index 086b01f..0b835de 100644 --- a/net/core/Makefile +++ b/net/core/Makefile @@ -9,7 +9,7 @@ obj-$(CONFIG_SYSCTL) += sysctl_net_core.o obj-y += dev.o ethtool.o dev_addr_lists.o dst.o netevent.o \ neighbour.o rtnetlink.o utils.o link_watch.o filter.o \ - sock_diag.o dev_ioctl.o tso.o + sock_diag.o dev_ioctl.o tso.o sock_reuseport.o obj-$(CONFIG_XFRM) += flow.o obj-y += net-sysfs.o diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c new file mode 100644 index 000..963c8d5 --- /dev/null +++ b/net/core/sock_reuseport.c @@ -0,0 +1,173 @@ +/* + * To speed up listener socket lookup, create an array to store all sockets + * listening on the same port. This allows a decision to be made after finding + * the first socket. + */ + +#include +#include + +#define INIT_SOCKS 128 + +static DEFINE_SPINLOCK(reuseport_lock); + +static struct sock_reuseport *__reuseport_alloc(u16 max_socks) +{ + size_t size = sizeof(struct sock_reuseport) + + sizeof(struct sock *) * max_socks; + struct sock_reuseport *reuse = kzalloc(size, GFP_ATOMIC); + + if (!reuse) + return NULL; + + reuse->max_socks = max_socks; + + return reuse; +} + +int reuseport_alloc(struct sock *sk) +{ + struct sock_reuseport *reuse; + + /* bh lock used since this function call may precede hlist lock in +* soft irq of receive path or setsockopt from process context +*/ + spin_lock_bh(&reuseport_lock); + WARN_ONCE(rcu_dereference_protected(sk->sk_reuseport_cb, + lockdep_is_held(&reuseport_lock)), + "multiple allocations for the same socket"); + reuse = __reuseport_alloc(INIT_SOCKS); + if (!reuse) { + spin_unlock_bh(&reuseport_lock);
[PATCH v3 net-next 3/4] soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF
From: Craig Gallek Expose socket options for setting a classic or extended BPF program for use when selecting sockets in an SO_REUSEPORT group. These options can be used on the first socket to belong to a group before bind or on any socket in the group after bind. This change includes refactoring of the existing sk_filter code to allow reuse of the existing BPF filter validation checks. Signed-off-by: Craig Gallek --- arch/alpha/include/uapi/asm/socket.h | 3 + arch/avr32/include/uapi/asm/socket.h | 3 + arch/frv/include/uapi/asm/socket.h | 3 + arch/ia64/include/uapi/asm/socket.h| 3 + arch/m32r/include/uapi/asm/socket.h| 3 + arch/mips/include/uapi/asm/socket.h| 3 + arch/mn10300/include/uapi/asm/socket.h | 3 + arch/parisc/include/uapi/asm/socket.h | 3 + arch/powerpc/include/uapi/asm/socket.h | 3 + arch/s390/include/uapi/asm/socket.h| 3 + arch/sparc/include/uapi/asm/socket.h | 3 + arch/xtensa/include/uapi/asm/socket.h | 3 + include/linux/filter.h | 2 + include/net/sock_reuseport.h | 10 ++- include/net/udp.h | 5 +- include/uapi/asm-generic/socket.h | 3 + net/core/filter.c | 121 +++-- net/core/sock.c| 29 net/core/sock_reuseport.c | 88 ++-- net/ipv4/udp.c | 14 ++-- net/ipv4/udp_diag.c| 4 +- net/ipv6/udp.c | 14 ++-- 22 files changed, 282 insertions(+), 44 deletions(-) diff --git a/arch/alpha/include/uapi/asm/socket.h b/arch/alpha/include/uapi/asm/socket.h index 9a20821..c5fb9e6 100644 --- a/arch/alpha/include/uapi/asm/socket.h +++ b/arch/alpha/include/uapi/asm/socket.h @@ -92,4 +92,7 @@ #define SO_ATTACH_BPF 50 #define SO_DETACH_BPF SO_DETACH_FILTER +#define SO_ATTACH_REUSEPORT_CBPF 51 +#define SO_ATTACH_REUSEPORT_EBPF 52 + #endif /* _UAPI_ASM_SOCKET_H */ diff --git a/arch/avr32/include/uapi/asm/socket.h b/arch/avr32/include/uapi/asm/socket.h index 2b65ed6..9de0796 100644 --- a/arch/avr32/include/uapi/asm/socket.h +++ b/arch/avr32/include/uapi/asm/socket.h @@ -85,4 +85,7 @@ #define SO_ATTACH_BPF 50 #define SO_DETACH_BPF SO_DETACH_FILTER +#define SO_ATTACH_REUSEPORT_CBPF 51 +#define SO_ATTACH_REUSEPORT_EBPF 52 + #endif /* _UAPI__ASM_AVR32_SOCKET_H */ diff --git a/arch/frv/include/uapi/asm/socket.h b/arch/frv/include/uapi/asm/socket.h index 4823ad1..f02e484 100644 --- a/arch/frv/include/uapi/asm/socket.h +++ b/arch/frv/include/uapi/asm/socket.h @@ -85,5 +85,8 @@ #define SO_ATTACH_BPF 50 #define SO_DETACH_BPF SO_DETACH_FILTER +#define SO_ATTACH_REUSEPORT_CBPF 51 +#define SO_ATTACH_REUSEPORT_EBPF 52 + #endif /* _ASM_SOCKET_H */ diff --git a/arch/ia64/include/uapi/asm/socket.h b/arch/ia64/include/uapi/asm/socket.h index 59be3d8..bce2916 100644 --- a/arch/ia64/include/uapi/asm/socket.h +++ b/arch/ia64/include/uapi/asm/socket.h @@ -94,4 +94,7 @@ #define SO_ATTACH_BPF 50 #define SO_DETACH_BPF SO_DETACH_FILTER +#define SO_ATTACH_REUSEPORT_CBPF 51 +#define SO_ATTACH_REUSEPORT_EBPF 52 + #endif /* _ASM_IA64_SOCKET_H */ diff --git a/arch/m32r/include/uapi/asm/socket.h b/arch/m32r/include/uapi/asm/socket.h index 7bc4cb2..14aa4a6 100644 --- a/arch/m32r/include/uapi/asm/socket.h +++ b/arch/m32r/include/uapi/asm/socket.h @@ -85,4 +85,7 @@ #define SO_ATTACH_BPF 50 #define SO_DETACH_BPF SO_DETACH_FILTER +#define SO_ATTACH_REUSEPORT_CBPF 51 +#define SO_ATTACH_REUSEPORT_EBPF 52 + #endif /* _ASM_M32R_SOCKET_H */ diff --git a/arch/mips/include/uapi/asm/socket.h b/arch/mips/include/uapi/asm/socket.h index dec3c85..5910fe2 100644 --- a/arch/mips/include/uapi/asm/socket.h +++ b/arch/mips/include/uapi/asm/socket.h @@ -103,4 +103,7 @@ #define SO_ATTACH_BPF 50 #define SO_DETACH_BPF SO_DETACH_FILTER +#define SO_ATTACH_REUSEPORT_CBPF 51 +#define SO_ATTACH_REUSEPORT_EBPF 52 + #endif /* _UAPI_ASM_SOCKET_H */ diff --git a/arch/mn10300/include/uapi/asm/socket.h b/arch/mn10300/include/uapi/asm/socket.h index cab7d6d..58b1aa0 100644 --- a/arch/mn10300/include/uapi/asm/socket.h +++ b/arch/mn10300/include/uapi/asm/socket.h @@ -85,4 +85,7 @@ #define SO_ATTACH_BPF 50 #define SO_DETACH_BPF SO_DETACH_FILTER +#define SO_ATTACH_REUSEPORT_CBPF 51 +#define SO_ATTACH_REUSEPORT_EBPF 52 + #endif /* _ASM_SOCKET_H */ diff --git a/arch/parisc/include/uapi/asm/socket.h b/arch/parisc/include/uapi/asm/socket.h index a5cd40c..f9cf122 100644 --- a/arch/parisc/include/uapi/asm/socket.h +++ b/arch/parisc/include/uapi/asm/socket.h @@ -84,4 +84,7 @@ #define SO_ATTACH_BPF 0x402B #define SO_DETACH_BPF SO_DETACH_FILTER +#define SO_ATTACH_REUSEPORT_CBPF 0x402C +#define SO_ATTAC
[PATCH v3 net-next 4/4] soreuseport: BPF selection functional test
From: Craig Gallek This program will build classic and extended BPF programs and validate the socket selection logic when used with SO_ATTACH_REUSEPORT_CBPF and SO_ATTACH_REUSEPORT_EBPF. It also validates the re-programing flow and several edge cases. Signed-off-by: Craig Gallek --- tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile| 2 +- tools/testing/selftests/net/reuseport_bpf.c | 467 3 files changed, 469 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/net/reuseport_bpf.c diff --git a/tools/testing/selftests/net/.gitignore b/tools/testing/selftests/net/.gitignore index 0032662..6fb2336 100644 --- a/tools/testing/selftests/net/.gitignore +++ b/tools/testing/selftests/net/.gitignore @@ -1,3 +1,4 @@ socket psock_fanout psock_tpacket +reuseport_bpf diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index fac4782..41449b5 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -4,7 +4,7 @@ CFLAGS = -Wall -O2 -g CFLAGS += -I../../../../usr/include/ -NET_PROGS = socket psock_fanout psock_tpacket +NET_PROGS = socket psock_fanout psock_tpacket reuseport_bpf all: $(NET_PROGS) %: %.c diff --git a/tools/testing/selftests/net/reuseport_bpf.c b/tools/testing/selftests/net/reuseport_bpf.c new file mode 100644 index 000..74ff099 --- /dev/null +++ b/tools/testing/selftests/net/reuseport_bpf.c @@ -0,0 +1,467 @@ +/* + * Test functionality of BPF filters for SO_REUSEPORT. The tests below will use + * a BPF program (both classic and extended) to read the first word from an + * incoming packet (expected to be in network byte-order), calculate a modulus + * of that number, and then dispatch the packet to the Nth socket using the + * result. These tests are run for each supported address family and protocol. + * Additionally, a few edge cases in the implementation are tested. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +#endif + +struct test_params { + int recv_family; + int send_family; + int protocol; + size_t recv_socks; + uint16_t recv_port; + uint16_t send_port_min; +}; + +static size_t sockaddr_size(void) +{ + return sizeof(struct sockaddr_storage); +} + +static struct sockaddr *new_any_sockaddr(int family, uint16_t port) +{ + struct sockaddr_storage *addr; + struct sockaddr_in *addr4; + struct sockaddr_in6 *addr6; + + addr = malloc(sizeof(struct sockaddr_storage)); + memset(addr, 0, sizeof(struct sockaddr_storage)); + + switch (family) { + case AF_INET: + addr4 = (struct sockaddr_in *)addr; + addr4->sin_family = AF_INET; + addr4->sin_addr.s_addr = htonl(INADDR_ANY); + addr4->sin_port = htons(port); + break; + case AF_INET6: + addr6 = (struct sockaddr_in6 *)addr; + addr6->sin6_family = AF_INET6; + addr6->sin6_addr = in6addr_any; + addr6->sin6_port = htons(port); + break; + default: + error(1, 0, "Unsupported family %d", family); + } + return (struct sockaddr *)addr; +} + +static struct sockaddr *new_loopback_sockaddr(int family, uint16_t port) +{ + struct sockaddr *addr = new_any_sockaddr(family, port); + struct sockaddr_in *addr4; + struct sockaddr_in6 *addr6; + + switch (family) { + case AF_INET: + addr4 = (struct sockaddr_in *)addr; + addr4->sin_addr.s_addr = htonl(INADDR_LOOPBACK); + break; + case AF_INET6: + addr6 = (struct sockaddr_in6 *)addr; + addr6->sin6_addr = in6addr_loopback; + break; + default: + error(1, 0, "Unsupported family %d", family); + } + return addr; +} + +static void attach_ebpf(int fd, uint16_t mod) +{ + static char bpf_log_buf[65536]; + static const char bpf_license[] = "GPL"; + + int bpf_fd; + const struct bpf_insn prog[] = { + /* BPF_MOV64_REG(BPF_REG_6, BPF_REG_1) */ + { BPF_ALU64 | BPF_MOV | BPF_X, BPF_REG_6, BPF_REG_1, 0, 0 }, + /* BPF_LD_ABS(BPF_W, 0) R0 = (uint32_t)skb[0] */ + { BPF_LD | BPF_ABS | BPF_W, 0, 0, 0, 0 }, + /* BPF_ALU64_IMM(BPF_MOD, BPF_REG_0, mod) */ + { BPF_ALU64 | BPF_MOD | BPF_K, BPF_REG_0, 0, 0, mod }, + /* BPF_EXIT_INSN() */ + { BPF_JMP | BPF_EXIT, 0, 0, 0, 0 } + }; + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.prog_type = BPF_PROG_TYPE_SOCKET_FILTER; + attr.insn_cnt = ARRAY_SIZE(prog); +
[PATCH v3 net-next 2/4] soreuseport: fast reuseport UDP socket selection
From: Craig Gallek Include a struct sock_reuseport instance when a UDP socket binds to a specific address for the first time with the reuseport flag set. When selecting a socket for an incoming UDP packet, use the information available in sock_reuseport if present. This required adding an additional field to the UDP source address equality function to differentiate between exact and wildcard matches. The original use case allowed wildcard matches when checking for existing port uses during bind. The new use case of adding a socket to a reuseport group requires exact address matching. Performance test (using a machine with 2 CPU sockets and a total of 48 cores): Create reuseport groups of varying size. Use one socket from this group per user thread (pinning each thread to a different core) calling recvmmsg in a tight loop. Record number of messages received per second while saturating a 10G link. 10 sockets: 18% increase (~2.8M -> 3.3M pkts/s) 20 sockets: 14% increase (~2.9M -> 3.3M pkts/s) 40 sockets: 13% increase (~3.0M -> 3.4M pkts/s) This work is based off a similar implementation written by Ying Cai for implementing policy-based reuseport selection. Signed-off-by: Craig Gallek --- include/net/addrconf.h | 3 +- include/net/udp.h| 2 +- net/ipv4/udp.c | 119 +++ net/ipv6/inet6_connection_sock.c | 4 +- net/ipv6/udp.c | 48 +--- 5 files changed, 141 insertions(+), 35 deletions(-) diff --git a/include/net/addrconf.h b/include/net/addrconf.h index 78003df..47f52d3 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h @@ -87,7 +87,8 @@ int __ipv6_get_lladdr(struct inet6_dev *idev, struct in6_addr *addr, u32 banned_flags); int ipv6_get_lladdr(struct net_device *dev, struct in6_addr *addr, u32 banned_flags); -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2); +int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2, +bool match_wildcard); void addrconf_join_solict(struct net_device *dev, const struct in6_addr *addr); void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr); diff --git a/include/net/udp.h b/include/net/udp.h index 6d4ed18..3b5d7f9 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -191,7 +191,7 @@ static inline void udp_lib_close(struct sock *sk, long timeout) } int udp_lib_get_port(struct sock *sk, unsigned short snum, -int (*)(const struct sock *, const struct sock *), +int (*)(const struct sock *, const struct sock *, bool), unsigned int hash2_nulladdr); u32 udp_flow_hashrnd(void); diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 8841e98..de2e1c0 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -113,6 +113,7 @@ #include #include #include "udp_impl.h" +#include struct udp_table udp_table __read_mostly; EXPORT_SYMBOL(udp_table); @@ -137,7 +138,8 @@ static int udp_lib_lport_inuse(struct net *net, __u16 num, unsigned long *bitmap, struct sock *sk, int (*saddr_comp)(const struct sock *sk1, -const struct sock *sk2), +const struct sock *sk2, +bool match_wildcard), unsigned int log) { struct sock *sk2; @@ -152,8 +154,9 @@ static int udp_lib_lport_inuse(struct net *net, __u16 num, (!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if || sk2->sk_bound_dev_if == sk->sk_bound_dev_if) && (!sk2->sk_reuseport || !sk->sk_reuseport || +rcu_access_pointer(sk->sk_reuseport_cb) || !uid_eq(uid, sock_i_uid(sk2))) && - saddr_comp(sk, sk2)) { + saddr_comp(sk, sk2, true)) { if (!bitmap) return 1; __set_bit(udp_sk(sk2)->udp_port_hash >> log, bitmap); @@ -170,7 +173,8 @@ static int udp_lib_lport_inuse2(struct net *net, __u16 num, struct udp_hslot *hslot2, struct sock *sk, int (*saddr_comp)(const struct sock *sk1, - const struct sock *sk2)) + const struct sock *sk2, + bool match_wildcard)) { struct sock *sk2; struct hlist_nulls_node *node; @@ -186,8 +190,9 @@ static int udp_lib_lport_inuse2(struct net *net, __u16 num, (!sk2->sk_bound_dev_if || !sk->sk_bound_dev_if || sk2->sk_bound_d
[RFC PATCH net-next] net: Add l3mdev cgroup
Add cgroup to assoicate tasks with L3 networking domains. AF_INET{6} sockets opened by tasks associated with an l3mdev cgroup are bound to the associated master device when the socket is created. This allows a user to run a command (and its children) within an L3 networking context. The master-device for an l3mdev cgroup must be an L3 master device (e.g., VRF), and it must be set before attaching tasks to the cgroup. Once set the master-device can not change. Nested l3mdev cgroups are not supported. The root (aka default) l3mdev cgroup can not be bound to a master device. Example: ip link add vrf-red type vrf table vrf-red ip link set dev vrf-red up ip link set dev eth1 master vrf-red cgcreate -g l3mdev:vrf-red cgset -r l3mdev.master-device=vrf-red vrf-red cgexec -g l3mdev:vrf-red bash At this point the current shell and its child processes are attached to the vrf-red L3 domain. Any AF_INET and AF_INET6 sockets opened by the tasks are bound to the vrf-red device. TO-DO: - how to auto-create the cgroup when a VRF device is created and auto-deleted when a VRF device is destroyed Signed-off-by: David Ahern --- include/linux/cgroup_subsys.h | 3 + include/net/l3mdev_cgroup.h | 27 ++ net/core/sock.c | 2 + net/l3mdev/Kconfig| 12 +++ net/l3mdev/Makefile | 1 + net/l3mdev/l3mdev_cgroup.c| 195 ++ 6 files changed, 240 insertions(+) create mode 100644 include/net/l3mdev_cgroup.h create mode 100644 net/l3mdev/l3mdev_cgroup.c diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h index 1a96fdaa33d5..507df40f11de 100644 --- a/include/linux/cgroup_subsys.h +++ b/include/linux/cgroup_subsys.h @@ -58,6 +58,9 @@ SUBSYS(net_prio) SUBSYS(hugetlb) #endif +#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV) +SUBSYS(l3mdev) +#endif /* * Subsystems that implement the can_fork() family of callbacks. */ diff --git a/include/net/l3mdev_cgroup.h b/include/net/l3mdev_cgroup.h new file mode 100644 index ..c20fbb0a7f46 --- /dev/null +++ b/include/net/l3mdev_cgroup.h @@ -0,0 +1,27 @@ +/* + * l3mdev_cgroup.h Control Group for L3 Master Device + * + * Copyright (c) 2015 Cumulus Networks. All rights reserved. + * Copyright (c) 2015 David Ahern + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef _L3MDEV_CGROUP_H +#define _L3MDEV_CGROUP_H + +#if IS_ENABLED(CONFIG_CGROUP_L3MDEV) + +void sock_update_l3mdev(struct sock *sk); + +#else /* !CONFIG_CGROUP_L3MDEV */ + +static inline void sock_update_l3mdev(struct sock *sk) +{ +} + +#endif /* CONFIG_CGROUP_L3MDEV */ +#endif /* _L3MDEV_CGROUP_H */ diff --git a/net/core/sock.c b/net/core/sock.c index 565bab7baca9..19ce06674dd9 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -131,6 +131,7 @@ #include #include #include +#include #include #include @@ -1424,6 +1425,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority, sock_update_classid(&sk->sk_cgrp_data); sock_update_netprioidx(&sk->sk_cgrp_data); + sock_update_l3mdev(sk); } return sk; diff --git a/net/l3mdev/Kconfig b/net/l3mdev/Kconfig index 5d47325037bc..3142d810e222 100644 --- a/net/l3mdev/Kconfig +++ b/net/l3mdev/Kconfig @@ -8,3 +8,15 @@ config NET_L3_MASTER_DEV ---help--- This module provides glue between core networking code and device drivers to support L3 master devices like VRF. + +config CGROUP_L3MDEV + bool "L3 Master Device cgroup" + depends on CGROUPS + depends on NET_L3_MASTER_DEV + ---help--- + Cgroup subsystem for assigning processes to an L3 domain. + When a process is assigned to an l3mdev domain all AF_INET and + AF_INET6 sockets opened by the process are bound to the L3 master + device. + + diff --git a/net/l3mdev/Makefile b/net/l3mdev/Makefile index 84a53a6f609a..ae74ebad8db7 100644 --- a/net/l3mdev/Makefile +++ b/net/l3mdev/Makefile @@ -3,3 +3,4 @@ # obj-$(CONFIG_NET_L3_MASTER_DEV) += l3mdev.o +obj-$(CONFIG_CGROUP_L3MDEV) += l3mdev_cgroup.o diff --git a/net/l3mdev/l3mdev_cgroup.c b/net/l3mdev/l3mdev_cgroup.c new file mode 100644 index ..0326c06bfe02 --- /dev/null +++ b/net/l3mdev/l3mdev_cgroup.c @@ -0,0 +1,195 @@ +/* + * net/l3mdev/l3mdev_cgroup.c Control Group for L3 Master Devices + * + * Copyright (c) 2015 Cumulus Networks. All rights reserved. + * Copyright (c) 2015 David Ahern + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version.
Re: [PATCH] net: Fix potential NULL pointer dereference in __skb_try_recv_datagram
On Mon, 2016-01-04 at 16:14 +, Rainer Weikusat wrote: > Eric Dumazet writes: > > On Mon, 2016-01-04 at 10:10 +0100, Jacob Siverskog wrote: > > [...] > > >> I believe the crash occurred between these two actions. I just saw > >> that there are some interesting events in the log prior to the crash: > >> kernel: Bluetooth: Unable to push skb to HCI core(-6) > >> kernel: (stc): proto stack 4's ->recv failed > >> kernel: (stc): remove_channel_from_table: id 3 > >> kernel: (stc): remove_channel_from_table: id 2 > >> kernel: (stc): remove_channel_from_table: id 4 > >> kernel: (stc): all chnl_ids unregistered > >> kernel: (stk) :ldisc_install = 0(stc): st_tty_close > >> > >> The first print is from btwilink.c. However, I can't see the > >> connection between Bluetooth (BLE) and UDP/IPv6 (we're not using > >> 6LoWPAN or anything similar). > >> > >> Thanks, Jacob > > > > Definitely these details are useful ;) > > > > Could you try : > > > > diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c > > index 6e3af8b42cdd..0c99a74fb895 100644 > > --- a/drivers/misc/ti-st/st_core.c > > +++ b/drivers/misc/ti-st/st_core.c > > @@ -912,7 +912,9 @@ void st_core_exit(struct st_data_s *st_gdata) > > skb_queue_purge(&st_gdata->txq); > > skb_queue_purge(&st_gdata->tx_waitq); > > kfree_skb(st_gdata->rx_skb); > > + st_gdata->rx_skb = NULL; > > kfree_skb(st_gdata->tx_skb); > > + st_gdata->tx_skb = NULL; > > /* TTY ldisc cleanup */ > > err = tty_unregister_ldisc(N_TI_WL); > > if (err) > > Hmm ... the code continues with > > err = tty_unregister_ldisc(N_TI_WL); > if (err) > pr_err("unable to un-register ldisc %ld", err); > /* free the global data pointer */ > kfree(st_gdata); > > So who would ever see that the rx_skb and tx_skb pointers were cleared > prior to freeing the data structure containing them? This is the theory, but I suspect a use after free. kfree(st_gdata) does not clear all content with 0, unless you use special SLUB/SLAB debugging features. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] rt2x00pci: Disable memory-write-invalidate when the driver exits
On Mon, Jan 4, 2016 at 8:55 AM, Jia-Ju Bai wrote: > The driver calls pci_set_mwi to enable memory-write-invalidate when it > is initialized, but does not call pci_clear_mwi when it is removed. Many > other drivers calls pci_clear_mwi when pci_set_mwi is called, such as > r8169, 8139cp and e1000. > > This patch adds pci_clear_mwi in error handling and removal procedure, > which can fix the problem. > > Signed-off-by: Jia-Ju Bai Looks good to me. Does this fix any actual issue? If yes it might we worth to mention it in the commit message. Helmut > --- > drivers/net/wireless/rt2x00/rt2x00pci.c |2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c > b/drivers/net/wireless/rt2x00/rt2x00pci.c > index d93db4b..eb6dbcd 100644 > --- a/drivers/net/wireless/rt2x00/rt2x00pci.c > +++ b/drivers/net/wireless/rt2x00/rt2x00pci.c > @@ -149,6 +149,7 @@ exit_free_device: > ieee80211_free_hw(hw); > > exit_release_regions: > + pci_clear_mwi(pci_dev); > pci_release_regions(pci_dev); > > exit_disable_device: > @@ -173,6 +174,7 @@ void rt2x00pci_remove(struct pci_dev *pci_dev) > /* > * Free the PCI device data. > */ > + pci_clear_mwi(pci_dev); > pci_disable_device(pci_dev); > pci_release_regions(pci_dev); > } > -- > 1.7.9.5 > > -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: next-20160104 build: 3 failures 15 warnings (next-20160104)
On Mon, Jan 04, 2016 at 12:12:20PM +, Build bot for Mark Brown wrote: Today's linux-next fails to build an arm allmodconfig (and probably also at least arm64 though other errors prevent that getting to linking currently) due to: | drivers/built-in.o: In function `dtsec_restart_autoneg': | :(.text+0x30f86c): undefined reference to `mdiobus_read' | :(.text+0x30f89c): undefined reference to `mdiobus_write' | drivers/built-in.o: In function `dtsec_init': | :(.text+0x31008c): undefined reference to `mdiobus_write' | :(.text+0x3100b4): undefined reference to `mdiobus_write' | :(.text+0x3100dc): undefined reference to `mdiobus_write' | :(.text+0x310128): undefined reference to `mdiobus_write' | drivers/built-in.o::(.text+0x310150): more undefined references to `mdiobus_write' follow | drivers/built-in.o: In function `dtsec_config': | :(.text+0x310804): undefined reference to `of_phy_find_device' and various other linker errors caused by the fact that the new fman driver uses PHYLIB but does not depend on or select it. signature.asc Description: PGP signature
[PATCH net] net: Propagate lookup failure in l3mdev_get_saddr to caller
Commands run in a vrf context are not failing as expected on a route lookup: root@kenny:~# ip ro ls table vrf-red unreachable default root@kenny:~# ping -I vrf-red -c1 -w1 10.100.1.254 ping: Warning: source address might be selected on device other than vrf-red. PING 10.100.1.254 (10.100.1.254) from 0.0.0.0 vrf-red: 56(84) bytes of data. --- 10.100.1.254 ping statistics --- 2 packets transmitted, 0 received, 100% packet loss, time 999ms Since the vrf table does not have a route for 10.100.1.254 the ping should have failed. The saddr lookup causes a full VRF table lookup. Propogating a lookup failure to the user allows the command to fail as expected: root@kenny:~# ping -I vrf-red -c1 -w1 10.100.1.254 connect: No route to host Signed-off-by: David Ahern --- DaveM: This is needed for 4.4; no backport to 4.3 is needed. drivers/net/vrf.c| 10 +++--- include/net/l3mdev.h | 16 ++-- include/net/route.h | 7 ++- net/ipv4/raw.c | 7 +-- net/ipv4/udp.c | 7 +-- 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index 56abdf224d35..66addb7a7911 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c @@ -742,7 +742,7 @@ static struct rtable *vrf_get_rtable(const struct net_device *dev, } /* called under rcu_read_lock */ -static void vrf_get_saddr(struct net_device *dev, struct flowi4 *fl4) +static int vrf_get_saddr(struct net_device *dev, struct flowi4 *fl4) { struct fib_result res = { .tclassid = 0 }; struct net *net = dev_net(dev); @@ -750,9 +750,10 @@ static void vrf_get_saddr(struct net_device *dev, struct flowi4 *fl4) u8 flags = fl4->flowi4_flags; u8 scope = fl4->flowi4_scope; u8 tos = RT_FL_TOS(fl4); + int rc; if (unlikely(!fl4->daddr)) - return; + return 0; fl4->flowi4_flags |= FLOWI_FLAG_SKIP_NH_OIF; fl4->flowi4_iif = LOOPBACK_IFINDEX; @@ -760,7 +761,8 @@ static void vrf_get_saddr(struct net_device *dev, struct flowi4 *fl4) fl4->flowi4_scope = ((tos & RTO_ONLINK) ? RT_SCOPE_LINK : RT_SCOPE_UNIVERSE); - if (!fib_lookup(net, fl4, &res, 0)) { + rc = fib_lookup(net, fl4, &res, 0); + if (!rc) { if (res.type == RTN_LOCAL) fl4->saddr = res.fi->fib_prefsrc ? : fl4->daddr; else @@ -770,6 +772,8 @@ static void vrf_get_saddr(struct net_device *dev, struct flowi4 *fl4) fl4->flowi4_flags = flags; fl4->flowi4_tos = orig_tos; fl4->flowi4_scope = scope; + + return rc; } #if IS_ENABLED(CONFIG_IPV6) diff --git a/include/net/l3mdev.h b/include/net/l3mdev.h index 786226f8e77b..5567d46b3cff 100644 --- a/include/net/l3mdev.h +++ b/include/net/l3mdev.h @@ -29,7 +29,7 @@ struct l3mdev_ops { /* IPv4 ops */ struct rtable * (*l3mdev_get_rtable)(const struct net_device *dev, const struct flowi4 *fl4); - void(*l3mdev_get_saddr)(struct net_device *dev, + int (*l3mdev_get_saddr)(struct net_device *dev, struct flowi4 *fl4); /* IPv6 ops */ @@ -130,10 +130,11 @@ static inline bool netif_index_is_l3_master(struct net *net, int ifindex) return rc; } -static inline void l3mdev_get_saddr(struct net *net, int ifindex, - struct flowi4 *fl4) +static inline int l3mdev_get_saddr(struct net *net, int ifindex, + struct flowi4 *fl4) { struct net_device *dev; + int rc = 0; if (ifindex) { @@ -142,11 +143,13 @@ static inline void l3mdev_get_saddr(struct net *net, int ifindex, dev = dev_get_by_index_rcu(net, ifindex); if (dev && netif_is_l3_master(dev) && dev->l3mdev_ops->l3mdev_get_saddr) { - dev->l3mdev_ops->l3mdev_get_saddr(dev, fl4); + rc = dev->l3mdev_ops->l3mdev_get_saddr(dev, fl4); } rcu_read_unlock(); } + + return rc; } static inline struct dst_entry *l3mdev_get_rt6_dst(const struct net_device *dev, @@ -223,9 +226,10 @@ static inline bool netif_index_is_l3_master(struct net *net, int ifindex) return false; } -static inline void l3mdev_get_saddr(struct net *net, int ifindex, - struct flowi4 *fl4) +static inline int l3mdev_get_saddr(struct net *net, int ifindex, + struct flowi4 *fl4) { + return 0; } static inline diff --git a/include/net/route.h b/include/net/route.h index ee81307863d5..a3b9ef74a389 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -283,7 +283,12 @@ static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
From: Dan Carpenter Date: Mon, 4 Jan 2016 12:28:57 +0300 > Please stop sending cleanup patches, Markus. Just send fixes. +1 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Q: bad routing table cache entries
04.01.2016 04:05, Sowmini Varadhan пишет: On (12/30/15 15:42), Stas Sergeev wrote: 29.12.2015 18:22, Sowmini Varadhan пишет: Do you have admin control over the ubuntu router? If yes, you might want to check the shared_media [#] setting on that router for the interfaces with overlapping subnets. (it is on by default, I would try turning it off). That didn't help, problem re-appears. the code that sets things up for redirect is this: I was also privately suggested that I could disable shared_media insufficiently. Indeed, I've only done that for "all" (net.ipv4.conf.all), but not for the every particular IFace. So I'll re-try the test. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[ANNOUNCE] NetDev 1.1 is approaching...
Hi! For those that still didn't hear about us, Netdev 1.1 is the community-driven Linux networking conference. This event will be again held back-to-back with NetConf in Sevilla, Spain, February 10-12, 2016. After the holidays break (happy new year everyone!), we would like to make a quick summary on what's been accepted meanwhile. = BoF = * Switchdev (Roopa Prabhu & Shrijeet Mukherjee) * IPsec performance (Steffen Klassert) = Talks = * Zebra 2.0 and Lagopus: newly-designed routing stack on high-performance packet forwarder (Yoshihiro Nakajima, Kunihiro Ishiguro, Masaru Oki, Hirokazu Takahashi) * Reducing Latency in Linux Wireless Network Drivers" (Tim Shepard) * Deterministic network emulation using KauNet" (Per Hurtig & Johan Garcia) * Suricata IDPS and its interaction with Linux kernel" (Eric Leblond & Giuseppe Longo) * The CLASShoFIREs: who's got your back?" (Jamal Hadi Salim) * MACsec: encryption for the wired LAN" (Sabrina Dubroca) * Bridge filtering with nftables" (Florian Westphal) * Deploying MPLS with Linux" (Roopa Prabhu) * IPv6 route lookup performance and scaling" (Michal Kubeček) * Namespaces and CGroups, the basis of Linux containers" (Rami Rosen) / We still have more sessions to \ \be announced, stay tuned! / \ ^__^ \ (oo)\___ (__)\ )\/\ ||w | || || For more info, visit: * netdev 1.1: https://www.netdevconf.org/1.1/ * netconf 2016: http://vger.kernel.org/netconf2016.html We would also like to thank those that already confirmed sponsorship: Cumulus Networks, Facebook, VmWare, Google, Cisco, Mellanox, Mojatatu Networks, OISF/Suricata, Zen Load Balancer and LWN.net. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 02/12] net: sched: free per cpu bstats
On Mon, 2016-01-04 at 16:21 +0100, Daniel Borkmann wrote: > On 12/30/2015 06:51 PM, John Fastabend wrote: > > When a qdisc is using per cpu stats only the bstats are being > > freed. This also free's the qstats. > > > > Signed-off-by: John Fastabend > > Seems like a bug fix, current code seems to free this only in error > path in qdisc_create(). Should this go to -net as an individual one? Absolutely, this is needed in -net as ingress qdisc uses this stuff already. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH net-next 06/24] net: dnet: Use phy_find_first() helper
Replace the open coded search for the first phy with a call to the existing helper function. Signed-off-by: Andrew Lunn --- drivers/net/ethernet/dnet.c | 8 +--- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/net/ethernet/dnet.c b/drivers/net/ethernet/dnet.c index 136b6010f704..0ec367521354 100644 --- a/drivers/net/ethernet/dnet.c +++ b/drivers/net/ethernet/dnet.c @@ -255,15 +255,9 @@ static int dnet_mii_probe(struct net_device *dev) { struct dnet *bp = netdev_priv(dev); struct phy_device *phydev = NULL; - int phy_addr; /* find the first phy */ - for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) { - if (bp->mii_bus->phy_map[phy_addr]) { - phydev = bp->mii_bus->phy_map[phy_addr]; - break; - } - } + phydev = phy_find_first(bp->mii_bus); if (!phydev) { printk(KERN_ERR "%s: no PHY found\n", dev->name); -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH net-next 10/24] mdio: Move allocation of interrupts into core
Have mdio_alloc() create the array of interrupt numbers, and initialize it to POLLING. This is what most MDIO drivers want, so allowing code to be removed from the drivers. Signed-off-by: Andrew Lunn --- arch/powerpc/platforms/82xx/ep8248e.c| 10 +- arch/powerpc/platforms/pasemi/gpio_mdio.c| 3 --- drivers/net/ethernet/8390/ax88796.c | 15 ++- drivers/net/ethernet/adi/bfin_mac.c | 11 +-- drivers/net/ethernet/aeroflex/greth.c| 5 - drivers/net/ethernet/aeroflex/greth.h| 1 - drivers/net/ethernet/agere/et131x.c | 13 + drivers/net/ethernet/altera/altera_tse_main.c| 13 + drivers/net/ethernet/amd/au1000_eth.c| 7 --- drivers/net/ethernet/broadcom/b44.c | 14 +- drivers/net/ethernet/broadcom/bcm63xx_enet.c | 9 - drivers/net/ethernet/broadcom/bgmac.c| 15 ++- drivers/net/ethernet/broadcom/genet/bcmmii.c | 10 -- drivers/net/ethernet/broadcom/sb1250-mac.c | 4 drivers/net/ethernet/broadcom/tg3.c | 4 drivers/net/ethernet/broadcom/tg3.h | 1 - drivers/net/ethernet/cadence/macb.c | 14 +- drivers/net/ethernet/dnet.c | 12 +--- drivers/net/ethernet/ethoc.c | 14 +- drivers/net/ethernet/faraday/ftgmac100.c | 6 -- drivers/net/ethernet/freescale/fec_main.c| 16 ++-- drivers/net/ethernet/freescale/fec_mpc52xx_phy.c | 4 drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c | 10 +- drivers/net/ethernet/freescale/fs_enet/mii-fec.c | 10 +- drivers/net/ethernet/freescale/fsl_pq_mdio.c | 2 -- drivers/net/ethernet/hisilicon/hns_mdio.c| 5 - drivers/net/ethernet/lantiq_etop.c | 14 +- drivers/net/ethernet/marvell/mvmdio.c| 10 +- drivers/net/ethernet/nxp/lpc_eth.c | 13 + drivers/net/ethernet/rdc/r6040.c | 14 +- drivers/net/ethernet/renesas/sh_eth.c| 12 +--- drivers/net/ethernet/smsc/smsc911x.c | 6 ++ drivers/net/ethernet/smsc/smsc9420.c | 6 +- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c| 14 -- drivers/net/ethernet/synopsys/dwc_eth_qos.c | 15 ++- drivers/net/ethernet/toshiba/tc35815.c | 14 +- drivers/net/ethernet/xilinx/ll_temac.h | 1 - drivers/net/ethernet/xilinx/ll_temac_mdio.c | 2 -- drivers/net/ethernet/xilinx/xilinx_axienet.h | 2 -- drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c| 2 -- drivers/net/ethernet/xilinx/xilinx_emaclite.c| 4 drivers/net/phy/fixed_phy.c | 4 +--- drivers/net/phy/mdio-bcm-unimac.c| 11 +-- drivers/net/phy/mdio-gpio.c | 2 +- drivers/net/phy/mdio-moxart.c| 7 --- drivers/net/phy/mdio-mux.c | 3 +-- drivers/net/phy/mdio-octeon.c| 2 -- drivers/net/phy/mdio-sun4i.c | 12 +--- drivers/net/phy/mdio_bus.c | 5 + drivers/net/usb/ax88172a.c | 14 ++ drivers/net/usb/lan78xx.c| 11 +-- include/linux/phy.h | 6 +++--- 52 files changed, 47 insertions(+), 387 deletions(-) diff --git a/arch/powerpc/platforms/82xx/ep8248e.c b/arch/powerpc/platforms/82xx/ep8248e.c index a0cb8bd41958..6781bda117be 100644 --- a/arch/powerpc/platforms/82xx/ep8248e.c +++ b/arch/powerpc/platforms/82xx/ep8248e.c @@ -131,23 +131,15 @@ static int ep8248e_mdio_probe(struct platform_device *ofdev) if (!bus) return -ENOMEM; - bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); - if (bus->irq == NULL) { - ret = -ENOMEM; - goto err_free_bus; - } - bus->name = "ep8248e-mdio-bitbang"; bus->parent = &ofdev->dev; snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start); ret = of_mdiobus_register(bus, ofdev->dev.of_node); if (ret) - goto err_free_irq; + goto err_free_bus; return 0; -err_free_irq: - kfree(bus->irq); err_free_bus: free_mdio_bitbang(bus); return ret; diff --git a/arch/powerpc/platforms/pasemi/gpio_mdio.c b/arch/powerpc/platforms/pasemi/gpio_mdio.c index ae3f47b25b18..ddf635000c6b 100644 --- a/arch/powerpc/platforms/pasemi/gpio_mdio.c +++ b/arch/powerpc/platforms/pasemi/gpio_mdio.
[RFC PATCH net-next 01/24] phy: Consistently use addr for address on an MII bus
Within phy.h, an address on an MII bus has been called both addr and phy_id. phy_id is particularly confusion, since it also means the ID found in register 3, if the device on the bus is a phy. Consistently use addr. Signed-off-by: Andrew Lunn --- include/linux/phy.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/phy.h b/include/linux/phy.h index a89cb0eef911..77b5e56e2a92 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -158,8 +158,8 @@ struct mii_bus { const char *name; char id[MII_BUS_ID_SIZE]; void *priv; - int (*read)(struct mii_bus *bus, int phy_id, int regnum); - int (*write)(struct mii_bus *bus, int phy_id, int regnum, u16 val); + int (*read)(struct mii_bus *bus, int addr, int regnum); + int (*write)(struct mii_bus *bus, int addr, int regnum, u16 val); int (*reset)(struct mii_bus *bus); /* -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH net-next 24/24] Add linux,mdio-nop support for testing
--- arch/arm/boot/dts/vf610-zii-dev-rev-b.dts | 5 + 1 file changed, 5 insertions(+) diff --git a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts index 6e657a9312ce..044e213f5809 100644 --- a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts +++ b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts @@ -68,6 +68,11 @@ reg = <8>; #address-cells = <1>; #size-cells = <0>; + + nop: nop@4 { +compatible = "linux,mdio-nop"; +reg = <4>; + }; }; }; -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH net-next 12/24] of: phy: Only register a phy device for phys
We will soon support devices other than phys on the mdio bus. Look at a child's compatibility string to determine if it is a phy, before registering a phy device. Signed-off-by: Andrew Lunn --- drivers/of/of_mdio.c | 37 ++--- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index 25bace4db85a..75a415d7cf8c 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -114,6 +114,31 @@ int of_mdio_parse_addr(struct device *dev, const struct device_node *np) } EXPORT_SYMBOL(of_mdio_parse_addr); +/* + * Return true if the child node is for a phy. It must either: + * o Compatible string of "ethernet-phy-idX.X" + * o Compatible string of "ethernet-phy-ieee802.3-c45" + * o No compatibility string + * + * A device which is not a phy is expected to have a compatible string + * indicating what sort of device it is. + */ +static bool of_mdiobus_child_is_phy(struct device_node *child) +{ + u32 phy_id; + + if (of_get_phy_id(child, &phy_id) != -EINVAL) + return true; + + if (of_device_is_compatible(child, "ethernet-phy-ieee802.3-c45")) + return true; + + if (!of_find_property(child, "compatible", NULL)) + return true; + + return false; +} + /** * of_mdiobus_register - Register mii_bus and create PHYs from the device tree * @mdio: pointer to mii_bus structure @@ -145,7 +170,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) if (rc) return rc; - /* Loop over the child nodes and register a phy_device for each one */ + /* Loop over the child nodes and register a phy_device for each phy */ for_each_available_child_of_node(np, child) { addr = of_mdio_parse_addr(&mdio->dev, child); if (addr < 0) { @@ -153,9 +178,8 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) continue; } - rc = of_mdiobus_register_phy(mdio, child, addr); - if (rc) - continue; + if (of_mdiobus_child_is_phy(child)) + of_mdiobus_register_phy(mdio, child, addr); } if (!scanphys) @@ -177,9 +201,8 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) dev_info(&mdio->dev, "scan phy %s at address %i\n", child->name, addr); - rc = of_mdiobus_register_phy(mdio, child, addr); - if (rc) - continue; + if (of_mdiobus_child_is_phy(child)) + of_mdiobus_register_phy(mdio, child, addr); } } -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH net-next 09/24] phy: mdio-octeon: Use devm_mdiobus_alloc_size()
Rather than use devm_kzalloc(), use the mdio helper function. Signed-off-by: Andrew Lunn --- drivers/net/phy/mdio-octeon.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/net/phy/mdio-octeon.c b/drivers/net/phy/mdio-octeon.c index fcf4e4df7cc8..0d5da1312dd3 100644 --- a/drivers/net/phy/mdio-octeon.c +++ b/drivers/net/phy/mdio-octeon.c @@ -268,12 +268,13 @@ static int octeon_mdiobus_write(struct mii_bus *bus, int phy_id, static int octeon_mdiobus_probe(struct platform_device *pdev) { struct octeon_mdiobus *bus; + struct mii_bus *mii_bus; struct resource *res_mem; union cvmx_smix_en smi_en; int err = -ENOENT; - bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL); - if (!bus) + mii_bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*bus)); + if (!mii_bus) return -ENOMEM; res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -282,6 +283,8 @@ static int octeon_mdiobus_probe(struct platform_device *pdev) return -ENXIO; } + bus = mii_bus->priv; + bus->mii_bus = mii_bus; bus->mdio_phys = res_mem->start; bus->regsize = resource_size(res_mem); @@ -298,10 +301,6 @@ static int octeon_mdiobus_probe(struct platform_device *pdev) return -ENOMEM; } - bus->mii_bus = mdiobus_alloc(); - if (!bus->mii_bus) - goto fail; - smi_en.u64 = 0; smi_en.s.en = 1; oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN); @@ -326,7 +325,6 @@ static int octeon_mdiobus_probe(struct platform_device *pdev) return 0; fail_register: mdiobus_free(bus->mii_bus); -fail: smi_en.u64 = 0; oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN); return err; -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH net-next 02/24] mdio: Move mdiobus_read/write operatings into mdio.h
These are logically MDIO operations, not phy operations, so move them into the mdio header. Signed-off-by: Andrew Lunn --- include/linux/mdio.h | 6 ++ include/linux/phy.h | 6 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/linux/mdio.h b/include/linux/mdio.h index b42963bc81dd..0d073c23c10d 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -11,6 +11,7 @@ #include +struct mii_bus; static inline bool mdio_phy_id_is_c45(int phy_id) { @@ -173,4 +174,9 @@ static inline u16 ethtool_adv_to_mmd_eee_adv_t(u32 adv) return reg; } +int mdiobus_read(struct mii_bus *bus, int addr, u32 regnum); +int mdiobus_read_nested(struct mii_bus *bus, int addr, u32 regnum); +int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val); +int mdiobus_write_nested(struct mii_bus *bus, int addr, u32 regnum, u16 val); + #endif /* __LINUX_MDIO_H__ */ diff --git a/include/linux/phy.h b/include/linux/phy.h index 77b5e56e2a92..8ca161a37e8a 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -212,11 +213,6 @@ static inline struct mii_bus *devm_mdiobus_alloc(struct device *dev) void devm_mdiobus_free(struct device *dev, struct mii_bus *bus); struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr); -int mdiobus_read(struct mii_bus *bus, int addr, u32 regnum); -int mdiobus_read_nested(struct mii_bus *bus, int addr, u32 regnum); -int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val); -int mdiobus_write_nested(struct mii_bus *bus, int addr, u32 regnum, u16 val); - #define PHY_INTERRUPT_DISABLED 0x0 #define PHY_INTERRUPT_ENABLED 0x8000 -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH net-next 11/24] phy: Add an mdio_device structure
Not all devices attached to an MDIO bus are phys. So add an mdio_device structure to represent the generic parts of an mdio device, and place this structure into the phy_device. Signed-off-by: Andrew Lunn --- drivers/net/ethernet/agere/et131x.c | 30 ++-- drivers/net/ethernet/altera/altera_tse_main.c| 2 +- drivers/net/ethernet/broadcom/b44.c | 2 +- drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 +- drivers/net/ethernet/broadcom/sb1250-mac.c | 4 +- drivers/net/ethernet/freescale/fman/fman_dtsec.c | 6 +-- drivers/net/ethernet/freescale/fman/fman_memac.c | 6 +-- drivers/net/ethernet/freescale/fs_enet/mac-fec.c | 2 +- drivers/net/ethernet/freescale/gianfar.c | 4 +- drivers/net/ethernet/freescale/ucc_geth.c| 4 +- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 2 +- drivers/net/ethernet/marvell/mv643xx_eth.c | 2 +- drivers/net/ethernet/marvell/mvneta.c| 2 +- drivers/net/ethernet/smsc/smsc911x.c | 11 +++-- drivers/net/ethernet/smsc/smsc9420.c | 3 +- drivers/net/ethernet/ti/cpsw.c | 3 +- drivers/net/ethernet/ti/davinci_mdio.c | 2 +- drivers/net/ethernet/xilinx/xilinx_emaclite.c| 2 +- drivers/net/phy/at803x.c | 2 +- drivers/net/phy/bcm87xx.c| 4 +- drivers/net/phy/dp83640.c| 22 + drivers/net/phy/dp83867.c| 4 +- drivers/net/phy/fixed_phy.c | 10 ++-- drivers/net/phy/icplus.c | 18 drivers/net/phy/marvell.c| 7 +-- drivers/net/phy/mdio_bus.c | 12 ++--- drivers/net/phy/micrel.c | 12 ++--- drivers/net/phy/microchip.c | 4 +- drivers/net/phy/phy.c| 20 drivers/net/phy/phy_device.c | 58 drivers/net/phy/smsc.c | 2 +- drivers/of/of_mdio.c | 6 +-- include/linux/mdio.h | 9 include/linux/phy.h | 26 +-- net/dsa/dsa.c| 2 +- 35 files changed, 160 insertions(+), 147 deletions(-) diff --git a/drivers/net/ethernet/agere/et131x.c b/drivers/net/ethernet/agere/et131x.c index 04b639781f1c..ac83e3ef5252 100644 --- a/drivers/net/ethernet/agere/et131x.c +++ b/drivers/net/ethernet/agere/et131x.c @@ -1235,7 +1235,7 @@ static int et131x_mii_read(struct et131x_adapter *adapter, u8 reg, u16 *value) if (!phydev) return -EIO; - return et131x_phy_mii_read(adapter, phydev->addr, reg, value); + return et131x_phy_mii_read(adapter, phydev->mdio.addr, reg, value); } static int et131x_mii_write(struct et131x_adapter *adapter, u8 addr, u8 reg, @@ -1462,7 +1462,7 @@ static void et1310_phy_power_switch(struct et131x_adapter *adapter, bool down) data &= ~BMCR_PDOWN; if (down) data |= BMCR_PDOWN; - et131x_mii_write(adapter, phydev->addr, MII_BMCR, data); + et131x_mii_write(adapter, phydev->mdio.addr, MII_BMCR, data); } /* et131x_xcvr_init - Init the phy if we are setting it into force mode */ @@ -1490,7 +1490,7 @@ static void et131x_xcvr_init(struct et131x_adapter *adapter) else lcr2 |= (LED_VAL_LINKON << LED_TXRX_SHIFT); - et131x_mii_write(adapter, phydev->addr, PHY_LED_2, lcr2); + et131x_mii_write(adapter, phydev->mdio.addr, PHY_LED_2, lcr2); } } @@ -3192,14 +3192,14 @@ static void et131x_adjust_link(struct net_device *netdev) et131x_mii_read(adapter, PHY_MPHY_CONTROL_REG, ®ister18); - et131x_mii_write(adapter, phydev->addr, + et131x_mii_write(adapter, phydev->mdio.addr, PHY_MPHY_CONTROL_REG, register18 | 0x4); - et131x_mii_write(adapter, phydev->addr, PHY_INDEX_REG, -register18 | 0x8402); - et131x_mii_write(adapter, phydev->addr, PHY_DATA_REG, -register18 | 511); - et131x_mii_write(adapter, phydev->addr, + et131x_mii_write(adapter, phydev->mdio.addr, +PHY_INDEX_REG, register18 | 0x8402); + et131x_mii_write(adapter, phydev->mdio.addr, +PHY_DATA_REG, register18 | 511); + et131x_mii_write(adapter, phydev->mdio.addr, PHY_MPHY_CONTROL_REG, register18); } @@ -3212,8 +3212,8 @@ s
[RFC PATCH net-next 08/24] phy: Centralise print about attached phy
Many Ethernet drivers contain the same netdev_info() print statement about the attached phy. Move it into the phy device code. Signed-off-by: Andrew Lunn --- drivers/net/ethernet/adi/bfin_mac.c | 5 - drivers/net/ethernet/agere/et131x.c | 4 drivers/net/ethernet/amd/au1000_eth.c| 4 drivers/net/ethernet/broadcom/b44.c | 3 --- drivers/net/ethernet/broadcom/bcm63xx_enet.c | 3 --- drivers/net/ethernet/broadcom/sb1250-mac.c | 4 drivers/net/ethernet/broadcom/tg3.c | 8 +--- drivers/net/ethernet/cadence/macb.c | 2 -- drivers/net/ethernet/dnet.c | 3 --- drivers/net/ethernet/freescale/fec_main.c| 4 drivers/net/ethernet/lantiq_etop.c | 3 --- drivers/net/ethernet/nxp/lpc_eth.c | 3 --- drivers/net/ethernet/rdc/r6040.c | 4 drivers/net/ethernet/renesas/ravb_main.c | 3 --- drivers/net/ethernet/renesas/sh_eth.c| 3 --- drivers/net/ethernet/smsc/smsc911x.c | 4 drivers/net/ethernet/smsc/smsc9420.c | 7 --- drivers/net/ethernet/synopsys/dwc_eth_qos.c | 13 - drivers/net/ethernet/ti/cpsw.c | 2 -- drivers/net/ethernet/ti/davinci_emac.c | 5 - drivers/net/ethernet/toshiba/tc35815.c | 4 drivers/net/phy/phy_device.c | 4 drivers/staging/netlogic/xlr_net.c | 2 -- net/dsa/slave.c | 3 --- 24 files changed, 5 insertions(+), 95 deletions(-) diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c index 5f8a5182b8dc..4c6f7a7f9352 100644 --- a/drivers/net/ethernet/adi/bfin_mac.c +++ b/drivers/net/ethernet/adi/bfin_mac.c @@ -444,11 +444,6 @@ static int mii_probe(struct net_device *dev, int phy_mode) lp->old_duplex = -1; lp->phydev = phydev; - pr_info("attached PHY driver [%s] " - "(mii_bus:phy_addr=%s, irq=%d, mdc_clk=%dHz(mdc_div=%d)@sclk=%dMHz)\n", - phydev->drv->name, phydev_name(phydev), phydev->irq, - MDC_CLK, mdc_div, sclk/100); - return 0; } diff --git a/drivers/net/ethernet/agere/et131x.c b/drivers/net/ethernet/agere/et131x.c index 80b706f0fc97..8c49b97ed19b 100644 --- a/drivers/net/ethernet/agere/et131x.c +++ b/drivers/net/ethernet/agere/et131x.c @@ -3289,10 +3289,6 @@ static int et131x_mii_probe(struct net_device *netdev) phydev->autoneg = AUTONEG_ENABLE; adapter->phydev = phydev; - dev_info(&adapter->pdev->dev, -"attached PHY driver [%s] (mii_bus:phy_addr=%s)\n", -phydev->drv->name, phydev_name(phydev)); - return 0; } diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c index 8a8d6f2a0f6f..edd85664b1c7 100644 --- a/drivers/net/ethernet/amd/au1000_eth.c +++ b/drivers/net/ethernet/amd/au1000_eth.c @@ -583,10 +583,6 @@ static int au1000_mii_probe(struct net_device *dev) aup->old_duplex = -1; aup->phy_dev = phydev; - netdev_info(dev, "attached PHY driver [%s] " - "(mii_bus:phy_addr=%s, irq=%d)\n", - phydev->drv->name, phydev_name(phydev), phydev->irq); - return 0; } diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c index 928a2210e788..9d009c540729 100644 --- a/drivers/net/ethernet/broadcom/b44.c +++ b/drivers/net/ethernet/broadcom/b44.c @@ -2315,9 +2315,6 @@ static int b44_register_phy_one(struct b44 *bp) bp->old_link = 0; bp->phy_addr = phydev->addr; - dev_info(sdev->dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s)\n", -phydev->drv->name, phydev_name(phydev)); - return 0; err_out_mdiobus_unregister: diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c index a54bafad3538..ac29e91e6e02 100644 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c @@ -908,9 +908,6 @@ static int bcm_enet_open(struct net_device *dev) else phydev->advertising &= ~SUPPORTED_Pause; - dev_info(kdev, "attached PHY at address %d [%s]\n", -phydev->addr, phydev->drv->name); - priv->old_link = 0; priv->old_duplex = -1; priv->old_pause = -1; diff --git a/drivers/net/ethernet/broadcom/sb1250-mac.c b/drivers/net/ethernet/broadcom/sb1250-mac.c index f557a2aaec23..51eaf55b8827 100644 --- a/drivers/net/ethernet/broadcom/sb1250-mac.c +++ b/drivers/net/ethernet/broadcom/sb1250-mac.c @@ -2390,10 +2390,6 @@ static int sbmac_mii_probe(struct net_device *dev) SUPPORTED_Asym_Pause; phy_dev->advertising = phy_dev->supported; - pr_info("%s: attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n", - d
[RFC PATCH net-next 05/24] phy: add phydev_name() macro
Add a phydev_name() macro, to help with moving some structure members from phy_device. Signed-off-by: Andrew Lunn --- drivers/net/ethernet/8390/ax88796.c | 2 +- drivers/net/ethernet/adi/bfin_mac.c | 4 ++-- drivers/net/ethernet/agere/et131x.c | 4 ++-- drivers/net/ethernet/amd/au1000_eth.c | 4 ++-- drivers/net/ethernet/broadcom/b44.c | 2 +- drivers/net/ethernet/broadcom/tg3.c | 4 ++-- drivers/net/ethernet/cadence/macb.c | 2 +- drivers/net/ethernet/dnet.c | 6 +++--- drivers/net/ethernet/faraday/ftgmac100.c | 2 +- drivers/net/ethernet/lantiq_etop.c| 4 ++-- drivers/net/ethernet/nxp/lpc_eth.c| 4 ++-- drivers/net/ethernet/rdc/r6040.c | 4 ++-- drivers/net/ethernet/renesas/ravb_main.c | 2 +- drivers/net/ethernet/renesas/sh_eth.c | 2 +- drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c | 2 +- drivers/net/ethernet/smsc/smsc911x.c | 2 +- drivers/net/ethernet/smsc/smsc9420.c | 4 ++-- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 +- drivers/net/ethernet/ti/davinci_emac.c| 2 +- drivers/net/ethernet/ti/davinci_mdio.c| 2 +- drivers/net/ethernet/ti/netcp_ethss.c | 4 ++-- drivers/net/ethernet/toshiba/tc35815.c| 4 ++-- drivers/net/phy/bcm7xxx.c | 2 +- drivers/net/phy/phy_device.c | 2 +- drivers/staging/netlogic/xlr_net.c| 6 +++--- include/linux/phy.h | 2 ++ 26 files changed, 41 insertions(+), 39 deletions(-) diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c index 0443654f0339..90b540a4a561 100644 --- a/drivers/net/ethernet/8390/ax88796.c +++ b/drivers/net/ethernet/8390/ax88796.c @@ -372,7 +372,7 @@ static int ax_mii_probe(struct net_device *dev) ax->phy_dev = phy_dev; netdev_info(dev, "PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n", - phy_dev->drv->name, dev_name(&phy_dev->dev), phy_dev->irq); + phy_dev->drv->name, phydev_name(phy_dev), phy_dev->irq); return 0; } diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c index e0e95a15cab0..5f8a5182b8dc 100644 --- a/drivers/net/ethernet/adi/bfin_mac.c +++ b/drivers/net/ethernet/adi/bfin_mac.c @@ -419,7 +419,7 @@ static int mii_probe(struct net_device *dev, int phy_mode) return -EINVAL; } - phydev = phy_connect(dev, dev_name(&phydev->dev), + phydev = phy_connect(dev, phydev_name(phydev), &bfin_mac_adjust_link, phy_mode); if (IS_ERR(phydev)) { @@ -446,7 +446,7 @@ static int mii_probe(struct net_device *dev, int phy_mode) pr_info("attached PHY driver [%s] " "(mii_bus:phy_addr=%s, irq=%d, mdc_clk=%dHz(mdc_div=%d)@sclk=%dMHz)\n", - phydev->drv->name, dev_name(&phydev->dev), phydev->irq, + phydev->drv->name, phydev_name(phydev), phydev->irq, MDC_CLK, mdc_div, sclk/100); return 0; diff --git a/drivers/net/ethernet/agere/et131x.c b/drivers/net/ethernet/agere/et131x.c index e0f3d197e7f2..80b706f0fc97 100644 --- a/drivers/net/ethernet/agere/et131x.c +++ b/drivers/net/ethernet/agere/et131x.c @@ -3265,7 +3265,7 @@ static int et131x_mii_probe(struct net_device *netdev) return -ENODEV; } - phydev = phy_connect(netdev, dev_name(&phydev->dev), + phydev = phy_connect(netdev, phydev_name(phydev), &et131x_adjust_link, PHY_INTERFACE_MODE_MII); if (IS_ERR(phydev)) { @@ -3291,7 +3291,7 @@ static int et131x_mii_probe(struct net_device *netdev) dev_info(&adapter->pdev->dev, "attached PHY driver [%s] (mii_bus:phy_addr=%s)\n", -phydev->drv->name, dev_name(&phydev->dev)); +phydev->drv->name, phydev_name(phydev)); return 0; } diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c index 5330bcb8a944..8a8d6f2a0f6f 100644 --- a/drivers/net/ethernet/amd/au1000_eth.c +++ b/drivers/net/ethernet/amd/au1000_eth.c @@ -558,7 +558,7 @@ static int au1000_mii_probe(struct net_device *dev) /* now we are supposed to have a proper phydev, to attach to... */ BUG_ON(phydev->attached_dev); - phydev = phy_connect(dev, dev_name(&phydev->dev), + phydev = phy_connect(dev, phydev_name(phydev), &au1000_adjust_link, PHY_INTERFACE_MODE_MII); if (IS_ERR(phydev)) { @@ -585,7 +585,7 @@ static int au1000_mii_probe(struct net_device *dev) netdev_info(dev, "attached PHY driver [%s] " "(mii_bus:phy_addr=%s, irq=%d)\n", - phydev->drv->name, dev_name(&phydev->dev), phyd
[RFC PATCH net-next 07/24] phy: phy_{read|write}_mmd_indirect: get addr from phydev
The address of the device can be determined from the phydev structure, rather than passing it as a parameter. Signed-off-by: Andrew Lunn --- drivers/net/phy/bcm-phy-lib.c | 8 drivers/net/phy/dp83867.c | 6 +++--- drivers/net/phy/microchip.c | 5 ++--- drivers/net/phy/phy.c | 36 ++-- include/linux/phy.h | 7 ++- 5 files changed, 25 insertions(+), 37 deletions(-) diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c index ddb377e53633..df0416db0b88 100644 --- a/drivers/net/phy/bcm-phy-lib.c +++ b/drivers/net/phy/bcm-phy-lib.c @@ -184,25 +184,25 @@ int bcm_phy_enable_eee(struct phy_device *phydev) /* Enable EEE at PHY level */ val = phy_read_mmd_indirect(phydev, BRCM_CL45VEN_EEE_CONTROL, - MDIO_MMD_AN, phydev->addr); + MDIO_MMD_AN); if (val < 0) return val; val |= LPI_FEATURE_EN | LPI_FEATURE_EN_DIG1000X; phy_write_mmd_indirect(phydev, BRCM_CL45VEN_EEE_CONTROL, - MDIO_MMD_AN, phydev->addr, (u32)val); + MDIO_MMD_AN, (u32)val); /* Advertise EEE */ val = phy_read_mmd_indirect(phydev, BCM_CL45VEN_EEE_ADV, - MDIO_MMD_AN, phydev->addr); + MDIO_MMD_AN); if (val < 0) return val; val |= (MDIO_AN_EEE_ADV_100TX | MDIO_AN_EEE_ADV_1000T); phy_write_mmd_indirect(phydev, BCM_CL45VEN_EEE_ADV, - MDIO_MMD_AN, phydev->addr, (u32)val); + MDIO_MMD_AN, (u32)val); return 0; } diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c index 4ebf601073d9..e4c0b0c0af02 100644 --- a/drivers/net/phy/dp83867.c +++ b/drivers/net/phy/dp83867.c @@ -160,7 +160,7 @@ static int dp83867_config_init(struct phy_device *phydev) if ((phydev->interface >= PHY_INTERFACE_MODE_RGMII_ID) && (phydev->interface <= PHY_INTERFACE_MODE_RGMII_RXID)) { val = phy_read_mmd_indirect(phydev, DP83867_RGMIICTL, - DP83867_DEVADDR, phydev->addr); + DP83867_DEVADDR); if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) val |= (DP83867_RGMII_TX_CLK_DELAY_EN | DP83867_RGMII_RX_CLK_DELAY_EN); @@ -172,13 +172,13 @@ static int dp83867_config_init(struct phy_device *phydev) val |= DP83867_RGMII_RX_CLK_DELAY_EN; phy_write_mmd_indirect(phydev, DP83867_RGMIICTL, - DP83867_DEVADDR, phydev->addr, val); + DP83867_DEVADDR, val); delay = (dp83867->rx_id_delay | (dp83867->tx_id_delay << DP83867_RGMII_TX_CLK_DELAY_SHIFT)); phy_write_mmd_indirect(phydev, DP83867_RGMIIDCTL, - DP83867_DEVADDR, phydev->addr, delay); + DP83867_DEVADDR, delay); } return 0; diff --git a/drivers/net/phy/microchip.c b/drivers/net/phy/microchip.c index c0a20ebd083b..99df5bc47424 100644 --- a/drivers/net/phy/microchip.c +++ b/drivers/net/phy/microchip.c @@ -78,10 +78,9 @@ static int lan88xx_probe(struct phy_device *phydev) priv->wolopts = 0; /* these values can be used to identify internal PHY */ - priv->chip_id = phy_read_mmd_indirect(phydev, LAN88XX_MMD3_CHIP_ID, - 3, phydev->addr); + priv->chip_id = phy_read_mmd_indirect(phydev, LAN88XX_MMD3_CHIP_ID, 3); priv->chip_rev = phy_read_mmd_indirect(phydev, LAN88XX_MMD3_CHIP_REV, - 3, phydev->addr); + 3); phydev->priv = priv; diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 287e3682fd58..1522042f8e01 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1027,7 +1027,6 @@ static inline void mmd_phy_indirect(struct mii_bus *bus, int prtad, int devad, * @phydev: The PHY device bus * @prtad: MMD Address * @devad: MMD DEVAD - * @addr: PHY address on the MII bus * * Description: it reads data from the MMD registers (clause 22 to access to * clause 45) of the specified phy address. @@ -1037,10 +1036,10 @@ static inline void mmd_phy_indirect(struct mii_bus *bus, int prtad, int devad, * 3) Write reg 13 // MMD Data Command for MMD DEVAD * 3) Read reg 14 // Read MMD data */ -int phy_read_mmd_indirect(struct phy_device *phydev, int prtad, -int devad, int addr) +int phy_read_mmd_indirect(struct phy_device *phydev, int prtad, int devad) { struct phy_driver *phydrv = phydev->drv; + int addr =
[RFC PATCH net-next 20/24] mdio_bus: Add comment to mdiobus_scan() and __mdiobus_register()
Make it clear that mdiobus_scan () will only find devices which have a vendor/product ID in registers 2 and 3. These are typically PHY devices. Other sort of MDIO devices, such as switches, are not expected to be found during the scan. Similarly, __mdiobus_register(), which calls mdiobus_scan() will only find PHY devices, and other sorts of MDIO devices are expected to be instantiated from device tree. Signed-off-by: Andrew Lunn --- drivers/net/phy/mdio_bus.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 0d369ad19d17..6f9ca51446db 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -291,7 +291,9 @@ static inline void of_mdiobus_link_mdiodev(struct mii_bus *mdio, * Description: Called by a bus driver to bring up all the PHYs * on a given bus, and attach them to the bus. Drivers should use * mdiobus_register() rather than __mdiobus_register() unless they - * need to pass a specific owner module. + * need to pass a specific owner module. MDIO devices which are not + * PHYs will not be brought up by this function. They are expected to + * to be explicitly listed in DT and instantiated by of_mdiobus_register(). * * Returns 0 on success or < 0 on error. */ @@ -394,6 +396,18 @@ void mdiobus_free(struct mii_bus *bus) } EXPORT_SYMBOL(mdiobus_free); +/** + * mdiobus_scan - scan a bus for MDIO devices. + * @bus: mii_bus to scan + * @addr: address on bus to scan + * + * This function scans the MDIO bus, looking for devices which can be + * identified using a vendor/product ID in registers 2 and 3. Not all + * MDIO devices have such registers, but PHY devices typically + * do. Hence this function assumes anything found is a PHY, or can be + * treated as a PHY. Other MDIO devices, such as switches, will + * probably not be found during the scan. + */ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr) { struct phy_device *phydev; -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH net-next 04/24] phy: Add phydev_err() and phydev_dbg() macros
In preparation for moving some of the phy_device structure members, add macros for printing errors and debug information. Signed-off-by: Andrew Lunn --- drivers/net/phy/at803x.c | 4 ++-- drivers/net/phy/bcm87xx.c | 5 +++-- drivers/net/phy/micrel.c | 16 +--- drivers/net/phy/phy.c | 5 +++-- include/linux/phy.h | 6 ++ 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 2d020a3ec0b5..62361f8af375 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -281,8 +281,8 @@ static void at803x_link_change_notify(struct phy_device *phydev) at803x_context_restore(phydev, &context); - dev_dbg(&phydev->dev, "%s(): phy was reset\n", - __func__); + phydev_dbg(phydev, "%s(): phy was reset\n", + __func__); priv->phy_reset = true; } } else { diff --git a/drivers/net/phy/bcm87xx.c b/drivers/net/phy/bcm87xx.c index 1eca20452f03..71b491c7bf96 100644 --- a/drivers/net/phy/bcm87xx.c +++ b/drivers/net/phy/bcm87xx.c @@ -163,8 +163,9 @@ static int bcm87xx_did_interrupt(struct phy_device *phydev) reg = phy_read(phydev, BCM87XX_LASI_STATUS); if (reg < 0) { - dev_err(&phydev->dev, - "Error: Read of BCM87XX_LASI_STATUS failed: %d\n", reg); + phydev_err(phydev, + "Error: Read of BCM87XX_LASI_STATUS failed: %d\n", + reg); return 0; } return (reg & 1) != 0; diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 1a6048a8c29d..bf72365e90bc 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -224,7 +224,7 @@ static int kszphy_setup_led(struct phy_device *phydev, u32 reg, int val) rc = phy_write(phydev, reg, temp); out: if (rc < 0) - dev_err(&phydev->dev, "failed to set led mode\n"); + phydev_err(phydev, "failed to set led mode\n"); return rc; } @@ -243,7 +243,7 @@ static int kszphy_broadcast_disable(struct phy_device *phydev) ret = phy_write(phydev, MII_KSZPHY_OMSO, ret | KSZPHY_OMSO_B_CAST_OFF); out: if (ret) - dev_err(&phydev->dev, "failed to disable broadcast address\n"); + phydev_err(phydev, "failed to disable broadcast address\n"); return ret; } @@ -263,7 +263,7 @@ static int kszphy_nand_tree_disable(struct phy_device *phydev) ret & ~KSZPHY_OMSO_NAND_TREE_ON); out: if (ret) - dev_err(&phydev->dev, "failed to disable NAND tree mode\n"); + phydev_err(phydev, "failed to disable NAND tree mode\n"); return ret; } @@ -288,7 +288,8 @@ static int kszphy_config_init(struct phy_device *phydev) if (priv->rmii_ref_clk_sel) { ret = kszphy_rmii_clk_sel(phydev, priv->rmii_ref_clk_sel_val); if (ret) { - dev_err(&phydev->dev, "failed to set rmii reference clock\n"); + phydev_err(phydev, + "failed to set rmii reference clock\n"); return ret; } } @@ -649,8 +650,8 @@ static int kszphy_probe(struct phy_device *phydev) priv->led_mode = -1; if (priv->led_mode > 3) { - dev_err(&phydev->dev, "invalid led mode: 0x%02x\n", - priv->led_mode); + phydev_err(phydev, "invalid led mode: 0x%02x\n", + priv->led_mode); priv->led_mode = -1; } } else { @@ -672,7 +673,8 @@ static int kszphy_probe(struct phy_device *phydev) } else if (rate > 4950 && rate < 5050) { priv->rmii_ref_clk_sel_val = !rmii_ref_clk_sel_25_mhz; } else { - dev_err(&phydev->dev, "Clock rate out of range: %ld\n", rate); + phydev_err(phydev, "Clock rate out of range: %ld\n", + rate); return -EINVAL; } } diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 67a77956ae6f..287e3682fd58 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -993,8 +993,9 @@ void phy_state_machine(struct work_struct *work) if (err < 0) phy_error(phydev); - dev_dbg(&phydev->dev, "PHY state change %s -> %s\n", - phy_state_to_str(old_state), phy_state_to_str(phydev->state)); + phydev_dbg(phydev, "PHY state change %s -> %s\n", + phy_state_to_str(old_state), +
[RFC PATCH net-next 00/24] Support MDIO devices
The discussions about changing the way DSA probes switches resulted in the wish to have switches attached to an MDIO bus to be represented as an MDIO device. However the current code only supports PHYs on MDIO busses. This patchset remedies this problem. It consists of a number of cleanups, abstraction for accessing structure members, and refactoring, as well as adding the concept of a generic MDIO device and MDIO driver. The last two patches then make use of this facility with a simple test driver, which will be discarded once we are past RFC stage. Andrew Lunn (24): phy: Consistently use addr for address on an MII bus mdio: Move mdiobus_read/write operatings into mdio.h phy: Use phy_read() instead of mdiobus_read() phy: Add phydev_err() and phydev_dbg() macros phy: add phydev_name() macro net: dnet: Use phy_find_first() helper phy: phy_{read|write}_mmd_indirect: get addr from phydev phy: Centralise print about attached phy phy: mdio-octeon: Use devm_mdiobus_alloc_size() mdio: Move allocation of interrupts into core phy: Add an mdio_device structure of: phy: Only register a phy device for phys phy: Add API for {un{registering an mdio device to a bus. phy_device: Move phy attributes into phy_device dsa: Register netdev before phy phy: Move PHY PM operations into phy_device phy: Centralize setting driver module owner phy: Move phy specific bus match into phy_device mdio_bus: Generalise of_mdiobus_link_phydev() mdio_bus: Add comment to mdiobus_scan() and __mdiobus_register() mdio: Add support for mdio drivers. mdio: Abstract device_remove() and device_free() mdio: mdio-nop: Dummy driver to testing Add linux,mdio-nop support for testing arch/arm/boot/dts/vf610-zii-dev-rev-b.dts | 5 + arch/powerpc/platforms/82xx/ep8248e.c | 10 +- arch/powerpc/platforms/pasemi/gpio_mdio.c | 3 - drivers/net/ethernet/8390/ax88796.c| 17 +- drivers/net/ethernet/adi/bfin_mac.c| 18 +- drivers/net/ethernet/aeroflex/greth.c | 5 - drivers/net/ethernet/aeroflex/greth.h | 1 - drivers/net/ethernet/agere/et131x.c| 49 ++-- drivers/net/ethernet/altera/altera_tse_main.c | 15 +- drivers/net/ethernet/amd/au1000_eth.c | 13 +- drivers/net/ethernet/broadcom/b44.c| 21 +- drivers/net/ethernet/broadcom/bcm63xx_enet.c | 12 - drivers/net/ethernet/broadcom/bgmac.c | 15 +- drivers/net/ethernet/broadcom/genet/bcmmii.c | 14 +- drivers/net/ethernet/broadcom/sb1250-mac.c | 12 +- drivers/net/ethernet/broadcom/tg3.c| 44 ++- drivers/net/ethernet/broadcom/tg3.h| 1 - drivers/net/ethernet/cadence/macb.c| 16 +- drivers/net/ethernet/dnet.c| 27 +- drivers/net/ethernet/ethoc.c | 18 +- drivers/net/ethernet/faraday/ftgmac100.c | 10 +- drivers/net/ethernet/freescale/fec_main.c | 27 +- drivers/net/ethernet/freescale/fec_mpc52xx_phy.c | 4 - drivers/net/ethernet/freescale/fman/fman_dtsec.c | 6 +- drivers/net/ethernet/freescale/fman/fman_memac.c | 6 +- drivers/net/ethernet/freescale/fs_enet/mac-fec.c | 2 +- .../net/ethernet/freescale/fs_enet/mii-bitbang.c | 10 +- drivers/net/ethernet/freescale/fs_enet/mii-fec.c | 10 +- drivers/net/ethernet/freescale/fsl_pq_mdio.c | 2 - drivers/net/ethernet/freescale/gianfar.c | 4 +- drivers/net/ethernet/freescale/ucc_geth.c | 4 +- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 106 +++ drivers/net/ethernet/hisilicon/hns_mdio.c | 5 - drivers/net/ethernet/lantiq_etop.c | 19 +- drivers/net/ethernet/marvell/mv643xx_eth.c | 2 +- drivers/net/ethernet/marvell/mvmdio.c | 10 +- drivers/net/ethernet/marvell/mvneta.c | 2 +- drivers/net/ethernet/nxp/lpc_eth.c | 18 +- drivers/net/ethernet/rdc/r6040.c | 20 +- drivers/net/ethernet/renesas/ravb_main.c | 3 - drivers/net/ethernet/renesas/sh_eth.c | 15 +- drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c| 4 +- drivers/net/ethernet/smsc/smsc911x.c | 21 +- drivers/net/ethernet/smsc/smsc9420.c | 21 +- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 18 +- drivers/net/ethernet/synopsys/dwc_eth_qos.c| 28 +- drivers/net/ethernet/ti/cpsw.c | 5 +- drivers/net/ethernet/ti/davinci_emac.c | 5 - drivers/net/ethernet/ti/davinci_mdio.c | 4 +- drivers/net/ethernet/ti/netcp_ethss.c | 4 +- drivers/net/ethernet/toshiba/tc35815.c | 20 +- drivers/net/ethernet/xilinx/ll_temac.h | 1 - drivers/net/ethernet/xilinx/ll_temac_mdio.c| 2 - drivers/net/ethernet/xilinx/xilinx_axienet.h | 2 -
[RFC PATCH net-next 03/24] phy: Use phy_read() instead of mdiobus_read()
Since we have a phydev, make use of it and the phy_read() function. This will help with later refactoring. Signed-off-by: Andrew Lunn --- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 104 --- drivers/net/phy/phy.c| 6 +- 2 files changed, 38 insertions(+), 72 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c index 3b234176dd36..4eddbeb19307 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c @@ -77,18 +77,16 @@ static void hns_get_mdix_mode(struct net_device *net_dev, return; } - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, HNS_PHY_PAGE_REG, - HNS_PHY_PAGE_MDIX); + phy_write(phy_dev, HNS_PHY_PAGE_REG, HNS_PHY_PAGE_MDIX); - retval = mdiobus_read(phy_dev->bus, phy_dev->addr, HNS_PHY_CSC_REG); + retval = phy_read(phy_dev, HNS_PHY_CSC_REG); mdix_ctrl = hnae_get_field(retval, PHY_MDIX_CTRL_M, PHY_MDIX_CTRL_S); - retval = mdiobus_read(phy_dev->bus, phy_dev->addr, HNS_PHY_CSS_REG); + retval = phy_read(phy_dev, HNS_PHY_CSS_REG); mdix = hnae_get_bit(retval, PHY_MDIX_STATUS_B); is_resolved = hnae_get_bit(retval, PHY_SPEED_DUP_RESOLVE_B); - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, HNS_PHY_PAGE_REG, - HNS_PHY_PAGE_COPPER); + phy_write(phy_dev, HNS_PHY_PAGE_REG, HNS_PHY_PAGE_COPPER); switch (mdix_ctrl) { case 0x0: @@ -253,53 +251,36 @@ static int hns_nic_config_phy_loopback(struct phy_device *phy_dev, u8 en) if (en) { /* speed : 1000M */ - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - HNS_PHY_PAGE_REG, 2); - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - 21, 0x1046); + phy_write(phy_dev, HNS_PHY_PAGE_REG, 2); + phy_write(phy_dev, 21, 0x1046); /* Force Master */ - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - 9, 0x1F00); + phy_write(phy_dev, 9, 0x1F00); /* Soft-reset */ - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - 0, 0x9140); + phy_write(phy_dev, 0, 0x9140); /* If autoneg disabled,two soft-reset operations */ - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - 0, 0x9140); - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - 22, 0xFA); + phy_write(phy_dev, 0, 0x9140); + phy_write(phy_dev, 22, 0xFA); /* Default is 0x0400 */ - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - 1, 0x418); + phy_write(phy_dev, 1, 0x418); /* Force 1000M Link, Default is 0x0200 */ - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - 7, 0x20C); - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - 22, 0); + phy_write(phy_dev, 7, 0x20C); + phy_write(phy_dev, 22, 0); /* Enable MAC loop-back */ - val = (u16)mdiobus_read(phy_dev->bus, phy_dev->addr, - COPPER_CONTROL_REG); + val = phy_read(phy_dev, COPPER_CONTROL_REG); val |= PHY_LOOP_BACK; - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - COPPER_CONTROL_REG, val); + phy_write(phy_dev, COPPER_CONTROL_REG, val); } else { - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - 22, 0xFA); - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - 1, 0x400); - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - 7, 0x200); - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - 22, 0); - - val = (u16)mdiobus_read(phy_dev->bus, phy_dev->addr, - COPPER_CONTROL_REG); + phy_write(phy_dev, 22, 0xFA); + phy_write(phy_dev, 1, 0x400); + phy_write(phy_dev, 7, 0x200); + phy_write(phy_dev, 22, 0); + + val = phy_read(phy_dev, COPPER_CONTROL_REG); val &= ~PHY_LOOP_BACK; - (void)mdiobus_write(phy_dev->bus, phy_dev->addr, - COPPER_CONTROL_REG, val); + phy_write(phy_dev, COPPER_CONTROL_REG, val); } return
[RFC PATCH net-next 13/24] phy: Add API for {un{registering an mdio device to a bus.
Rather than have drivers directly manipulate the mii_bus structure, provide and API for registering and unregistering devices on an MDIO bus, and performing lookups. Signed-off-by: Andrew Lunn --- drivers/net/ethernet/broadcom/b44.c | 2 +- drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 +- drivers/net/ethernet/broadcom/tg3.c | 30 +++ drivers/net/ethernet/ethoc.c | 4 +- drivers/net/ethernet/faraday/ftgmac100.c | 2 +- drivers/net/ethernet/freescale/fec_main.c | 7 +--- drivers/net/ethernet/samsung/sxgbe/sxgbe_mdio.c | 2 +- drivers/net/ethernet/smsc/smsc9420.c | 3 +- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 +- drivers/net/ethernet/ti/davinci_mdio.c| 2 +- drivers/net/phy/mdio_bus.c| 46 ++- drivers/net/phy/phy_device.c | 21 +-- drivers/of/of_mdio.c | 2 +- include/linux/mdio.h | 8 include/linux/phy.h | 2 +- net/dsa/slave.c | 3 +- 16 files changed, 93 insertions(+), 45 deletions(-) diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c index 15f3ccaef8b7..abc0fb76f28a 100644 --- a/drivers/net/ethernet/broadcom/b44.c +++ b/drivers/net/ethernet/broadcom/b44.c @@ -2272,7 +2272,7 @@ static int b44_register_phy_one(struct b44 *bp) goto err_out_mdiobus; } - if (!bp->mii_bus->phy_map[bp->phy_addr] && + if (!mdiobus_is_registered_device(bp->mii_bus, bp->phy_addr) && (sprom->boardflags_lo & (B44_BOARDFLAG_ROBO | B44_BOARDFLAG_ADM))) { dev_info(sdev->dev, diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index 633b59db813a..0d775964b060 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -573,7 +573,7 @@ static int bcmgenet_mii_pd_init(struct bcmgenet_priv *priv) } if (pd->phy_address >= 0 && pd->phy_address < PHY_MAX_ADDR) - phydev = mdio->phy_map[pd->phy_address]; + phydev = mdiobus_get_phy(mdio, pd->phy_address); else phydev = phy_find_first(mdio); diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 5d659a5c86b5..aaa5064672ac 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -1406,7 +1406,7 @@ static void tg3_mdio_config_5785(struct tg3 *tp) u32 val; struct phy_device *phydev; - phydev = tp->mdio_bus->phy_map[tp->phy_addr]; + phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); switch (phydev->drv->phy_id & phydev->drv->phy_id_mask) { case PHY_ID_BCM50610: case PHY_ID_BCM50610M: @@ -1554,7 +1554,7 @@ static int tg3_mdio_init(struct tg3 *tp) return i; } - phydev = tp->mdio_bus->phy_map[tp->phy_addr]; + phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); if (!phydev || !phydev->drv) { dev_warn(&tp->pdev->dev, "No PHY devices\n"); @@ -1964,7 +1964,7 @@ static void tg3_setup_flow_control(struct tg3 *tp, u32 lcladv, u32 rmtadv) u32 old_tx_mode = tp->tx_mode; if (tg3_flag(tp, USE_PHYLIB)) - autoneg = tp->mdio_bus->phy_map[tp->phy_addr]->autoneg; + autoneg = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr)->autoneg; else autoneg = tp->link_config.autoneg; @@ -2000,7 +2000,7 @@ static void tg3_adjust_link(struct net_device *dev) u8 oldflowctrl, linkmesg = 0; u32 mac_mode, lcl_adv, rmt_adv; struct tg3 *tp = netdev_priv(dev); - struct phy_device *phydev = tp->mdio_bus->phy_map[tp->phy_addr]; + struct phy_device *phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); spin_lock_bh(&tp->lock); @@ -2089,7 +2089,7 @@ static int tg3_phy_init(struct tg3 *tp) /* Bring the PHY back to a known state. */ tg3_bmcr_reset(tp); - phydev = tp->mdio_bus->phy_map[tp->phy_addr]; + phydev = mdiobus_get_phy(tp->mdio_bus, tp->phy_addr); /* Attach the MAC to the PHY. */ phydev = phy_connect(tp->dev, phydev_name(phydev), @@ -2116,7 +2116,7 @@ static int tg3_phy_init(struct tg3 *tp) SUPPORTED_Asym_Pause); break; default: - phy_disconnect(tp->mdio_bus->phy_map[tp->phy_addr]); + phy_disconnect(mdiobus_get_phy(tp->mdio_bus, tp->phy_addr)); return -EINVAL; } @@ -2134,7 +2134,7 @@ static void tg3_phy_start(struct tg3 *tp) if (!(tp->phy_flags & TG3_PHYFLG_IS_CONNECTED)) return;
[RFC PATCH net-next 14/24] phy_device: Move phy attributes into phy_device
The mdio_bus exports three attributes. However these are all phy attributes, not generic mdio attributes. So move the attributes into the phy device code. Signed-off-by: Andrew Lunn --- drivers/net/phy/mdio_bus.c | 42 -- drivers/net/phy/phy_device.c | 44 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index f28f89e109ba..e6dddb086265 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -670,52 +670,10 @@ static const struct dev_pm_ops mdio_bus_pm_ops = { #endif /* CONFIG_PM */ -static ssize_t -phy_id_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct phy_device *phydev = to_phy_device(dev); - - return sprintf(buf, "0x%.8lx\n", (unsigned long)phydev->phy_id); -} -static DEVICE_ATTR_RO(phy_id); - -static ssize_t -phy_interface_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct phy_device *phydev = to_phy_device(dev); - const char *mode = NULL; - - if (phy_is_internal(phydev)) - mode = "internal"; - else - mode = phy_modes(phydev->interface); - - return sprintf(buf, "%s\n", mode); -} -static DEVICE_ATTR_RO(phy_interface); - -static ssize_t -phy_has_fixups_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - struct phy_device *phydev = to_phy_device(dev); - - return sprintf(buf, "%d\n", phydev->has_fixups); -} -static DEVICE_ATTR_RO(phy_has_fixups); - -static struct attribute *mdio_dev_attrs[] = { - &dev_attr_phy_id.attr, - &dev_attr_phy_interface.attr, - &dev_attr_phy_has_fixups.attr, - NULL, -}; -ATTRIBUTE_GROUPS(mdio_dev); - struct bus_type mdio_bus_type = { .name = "mdio_bus", .match = mdio_bus_match, .pm = MDIO_BUS_PM_OPS, - .dev_groups = mdio_dev_groups, }; EXPORT_SYMBOL(mdio_bus_type); diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 37fc8d6269ec..4dd42f75a0d2 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -376,6 +376,48 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) } EXPORT_SYMBOL(get_phy_device); +static ssize_t +phy_id_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct phy_device *phydev = to_phy_device(dev); + + return sprintf(buf, "0x%.8lx\n", (unsigned long)phydev->phy_id); +} +static DEVICE_ATTR_RO(phy_id); + +static ssize_t +phy_interface_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct phy_device *phydev = to_phy_device(dev); + const char *mode = NULL; + + if (phy_is_internal(phydev)) + mode = "internal"; + else + mode = phy_modes(phydev->interface); + + return sprintf(buf, "%s\n", mode); +} +static DEVICE_ATTR_RO(phy_interface); + +static ssize_t +phy_has_fixups_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct phy_device *phydev = to_phy_device(dev); + + return sprintf(buf, "%d\n", phydev->has_fixups); +} +static DEVICE_ATTR_RO(phy_has_fixups); + +static struct attribute *phy_dev_attrs[] = { + &dev_attr_phy_id.attr, + &dev_attr_phy_interface.attr, + &dev_attr_phy_has_fixups.attr, + NULL, +}; +ATTRIBUTE_GROUPS(phy_dev); + /** * phy_device_register - Register the phy device on the MDIO bus * @phydev: phy_device structure to be added to the MDIO bus @@ -395,6 +437,8 @@ int phy_device_register(struct phy_device *phydev) goto out; } + phydev->mdio.dev.groups = phy_dev_groups; + err = device_add(&phydev->mdio.dev); if (err) { pr_err("PHY %d failed to add\n", phydev->mdio.addr); -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH net-next 15/24] dsa: Register netdev before phy
When the phy is connected, an info message is printed. If the netdev it is attached to has not been registered yet, the name 'uninitialised' in the output. By registering the netdev first, then connecting they phy, we can avoid this. Signed-off-by: Andrew Lunn --- net/dsa/slave.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 68fae0cf17cd..25606c1b963d 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1187,13 +1187,6 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent, p->old_link = -1; p->old_duplex = -1; - ret = dsa_slave_phy_setup(p, slave_dev); - if (ret) { - netdev_err(master, "error %d setting up slave phy\n", ret); - free_netdev(slave_dev); - return ret; - } - ds->ports[port] = slave_dev; ret = register_netdev(slave_dev); if (ret) { @@ -1205,6 +1198,13 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent, return ret; } + ret = dsa_slave_phy_setup(p, slave_dev); + if (ret) { + netdev_err(master, "error %d setting up slave phy\n", ret); + free_netdev(slave_dev); + return ret; + } + netif_carrier_off(slave_dev); return 0; -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH net-next 18/24] phy: Move phy specific bus match into phy_device
Matching a driver to a device has both generic parts, and parts which are specific to PHY devices. Move the PHY specific parts into phy_device. Signed-off-by: Andrew Lunn --- drivers/net/phy/mdio_bus.c | 38 -- drivers/net/phy/phy_device.c | 28 include/linux/mdio.h | 1 + 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 65ff8199bd09..bd523b2c6331 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -523,41 +523,27 @@ int mdiobus_write(struct mii_bus *bus, int addr, u32 regnum, u16 val) EXPORT_SYMBOL(mdiobus_write); /** - * mdio_bus_match - determine if given PHY driver supports the given PHY device - * @dev: target PHY device - * @drv: given PHY driver + * mdio_bus_match - determine if given MDIO driver supports the given + * MDIO device + * @dev: target MDIO device + * @drv: given MDIO driver * - * Description: Given a PHY device, and a PHY driver, return 1 if - * the driver supports the device. Otherwise, return 0. + * Description: Given a MDIO device, and a MDIO driver, return 1 if + * the driver supports the device. Otherwise, return 0. This may + * require calling the devices own match function, since different classes + * of MDIO devices have different match criteria. */ static int mdio_bus_match(struct device *dev, struct device_driver *drv) { - struct phy_device *phydev = to_phy_device(dev); - struct phy_driver *phydrv = to_phy_driver(drv); - const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids); - int i; + struct mdio_device *mdio = to_mdio_device(dev); if (of_driver_match_device(dev, drv)) return 1; - if (phydrv->match_phy_device) - return phydrv->match_phy_device(phydev); + if (mdio->bus_match) + return mdio->bus_match(dev, drv); - if (phydev->is_c45) { - for (i = 1; i < num_ids; i++) { - if (!(phydev->c45_ids.devices_in_package & (1 << i))) - continue; - - if ((phydrv->phy_id & phydrv->phy_id_mask) == - (phydev->c45_ids.device_ids[i] & -phydrv->phy_id_mask)) - return 1; - } - return 0; - } else { - return (phydrv->phy_id & phydrv->phy_id_mask) == - (phydev->phy_id & phydrv->phy_id_mask); - } + return 0; } #ifdef CONFIG_PM diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 85a942cb1a2d..f08d3a9709de 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -257,6 +257,33 @@ static int phy_scan_fixups(struct phy_device *phydev) return 0; } +static int phy_bus_match(struct device *dev, struct device_driver *drv) +{ + struct phy_device *phydev = to_phy_device(dev); + struct phy_driver *phydrv = to_phy_driver(drv); + const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids); + int i; + + if (phydrv->match_phy_device) + return phydrv->match_phy_device(phydev); + + if (phydev->is_c45) { + for (i = 1; i < num_ids; i++) { + if (!(phydev->c45_ids.devices_in_package & (1 << i))) + continue; + + if ((phydrv->phy_id & phydrv->phy_id_mask) == + (phydev->c45_ids.device_ids[i] & +phydrv->phy_id_mask)) + return 1; + } + return 0; + } else { + return (phydrv->phy_id & phydrv->phy_id_mask) == + (phydev->phy_id & phydrv->phy_id_mask); + } +} + struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id, bool is_c45, struct phy_c45_device_ids *c45_ids) @@ -275,6 +302,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id, mdiodev->dev.bus = &mdio_bus_type; mdiodev->bus = bus; mdiodev->pm_ops = MDIO_BUS_PHY_PM_OPS; + mdiodev->bus_match = phy_bus_match; mdiodev->addr = addr; mdiodev->flags = MDIO_DEVICE_FLAG_PHY; diff --git a/include/linux/mdio.h b/include/linux/mdio.h index 9f844d372ed5..0690359e55a5 100644 --- a/include/linux/mdio.h +++ b/include/linux/mdio.h @@ -17,6 +17,7 @@ struct mdio_device { struct device dev; const struct dev_pm_ops *pm_ops; struct mii_bus *bus; + int (*bus_match)(struct device *dev, struct device_driver *drv); /* Bus address of the MDIO device (0-31) */ int addr; int flags; -- 2.6.4 -- To unsubscribe from this list: send the line "unsubsc
[RFC PATCH net-next 19/24] mdio_bus: Generalise of_mdiobus_link_phydev()
This function should work with any sort of MDIO device which can be probed on the bus, not just PHY devices. So generalise it. Signed-off-by: Andrew Lunn --- drivers/net/phy/mdio_bus.c | 29 +++-- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index bd523b2c6331..0d369ad19d17 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -237,15 +237,16 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np) } EXPORT_SYMBOL(of_mdio_find_bus); -/* Walk the list of subnodes of a mdio bus and look for a node that matches the - * phy's address with its 'reg' property. If found, set the of_node pointer for - * the phy. This allows auto-probed pyh devices to be supplied with information - * passed in via DT. +/* Walk the list of subnodes of a mdio bus and look for a node that + * matches the mdio device's address with its 'reg' property. If + * found, set the of_node pointer for the mdio device. This allows + * auto-probed phy devices to be supplied with information passed in + * via DT. */ -static void of_mdiobus_link_phydev(struct mii_bus *bus, - struct phy_device *phydev) +static void of_mdiobus_link_mdiodev(struct mii_bus *bus, + struct mdio_device *mdiodev) { - struct device *dev = &phydev->mdio.dev; + struct device *dev = &mdiodev->dev; struct device_node *child; if (dev->of_node || !bus->dev.of_node) @@ -257,27 +258,27 @@ static void of_mdiobus_link_phydev(struct mii_bus *bus, ret = of_property_read_u32(child, "reg", &addr); if (ret < 0) { - dev_err(dev, "%s has invalid PHY address\n", + dev_err(dev, "%s has invalid MDIO address\n", child->full_name); continue; } - /* A PHY must have a reg property in the range [0-31] */ + /* A MDIO device must have a reg property in the range [0-31] */ if (addr >= PHY_MAX_ADDR) { - dev_err(dev, "%s PHY address %i is too large\n", + dev_err(dev, "%s MDIO address %i is too large\n", child->full_name, addr); continue; } - if (addr == phydev->mdio.addr) { + if (addr == mdiodev->addr) { dev->of_node = child; return; } } } #else /* !IS_ENABLED(CONFIG_OF_MDIO) */ -static inline void of_mdiobus_link_phydev(struct mii_bus *mdio, - struct phy_device *phydev) +static inline void of_mdiobus_link_mdiodev(struct mii_bus *mdio, + struct mdio_device *mdiodev) { } #endif @@ -406,7 +407,7 @@ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr) * For DT, see if the auto-probed phy has a correspoding child * in the bus node, and set the of_node pointer in this case. */ - of_mdiobus_link_phydev(bus, phydev); + of_mdiobus_link_mdiodev(bus, &phydev->mdio); err = phy_device_register(phydev); if (err) { -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC PATCH net-next 23/24] mdio: mdio-nop: Dummy driver to testing
Add a dummy driver which does nothing, but is useful for testing the mdio device framework. --- drivers/net/phy/Kconfig| 8 drivers/net/phy/Makefile | 1 + drivers/net/phy/mdio-nop.c | 37 + 3 files changed, 46 insertions(+) create mode 100644 drivers/net/phy/mdio-nop.c diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 60994a83a0d6..107613354b14 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -256,6 +256,14 @@ config MDIO_BCM_IPROC This module provides a driver for the MDIO busses found in the Broadcom iProc SoC's. +comment "MDIO devices" + +config MDIO_NOP + tristate "linux MDIO NOP driver" + help + MDIO driver which does nothing, other than test the MDIO framework. +Say No, unless you are testing the framework. + endif # PHYLIB config MICREL_KS8995MA diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 680e88f9915a..258542178c98 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -42,3 +42,4 @@ obj-$(CONFIG_MDIO_MOXART) += mdio-moxart.o obj-$(CONFIG_MDIO_BCM_UNIMAC) += mdio-bcm-unimac.o obj-$(CONFIG_MICROCHIP_PHY)+= microchip.o obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o +obj-$(CONFIG_MDIO_NOP) += mdio-nop.o diff --git a/drivers/net/phy/mdio-nop.c b/drivers/net/phy/mdio-nop.c new file mode 100644 index ..c2ff06c58a5c --- /dev/null +++ b/drivers/net/phy/mdio-nop.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +static int mdio_nop_probe(struct mdio_device *mdiodev) +{ + dev_info(&mdiodev->dev, "mdio_nop_probe for address %d\n", +mdiodev->addr); + + return 0; +} + +static void mdio_nop_remove(struct mdio_device *mdiodev) +{ + dev_info(&mdiodev->dev, "mdio_nop_remove for address %d\n", +mdiodev->addr); +} + +static const struct of_device_id mdio_nop_ids[] = { + { .compatible = "linux,mdio-nop" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, mdio_nop_ids); + +struct mdio_driver mdio_nop_drv = { + .probe = mdio_nop_probe, + .remove = mdio_nop_remove, + .mdiodrv = { + .driver = { + .name = "mdio-nop", + .of_match_table = mdio_nop_ids, + }, + }, +}; + +mdio_module_driver(mdio_nop_drv); -- 2.6.4 -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html