Commit 4897313b authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'fs_enet-cleanup'

Maxime Chevallier says:

====================
net: ethernet: fs_enet: Cleanup and phylink conversion

This is V3 of a series that cleans-up fs_enet, with the ultimate goal of
converting it to phylink (patch 8).

The main changes compared to V2 are :
 - Reviewed-by tags from Andrew were gathered
 - Patch 5 now includes the removal of now unused includes, thanks
   Andrew for spotting this
 - Patch 4 is new, it reworks the adjust_link to move the spinlock
   acquisition to a more suitable location. Although this dissapears in
   the actual phylink port, it makes the phylink conversion clearer on
   that point
 - Patch 8 includes fixes in the tx_timeout cancellation, to prevent
   taking rtnl twice when canceling a pending tx_timeout. Thanks Jakub
   for spotting this.

Link to V2: https://lore.kernel.org/netdev/20240829161531.610874-1-maxime.chevallier@bootlin.com/
Link to V1: https://lore.kernel.org/netdev/20240828095103.132625-1-maxime.chevallier@bootlin.com/


====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c259acab 41f5fbff
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ config FS_ENET
	tristate "Freescale Ethernet Driver"
	depends on NET_VENDOR_FREESCALE && (CPM1 || CPM2 || PPC_MPC512x)
	select MII
	select PHYLIB
	select PHYLINK

config FS_ENET_MPC5121_FEC
	def_bool y if (FS_ENET && PPC_MPC512x)
+194 −250

File changed.

Preview size limit exceeded, changes collapsed.

+5 −22
Original line number Diff line number Diff line
@@ -3,11 +3,11 @@
#define FS_ENET_H

#include <linux/clk.h>
#include <linux/mii.h>
#include <linux/netdevice.h>
#include <linux/types.h>
#include <linux/list.h>
#include <linux/phy.h>
#include <linux/phylink.h>
#include <linux/dma-mapping.h>

#ifdef CONFIG_CPM1
@@ -77,8 +77,8 @@ struct fs_ops {
	void (*free_bd)(struct net_device *dev);
	void (*cleanup_data)(struct net_device *dev);
	void (*set_multicast_list)(struct net_device *dev);
	void (*adjust_link)(struct net_device *dev);
	void (*restart)(struct net_device *dev);
	void (*restart)(struct net_device *dev, phy_interface_t interface,
			int speed, int duplex);
	void (*stop)(struct net_device *dev);
	void (*napi_clear_event)(struct net_device *dev);
	void (*napi_enable)(struct net_device *dev);
@@ -93,14 +93,6 @@ struct fs_ops {
	void (*tx_restart)(struct net_device *dev);
};

struct phy_info {
	unsigned int id;
	const char *name;
	void (*startup) (struct net_device * dev);
	void (*shutdown) (struct net_device * dev);
	void (*ack_int) (struct net_device * dev);
};

/* The FEC stores dest/src/type, data, and checksum for receive packets.
 */
#define MAX_MTU 1508		/* Allow fullsized pppoe packets over VLAN */
@@ -122,15 +114,9 @@ struct fs_platform_info {

	u32 dpram_offset;

	struct device_node *phy_node;

	int rx_ring, tx_ring;	/* number of buffers on rx	*/
	int rx_copybreak;	/* limit we copy small frames	*/
	int napi_weight;	/* NAPI weight			*/

	int use_rmii;		/* use RMII mode		*/

	struct clk *clk_per;	/* 'per' clock for register access */
};

struct fs_enet_private {
@@ -154,14 +140,11 @@ struct fs_enet_private {
	cbd_t __iomem *cur_rx;
	cbd_t __iomem *cur_tx;
	int tx_free;
	const struct phy_info *phy;
	u32 msg_enable;
	struct mii_if_info mii_if;
	unsigned int last_mii_status;
	struct phylink *phylink;
	struct phylink_config phylink_config;
	int interrupt;

	int oldduplex, oldspeed, oldlink;	/* current settings */

	/* event masks */
	u32 ev_napi;		/* mask of NAPI events */
	u32 ev;			/* event mask          */
+7 −10

File changed.

Preview size limit exceeded, changes collapsed.

+6 −9
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Freescale Ethernet controllers
 *
@@ -6,10 +7,6 @@
 *
 * 2005 (c) MontaVista Software, Inc.
 * Vitaly Bordug <vbordug@ru.mvista.com>
 *
 * This file is licensed under the terms of the GNU General Public License
 * version 2. This program is licensed "as is" without any warranty of any
 * kind, whether express or implied.
 */

#include <linux/module.h>
@@ -26,7 +23,6 @@
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/spinlock.h>
#include <linux/mii.h>
#include <linux/ethtool.h>
#include <linux/bitops.h>
#include <linux/fs.h>
@@ -224,7 +220,8 @@ static void set_multicast_list(struct net_device *dev)
		set_promiscuous_mode(dev);
}

static void restart(struct net_device *dev)
static void restart(struct net_device *dev, phy_interface_t interface,
		    int speed, int duplex)
{
	struct fs_enet_private *fep = netdev_priv(dev);
	struct fec __iomem *fecp = fep->fec.fecp;
@@ -306,13 +303,13 @@ static void restart(struct net_device *dev)
	 * Only set MII/RMII mode - do not touch maximum frame length
	 * configured before.
	 */
	FS(fecp, r_cntrl, fpi->use_rmii ?
	FS(fecp, r_cntrl, interface == PHY_INTERFACE_MODE_RMII ?
			  FEC_RCNTRL_RMII_MODE : FEC_RCNTRL_MII_MODE);
#endif
	/*
	 * adjust to duplex mode
	 */
	if (dev->phydev->duplex) {
	if (duplex == DUPLEX_FULL) {
		FC(fecp, r_cntrl, FEC_RCNTRL_DRT);
		FS(fecp, x_cntrl, FEC_TCNTRL_FDEN);	/* FD enable */
	} else {
Loading