* [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates
@ 2005-03-28 23:38 Dale Farnsworth
2005-03-28 23:40 ` mv643xx(1/20): Add mv643xx_enet support for PPC Pegasos platform Dale Farnsworth
` (19 more replies)
0 siblings, 20 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:38 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Jeff,
Here are some updates to the Marvell mv643xx Ethernet driver.
Both bug fixes and source code cleanups are included.
Most of these changes were submitted by James Chapman <jchapman@katalix.com>.
I didn't include the gcapatch because it's big and not very useful
since essentially all the functions in drivers/net/mv643xx_eth.c
have been reordered.
I will followup to this message with each individual changeset patch
(except for the code reorder changeset).
These changes depend on the previously accepted patch found in:
http://marc.theaimsgroup.com/?l=linux-netdev&m=111155864303860&w=2
Thank you,
Dale Farnsworth
Please do a
bk pull bk://dfarnsworth.bkbits.net/linux-2.5-mv643xx-enet
This will update the following files:
arch/ppc/platforms/katana.c | 24
arch/ppc/platforms/radstone_ppc7d.c | 25
drivers/net/Kconfig | 2
drivers/net/mv643xx_eth.c | 4186 ++++++++++++++++--------------------
drivers/net/mv643xx_eth.h | 235 +-
include/linux/mv643xx.h | 204 -
6 files changed, 2149 insertions(+), 2527 deletions(-)
through these ChangeSets:
<dale@farnsworth.org> (05/03/28 1.2252)
mv643xx: Fix promiscuous mode handling
mv643xx_eth_get_config_reg() was reading the wrong register.
mv643xx_eth_set_config_reg() was or'ing instead of setting the
register. These functions are trivial and both are called only from
mv643xx_eth_set_rx_mode() when changing the promiscuous mode. Remove both
functions and do the operations directly in mv643xx_eth_set_rx_mode().
Also, maintain promiscuous mode setting across port resets.
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2251)
mv643xx: Ensure NAPI poll routine only clears IRQs handled by itself
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2250)
mv643xx: Isolate the PHY at device close
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2249)
mv643xx: Reset the PHY only at driver open time
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2248)
mv643xx: Limit MTU to 1500 bytes unless connected at GigE speed
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2247)
mv643xx: Add James Chapman to copyright statement and author list
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2246)
mv643xx: whitespace and indentation cleanup
Code passed through Lindent to fixup some broken indentation and to
force consistent use of tabs. Unfortunately, very long macro names
used for register accesses mean keeping to the 80 char line length
constraint is impossible so several lines have been manually fixed up
and are longer than 80 chars.
There are no functional changes in this patch.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2245)
mv643xx: remove useless function header block comments
This driver was full of big function header block comments with Name,
Description, Parameter, Input, Output and ReturnValue clauses, most of
which were completely useless. The parameter tables made the code
difficult to maintain and they added no value anyway. Where the
description text was useful, I retained it in a simple comment block
above the function but (as in most cases) where even the description
added no value, I simply deleted the whole comment block.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2244)
mv643xx: reorder code to avoid prototype function declarations where possible.
This patch reorders functions to avoid the need for function
prototypes. In practice, low-level routines are moved to the top of
the file and driver API functions to the bottom. This is how most
Linux drivers are laid out.
There are no functional changes here.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2243)
mv643xx: rename all functions to have a common mv643xx_eth prefix.
This patch just establishes consistent function naming. No functional
changes here.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2242)
mv643xx: compile fix for non-NAPI case.
Compiles for the non-NAPI configuration were broken.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2241)
mv643xx: make internal functions take device pointer param consistently
Some internal driver functions take int port_num as a parameter to
identify the device. It makes no sense to hide the internal device
structure data from these routines so pass a pointer to the net_device
structure instead. Although in many cases the device data is needed only
to get the port number, this change makes the code more consistent and
easier to maintain.
Signed-off-by: James Chapman <jchapman@katalix.com>
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2240)
mv643xx: remove ETH_FUNC_RET_STATUS and unused ETH_TARGET enums.
The ETH_FUNC_RET_STATUS enum makes the driver code look more complex
than it needs to be so remove it. The ETH_TARGET enum was no longer
used so that goes as well.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2239)
mv643xx: move static prototypes from header file into driver C file.
Static function prototypes don't belong in a header file so move them
into the driver C file. Also add a check for valid port number at
device create to catch silly platform data errors.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2238)
mv643xx: use netif_msg_xxx() to control log messages where appropriate
Network driver messages can be controlled using ethtool msglvl via the
netif_msg_xxx() macros. This patch allows mv643xx's driver message
verbosity to be controlled by ethtool.
Some debug messages have also been added (not enabled by default) to
trace low-level (per packet) device access.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2237)
ppc32: update ppc7d platform for new mv643xx_eth platform data
This patch updates the ethernet device platform data of Radstone
PPC7D.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2236)
ppc32: Update Artesyn katana mv643xx ethernet platform data
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2235)
mv643xx: use MII library for ethtool functions
Use the common ethtool support functions of the MII library.
Add generic MII ioctl handler.
Add PHY parameter (speed/duplex/negotiation etc) modification support.
Signed-off-by: James Chapman <jchapman@katalix.com>
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2234)
mv643xx: use MII library for PHY management.
Modify link up/down handling to use the functions from the MII
library. Note that I track link state using the MII PHY registers
rather than the mv643xx chip's link state registers because I think
it's cleaner to use the MII library code rather than writing local
driver support code. It is also useful to make the actual MII
registers available to the user with maskable kernel printk messages
so the MII registers are being read anyway
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
<dale@farnsworth.org> (05/03/28 1.2233)
mv643xx: Add mv643xx_enet support for PPC Pegasos platform
Set SA_SHIRQ flag on call to request_irq()
Add MV643XX_ETH dependency on PPC_MULTIPLATFORM
Signed-off-by: Nicolas DET <nd@bplan-gmbh.de>
Signed-off-by: Sven Luther <sl@bplan-gmbh.de>
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(1/20): Add mv643xx_enet support for PPC Pegasos platform
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
@ 2005-03-28 23:40 ` Dale Farnsworth
2005-03-28 23:42 ` mv643xx(2/20): use MII library for PHY management Dale Farnsworth
` (18 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:40 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Set SA_SHIRQ flag on call to request_irq()
Add MV643XX_ETH dependency on PPC_MULTIPLATFORM
Signed-off-by: Nicolas DET <nd@bplan-gmbh.de>
Signed-off-by: Sven Luther <sl@bplan-gmbh.de>
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -668,7 +668,7 @@
spin_lock_irq(&mp->lock);
err = request_irq(dev->irq, mv643xx_eth_int_handler,
- SA_INTERRUPT | SA_SAMPLE_RANDOM, dev->name, dev);
+ SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
if (err) {
printk(KERN_ERR "Can not assign IRQ number to MV643XX_eth%d\n",
Index: linux-2.5-enet/drivers/net/Kconfig
===================================================================
--- linux-2.5-enet.orig/drivers/net/Kconfig
+++ linux-2.5-enet/drivers/net/Kconfig
@@ -2066,7 +2066,7 @@
config MV643XX_ETH
tristate "MV-643XX Ethernet support"
- depends on MOMENCO_OCELOT_C || MOMENCO_JAGUAR_ATX || MV64360 || MOMENCO_OCELOT_3
+ depends on MOMENCO_OCELOT_C || MOMENCO_JAGUAR_ATX || MV64360 || MOMENCO_OCELOT_3 || PPC_MULTIPLATFORM
help
This driver supports the gigabit Ethernet on the Marvell MV643XX
chipset which is used in the Momenco Ocelot C and Jaguar ATX and
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(2/20): use MII library for PHY management
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
2005-03-28 23:40 ` mv643xx(1/20): Add mv643xx_enet support for PPC Pegasos platform Dale Farnsworth
@ 2005-03-28 23:42 ` Dale Farnsworth
2005-08-24 0:34 ` Mark Huth
2005-03-28 23:43 ` mv643xx(3/20): use MII library for ethtool functions Dale Farnsworth
` (17 subsequent siblings)
19 siblings, 1 reply; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:42 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Modify link up/down handling to use the functions from the MII
library. Note that I track link state using the MII PHY registers
rather than the mv643xx chip's link state registers because I think
it's cleaner to use the MII library code rather than writing local
driver support code. It is also useful to make the actual MII
registers available to the user with maskable kernel printk messages
so the MII registers are being read anyway
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.h
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.h
+++ linux-2.5-enet/drivers/net/mv643xx_eth.h
@@ -6,6 +6,7 @@
#include <linux/kernel.h>
#include <linux/spinlock.h>
#include <linux/workqueue.h>
+#include <linux/mii.h>
#include <linux/mv643xx.h>
@@ -397,6 +398,9 @@
u32 rx_int_coal;
u32 tx_int_coal;
+
+ u32 msg_enable;
+ struct mii_if_info mii;
};
/* ethernet.h API list */
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -74,7 +74,6 @@
#define PHY_WAIT_MICRO_SECONDS 10
/* Static function declarations */
-static int eth_port_link_is_up(unsigned int eth_port_num);
static void eth_port_uc_addr_get(struct net_device *dev,
unsigned char *MacAddr);
static int mv643xx_eth_real_open(struct net_device *);
@@ -85,8 +84,11 @@
#ifdef MV643XX_NAPI
static int mv643xx_poll(struct net_device *dev, int *budget);
#endif
+static int ethernet_phy_get(unsigned int eth_port_num);
static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr);
static int ethernet_phy_detect(unsigned int eth_port_num);
+static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location);
+static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val);
static struct ethtool_ops mv643xx_ethtool_ops;
static char mv643xx_driver_name[] = "mv643xx_eth";
@@ -550,16 +552,38 @@
}
/* PHY status changed */
if (eth_int_cause_ext & (BIT16 | BIT20)) {
- if (eth_port_link_is_up(port_num)) {
- netif_carrier_on(dev);
+ struct ethtool_cmd cmd;
+
+ /* mii library handles link maintenance tasks */
+
+ mii_ethtool_gset(&mp->mii, &cmd);
+ if (netif_msg_link(mp))
+ printk(KERN_DEBUG "%s: link phy regs: "
+ "supported=%x advert=%x "
+ "autoneg=%x speed=%d duplex=%d\n",
+ dev->name,
+ cmd.supported, cmd.advertising,
+ cmd.autoneg, cmd.speed, cmd.duplex);
+
+ if(mii_link_ok(&mp->mii) && !netif_carrier_ok(dev)) {
+ if (netif_msg_ifup(mp))
+ printk(KERN_INFO "%s: link up, %sMbps, %s-duplex\n",
+ dev->name,
+ cmd.speed == SPEED_1000 ? "1000" :
+ cmd.speed == SPEED_100 ? "100" : "10",
+ cmd.duplex == DUPLEX_FULL ? "full" : "half");
+
netif_wake_queue(dev);
/* Start TX queue */
- mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG
- (port_num), 1);
- } else {
- netif_carrier_off(dev);
+ mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num), 1);
+
+ } else if(!mii_link_ok(&mp->mii) && netif_carrier_ok(dev)) {
netif_stop_queue(dev);
+ if (netif_msg_ifdown(mp))
+ printk(KERN_INFO "%s: link down\n", dev->name);
}
+
+ mii_check_link(&mp->mii);
}
/*
@@ -1379,6 +1403,10 @@
mp = netdev_priv(dev);
+ /* By default, log probe, interface up/down and error events */
+ mp->msg_enable = NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN |
+ NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR;
+
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
BUG_ON(!res);
dev->irq = res->start;
@@ -1415,6 +1443,15 @@
#endif
#endif
+ /* Hook up MII support for ethtool */
+ mp->mii.dev = dev;
+ mp->mii.mdio_read = mv643xx_mdio_read;
+ mp->mii.mdio_write = mv643xx_mdio_write;
+ mp->mii.phy_id = ethernet_phy_get(mp->port_num);
+ mp->mii.phy_id_mask = 0x3f;
+ mp->mii.reg_num_mask = 0x1f;
+ mp->mii.supports_gmii = 1;
+
/* Configure the timeout task */
INIT_WORK(&mp->tx_timeout_task,
(void (*)(void *))mv643xx_eth_tx_timeout_task, dev);
@@ -2323,21 +2360,6 @@
return phy_reg_data0 & 0x1000;
}
-static int eth_port_link_is_up(unsigned int eth_port_num)
-{
- unsigned int phy_reg_data1;
-
- eth_port_read_smi_reg(eth_port_num, 1, &phy_reg_data1);
-
- if (eth_port_autoneg_supported(eth_port_num)) {
- if (phy_reg_data1 & 0x20) /* auto-neg complete */
- return 1;
- } else if (phy_reg_data1 & 0x4) /* link up */
- return 1;
-
- return 0;
-}
-
/*
* ethernet_get_config_reg - Get the port configuration register
*
@@ -2468,6 +2490,24 @@
}
/*
+ * Wrappers for MII support library.
+ */
+static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location)
+{
+ int val;
+ struct mv643xx_private *mp = netdev_priv(dev);
+
+ eth_port_read_smi_reg(mp->port_num, location, &val);
+ return val;
+}
+
+static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val)
+{
+ struct mv643xx_private *mp = netdev_priv(dev);
+ eth_port_write_smi_reg(mp->port_num, location, val);
+}
+
+/*
* eth_port_send - Send an Ethernet packet
*
* DESCRIPTION:
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(3/20): use MII library for ethtool functions
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
2005-03-28 23:40 ` mv643xx(1/20): Add mv643xx_enet support for PPC Pegasos platform Dale Farnsworth
2005-03-28 23:42 ` mv643xx(2/20): use MII library for PHY management Dale Farnsworth
@ 2005-03-28 23:43 ` Dale Farnsworth
2005-03-28 23:44 ` mv643xx(4/20): Update the Artesyn katana mv643xx ethernet platform data Dale Farnsworth
` (16 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:43 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Use the common ethtool support functions of the MII library.
Add generic MII ioctl handler.
Add PHY parameter (speed/duplex/negotiation etc) modification support.
Signed-off-by: James Chapman <jchapman@katalix.com>
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -89,6 +89,7 @@
static int ethernet_phy_detect(unsigned int eth_port_num);
static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location);
static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val);
+static int mv643xx_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
static struct ethtool_ops mv643xx_ethtool_ops;
static char mv643xx_driver_name[] = "mv643xx_eth";
@@ -670,6 +671,115 @@
return coal;
}
+/* Set the mv643xx port configuration for the speed/duplex mode.
+ * In the MV643XX PSCR, the following bits are defined:
+ * Bit2 - AN_Duplex, autoneg duplex, 0=>enable
+ * Bit13 - AN_Speed, autoneg speed, 0=>enable
+ * Bit21 - Set_Fdx, set full duplex. 1=>FD
+ * Bit23 - Set_GMII_Speed, 0=>10/100, 1=>1000
+ * Bit24 - Set_MII_Speed, 0=>10, 1=>100
+ */
+static void mv643xx_eth_update_pscr(struct net_device *dev,
+ struct ethtool_cmd *cmd)
+{
+ struct mv643xx_private *mp = netdev_priv(dev);
+
+ mp->port_serial_control &= ~(BIT2 | BIT13 | BIT21 | BIT23 | BIT24);
+ if (!cmd->autoneg)
+ mp->port_serial_control |= BIT2 | BIT13;
+
+ if (cmd->duplex)
+ mp->port_serial_control |= BIT21;
+
+ if (cmd->speed == SPEED_100)
+ mp->port_serial_control |= BIT24;
+ else if (cmd->speed == SPEED_1000)
+ mp->port_serial_control |= BIT23;
+}
+
+static int mv643xx_set_settings(struct net_device *dev,
+ struct ethtool_cmd *cmd)
+{
+ struct mv643xx_private *mp = netdev_priv(dev);
+ int err;
+
+ /* If we get here, the user wants to configure specific
+ * settings. There are 2 cases: autonegotiation on/off. When
+ * autoneg is off, the PHY is forced to a specific mode. When
+ * autoneg is on, we enable/disable specified negotiation
+ * parameters.
+ */
+ cmd->advertising &= ~(ADVERTISED_10baseT_Half |
+ ADVERTISED_10baseT_Full |
+ ADVERTISED_100baseT_Half |
+ ADVERTISED_100baseT_Full |
+ ADVERTISED_1000baseT_Half |
+ ADVERTISED_1000baseT_Full);
+ if (!cmd->autoneg) {
+ switch (cmd->speed) {
+ case SPEED_10:
+ cmd->advertising |= ADVERTISED_10baseT_Half;
+ if (cmd->duplex == DUPLEX_FULL)
+ cmd->advertising |= ADVERTISED_10baseT_Full;
+ break;
+ case SPEED_100:
+ cmd->advertising |= ADVERTISED_100baseT_Half;
+ if (cmd->duplex == DUPLEX_FULL)
+ cmd->advertising |= ADVERTISED_100baseT_Full;
+ break;
+ case SPEED_1000:
+ if (cmd->duplex == DUPLEX_FULL)
+ cmd->advertising |= ADVERTISED_1000baseT_Full;
+ else
+ return -EINVAL;
+ break;
+ }
+ } else {
+ switch (cmd->speed) {
+ default:
+ case SPEED_1000:
+ if (cmd->duplex == DUPLEX_FULL)
+ cmd->advertising |= ADVERTISED_1000baseT_Full;
+ else
+ return -EINVAL;
+ /* NOBREAK */
+ case SPEED_100:
+ cmd->advertising |= ADVERTISED_100baseT_Half;
+ if (cmd->duplex == DUPLEX_FULL)
+ cmd->advertising |= ADVERTISED_100baseT_Full;
+ /* NOBREAK */
+ case SPEED_10:
+ cmd->advertising |= ADVERTISED_10baseT_Half;
+ if (cmd->duplex == DUPLEX_FULL)
+ cmd->advertising |= ADVERTISED_10baseT_Full;
+ /* NOBREAK */
+ }
+ }
+
+ /* Reconfigure the PHY */
+ err = mii_ethtool_sset(&mp->mii, cmd);
+ if (err)
+ return err;
+
+ mv643xx_eth_update_pscr(dev, cmd);
+
+ memcpy(&mp->ethtool_cmd, cmd, sizeof *cmd);
+
+ /* Restart the port with new settings. This will use the value
+ * of port_serial_control that was configured above.
+ */
+ if (netif_running(dev)) {
+ if (mv643xx_eth_real_stop(dev))
+ printk(KERN_ERR "%s: Fatal error on stopping "
+ "device\n", dev->name);
+ if (mv643xx_eth_real_open(dev))
+ printk(KERN_ERR "%s: Fatal error on opening "
+ "device\n", dev->name);
+ }
+
+ return 0;
+}
+
/*
* mv643xx_eth_open
*
@@ -708,6 +818,9 @@
}
spin_unlock_irq(&mp->lock);
+
+ if (mp->ethtool_cmd.autoneg || mp->ethtool_cmd.speed)
+ mv643xx_set_settings(dev, &mp->ethtool_cmd);
return 0;
@@ -1394,6 +1507,7 @@
u8 *p;
struct resource *res;
int err;
+ struct ethtool_cmd *ecmd;
dev = alloc_etherdev(sizeof(struct mv643xx_private));
if (!dev)
@@ -1431,6 +1545,7 @@
dev->tx_queue_len = mp->tx_ring_size;
dev->base_addr = 0;
dev->change_mtu = mv643xx_eth_change_mtu;
+ dev->do_ioctl = mv643xx_eth_do_ioctl;
SET_ETHTOOL_OPS(dev, &mv643xx_ethtool_ops);
#ifdef MV643XX_CHECKSUM_OFFLOAD_TX
@@ -1443,15 +1558,6 @@
#endif
#endif
- /* Hook up MII support for ethtool */
- mp->mii.dev = dev;
- mp->mii.mdio_read = mv643xx_mdio_read;
- mp->mii.mdio_write = mv643xx_mdio_write;
- mp->mii.phy_id = ethernet_phy_get(mp->port_num);
- mp->mii.phy_id_mask = 0x3f;
- mp->mii.reg_num_mask = 0x1f;
- mp->mii.supports_gmii = 1;
-
/* Configure the timeout task */
INIT_WORK(&mp->tx_timeout_task,
(void (*)(void *))mv643xx_eth_tx_timeout_task, dev);
@@ -1460,33 +1566,20 @@
/* set default config values */
eth_port_uc_addr_get(dev, dev->dev_addr);
- mp->port_config = MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE;
- mp->port_config_extend = MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE;
- mp->port_sdma_config = MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE;
- mp->port_serial_control = MV643XX_ETH_PORT_SERIAL_CONTROL_DEFAULT_VALUE;
+ mp->port_serial_control =
+ mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
+ mp->port_serial_control &= ~MV643XX_ETH_SERIAL_PORT_ENABLE;
+ mp->port_serial_control |= MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL |
+ MV643XX_ETH_SERIAL_PORT_CONTROL_RESERVED |
+ MV643XX_ETH_DO_NOT_FORCE_LINK_FAIL;
mp->rx_ring_size = MV643XX_ETH_PORT_DEFAULT_RECEIVE_QUEUE_SIZE;
mp->tx_ring_size = MV643XX_ETH_PORT_DEFAULT_TRANSMIT_QUEUE_SIZE;
pd = pdev->dev.platform_data;
if (pd) {
- if (pd->mac_addr != NULL)
+ if (pd->mac_addr)
memcpy(dev->dev_addr, pd->mac_addr, 6);
- if (pd->phy_addr || pd->force_phy_addr)
- ethernet_phy_set(port_num, pd->phy_addr);
-
- if (pd->port_config || pd->force_port_config)
- mp->port_config = pd->port_config;
-
- if (pd->port_config_extend || pd->force_port_config_extend)
- mp->port_config_extend = pd->port_config_extend;
-
- if (pd->port_sdma_config || pd->force_port_sdma_config)
- mp->port_sdma_config = pd->port_sdma_config;
-
- if (pd->port_serial_control || pd->force_port_serial_control)
- mp->port_serial_control = pd->port_serial_control;
-
if (pd->rx_queue_size)
mp->rx_ring_size = pd->rx_queue_size;
@@ -1502,8 +1595,32 @@
mp->rx_sram_size = pd->rx_sram_size;
mp->rx_sram_addr = pd->rx_sram_addr;
}
+
+ if (pd->ethtool_cmd) {
+ ecmd = pd->ethtool_cmd;
+ if (ecmd->advertising == 0)
+ ecmd->advertising = ADVERTISED_10baseT_Half |
+ ADVERTISED_10baseT_Full |
+ ADVERTISED_100baseT_Half |
+ ADVERTISED_100baseT_Full |
+ ADVERTISED_1000baseT_Full |
+ ADVERTISED_Autoneg |
+ ADVERTISED_MII;
+
+ ethernet_phy_set(port_num, ecmd->phy_address);
+ memcpy(&mp->ethtool_cmd, ecmd, sizeof *ecmd);
+ mv643xx_eth_update_pscr(dev, ecmd);
+ }
}
+ /* Hook up MII support for ethtool */
+ mp->mii.dev = dev;
+ mp->mii.mdio_read = mv643xx_mdio_read;
+ mp->mii.mdio_write = mv643xx_mdio_write;
+ mp->mii.phy_id = ethernet_phy_get(port_num);
+ mp->mii.phy_id_mask = 0x3f;
+ mp->mii.reg_num_mask = 0x1f;
+
err = ethernet_phy_detect(port_num);
if (err) {
pr_debug("MV643xx ethernet port %d: "
@@ -1516,6 +1633,8 @@
if (err)
goto out;
+ mp->mii.supports_gmii = mii_check_gmii_support(&mp->mii);
+
p = dev->dev_addr;
printk(KERN_NOTICE
"%s: port %d with MAC address %02x:%02x:%02x:%02x:%02x:%02x\n",
@@ -1888,10 +2007,15 @@
eth_port_uc_addr_set(port_num, mp->port_mac_addr);
/* Assign port configuration and command. */
- mv_write(MV643XX_ETH_PORT_CONFIG_REG(port_num), mp->port_config);
+ mv_write(MV643XX_ETH_PORT_CONFIG_REG(port_num),
+ MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE);
mv_write(MV643XX_ETH_PORT_CONFIG_EXTEND_REG(port_num),
- mp->port_config_extend);
+ MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE);
+
+ /* the mv643xx users manual says the following read/write are needed */
+ mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
+ mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), 0);
/* Increase the Rx side buffer size if supporting GigE */
@@ -1903,12 +2027,12 @@
mp->port_serial_control);
mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
- mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num)) |
- MV643XX_ETH_SERIAL_PORT_ENABLE);
+ mp->port_serial_control |
+ MV643XX_ETH_SERIAL_PORT_ENABLE);
/* Assign port SDMA configuration */
mv_write(MV643XX_ETH_SDMA_CONFIG_REG(port_num),
- mp->port_sdma_config);
+ MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE);
/* Enable port Rx. */
mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num),
@@ -2351,15 +2475,6 @@
mv_write(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num), eth_config_reg);
}
-static int eth_port_autoneg_supported(unsigned int eth_port_num)
-{
- unsigned int phy_reg_data0;
-
- eth_port_read_smi_reg(eth_port_num, 0, &phy_reg_data0);
-
- return phy_reg_data0 & 0x1000;
-}
-
/*
* ethernet_get_config_reg - Get the port configuration register
*
@@ -2908,106 +3023,17 @@
static int
mv643xx_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
{
- struct mv643xx_private *mp = netdev->priv;
- int port_num = mp->port_num;
- int autoneg = eth_port_autoneg_supported(port_num);
- int mode_10_bit;
- int auto_duplex;
- int half_duplex = 0;
- int full_duplex = 0;
- int auto_speed;
- int speed_10 = 0;
- int speed_100 = 0;
- int speed_1000 = 0;
-
- u32 pcs = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
- u32 psr = mv_read(MV643XX_ETH_PORT_STATUS_REG(port_num));
-
- mode_10_bit = psr & MV643XX_ETH_PORT_STATUS_MODE_10_BIT;
-
- if (mode_10_bit) {
- ecmd->supported = SUPPORTED_10baseT_Half;
- } else {
- ecmd->supported = (SUPPORTED_10baseT_Half |
- SUPPORTED_10baseT_Full |
- SUPPORTED_100baseT_Half |
- SUPPORTED_100baseT_Full |
- SUPPORTED_1000baseT_Full |
- (autoneg ? SUPPORTED_Autoneg : 0) |
- SUPPORTED_TP);
-
- auto_duplex = !(pcs & MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX);
- auto_speed = !(pcs & MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII);
-
- ecmd->advertising = ADVERTISED_TP;
-
- if (autoneg) {
- ecmd->advertising |= ADVERTISED_Autoneg;
-
- if (auto_duplex) {
- half_duplex = 1;
- full_duplex = 1;
- } else {
- if (pcs & MV643XX_ETH_SET_FULL_DUPLEX_MODE)
- full_duplex = 1;
- else
- half_duplex = 1;
- }
-
- if (auto_speed) {
- speed_10 = 1;
- speed_100 = 1;
- speed_1000 = 1;
- } else {
- if (pcs & MV643XX_ETH_SET_GMII_SPEED_TO_1000)
- speed_1000 = 1;
- else if (pcs & MV643XX_ETH_SET_MII_SPEED_TO_100)
- speed_100 = 1;
- else
- speed_10 = 1;
- }
-
- if (speed_10 & half_duplex)
- ecmd->advertising |= ADVERTISED_10baseT_Half;
- if (speed_10 & full_duplex)
- ecmd->advertising |= ADVERTISED_10baseT_Full;
- if (speed_100 & half_duplex)
- ecmd->advertising |= ADVERTISED_100baseT_Half;
- if (speed_100 & full_duplex)
- ecmd->advertising |= ADVERTISED_100baseT_Full;
- if (speed_1000)
- ecmd->advertising |= ADVERTISED_1000baseT_Full;
- }
- }
+ int rc;
+ struct mv643xx_private *mp = netdev_priv(netdev);
- ecmd->port = PORT_TP;
- ecmd->phy_address = ethernet_phy_get(port_num);
-
- ecmd->transceiver = XCVR_EXTERNAL;
-
- if (netif_carrier_ok(netdev)) {
- if (mode_10_bit)
- ecmd->speed = SPEED_10;
- else {
- if (psr & MV643XX_ETH_PORT_STATUS_GMII_1000)
- ecmd->speed = SPEED_1000;
- else if (psr & MV643XX_ETH_PORT_STATUS_MII_100)
- ecmd->speed = SPEED_100;
- else
- ecmd->speed = SPEED_10;
- }
+ ecmd->supported = SUPPORTED_MII;
+ ecmd->port = PORT_MII;
+ rc = mii_ethtool_gset(&mp->mii, ecmd);
- if (psr & MV643XX_ETH_PORT_STATUS_FULL_DUPLEX)
- ecmd->duplex = DUPLEX_FULL;
- else
- ecmd->duplex = DUPLEX_HALF;
- } else {
- ecmd->speed = -1;
- ecmd->duplex = -1;
- }
+ ecmd->supported &= ~SUPPORTED_1000baseT_Half;
+ ecmd->advertising &= ~ADVERTISED_1000baseT_Half;
- ecmd->autoneg = autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE;
- return 0;
+ return rc;
}
static void
@@ -3059,15 +3085,54 @@
}
}
+static u32 mv643xx_eth_get_msglevel(struct net_device *dev)
+{
+ struct mv643xx_private *mp = netdev_priv(dev);
+ return mp->msg_enable;
+}
+
+static void mv643xx_eth_set_msglevel(struct net_device *dev, u32 value)
+{
+ struct mv643xx_private *mp = netdev_priv(dev);
+ mp->msg_enable = value;
+}
+
+static u32 mv643xx_eth_get_link(struct net_device *dev)
+{
+ struct mv643xx_private *mp = netdev_priv(dev);
+ return mii_link_ok(&mp->mii);
+}
+
+static int mv643xx_eth_nway_restart(struct net_device *dev)
+{
+ struct mv643xx_private *mp = netdev_priv(dev);
+
+ return mii_nway_restart(&mp->mii);
+}
+
+static int mv643xx_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+ struct mv643xx_private *mp = netdev_priv(dev);
+
+ return generic_mii_ioctl(&mp->mii, if_mii(ifr), cmd, NULL);
+}
+
static struct ethtool_ops mv643xx_ethtool_ops = {
.get_settings = mv643xx_get_settings,
+ .set_settings = mv643xx_set_settings,
.get_drvinfo = mv643xx_get_drvinfo,
- .get_link = ethtool_op_get_link,
+ .get_link = mv643xx_eth_get_link,
.get_sg = ethtool_op_get_sg,
.set_sg = ethtool_op_set_sg,
.get_strings = mv643xx_get_strings,
.get_stats_count = mv643xx_get_stats_count,
.get_ethtool_stats = mv643xx_get_ethtool_stats,
+ .get_strings = mv643xx_get_strings,
+ .get_stats_count = mv643xx_get_stats_count,
+ .get_ethtool_stats = mv643xx_get_ethtool_stats,
+ .get_msglevel = mv643xx_eth_get_msglevel,
+ .set_msglevel = mv643xx_eth_set_msglevel,
+ .nway_reset = mv643xx_eth_nway_restart,
};
/************* End ethtool support *************************/
Index: linux-2.5-enet/drivers/net/mv643xx_eth.h
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.h
+++ linux-2.5-enet/drivers/net/mv643xx_eth.h
@@ -156,6 +156,171 @@
#define ETH_PORT_TX_FIFO_NOT_EMPTY 0
#define ETH_PORT_TX_FIFO_EMPTY BIT10
+/* These macros describe Ethernet Port configuration reg (Px_cR) bits */
+#define MV643XX_ETH_UNICAST_NORMAL_MODE 0
+#define MV643XX_ETH_UNICAST_PROMISCUOUS_MODE (1<<0)
+#define MV643XX_ETH_DEFAULT_RX_QUEUE_0 0
+#define MV643XX_ETH_DEFAULT_RX_QUEUE_1 (1<<1)
+#define MV643XX_ETH_DEFAULT_RX_QUEUE_2 (1<<2)
+#define MV643XX_ETH_DEFAULT_RX_QUEUE_3 ((1<<2) | (1<<1))
+#define MV643XX_ETH_DEFAULT_RX_QUEUE_4 (1<<3)
+#define MV643XX_ETH_DEFAULT_RX_QUEUE_5 ((1<<3) | (1<<1))
+#define MV643XX_ETH_DEFAULT_RX_QUEUE_6 ((1<<3) | (1<<2))
+#define MV643XX_ETH_DEFAULT_RX_QUEUE_7 ((1<<3) | (1<<2) | (1<<1))
+#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_0 0
+#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_1 (1<<4)
+#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_2 (1<<5)
+#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_3 ((1<<5) | (1<<4))
+#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_4 (1<<6)
+#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_5 ((1<<6) | (1<<4))
+#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_6 ((1<<6) | (1<<5))
+#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_7 ((1<<6) | (1<<5) | (1<<4))
+#define MV643XX_ETH_RECEIVE_BC_IF_NOT_IP_OR_ARP 0
+#define MV643XX_ETH_REJECT_BC_IF_NOT_IP_OR_ARP (1<<7)
+#define MV643XX_ETH_RECEIVE_BC_IF_IP 0
+#define MV643XX_ETH_REJECT_BC_IF_IP (1<<8)
+#define MV643XX_ETH_RECEIVE_BC_IF_ARP 0
+#define MV643XX_ETH_REJECT_BC_IF_ARP (1<<9)
+#define MV643XX_ETH_TX_AM_NO_UPDATE_ERROR_SUMMARY (1<<12)
+#define MV643XX_ETH_CAPTURE_TCP_FRAMES_DIS 0
+#define MV643XX_ETH_CAPTURE_TCP_FRAMES_EN (1<<14)
+#define MV643XX_ETH_CAPTURE_UDP_FRAMES_DIS 0
+#define MV643XX_ETH_CAPTURE_UDP_FRAMES_EN (1<<15)
+#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_0 0
+#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_1 (1<<16)
+#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_2 (1<<17)
+#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_3 ((1<<17) | (1<<16))
+#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_4 (1<<18)
+#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_5 ((1<<18) | (1<<16))
+#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_6 ((1<<18) | (1<<17))
+#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_7 ((1<<18) | (1<<17) | (1<<16))
+#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_0 0
+#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_1 (1<<19)
+#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_2 (1<<20)
+#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_3 ((1<<20) | (1<<19))
+#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_4 ((1<<21)
+#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_5 ((1<<21) | (1<<19))
+#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_6 ((1<<21) | (1<<20))
+#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_7 ((1<<21) | (1<<20) | (1<<19))
+#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_0 0
+#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_1 (1<<22)
+#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_2 (1<<23)
+#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_3 ((1<<23) | (1<<22))
+#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_4 (1<<24)
+#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_5 ((1<<24) | (1<<22))
+#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_6 ((1<<24) | (1<<23))
+#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_7 ((1<<24) | (1<<23) | (1<<22))
+
+#define MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE \
+ MV643XX_ETH_UNICAST_NORMAL_MODE | \
+ MV643XX_ETH_DEFAULT_RX_QUEUE_0 | \
+ MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_0 | \
+ MV643XX_ETH_RECEIVE_BC_IF_NOT_IP_OR_ARP | \
+ MV643XX_ETH_RECEIVE_BC_IF_IP | \
+ MV643XX_ETH_RECEIVE_BC_IF_ARP | \
+ MV643XX_ETH_CAPTURE_TCP_FRAMES_DIS | \
+ MV643XX_ETH_CAPTURE_UDP_FRAMES_DIS | \
+ MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_0 | \
+ MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_0 | \
+ MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_0
+
+/* These macros describe Ethernet Port configuration extend reg (Px_cXR) bits*/
+#define MV643XX_ETH_CLASSIFY_EN (1<<0)
+#define MV643XX_ETH_SPAN_BPDU_PACKETS_AS_NORMAL 0
+#define MV643XX_ETH_SPAN_BPDU_PACKETS_TO_RX_QUEUE_7 (1<<1)
+#define MV643XX_ETH_PARTITION_DISABLE 0
+#define MV643XX_ETH_PARTITION_ENABLE (1<<2)
+
+#define MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE \
+ MV643XX_ETH_SPAN_BPDU_PACKETS_AS_NORMAL | \
+ MV643XX_ETH_PARTITION_DISABLE
+
+/* These macros describe Ethernet Port Sdma configuration reg (SDCR) bits */
+#define MV643XX_ETH_RIFB (1<<0)
+#define MV643XX_ETH_RX_BURST_SIZE_1_64BIT 0
+#define MV643XX_ETH_RX_BURST_SIZE_2_64BIT (1<<1)
+#define MV643XX_ETH_RX_BURST_SIZE_4_64BIT (1<<2)
+#define MV643XX_ETH_RX_BURST_SIZE_8_64BIT ((1<<2) | (1<<1))
+#define MV643XX_ETH_RX_BURST_SIZE_16_64BIT (1<<3)
+#define MV643XX_ETH_BLM_RX_NO_SWAP (1<<4)
+#define MV643XX_ETH_BLM_RX_BYTE_SWAP 0
+#define MV643XX_ETH_BLM_TX_NO_SWAP (1<<5)
+#define MV643XX_ETH_BLM_TX_BYTE_SWAP 0
+#define MV643XX_ETH_DESCRIPTORS_BYTE_SWAP (1<<6)
+#define MV643XX_ETH_DESCRIPTORS_NO_SWAP 0
+#define MV643XX_ETH_TX_BURST_SIZE_1_64BIT 0
+#define MV643XX_ETH_TX_BURST_SIZE_2_64BIT (1<<22)
+#define MV643XX_ETH_TX_BURST_SIZE_4_64BIT (1<<23)
+#define MV643XX_ETH_TX_BURST_SIZE_8_64BIT ((1<<23) | (1<<22))
+#define MV643XX_ETH_TX_BURST_SIZE_16_64BIT (1<<24)
+
+#define MV643XX_ETH_IPG_INT_RX(value) ((value & 0x3fff) << 8)
+
+#define MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE \
+ MV643XX_ETH_RX_BURST_SIZE_4_64BIT | \
+ MV643XX_ETH_IPG_INT_RX(0) | \
+ MV643XX_ETH_TX_BURST_SIZE_4_64BIT
+
+/* These macros describe Ethernet Port serial control reg (PSCR) bits */
+#define MV643XX_ETH_SERIAL_PORT_DISABLE 0
+#define MV643XX_ETH_SERIAL_PORT_ENABLE (1<<0)
+#define MV643XX_ETH_FORCE_LINK_PASS (1<<1)
+#define MV643XX_ETH_DO_NOT_FORCE_LINK_PASS 0
+#define MV643XX_ETH_ENABLE_AUTO_NEG_FOR_DUPLX 0
+#define MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX (1<<2)
+#define MV643XX_ETH_ENABLE_AUTO_NEG_FOR_FLOW_CTRL 0
+#define MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL (1<<3)
+#define MV643XX_ETH_ADV_NO_FLOW_CTRL 0
+#define MV643XX_ETH_ADV_SYMMETRIC_FLOW_CTRL (1<<4)
+#define MV643XX_ETH_FORCE_FC_MODE_NO_PAUSE_DIS_TX 0
+#define MV643XX_ETH_FORCE_FC_MODE_TX_PAUSE_DIS (1<<5)
+#define MV643XX_ETH_FORCE_BP_MODE_NO_JAM 0
+#define MV643XX_ETH_FORCE_BP_MODE_JAM_TX (1<<7)
+#define MV643XX_ETH_FORCE_BP_MODE_JAM_TX_ON_RX_ERR (1<<8)
+#define MV643XX_ETH_FORCE_LINK_FAIL 0
+#define MV643XX_ETH_SERIAL_PORT_CONTROL_RESERVED (1<<9)
+#define MV643XX_ETH_DO_NOT_FORCE_LINK_FAIL (1<<10)
+#define MV643XX_ETH_RETRANSMIT_16_ATTEMPTS 0
+#define MV643XX_ETH_RETRANSMIT_FOREVER (1<<11)
+#define MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII (1<<13)
+#define MV643XX_ETH_ENABLE_AUTO_NEG_SPEED_GMII 0
+#define MV643XX_ETH_DTE_ADV_0 0
+#define MV643XX_ETH_DTE_ADV_1 (1<<14)
+#define MV643XX_ETH_DISABLE_AUTO_NEG_BYPASS 0
+#define MV643XX_ETH_ENABLE_AUTO_NEG_BYPASS (1<<15)
+#define MV643XX_ETH_AUTO_NEG_NO_CHANGE 0
+#define MV643XX_ETH_RESTART_AUTO_NEG (1<<16)
+#define MV643XX_ETH_MAX_RX_PACKET_1518BYTE 0
+#define MV643XX_ETH_MAX_RX_PACKET_1522BYTE (1<<17)
+#define MV643XX_ETH_MAX_RX_PACKET_1552BYTE (1<<18)
+#define MV643XX_ETH_MAX_RX_PACKET_9022BYTE ((1<<18) | (1<<17))
+#define MV643XX_ETH_MAX_RX_PACKET_9192BYTE (1<<19)
+#define MV643XX_ETH_MAX_RX_PACKET_9700BYTE ((1<<19) | (1<<17))
+#define MV643XX_ETH_SET_EXT_LOOPBACK (1<<20)
+#define MV643XX_ETH_CLR_EXT_LOOPBACK 0
+#define MV643XX_ETH_SET_FULL_DUPLEX_MODE (1<<21)
+#define MV643XX_ETH_SET_HALF_DUPLEX_MODE 0
+#define MV643XX_ETH_ENABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX (1<<22)
+#define MV643XX_ETH_DISABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX 0
+#define MV643XX_ETH_SET_GMII_SPEED_TO_10_100 0
+#define MV643XX_ETH_SET_GMII_SPEED_TO_1000 (1<<23)
+#define MV643XX_ETH_SET_MII_SPEED_TO_10 0
+#define MV643XX_ETH_SET_MII_SPEED_TO_100 (1<<24)
+
+/* These macros describe Ethernet Serial Status reg (PSR) bits */
+#define MV643XX_ETH_PORT_STATUS_MODE_10_BIT (1<<0)
+#define MV643XX_ETH_PORT_STATUS_LINK_UP (1<<1)
+#define MV643XX_ETH_PORT_STATUS_FULL_DUPLEX (1<<2)
+#define MV643XX_ETH_PORT_STATUS_FLOW_CONTROL (1<<3)
+#define MV643XX_ETH_PORT_STATUS_GMII_1000 (1<<4)
+#define MV643XX_ETH_PORT_STATUS_MII_100 (1<<5)
+/* PSR bit 6 is undocumented */
+#define MV643XX_ETH_PORT_STATUS_TX_IN_PROGRESS (1<<7)
+#define MV643XX_ETH_PORT_STATUS_AUTONEG_BYPASSED (1<<8)
+#define MV643XX_ETH_PORT_STATUS_PARTITION (1<<9)
+#define MV643XX_ETH_PORT_STATUS_TX_FIFO_EMPTY (1<<10)
+/* PSR bits 11-31 are reserved */
+
#define ETH_DEFAULT_RX_BPDU_QUEUE_3 (BIT23 | BIT22)
#define ETH_DEFAULT_RX_BPDU_QUEUE_4 BIT24
#define ETH_DEFAULT_RX_BPDU_QUEUE_5 (BIT24 | BIT22)
@@ -325,10 +490,8 @@
struct mv643xx_private {
int port_num; /* User Ethernet port number */
u8 port_mac_addr[6]; /* User defined port MAC address.*/
- u32 port_config; /* User port configuration value*/
- u32 port_config_extend; /* User port config extend value*/
- u32 port_sdma_config; /* User port SDMA config value */
- u32 port_serial_control; /* User port serial control value */
+ u32 port_serial_control; /* Port serial control value */
+ struct ethtool_cmd ethtool_cmd; /* ethtool_cmd used at open */
u32 port_tx_queue_command; /* Port active Tx queues summary*/
u32 port_rx_queue_command; /* Port active Rx queues summary*/
Index: linux-2.5-enet/include/linux/mv643xx.h
===================================================================
--- linux-2.5-enet.orig/include/linux/mv643xx.h
+++ linux-2.5-enet/include/linux/mv643xx.h
@@ -1093,189 +1093,6 @@
u32 retries;
};
-/* These macros describe Ethernet Port configuration reg (Px_cR) bits */
-#define MV643XX_ETH_UNICAST_NORMAL_MODE 0
-#define MV643XX_ETH_UNICAST_PROMISCUOUS_MODE (1<<0)
-#define MV643XX_ETH_DEFAULT_RX_QUEUE_0 0
-#define MV643XX_ETH_DEFAULT_RX_QUEUE_1 (1<<1)
-#define MV643XX_ETH_DEFAULT_RX_QUEUE_2 (1<<2)
-#define MV643XX_ETH_DEFAULT_RX_QUEUE_3 ((1<<2) | (1<<1))
-#define MV643XX_ETH_DEFAULT_RX_QUEUE_4 (1<<3)
-#define MV643XX_ETH_DEFAULT_RX_QUEUE_5 ((1<<3) | (1<<1))
-#define MV643XX_ETH_DEFAULT_RX_QUEUE_6 ((1<<3) | (1<<2))
-#define MV643XX_ETH_DEFAULT_RX_QUEUE_7 ((1<<3) | (1<<2) | (1<<1))
-#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_0 0
-#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_1 (1<<4)
-#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_2 (1<<5)
-#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_3 ((1<<5) | (1<<4))
-#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_4 (1<<6)
-#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_5 ((1<<6) | (1<<4))
-#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_6 ((1<<6) | (1<<5))
-#define MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_7 ((1<<6) | (1<<5) | (1<<4))
-#define MV643XX_ETH_RECEIVE_BC_IF_NOT_IP_OR_ARP 0
-#define MV643XX_ETH_REJECT_BC_IF_NOT_IP_OR_ARP (1<<7)
-#define MV643XX_ETH_RECEIVE_BC_IF_IP 0
-#define MV643XX_ETH_REJECT_BC_IF_IP (1<<8)
-#define MV643XX_ETH_RECEIVE_BC_IF_ARP 0
-#define MV643XX_ETH_REJECT_BC_IF_ARP (1<<9)
-#define MV643XX_ETH_TX_AM_NO_UPDATE_ERROR_SUMMARY (1<<12)
-#define MV643XX_ETH_CAPTURE_TCP_FRAMES_DIS 0
-#define MV643XX_ETH_CAPTURE_TCP_FRAMES_EN (1<<14)
-#define MV643XX_ETH_CAPTURE_UDP_FRAMES_DIS 0
-#define MV643XX_ETH_CAPTURE_UDP_FRAMES_EN (1<<15)
-#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_0 0
-#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_1 (1<<16)
-#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_2 (1<<17)
-#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_3 ((1<<17) | (1<<16))
-#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_4 (1<<18)
-#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_5 ((1<<18) | (1<<16))
-#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_6 ((1<<18) | (1<<17))
-#define MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_7 ((1<<18) | (1<<17) | (1<<16))
-#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_0 0
-#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_1 (1<<19)
-#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_2 (1<<20)
-#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_3 ((1<<20) | (1<<19))
-#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_4 ((1<<21)
-#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_5 ((1<<21) | (1<<19))
-#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_6 ((1<<21) | (1<<20))
-#define MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_7 ((1<<21) | (1<<20) | (1<<19))
-#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_0 0
-#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_1 (1<<22)
-#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_2 (1<<23)
-#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_3 ((1<<23) | (1<<22))
-#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_4 (1<<24)
-#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_5 ((1<<24) | (1<<22))
-#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_6 ((1<<24) | (1<<23))
-#define MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_7 ((1<<24) | (1<<23) | (1<<22))
-
-#define MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE \
- MV643XX_ETH_UNICAST_NORMAL_MODE | \
- MV643XX_ETH_DEFAULT_RX_QUEUE_0 | \
- MV643XX_ETH_DEFAULT_RX_ARP_QUEUE_0 | \
- MV643XX_ETH_RECEIVE_BC_IF_NOT_IP_OR_ARP | \
- MV643XX_ETH_RECEIVE_BC_IF_IP | \
- MV643XX_ETH_RECEIVE_BC_IF_ARP | \
- MV643XX_ETH_CAPTURE_TCP_FRAMES_DIS | \
- MV643XX_ETH_CAPTURE_UDP_FRAMES_DIS | \
- MV643XX_ETH_DEFAULT_RX_TCP_QUEUE_0 | \
- MV643XX_ETH_DEFAULT_RX_UDP_QUEUE_0 | \
- MV643XX_ETH_DEFAULT_RX_BPDU_QUEUE_0
-
-/* These macros describe Ethernet Port configuration extend reg (Px_cXR) bits*/
-#define MV643XX_ETH_CLASSIFY_EN (1<<0)
-#define MV643XX_ETH_SPAN_BPDU_PACKETS_AS_NORMAL 0
-#define MV643XX_ETH_SPAN_BPDU_PACKETS_TO_RX_QUEUE_7 (1<<1)
-#define MV643XX_ETH_PARTITION_DISABLE 0
-#define MV643XX_ETH_PARTITION_ENABLE (1<<2)
-
-#define MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE \
- MV643XX_ETH_SPAN_BPDU_PACKETS_AS_NORMAL | \
- MV643XX_ETH_PARTITION_DISABLE
-
-/* These macros describe Ethernet Port Sdma configuration reg (SDCR) bits */
-#define MV643XX_ETH_RIFB (1<<0)
-#define MV643XX_ETH_RX_BURST_SIZE_1_64BIT 0
-#define MV643XX_ETH_RX_BURST_SIZE_2_64BIT (1<<1)
-#define MV643XX_ETH_RX_BURST_SIZE_4_64BIT (1<<2)
-#define MV643XX_ETH_RX_BURST_SIZE_8_64BIT ((1<<2) | (1<<1))
-#define MV643XX_ETH_RX_BURST_SIZE_16_64BIT (1<<3)
-#define MV643XX_ETH_BLM_RX_NO_SWAP (1<<4)
-#define MV643XX_ETH_BLM_RX_BYTE_SWAP 0
-#define MV643XX_ETH_BLM_TX_NO_SWAP (1<<5)
-#define MV643XX_ETH_BLM_TX_BYTE_SWAP 0
-#define MV643XX_ETH_DESCRIPTORS_BYTE_SWAP (1<<6)
-#define MV643XX_ETH_DESCRIPTORS_NO_SWAP 0
-#define MV643XX_ETH_TX_BURST_SIZE_1_64BIT 0
-#define MV643XX_ETH_TX_BURST_SIZE_2_64BIT (1<<22)
-#define MV643XX_ETH_TX_BURST_SIZE_4_64BIT (1<<23)
-#define MV643XX_ETH_TX_BURST_SIZE_8_64BIT ((1<<23) | (1<<22))
-#define MV643XX_ETH_TX_BURST_SIZE_16_64BIT (1<<24)
-
-#define MV643XX_ETH_IPG_INT_RX(value) ((value & 0x3fff) << 8)
-
-#define MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE \
- MV643XX_ETH_RX_BURST_SIZE_4_64BIT | \
- MV643XX_ETH_IPG_INT_RX(0) | \
- MV643XX_ETH_TX_BURST_SIZE_4_64BIT
-
-/* These macros describe Ethernet Port serial control reg (PSCR) bits */
-#define MV643XX_ETH_SERIAL_PORT_DISABLE 0
-#define MV643XX_ETH_SERIAL_PORT_ENABLE (1<<0)
-#define MV643XX_ETH_FORCE_LINK_PASS (1<<1)
-#define MV643XX_ETH_DO_NOT_FORCE_LINK_PASS 0
-#define MV643XX_ETH_ENABLE_AUTO_NEG_FOR_DUPLX 0
-#define MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX (1<<2)
-#define MV643XX_ETH_ENABLE_AUTO_NEG_FOR_FLOW_CTRL 0
-#define MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL (1<<3)
-#define MV643XX_ETH_ADV_NO_FLOW_CTRL 0
-#define MV643XX_ETH_ADV_SYMMETRIC_FLOW_CTRL (1<<4)
-#define MV643XX_ETH_FORCE_FC_MODE_NO_PAUSE_DIS_TX 0
-#define MV643XX_ETH_FORCE_FC_MODE_TX_PAUSE_DIS (1<<5)
-#define MV643XX_ETH_FORCE_BP_MODE_NO_JAM 0
-#define MV643XX_ETH_FORCE_BP_MODE_JAM_TX (1<<7)
-#define MV643XX_ETH_FORCE_BP_MODE_JAM_TX_ON_RX_ERR (1<<8)
-#define MV643XX_ETH_FORCE_LINK_FAIL 0
-#define MV643XX_ETH_DO_NOT_FORCE_LINK_FAIL (1<<10)
-#define MV643XX_ETH_RETRANSMIT_16_ATTEMPTS 0
-#define MV643XX_ETH_RETRANSMIT_FOREVER (1<<11)
-#define MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII (1<<13)
-#define MV643XX_ETH_ENABLE_AUTO_NEG_SPEED_GMII 0
-#define MV643XX_ETH_DTE_ADV_0 0
-#define MV643XX_ETH_DTE_ADV_1 (1<<14)
-#define MV643XX_ETH_DISABLE_AUTO_NEG_BYPASS 0
-#define MV643XX_ETH_ENABLE_AUTO_NEG_BYPASS (1<<15)
-#define MV643XX_ETH_AUTO_NEG_NO_CHANGE 0
-#define MV643XX_ETH_RESTART_AUTO_NEG (1<<16)
-#define MV643XX_ETH_MAX_RX_PACKET_1518BYTE 0
-#define MV643XX_ETH_MAX_RX_PACKET_1522BYTE (1<<17)
-#define MV643XX_ETH_MAX_RX_PACKET_1552BYTE (1<<18)
-#define MV643XX_ETH_MAX_RX_PACKET_9022BYTE ((1<<18) | (1<<17))
-#define MV643XX_ETH_MAX_RX_PACKET_9192BYTE (1<<19)
-#define MV643XX_ETH_MAX_RX_PACKET_9700BYTE ((1<<19) | (1<<17))
-#define MV643XX_ETH_SET_EXT_LOOPBACK (1<<20)
-#define MV643XX_ETH_CLR_EXT_LOOPBACK 0
-#define MV643XX_ETH_SET_FULL_DUPLEX_MODE (1<<21)
-#define MV643XX_ETH_SET_HALF_DUPLEX_MODE 0
-#define MV643XX_ETH_ENABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX (1<<22)
-#define MV643XX_ETH_DISABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX 0
-#define MV643XX_ETH_SET_GMII_SPEED_TO_10_100 0
-#define MV643XX_ETH_SET_GMII_SPEED_TO_1000 (1<<23)
-#define MV643XX_ETH_SET_MII_SPEED_TO_10 0
-#define MV643XX_ETH_SET_MII_SPEED_TO_100 (1<<24)
-
-#define MV643XX_ETH_PORT_SERIAL_CONTROL_DEFAULT_VALUE \
- MV643XX_ETH_DO_NOT_FORCE_LINK_PASS | \
- MV643XX_ETH_ENABLE_AUTO_NEG_FOR_DUPLX | \
- MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL | \
- MV643XX_ETH_ADV_SYMMETRIC_FLOW_CTRL | \
- MV643XX_ETH_FORCE_FC_MODE_NO_PAUSE_DIS_TX | \
- MV643XX_ETH_FORCE_BP_MODE_NO_JAM | \
- (1<<9) /* reserved */ | \
- MV643XX_ETH_DO_NOT_FORCE_LINK_FAIL | \
- MV643XX_ETH_RETRANSMIT_16_ATTEMPTS | \
- MV643XX_ETH_ENABLE_AUTO_NEG_SPEED_GMII | \
- MV643XX_ETH_DTE_ADV_0 | \
- MV643XX_ETH_DISABLE_AUTO_NEG_BYPASS | \
- MV643XX_ETH_AUTO_NEG_NO_CHANGE | \
- MV643XX_ETH_MAX_RX_PACKET_9700BYTE | \
- MV643XX_ETH_CLR_EXT_LOOPBACK | \
- MV643XX_ETH_SET_FULL_DUPLEX_MODE | \
- MV643XX_ETH_ENABLE_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX
-
-/* These macros describe Ethernet Serial Status reg (PSR) bits */
-#define MV643XX_ETH_PORT_STATUS_MODE_10_BIT (1<<0)
-#define MV643XX_ETH_PORT_STATUS_LINK_UP (1<<1)
-#define MV643XX_ETH_PORT_STATUS_FULL_DUPLEX (1<<2)
-#define MV643XX_ETH_PORT_STATUS_FLOW_CONTROL (1<<3)
-#define MV643XX_ETH_PORT_STATUS_GMII_1000 (1<<4)
-#define MV643XX_ETH_PORT_STATUS_MII_100 (1<<5)
-/* PSR bit 6 is undocumented */
-#define MV643XX_ETH_PORT_STATUS_TX_IN_PROGRESS (1<<7)
-#define MV643XX_ETH_PORT_STATUS_AUTONEG_BYPASSED (1<<8)
-#define MV643XX_ETH_PORT_STATUS_PARTITION (1<<9)
-#define MV643XX_ETH_PORT_STATUS_TX_FIFO_EMPTY (1<<10)
-/* PSR bits 11-31 are reserved */
-
#define MV643XX_ETH_PORT_DEFAULT_TRANSMIT_QUEUE_SIZE 800
#define MV643XX_ETH_PORT_DEFAULT_RECEIVE_QUEUE_SIZE 400
@@ -1285,29 +1102,16 @@
#define MV643XX_ETH_NAME "mv643xx_eth"
struct mv643xx_eth_platform_data {
- /*
- * Non-values for mac_addr, phy_addr, port_config, etc.
- * override the default value. Setting the corresponding
- * force_* field, causes the default value to be overridden
- * even when zero.
- */
- unsigned int force_phy_addr:1;
- unsigned int force_port_config:1;
- unsigned int force_port_config_extend:1;
- unsigned int force_port_sdma_config:1;
- unsigned int force_port_serial_control:1;
- int phy_addr;
- char *mac_addr; /* pointer to mac address */
- u32 port_config;
- u32 port_config_extend;
- u32 port_sdma_config;
- u32 port_serial_control;
+ /* non-zero values of these fields override defaults */
+ char *mac_addr;
u32 tx_queue_size;
u32 rx_queue_size;
u32 tx_sram_addr;
u32 tx_sram_size;
u32 rx_sram_addr;
u32 rx_sram_size;
+ /* ethtool_cmd can be used to initialize the phy_addr, speed, etc. */
+ struct ethtool_cmd *ethtool_cmd;
};
#endif /* __ASM_MV643XX_H */
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(4/20): Update the Artesyn katana mv643xx ethernet platform data
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (2 preceding siblings ...)
2005-03-28 23:43 ` mv643xx(3/20): use MII library for ethtool functions Dale Farnsworth
@ 2005-03-28 23:44 ` Dale Farnsworth
2005-03-28 23:45 ` mv643xx(5/20): update ppc7d platform for new mv643xx_eth " Dale Farnsworth
` (15 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:44 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/arch/ppc/platforms/katana.c
===================================================================
--- linux-2.5-enet.orig/arch/ppc/platforms/katana.c
+++ linux-2.5-enet/arch/ppc/platforms/katana.c
@@ -30,6 +30,7 @@
#include <linux/bootmem.h>
#include <linux/mtd/physmap.h>
#include <linux/mv643xx.h>
+#include <linux/ethtool.h>
#ifdef CONFIG_BOOTIMG
#include <linux/bootimg.h>
#endif
@@ -495,21 +496,30 @@
#endif
#if defined(CONFIG_MV643XX_ETH)
+static struct ethtool_cmd mv643xx_ethtool_cmd[] = {
+ [0] = {
+ .phy_address = KATANA_ETH0_PHY_ADDR,
+ .autoneg = AUTONEG_ENABLE,
+ },
+ [1] = {
+ .phy_address = KATANA_ETH1_PHY_ADDR,
+ .autoneg = AUTONEG_ENABLE,
+ },
+ [2] = {
+ .phy_address = KATANA_ETH2_PHY_ADDR,
+ .autoneg = AUTONEG_ENABLE,
+ }
+};
+
static void __init
katana_fixup_eth_pdata(struct platform_device *pdev)
{
struct mv643xx_eth_platform_data *eth_pd;
- static u16 phy_addr[] = {
- KATANA_ETH0_PHY_ADDR,
- KATANA_ETH1_PHY_ADDR,
- KATANA_ETH2_PHY_ADDR,
- };
eth_pd = pdev->dev.platform_data;
- eth_pd->force_phy_addr = 1;
- eth_pd->phy_addr = phy_addr[pdev->id];
eth_pd->tx_queue_size = KATANA_ETH_TX_QUEUE_SIZE;
eth_pd->rx_queue_size = KATANA_ETH_RX_QUEUE_SIZE;
+ eth_pd->ethtool_cmd = &mv643xx_ethtool_cmd[pdev->id];
}
#endif
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(5/20): update ppc7d platform for new mv643xx_eth platform data
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (3 preceding siblings ...)
2005-03-28 23:44 ` mv643xx(4/20): Update the Artesyn katana mv643xx ethernet platform data Dale Farnsworth
@ 2005-03-28 23:45 ` Dale Farnsworth
2005-03-28 23:46 ` mv643xx(6/20): use netif_msg_xxx() to control log messages where appropriate Dale Farnsworth
` (14 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:45 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
This patch updates the ethernet device platform data of Radstone
PPC7D.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.6/arch/ppc/platforms/radstone_ppc7d.c
===================================================================
--- linux-2.6.orig/arch/ppc/platforms/radstone_ppc7d.c 2005-03-27 15:09:33.000000000 +0100
+++ linux-2.6/arch/ppc/platforms/radstone_ppc7d.c 2005-03-27 15:29:58.000000000 +0100
@@ -41,6 +41,7 @@
#include <linux/serial_core.h>
#include <linux/mv643xx.h>
#include <linux/netdevice.h>
+#include <linux/ethtool.h>
#include <asm/system.h>
#include <asm/pgtable.h>
@@ -638,21 +639,30 @@
#endif
#if defined(CONFIG_MV643XX_ETH)
+static struct ethtool_cmd ppc7d_ethtool_cmd[] = {
+ [0] = {
+ .phy_address = PPC7D_ETH0_PHY_ADDR,
+ .autoneg = AUTONEG_ENABLE,
+ },
+ [1] = {
+ .phy_address = PPC7D_ETH1_PHY_ADDR,
+ .autoneg = AUTONEG_ENABLE,
+ },
+ [2] = {
+ .phy_address = PPC7D_ETH2_PHY_ADDR,
+ .autoneg = AUTONEG_ENABLE,
+ }
+};
+
static void __init ppc7d_fixup_eth_pdata(struct platform_device *pdev)
{
struct mv643xx_eth_platform_data *eth_pd;
- static u16 phy_addr[] = {
- PPC7D_ETH0_PHY_ADDR,
- PPC7D_ETH1_PHY_ADDR,
- PPC7D_ETH2_PHY_ADDR,
- };
int i;
eth_pd = pdev->dev.platform_data;
- eth_pd->force_phy_addr = 1;
- eth_pd->phy_addr = phy_addr[pdev->id];
eth_pd->tx_queue_size = PPC7D_ETH_TX_QUEUE_SIZE;
eth_pd->rx_queue_size = PPC7D_ETH_RX_QUEUE_SIZE;
+ eth_pd->ethtool_cmd = &ppc7d_ethtool_cmd[pdev->id];
/* Adjust IRQ by mv64360_irq_base */
for (i = 0; i < pdev->num_resources; i++) {
@@ -665,7 +675,6 @@
(int)r->start);
}
}
-
}
#endif
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(6/20): use netif_msg_xxx() to control log messages where appropriate
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (4 preceding siblings ...)
2005-03-28 23:45 ` mv643xx(5/20): update ppc7d platform for new mv643xx_eth " Dale Farnsworth
@ 2005-03-28 23:46 ` Dale Farnsworth
2005-03-28 23:47 ` mv643xx(7/20): move static prototypes from header file into driver C file Dale Farnsworth
` (13 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:46 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Network driver messages can be controlled using ethtool msglvl via the
netif_msg_xxx() macros. This patch allows mv643xx's driver message
verbosity to be controlled by ethtool.
Some debug messages have also been added (not enabled by default) to
trace low-level (per packet) device access.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.h
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.h
+++ linux-2.5-enet/drivers/net/mv643xx_eth.h
@@ -564,6 +564,7 @@
u32 msg_enable;
struct mii_if_info mii;
+ struct net_device *netdev;
};
/* ethernet.h API list */
@@ -582,12 +583,12 @@
unsigned char *p_addr);
/* PHY and MIB routines */
-static void ethernet_phy_reset(unsigned int eth_port_num);
+static void ethernet_phy_reset(struct mv643xx_private *mp);
-static void eth_port_write_smi_reg(unsigned int eth_port_num,
+static void eth_port_write_smi_reg(struct mv643xx_private *mp,
unsigned int phy_reg, unsigned int value);
-static void eth_port_read_smi_reg(unsigned int eth_port_num,
+static void eth_port_read_smi_reg(struct mv643xx_private *mp,
unsigned int phy_reg, unsigned int *value);
static void eth_clear_mib_counters(unsigned int eth_port_num);
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -86,7 +86,7 @@
#endif
static int ethernet_phy_get(unsigned int eth_port_num);
static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr);
-static int ethernet_phy_detect(unsigned int eth_port_num);
+static int ethernet_phy_detect(struct mv643xx_private *mp);
static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location);
static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val);
static int mv643xx_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
@@ -199,7 +199,8 @@
* again in a later time .
*/
if ((mp->rx_ring_skbs == 0) && (mp->rx_timer_flag == 0)) {
- printk(KERN_INFO "%s: Rx ring is empty\n", dev->name);
+ if (netif_msg_rx_status(mp))
+ printk(KERN_INFO "%s: Rx ring is empty\n", dev->name);
/* After 100mSec */
mp->timeout.expires = jiffies + (HZ / 10);
add_timer(&mp->timeout);
@@ -306,7 +307,8 @@
{
struct mv643xx_private *mp = netdev_priv(dev);
- printk(KERN_INFO "%s: TX timeout ", dev->name);
+ if (netif_msg_tx_err(mp))
+ printk(KERN_INFO "%s: TX timeout ", dev->name);
/* Do the reset outside of interrupt context */
schedule_work(&mp->tx_timeout_task);
@@ -350,7 +352,9 @@
/* Check only queue 0 */
while (eth_tx_return_desc(mp, &pkt_info) == ETH_OK) {
if (pkt_info.cmd_sts & BIT0) {
- printk("%s: Error in TX\n", dev->name);
+ if (netif_msg_tx_err(mp))
+ printk(KERN_WARNING "%s: Error in TX: cmd_sts=%08x\n",
+ dev->name, pkt_info.cmd_sts);
stats->tx_errors++;
}
@@ -440,11 +444,10 @@
if ((pkt_info.cmd_sts & (ETH_RX_FIRST_DESC |
ETH_RX_LAST_DESC)) !=
(ETH_RX_FIRST_DESC | ETH_RX_LAST_DESC)) {
- if (net_ratelimit())
- printk(KERN_ERR
- "%s: Received packet spread "
- "on multiple descriptors\n",
- dev->name);
+ if (net_ratelimit() && netif_msg_rx_err(mp))
+ printk(KERN_WARNING "%s: Received "
+ "packet spread on multiple "
+ "descriptors\n", dev->name);
}
if (pkt_info.cmd_sts & ETH_ERROR_SUMMARY)
stats->rx_errors++;
@@ -812,7 +815,7 @@
}
if (mv643xx_eth_real_open(dev)) {
- printk("%s: Error opening interface\n", dev->name);
+ printk(KERN_ERR "%s: Error opening interface\n", dev->name);
err = -EBUSY;
goto out_free;
}
@@ -1019,8 +1022,6 @@
if (!mp->p_rx_desc_area) {
printk(KERN_ERR "%s: Cannot allocate Rx ring (size %d bytes)\n",
dev->name, size);
- printk(KERN_ERR "%s: Freeing previously allocated TX queues...",
- dev->name);
if (mp->rx_sram_size)
iounmap(mp->p_rx_desc_area);
else
@@ -1070,8 +1071,8 @@
}
}
if (mp->tx_ring_skbs)
- printk("%s: Error on Tx descriptor free - could not free %d"
- " descriptors\n", dev->name, mp->tx_ring_skbs);
+ printk(KERN_ERR "%s: Error on Tx descriptor free - could not "
+ "free %d descriptors\n", dev->name, mp->tx_ring_skbs);
/* Free TX ring */
if (mp->tx_sram_size)
@@ -1099,10 +1100,10 @@
}
if (mp->rx_ring_skbs)
- printk(KERN_ERR
- "%s: Error in freeing Rx Ring. %d skb's still"
- " stuck in RX Ring - ignoring them\n", dev->name,
- mp->rx_ring_skbs);
+ printk(KERN_ERR "%s: Error in freeing Rx Ring. "
+ "%d skb's still stuck in RX Ring - "
+ "ignoring them\n", dev->name, mp->rx_ring_skbs);
+
/* Free RX ring */
if (mp->rx_sram_size)
iounmap(mp->p_rx_desc_area);
@@ -1264,9 +1265,8 @@
struct pkt_info pkt_info;
if (netif_queue_stopped(dev)) {
- printk(KERN_ERR
- "%s: Tried sending packet when interface is stopped\n",
- dev->name);
+ printk(KERN_ERR "%s: Tried sending packet when interface is "
+ "stopped\n", dev->name);
return 1;
}
@@ -1274,16 +1274,15 @@
if ((mp->tx_ring_size - mp->tx_ring_skbs) <=
(skb_shinfo(skb)->nr_frags + 1)) {
netif_stop_queue(dev);
- printk(KERN_ERR
- "%s: Bug in mv643xx_eth - Trying to transmit when"
- " queue full !\n", dev->name);
+ printk(KERN_ERR "%s: Trying to transmit when queue full!\n",
+ dev->name);
return 1;
}
/* Paranoid check - this shouldn't happen */
if (skb == NULL) {
stats->tx_dropped++;
- printk(KERN_ERR "mv64320_eth paranoid check failed\n");
+ printk(KERN_ERR "%s: paranoid check failed\n", dev->name);
return 1;
}
@@ -1311,9 +1310,8 @@
} else if (skb->nh.iph->protocol == IPPROTO_TCP)
pkt_info.l4i_chk = skb->h.th->check;
else {
- printk(KERN_ERR
- "%s: chksum proto != TCP or UDP\n",
- dev->name);
+ printk(KERN_ERR "%s: chksum proto != TCP "
+ "or UDP\n", dev->name);
spin_unlock_irqrestore(&mp->lock, flags);
return 1;
}
@@ -1325,8 +1323,9 @@
mp->tx_ring_skbs++;
status = eth_port_send(mp, &pkt_info);
if ((status == ETH_ERROR) || (status == ETH_QUEUE_FULL))
- printk(KERN_ERR "%s: Error on transmitting packet\n",
- dev->name);
+ if (netif_msg_tx_err(mp))
+ printk(KERN_WARNING "%s: Error on transmitting "
+ "packet\n", dev->name);
stats->tx_bytes += pkt_info.byte_cnt;
} else {
unsigned int frag;
@@ -1344,10 +1343,12 @@
fragp = &skb_shinfo(skb)->frags[frag];
if (fragp->size <= 8 && fragp->page_offset & 0x7) {
skb_linearize(skb, GFP_ATOMIC);
- printk(KERN_DEBUG "%s: unaligned tiny fragment"
- "%d of %d, fixed\n",
- dev->name, frag,
- skb_shinfo(skb)->nr_frags);
+ if (netif_msg_pktdata(mp))
+ printk(KERN_DEBUG "%s: unaligned "
+ "tiny fragment"
+ "%d of %d, fixed\n",
+ dev->name, frag,
+ skb_shinfo(skb)->nr_frags);
goto linear;
}
}
@@ -1372,9 +1373,8 @@
} else if (skb->nh.iph->protocol == IPPROTO_TCP)
pkt_info.l4i_chk = skb->h.th->check;
else {
- printk(KERN_ERR
- "%s: chksum proto != TCP or UDP\n",
- dev->name);
+ printk(KERN_ERR "%s: chksum proto != TCP "
+ "or UDP\n", dev->name);
spin_unlock_irqrestore(&mp->lock, flags);
return 1;
}
@@ -1383,13 +1383,16 @@
status = eth_port_send(mp, &pkt_info);
if (status != ETH_OK) {
if ((status == ETH_ERROR))
- printk(KERN_ERR
- "%s: Error on transmitting packet\n",
- dev->name);
+ printk(KERN_WARNING "%s: Error on "
+ "transmitting packet\n",
+ dev->name);
if (status == ETH_QUEUE_FULL)
- printk("Error on Queue Full \n");
+ printk(KERN_WARNING "%s: Error on "
+ "Queue Full\n",
+ dev->name);
if (status == ETH_QUEUE_LAST_RESOURCE)
- printk("Tx resource error \n");
+ printk(KERN_WARNING "%s: Tx resource error\n",
+ dev->name);
}
stats->tx_bytes += pkt_info.byte_cnt;
@@ -1420,15 +1423,20 @@
if (status != ETH_OK) {
if ((status == ETH_ERROR))
- printk(KERN_ERR "%s: Error on "
- "transmitting packet\n",
- dev->name);
+ if (netif_msg_tx_err(mp))
+ printk(KERN_WARNING "%s: Error on "
+ "transmitting packet\n",
+ dev->name);
if (status == ETH_QUEUE_LAST_RESOURCE)
- printk("Tx resource error \n");
+ if (netif_msg_tx_err(mp))
+ printk(KERN_WARNING "%s: Tx resource "
+ "error\n", dev->name);
if (status == ETH_QUEUE_FULL)
- printk("Queue is full \n");
+ if (netif_msg_tx_err(mp))
+ printk(KERN_WARNING "%s: Queue is full\n",
+ dev->name);
}
stats->tx_bytes += pkt_info.byte_cnt;
}
@@ -1444,8 +1452,10 @@
mp->tx_ring_skbs++;
status = eth_port_send(mp, &pkt_info);
if ((status == ETH_ERROR) || (status == ETH_QUEUE_FULL))
- printk(KERN_ERR "%s: Error on transmitting packet\n",
- dev->name);
+ if (netif_msg_tx_err(mp))
+ printk(KERN_WARNING "%s: Error on transmitting packet\n",
+ dev->name);
+
stats->tx_bytes += pkt_info.byte_cnt;
#endif
@@ -1516,6 +1526,7 @@
dev_set_drvdata(ddev, dev);
mp = netdev_priv(dev);
+ mp->netdev = dev;
/* By default, log probe, interface up/down and error events */
mp->msg_enable = NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN |
@@ -1621,11 +1632,11 @@
mp->mii.phy_id_mask = 0x3f;
mp->mii.reg_num_mask = 0x1f;
- err = ethernet_phy_detect(port_num);
+ err = ethernet_phy_detect(mp);
if (err) {
- pr_debug("MV643xx ethernet port %d: "
- "No PHY detected at addr %d\n",
- port_num, ethernet_phy_get(port_num));
+ printk(KERN_ERR "MV643xx ethernet port %d: "
+ "No PHY detected at addr %d\n",
+ port_num, ethernet_phy_get(port_num));
return err;
}
@@ -1636,28 +1647,36 @@
mp->mii.supports_gmii = mii_check_gmii_support(&mp->mii);
p = dev->dev_addr;
- printk(KERN_NOTICE
- "%s: port %d with MAC address %02x:%02x:%02x:%02x:%02x:%02x\n",
- dev->name, port_num, p[0], p[1], p[2], p[3], p[4], p[5]);
+ if (netif_msg_probe(mp))
+ printk(KERN_NOTICE "%s: has MAC address "
+ "%02x:%02x:%02x:%02x:%02x:%02x\n",
+ dev->name, p[0], p[1], p[2], p[3], p[4], p[5]);
if (dev->features & NETIF_F_SG)
- printk(KERN_NOTICE "%s: Scatter Gather Enabled\n", dev->name);
+ if (netif_msg_probe(mp))
+ printk(KERN_NOTICE "%s: Scatter Gather Enabled\n",
+ dev->name);
if (dev->features & NETIF_F_IP_CSUM)
- printk(KERN_NOTICE "%s: TX TCP/IP Checksumming Supported\n",
- dev->name);
+ if (netif_msg_probe(mp))
+ printk(KERN_NOTICE "%s: TX TCP/IP Checksumming Supported\n",
+ dev->name);
#ifdef MV643XX_CHECKSUM_OFFLOAD_TX
- printk(KERN_NOTICE "%s: RX TCP/UDP Checksum Offload ON \n", dev->name);
+ if (netif_msg_probe(mp))
+ printk(KERN_NOTICE "%s: RX TCP/UDP Checksum Offload ON\n",
+ dev->name);
#endif
#ifdef MV643XX_COAL
- printk(KERN_NOTICE "%s: TX and RX Interrupt Coalescing ON \n",
- dev->name);
+ if (netif_msg_probe(mp))
+ printk(KERN_NOTICE "%s: TX and RX Interrupt Coalescing ON\n",
+ dev->name);
#endif
#ifdef MV643XX_NAPI
- printk(KERN_NOTICE "%s: RX NAPI Enabled \n", dev->name);
+ if (netif_msg_probe(mp))
+ printk(KERN_NOTICE "%s: RX NAPI Enabled\n", dev->name);
#endif
return 0;
@@ -1958,7 +1977,7 @@
eth_port_init_mac_tables(mp->port_num);
- ethernet_phy_reset(mp->port_num);
+ ethernet_phy_reset(mp);
}
/*
@@ -2287,22 +2306,22 @@
* -ENODEV on failure
*
*/
-static int ethernet_phy_detect(unsigned int port_num)
+static int ethernet_phy_detect(struct mv643xx_private *mp)
{
unsigned int phy_reg_data0;
int auto_neg;
- eth_port_read_smi_reg(port_num, 0, &phy_reg_data0);
+ eth_port_read_smi_reg(mp, 0, &phy_reg_data0);
auto_neg = phy_reg_data0 & 0x1000;
phy_reg_data0 ^= 0x1000; /* invert auto_neg */
- eth_port_write_smi_reg(port_num, 0, phy_reg_data0);
+ eth_port_write_smi_reg(mp, 0, phy_reg_data0);
- eth_port_read_smi_reg(port_num, 0, &phy_reg_data0);
+ eth_port_read_smi_reg(mp, 0, &phy_reg_data0);
if ((phy_reg_data0 & 0x1000) == auto_neg)
return -ENODEV; /* change didn't take */
phy_reg_data0 ^= 0x1000;
- eth_port_write_smi_reg(port_num, 0, phy_reg_data0);
+ eth_port_write_smi_reg(mp, 0, phy_reg_data0);
return 0;
}
@@ -2375,14 +2394,14 @@
* None.
*
*/
-static void ethernet_phy_reset(unsigned int eth_port_num)
+static void ethernet_phy_reset(struct mv643xx_private *mp)
{
unsigned int phy_reg_data;
/* Reset the PHY */
- eth_port_read_smi_reg(eth_port_num, 0, &phy_reg_data);
+ eth_port_read_smi_reg(mp, 0, &phy_reg_data);
phy_reg_data |= 0x8000; /* Set bit 15 to reset the PHY */
- eth_port_write_smi_reg(eth_port_num, 0, phy_reg_data);
+ eth_port_write_smi_reg(mp, 0, phy_reg_data);
}
/*
@@ -2520,9 +2539,10 @@
* true otherwise.
*
*/
-static void eth_port_read_smi_reg(unsigned int port_num,
+static void eth_port_read_smi_reg(struct mv643xx_private *mp,
unsigned int phy_reg, unsigned int *value)
{
+ unsigned int port_num = mp->port_num;
int phy_addr = ethernet_phy_get(port_num);
unsigned long flags;
int i;
@@ -2533,7 +2553,8 @@
/* wait for the SMI register to become available */
for (i = 0; mv_read(MV643XX_ETH_SMI_REG) & ETH_SMI_BUSY; i++) {
if (i == PHY_WAIT_ITERATIONS) {
- printk("mv643xx PHY busy timeout, port %d\n", port_num);
+ printk(KERN_ERR "%s: PHY busy timeout\n",
+ mp->netdev->name);
goto out;
}
udelay(PHY_WAIT_MICRO_SECONDS);
@@ -2545,7 +2566,8 @@
/* now wait for the data to be valid */
for (i = 0; !(mv_read(MV643XX_ETH_SMI_REG) & ETH_SMI_READ_VALID); i++) {
if (i == PHY_WAIT_ITERATIONS) {
- printk("mv643xx PHY read timeout, port %d\n", port_num);
+ printk(KERN_ERR "%s: PHY read timeout\n",
+ mp->netdev->name);
goto out;
}
udelay(PHY_WAIT_MICRO_SECONDS);
@@ -2576,12 +2598,13 @@
* true otherwise.
*
*/
-static void eth_port_write_smi_reg(unsigned int eth_port_num,
+static void eth_port_write_smi_reg(struct mv643xx_private *mp,
unsigned int phy_reg, unsigned int value)
{
int phy_addr;
int i;
unsigned long flags;
+ unsigned int eth_port_num = mp->port_num;
phy_addr = ethernet_phy_get(eth_port_num);
@@ -2591,8 +2614,8 @@
/* wait for the SMI register to become available */
for (i = 0; mv_read(MV643XX_ETH_SMI_REG) & ETH_SMI_BUSY; i++) {
if (i == PHY_WAIT_ITERATIONS) {
- printk("mv643xx PHY busy timeout, port %d\n",
- eth_port_num);
+ printk(KERN_ERR "%s: PHY busy timeout\n",
+ mp->netdev->name);
goto out;
}
udelay(PHY_WAIT_MICRO_SECONDS);
@@ -2612,14 +2635,14 @@
int val;
struct mv643xx_private *mp = netdev_priv(dev);
- eth_port_read_smi_reg(mp->port_num, location, &val);
+ eth_port_read_smi_reg(mp, location, &val);
return val;
}
static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val)
{
struct mv643xx_private *mp = netdev_priv(dev);
- eth_port_write_smi_reg(mp->port_num, location, val);
+ eth_port_write_smi_reg(mp, location, val);
}
/*
@@ -2670,9 +2693,8 @@
* in length must be aligned on an 8 byte boundary.
*/
if (p_pkt_info->byte_cnt <= 8 && p_pkt_info->buf_ptr & 0x7) {
- printk(KERN_ERR
- "mv643xx_eth port %d: packet size <= 8 problem\n",
- mp->port_num);
+ printk(KERN_ERR "%s: packet size <= 8 (%d) problem\n",
+ dev->name, p_pkt_info->byte_cnt);
return ETH_ERROR;
}
@@ -2703,6 +2725,13 @@
current_descriptor->cmd_sts = command;
}
+ if (netif_msg_txqueued(mp))
+ printk( KERN_DEBUG "%s: send pkt: len=%d, desc=%d, "
+ "f/l=%d/%d\n", dev->name,
+ p_pkt_info->byte_cnt, tx_desc_curr,
+ ((command & ETH_TX_FIRST_DESC) != 0),
+ ((command & ETH_TX_LAST_DESC) != 0));
+
if (command & ETH_TX_LAST_DESC) {
wmb();
first_descriptor->cmd_sts = mp->tx_first_command;
@@ -2752,6 +2781,13 @@
current_descriptor->byte_cnt = p_pkt_info->byte_cnt;
mp->tx_skb[tx_desc_curr] = p_pkt_info->return_info;
+ if (netif_msg_tx_queued(mp))
+ printk(KERN_DEBUG "%s: send pkt: desc=%d len=%d, f/l=%d/%d\n",
+ mp->netdev->name, tx_desc_curr,
+ p_pkt_info->byte_cnt,
+ ((command_status & ETH_TX_FIRST_DESC) != 0),
+ ((command_status & ETH_TX_LAST_DESC) != 0));
+
/* Set last desc with DMA ownership and interrupt enable. */
wmb();
current_descriptor->cmd_sts = command_status |
@@ -2899,6 +2935,13 @@
p_pkt_info->return_info = mp->rx_skb[rx_curr_desc];
p_pkt_info->l4i_chk = p_rx_desc->buf_size;
+ if (netif_msg_rx_status(mp))
+ printk(KERN_DEBUG "%s: rcv pkt: len=%d, desc=%d, f/l=%d/%d\n",
+ mp->netdev->name,
+ p_pkt_info->byte_cnt, rx_curr_desc,
+ ((command_status & ETH_RX_FIRST_DESC) != 0),
+ ((command_status & ETH_RX_LAST_DESC) != 0));
+
/* Clean the return info field to indicate that the packet has been */
/* moved to the upper layers */
mp->rx_skb[rx_curr_desc] = NULL;
@@ -2948,6 +2991,11 @@
p_used_rx_desc->buf_size = p_pkt_info->byte_cnt;
mp->rx_skb[used_rx_desc] = p_pkt_info->return_info;
+ if (netif_msg_rx_status(mp))
+ printk(KERN_DEBUG "%s: rx done, len=%d, desc=%d, status=%08x\n",
+ mp->netdev->name, p_pkt_info->byte_cnt, used_rx_desc,
+ p_used_rx_desc->cmd_sts);
+
/* Flush the write pipe */
/* Return the descriptor to DMA ownership */
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(7/20): move static prototypes from header file into driver C file
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (5 preceding siblings ...)
2005-03-28 23:46 ` mv643xx(6/20): use netif_msg_xxx() to control log messages where appropriate Dale Farnsworth
@ 2005-03-28 23:47 ` Dale Farnsworth
2005-03-28 23:48 ` mv643xx(8/20): remove ETH_FUNC_RET_STATUS and unused ETH_TARGET enums Dale Farnsworth
` (12 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:47 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Static function prototypes don't belong in a header file so move them
into the driver C file. Also add a check for valid port number at
device create to catch silly platform data errors.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.h
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.h
+++ linux-2.5-enet/drivers/net/mv643xx_eth.h
@@ -75,6 +75,8 @@
#define MV643XX_RX_COAL 100
#endif
+#define MV643XX_PORT_MAX 3
+
/*
* The second part is the low level driver of the gigE ethernet ports.
*/
@@ -567,40 +569,4 @@
struct net_device *netdev;
};
-/* ethernet.h API list */
-
-/* Port operation control routines */
-static void eth_port_init(struct mv643xx_private *mp);
-static void eth_port_reset(unsigned int eth_port_num);
-static void eth_port_start(struct mv643xx_private *mp);
-
-static void ethernet_set_config_reg(unsigned int eth_port_num,
- unsigned int value);
-static unsigned int ethernet_get_config_reg(unsigned int eth_port_num);
-
-/* Port MAC address routines */
-static void eth_port_uc_addr_set(unsigned int eth_port_num,
- unsigned char *p_addr);
-
-/* PHY and MIB routines */
-static void ethernet_phy_reset(struct mv643xx_private *mp);
-
-static void eth_port_write_smi_reg(struct mv643xx_private *mp,
- unsigned int phy_reg, unsigned int value);
-
-static void eth_port_read_smi_reg(struct mv643xx_private *mp,
- unsigned int phy_reg, unsigned int *value);
-
-static void eth_clear_mib_counters(unsigned int eth_port_num);
-
-/* Port data flow control routines */
-static ETH_FUNC_RET_STATUS eth_port_send(struct mv643xx_private *mp,
- struct pkt_info *p_pkt_info);
-static ETH_FUNC_RET_STATUS eth_tx_return_desc(struct mv643xx_private *mp,
- struct pkt_info *p_pkt_info);
-static ETH_FUNC_RET_STATUS eth_port_receive(struct mv643xx_private *mp,
- struct pkt_info *p_pkt_info);
-static ETH_FUNC_RET_STATUS eth_rx_return_buff(struct mv643xx_private *mp,
- struct pkt_info *p_pkt_info);
-
#endif /* __MV643XX_ETH_H__ */
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -92,6 +92,40 @@
static int mv643xx_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
static struct ethtool_ops mv643xx_ethtool_ops;
+/* Port operation control routines */
+static void eth_port_init(struct mv643xx_private *mp);
+static void eth_port_reset(unsigned int eth_port_num);
+static void eth_port_start(struct mv643xx_private *mp);
+
+static void ethernet_set_config_reg(unsigned int eth_port_num,
+ unsigned int value);
+static unsigned int ethernet_get_config_reg(unsigned int eth_port_num);
+
+/* Port MAC address routines */
+static void eth_port_uc_addr_set(unsigned int eth_port_num,
+ unsigned char *p_addr);
+
+/* PHY and MIB routines */
+static void ethernet_phy_reset(struct mv643xx_private *mp);
+
+static void eth_port_write_smi_reg(struct mv643xx_private *mp,
+ unsigned int phy_reg, unsigned int value);
+
+static void eth_port_read_smi_reg(struct mv643xx_private *mp,
+ unsigned int phy_reg, unsigned int *value);
+
+static void eth_clear_mib_counters(unsigned int eth_port_num);
+
+/* Port data flow control routines */
+static ETH_FUNC_RET_STATUS eth_port_send(struct mv643xx_private *mp,
+ struct pkt_info *p_pkt_info);
+static ETH_FUNC_RET_STATUS eth_tx_return_desc(struct mv643xx_private *mp,
+ struct pkt_info *p_pkt_info);
+static ETH_FUNC_RET_STATUS eth_port_receive(struct mv643xx_private *mp,
+ struct pkt_info *p_pkt_info);
+static ETH_FUNC_RET_STATUS eth_rx_return_buff(struct mv643xx_private *mp,
+ struct pkt_info *p_pkt_info);
+
static char mv643xx_driver_name[] = "mv643xx_eth";
static char mv643xx_driver_version[] = "1.0";
@@ -1519,6 +1553,9 @@
int err;
struct ethtool_cmd *ecmd;
+ if (port_num >= MV643XX_PORT_MAX)
+ return -EINVAL;
+
dev = alloc_etherdev(sizeof(struct mv643xx_private));
if (!dev)
return -ENOMEM;
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(8/20): remove ETH_FUNC_RET_STATUS and unused ETH_TARGET enums
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (6 preceding siblings ...)
2005-03-28 23:47 ` mv643xx(7/20): move static prototypes from header file into driver C file Dale Farnsworth
@ 2005-03-28 23:48 ` Dale Farnsworth
2005-03-28 23:49 ` mv643xx(9/20): make internal functions take device pointer param consistently Dale Farnsworth
` (11 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:48 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
The ETH_FUNC_RET_STATUS enum makes the driver code look more complex
than it needs to be so remove it. The ETH_TARGET enum was no longer
used so that goes as well.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.h
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.h
+++ linux-2.5-enet/drivers/net/mv643xx_eth.h
@@ -385,25 +385,6 @@
#define ETH_TX_ENABLE_INTERRUPT (BIT23)
#define ETH_AUTO_MODE (BIT30)
-/* typedefs */
-
-typedef enum _eth_func_ret_status {
- ETH_OK, /* Returned as expected. */
- ETH_ERROR, /* Fundamental error. */
- ETH_RETRY, /* Could not process request. Try later.*/
- ETH_END_OF_JOB, /* Ring has nothing to process. */
- ETH_QUEUE_FULL, /* Ring resource error. */
- ETH_QUEUE_LAST_RESOURCE /* Ring resources about to exhaust. */
-} ETH_FUNC_RET_STATUS;
-
-typedef enum _eth_target {
- ETH_TARGET_DRAM,
- ETH_TARGET_DEVICE,
- ETH_TARGET_CBS,
- ETH_TARGET_PCI0,
- ETH_TARGET_PCI1
-} ETH_TARGET;
-
/* These are for big-endian machines. Little endian needs different
* definitions.
*/
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -117,14 +117,14 @@
static void eth_clear_mib_counters(unsigned int eth_port_num);
/* Port data flow control routines */
-static ETH_FUNC_RET_STATUS eth_port_send(struct mv643xx_private *mp,
- struct pkt_info *p_pkt_info);
-static ETH_FUNC_RET_STATUS eth_tx_return_desc(struct mv643xx_private *mp,
- struct pkt_info *p_pkt_info);
-static ETH_FUNC_RET_STATUS eth_port_receive(struct mv643xx_private *mp,
- struct pkt_info *p_pkt_info);
-static ETH_FUNC_RET_STATUS eth_rx_return_buff(struct mv643xx_private *mp,
- struct pkt_info *p_pkt_info);
+static int eth_port_send(struct mv643xx_private *mp,
+ struct pkt_info *p_pkt_info);
+static int eth_tx_return_desc(struct mv643xx_private *mp,
+ struct pkt_info *p_pkt_info);
+static int eth_port_receive(struct mv643xx_private *mp,
+ struct pkt_info *p_pkt_info);
+static void eth_rx_return_buff(struct mv643xx_private *mp,
+ struct pkt_info *p_pkt_info);
static char mv643xx_driver_name[] = "mv643xx_eth";
static char mv643xx_driver_version[] = "1.0";
@@ -220,11 +220,7 @@
pkt_info.buf_ptr = dma_map_single(NULL, skb->data, RX_SKB_SIZE,
DMA_FROM_DEVICE);
pkt_info.return_info = skb;
- if (eth_rx_return_buff(mp, &pkt_info) != ETH_OK) {
- printk(KERN_ERR
- "%s: Error allocating RX Ring\n", dev->name);
- break;
- }
+ eth_rx_return_buff(mp, &pkt_info);
skb_reserve(skb, 2);
}
clear_bit(0, &mp->rx_task_busy);
@@ -384,7 +380,7 @@
spin_lock(&mp->lock);
/* Check only queue 0 */
- while (eth_tx_return_desc(mp, &pkt_info) == ETH_OK) {
+ while (eth_tx_return_desc(mp, &pkt_info) == 0) {
if (pkt_info.cmd_sts & BIT0) {
if (netif_msg_tx_err(mp))
printk(KERN_WARNING "%s: Error in TX: cmd_sts=%08x\n",
@@ -453,9 +449,9 @@
struct pkt_info pkt_info;
#ifdef MV643XX_NAPI
- while (eth_port_receive(mp, &pkt_info) == ETH_OK && budget > 0) {
+ while (eth_port_receive(mp, &pkt_info) == 0 && budget > 0) {
#else
- while (eth_port_receive(mp, &pkt_info) == ETH_OK) {
+ while (eth_port_receive(mp, &pkt_info) == 0) {
#endif
mp->rx_ring_skbs--;
received_packets++;
@@ -1204,7 +1200,7 @@
struct mv643xx_private *mp = netdev_priv(dev);
struct pkt_info pkt_info;
- while (eth_tx_return_desc(mp, &pkt_info) == ETH_OK) {
+ while (eth_tx_return_desc(mp, &pkt_info) == 0) {
if (pkt_info.return_info) {
if (skb_shinfo(pkt_info.return_info)->nr_frags)
dma_unmap_page(NULL, pkt_info.buf_ptr,
@@ -1294,7 +1290,7 @@
{
struct mv643xx_private *mp = netdev_priv(dev);
struct net_device_stats *stats = &mp->stats;
- ETH_FUNC_RET_STATUS status;
+ int status;
unsigned long flags;
struct pkt_info pkt_info;
@@ -1356,10 +1352,9 @@
pkt_info.return_info = skb;
mp->tx_ring_skbs++;
status = eth_port_send(mp, &pkt_info);
- if ((status == ETH_ERROR) || (status == ETH_QUEUE_FULL))
- if (netif_msg_tx_err(mp))
- printk(KERN_WARNING "%s: Error on transmitting "
- "packet\n", dev->name);
+ if (status < 0)
+ goto out;
+
stats->tx_bytes += pkt_info.byte_cnt;
} else {
unsigned int frag;
@@ -1415,19 +1410,9 @@
}
status = eth_port_send(mp, &pkt_info);
- if (status != ETH_OK) {
- if ((status == ETH_ERROR))
- printk(KERN_WARNING "%s: Error on "
- "transmitting packet\n",
- dev->name);
- if (status == ETH_QUEUE_FULL)
- printk(KERN_WARNING "%s: Error on "
- "Queue Full\n",
- dev->name);
- if (status == ETH_QUEUE_LAST_RESOURCE)
- printk(KERN_WARNING "%s: Tx resource error\n",
- dev->name);
- }
+ if (status < 0)
+ goto out;
+
stats->tx_bytes += pkt_info.byte_cnt;
/* Check for the remaining frags */
@@ -1454,24 +1439,9 @@
DMA_TO_DEVICE);
status = eth_port_send(mp, &pkt_info);
+ if (status < 0)
+ goto out;
- if (status != ETH_OK) {
- if ((status == ETH_ERROR))
- if (netif_msg_tx_err(mp))
- printk(KERN_WARNING "%s: Error on "
- "transmitting packet\n",
- dev->name);
-
- if (status == ETH_QUEUE_LAST_RESOURCE)
- if (netif_msg_tx_err(mp))
- printk(KERN_WARNING "%s: Tx resource "
- "error\n", dev->name);
-
- if (status == ETH_QUEUE_FULL)
- if (netif_msg_tx_err(mp))
- printk(KERN_WARNING "%s: Queue is full\n",
- dev->name);
- }
stats->tx_bytes += pkt_info.byte_cnt;
}
}
@@ -1485,10 +1455,8 @@
pkt_info.return_info = skb;
mp->tx_ring_skbs++;
status = eth_port_send(mp, &pkt_info);
- if ((status == ETH_ERROR) || (status == ETH_QUEUE_FULL))
- if (netif_msg_tx_err(mp))
- printk(KERN_WARNING "%s: Error on transmitting packet\n",
- dev->name);
+ if (status == 0)
+ goto out;
stats->tx_bytes += pkt_info.byte_cnt;
#endif
@@ -1508,6 +1476,7 @@
stats->tx_packets++;
dev->trans_start = jiffies;
+out:
spin_unlock_irqrestore(&mp->lock, flags);
return 0; /* success */
@@ -2713,17 +2682,20 @@
/*
* Modified to include the first descriptor pointer in case of SG
*/
-static ETH_FUNC_RET_STATUS eth_port_send(struct mv643xx_private *mp,
- struct pkt_info *p_pkt_info)
+static int eth_port_send(struct mv643xx_private *mp,
+ struct pkt_info *p_pkt_info)
{
int tx_desc_curr, tx_desc_used, tx_first_desc, tx_next_desc;
struct eth_tx_desc *current_descriptor;
struct eth_tx_desc *first_descriptor;
u32 command;
+ int status;
/* Do not process Tx ring in case of Tx ring resource error */
- if (mp->tx_resource_err)
- return ETH_QUEUE_FULL;
+ if (mp->tx_resource_err) {
+ status = -ENOBUFS;
+ goto out;
+ }
/*
* The hardware requires that each buffer that is <= 8 bytes
@@ -2732,7 +2704,8 @@
if (p_pkt_info->byte_cnt <= 8 && p_pkt_info->buf_ptr & 0x7) {
printk(KERN_ERR "%s: packet size <= 8 (%d) problem\n",
dev->name, p_pkt_info->byte_cnt);
- return ETH_ERROR;
+ status = -EIO;
+ goto out;
}
/* Get the Tx Desc ring indexes */
@@ -2787,26 +2760,34 @@
if (tx_next_desc == tx_desc_used) {
mp->tx_resource_err = 1;
mp->tx_curr_desc_q = tx_first_desc;
-
- return ETH_QUEUE_LAST_RESOURCE;
+ result = -ENOBUFS;
+ goto out;
}
mp->tx_curr_desc_q = tx_next_desc;
+ status = 0;
+
+out:
+ if (status == -ENOBUFS)
+ printk(KERN_ERR "%s: Tx queue full\n", dev->name);
- return ETH_OK;
+ return status;
}
#else
-static ETH_FUNC_RET_STATUS eth_port_send(struct mv643xx_private *mp,
- struct pkt_info *p_pkt_info)
+static int eth_port_send(struct mv643xx_private *mp,
+ struct pkt_info *p_pkt_info)
{
int tx_desc_curr;
int tx_desc_used;
struct eth_tx_desc *current_descriptor;
unsigned int command_status;
+ int status;
/* Do not process Tx ring in case of Tx ring resource error */
- if (mp->tx_resource_err)
- return ETH_QUEUE_FULL;
+ if (mp->tx_resource_err) {
+ status = -ENOBUFS;
+ goto out;
+ }
/* Get the Tx Desc ring indexes */
tx_desc_curr = mp->tx_curr_desc_q;
@@ -2842,10 +2823,17 @@
/* Check for ring index overlap in the Tx desc ring */
if (tx_desc_curr == tx_desc_used) {
mp->tx_resource_err = 1;
- return ETH_QUEUE_LAST_RESOURCE;
+ status = -ENOBUFS;
+ goto out;
}
- return ETH_OK;
+ status = 0;
+
+out:
+ if (status == -ENOBUFS)
+ printk(KERN_ERR "%s: Error on Queue Full\n", mp->netdev->name);
+
+ return status;
}
#endif
@@ -2873,8 +2861,8 @@
* ETH_OK otherwise.
*
*/
-static ETH_FUNC_RET_STATUS eth_tx_return_desc(struct mv643xx_private *mp,
- struct pkt_info *p_pkt_info)
+static int eth_tx_return_desc(struct mv643xx_private *mp,
+ struct pkt_info *p_pkt_info)
{
int tx_desc_used;
#ifdef MV643XX_CHECKSUM_OFFLOAD_TX
@@ -2892,17 +2880,17 @@
/* Sanity check */
if (p_tx_desc_used == NULL)
- return ETH_ERROR;
+ return -EBADMSG;
/* Stop release. About to overlap the current available Tx descriptor */
if (tx_desc_used == tx_busy_desc && !mp->tx_resource_err)
- return ETH_END_OF_JOB;
+ return -ENOMSG;
command_status = p_tx_desc_used->cmd_sts;
/* Still transmitting... */
if (command_status & (ETH_BUFFER_OWNED_BY_DMA))
- return ETH_RETRY;
+ return -EBUSY;
/* Pass the packet information to the caller */
p_pkt_info->cmd_sts = command_status;
@@ -2915,7 +2903,7 @@
/* Any Tx return cancels the Tx resource error status */
mp->tx_resource_err = 0;
- return ETH_OK;
+ return 0;
}
/*
@@ -2941,7 +2929,7 @@
* ETH_END_OF_JOB if there is no received data.
* ETH_OK otherwise.
*/
-static ETH_FUNC_RET_STATUS eth_port_receive(struct mv643xx_private *mp,
+static int eth_port_receive(struct mv643xx_private *mp,
struct pkt_info *p_pkt_info)
{
int rx_next_curr_desc, rx_curr_desc, rx_used_desc;
@@ -2950,7 +2938,7 @@
/* Do not process Rx ring in case of Rx ring resource error */
if (mp->rx_resource_err)
- return ETH_QUEUE_FULL;
+ return -ENOBUFS;
/* Get the Rx Desc ring 'curr and 'used' indexes */
rx_curr_desc = mp->rx_curr_desc_q;
@@ -2964,7 +2952,7 @@
/* Nothing to receive... */
if (command_status & (ETH_BUFFER_OWNED_BY_DMA))
- return ETH_END_OF_JOB;
+ return -ENOMSG;
p_pkt_info->byte_cnt = (p_rx_desc->byte_cnt) - RX_BUF_OFFSET;
p_pkt_info->cmd_sts = command_status;
@@ -2991,7 +2979,7 @@
if (rx_next_curr_desc == rx_used_desc)
mp->rx_resource_err = 1;
- return ETH_OK;
+ return 0;
}
/*
@@ -3014,8 +3002,8 @@
* ETH_ERROR in case the routine can not access Rx desc ring.
* ETH_OK otherwise.
*/
-static ETH_FUNC_RET_STATUS eth_rx_return_buff(struct mv643xx_private *mp,
- struct pkt_info *p_pkt_info)
+static void eth_rx_return_buff(struct mv643xx_private *mp,
+ struct pkt_info *p_pkt_info)
{
int used_rx_desc; /* Where to return Rx resource */
volatile struct eth_rx_desc *p_used_rx_desc;
@@ -3046,8 +3034,6 @@
/* Any Rx return cancels the Rx resource error status */
mp->rx_resource_err = 0;
-
- return ETH_OK;
}
/************* Begin ethtool support *************************/
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(9/20): make internal functions take device pointer param consistently
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (7 preceding siblings ...)
2005-03-28 23:48 ` mv643xx(8/20): remove ETH_FUNC_RET_STATUS and unused ETH_TARGET enums Dale Farnsworth
@ 2005-03-28 23:49 ` Dale Farnsworth
2005-03-28 23:49 ` mv643xx(10/20): compile fix for non-NAPI case Dale Farnsworth
` (10 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:49 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Some internal driver functions take int port_num as a parameter to
identify the device. It makes no sense to hide the internal device
structure data from these routines so pass a pointer to the net_device
structure instead. Although in many cases the device data is needed only
to get the port number, this change makes the code more consistent and
easier to maintain.
Signed-off-by: James Chapman <jchapman@katalix.com>
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -80,50 +80,51 @@
static int mv643xx_eth_real_stop(struct net_device *);
static int mv643xx_eth_change_mtu(struct net_device *, int);
static struct net_device_stats *mv643xx_eth_get_stats(struct net_device *);
-static void eth_port_init_mac_tables(unsigned int eth_port_num);
+static void eth_port_init_mac_tables(struct net_device *dev);
#ifdef MV643XX_NAPI
static int mv643xx_poll(struct net_device *dev, int *budget);
#endif
-static int ethernet_phy_get(unsigned int eth_port_num);
-static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr);
-static int ethernet_phy_detect(struct mv643xx_private *mp);
+static int ethernet_phy_get(struct net_device *dev);
+static void ethernet_phy_set(struct net_device *dev, int phy_addr);
+static void ethernet_phy_reset(struct net_device *dev);
+static int ethernet_phy_detect(struct net_device *dev);
static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location);
static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val);
static int mv643xx_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
static struct ethtool_ops mv643xx_ethtool_ops;
/* Port operation control routines */
-static void eth_port_init(struct mv643xx_private *mp);
-static void eth_port_reset(unsigned int eth_port_num);
-static void eth_port_start(struct mv643xx_private *mp);
+static void eth_port_init(struct net_device *dev);
+static void eth_port_reset(struct net_device *dev);
+static void eth_port_start(struct net_device *dev);
-static void ethernet_set_config_reg(unsigned int eth_port_num,
+static void ethernet_set_config_reg(struct net_device *dev,
unsigned int value);
-static unsigned int ethernet_get_config_reg(unsigned int eth_port_num);
+static unsigned int ethernet_get_config_reg(struct net_device *dev);
/* Port MAC address routines */
-static void eth_port_uc_addr_set(unsigned int eth_port_num,
+static void eth_port_uc_addr_set(struct net_device *dev,
unsigned char *p_addr);
/* PHY and MIB routines */
-static void ethernet_phy_reset(struct mv643xx_private *mp);
+static void ethernet_phy_reset(struct net_device *dev);
-static void eth_port_write_smi_reg(struct mv643xx_private *mp,
+static void eth_port_write_smi_reg(struct net_device *dev,
unsigned int phy_reg, unsigned int value);
-static void eth_port_read_smi_reg(struct mv643xx_private *mp,
+static void eth_port_read_smi_reg(struct net_device *dev,
unsigned int phy_reg, unsigned int *value);
-static void eth_clear_mib_counters(unsigned int eth_port_num);
+static void eth_clear_mib_counters(struct net_device *dev);
/* Port data flow control routines */
-static int eth_port_send(struct mv643xx_private *mp,
+static int eth_port_send(struct net_device *dev,
struct pkt_info *p_pkt_info);
-static int eth_tx_return_desc(struct mv643xx_private *mp,
+static int eth_tx_return_desc(struct net_device *dev,
struct pkt_info *p_pkt_info);
-static int eth_port_receive(struct mv643xx_private *mp,
+static int eth_port_receive(struct net_device *dev,
struct pkt_info *p_pkt_info);
-static void eth_rx_return_buff(struct mv643xx_private *mp,
+static void eth_rx_return_buff(struct net_device *dev,
struct pkt_info *p_pkt_info);
static char mv643xx_driver_name[] = "mv643xx_eth";
@@ -220,7 +221,7 @@
pkt_info.buf_ptr = dma_map_single(NULL, skb->data, RX_SKB_SIZE,
DMA_FROM_DEVICE);
pkt_info.return_info = skb;
- eth_rx_return_buff(mp, &pkt_info);
+ eth_rx_return_buff(dev, &pkt_info);
skb_reserve(skb, 2);
}
clear_bit(0, &mp->rx_task_busy);
@@ -275,11 +276,10 @@
static void mv643xx_eth_update_mac_address(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
- unsigned int port_num = mp->port_num;
- eth_port_init_mac_tables(port_num);
+ eth_port_init_mac_tables(dev);
memcpy(mp->port_mac_addr, dev->dev_addr, 6);
- eth_port_uc_addr_set(port_num, mp->port_mac_addr);
+ eth_port_uc_addr_set(dev, mp->port_mac_addr);
}
/*
@@ -292,15 +292,14 @@
*/
static void mv643xx_eth_set_rx_mode(struct net_device *dev)
{
- struct mv643xx_private *mp = netdev_priv(dev);
u32 config_reg;
- config_reg = ethernet_get_config_reg(mp->port_num);
+ config_reg = ethernet_get_config_reg(dev);
if (dev->flags & IFF_PROMISC)
config_reg |= (u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
else
config_reg &= ~(u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
- ethernet_set_config_reg(mp->port_num, config_reg);
+ ethernet_set_config_reg(dev, config_reg);
}
/*
@@ -351,11 +350,9 @@
*/
static void mv643xx_eth_tx_timeout_task(struct net_device *dev)
{
- struct mv643xx_private *mp = netdev_priv(dev);
-
netif_device_detach(dev);
- eth_port_reset(mp->port_num);
- eth_port_start(mp);
+ eth_port_reset(dev);
+ eth_port_start(dev);
netif_device_attach(dev);
}
@@ -380,7 +377,7 @@
spin_lock(&mp->lock);
/* Check only queue 0 */
- while (eth_tx_return_desc(mp, &pkt_info) == 0) {
+ while (eth_tx_return_desc(dev, &pkt_info) == 0) {
if (pkt_info.cmd_sts & BIT0) {
if (netif_msg_tx_err(mp))
printk(KERN_WARNING "%s: Error in TX: cmd_sts=%08x\n",
@@ -449,9 +446,9 @@
struct pkt_info pkt_info;
#ifdef MV643XX_NAPI
- while (eth_port_receive(mp, &pkt_info) == 0 && budget > 0) {
+ while (eth_port_receive(dev, &pkt_info) == 0 && budget > 0) {
#else
- while (eth_port_receive(mp, &pkt_info) == 0) {
+ while (eth_port_receive(dev, &pkt_info) == 0) {
#endif
mp->rx_ring_skbs--;
received_packets++;
@@ -829,7 +826,6 @@
static int mv643xx_eth_open(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
- unsigned int port_num = mp->port_num;
int err;
spin_lock_irq(&mp->lock);
@@ -838,8 +834,8 @@
SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
if (err) {
- printk(KERN_ERR "Can not assign IRQ number to MV643XX_eth%d\n",
- port_num);
+ printk(KERN_ERR "%s: Cannot assign IRQ number\n",
+ dev->name);
err = -EAGAIN;
goto out;
}
@@ -879,7 +875,7 @@
* with physical addresses.
*
* INPUT:
- * struct mv643xx_private *mp Ethernet Port Control srtuct.
+ * struct net_device *dev Ethernet Port Control srtuct.
*
* OUTPUT:
* The routine updates the Ethernet port control struct with information
@@ -888,8 +884,9 @@
* RETURN:
* None.
*/
-static void ether_init_rx_desc_ring(struct mv643xx_private *mp)
+static void ether_init_rx_desc_ring(struct net_device *dev)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
volatile struct eth_rx_desc *p_rx_desc;
int rx_desc_num = mp->rx_ring_size;
int i;
@@ -924,7 +921,7 @@
* with physical addresses.
*
* INPUT:
- * struct mv643xx_private *mp Ethernet Port Control srtuct.
+ * struct net_device *dev Ethernet Port Control srtuct.
*
* OUTPUT:
* The routine updates the Ethernet port control struct with information
@@ -933,8 +930,9 @@
* RETURN:
* None.
*/
-static void ether_init_tx_desc_ring(struct mv643xx_private *mp)
+static void ether_init_tx_desc_ring(struct net_device *dev)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
int tx_desc_num = mp->tx_ring_size;
struct eth_tx_desc *p_tx_desc;
int i;
@@ -983,7 +981,7 @@
/* Set the MAC Address */
memcpy(mp->port_mac_addr, dev->dev_addr, 6);
- eth_port_init(mp);
+ eth_port_init(dev);
INIT_WORK(&mp->rx_task, (void (*)(void *))mv643xx_eth_rx_task, dev);
@@ -1033,7 +1031,7 @@
BUG_ON((u32) mp->p_tx_desc_area & 0xf); /* check 16-byte alignment */
memset((void *)mp->p_tx_desc_area, 0, mp->tx_desc_area_size);
- ether_init_tx_desc_ring(mp);
+ ether_init_tx_desc_ring(dev);
/* Allocate RX ring */
mp->rx_ring_skbs = 0;
@@ -1063,11 +1061,11 @@
}
memset((void *)mp->p_rx_desc_area, 0, size);
- ether_init_rx_desc_ring(mp);
+ ether_init_rx_desc_ring(dev);
mv643xx_eth_rx_task(dev); /* Fill RX ring with skb's */
- eth_port_start(mp);
+ eth_port_start(dev);
/* Interrupt Coalescing */
@@ -1087,11 +1085,10 @@
static void mv643xx_eth_free_tx_rings(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
- unsigned int port_num = mp->port_num;
unsigned int curr;
/* Stop Tx Queues */
- mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num), 0x0000ff00);
+ mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(mp->port_num), 0x0000ff00);
/* Free outstanding skb's on TX rings */
for (curr = 0; mp->tx_ring_skbs && curr < mp->tx_ring_size; curr++) {
@@ -1115,11 +1112,10 @@
static void mv643xx_eth_free_rx_rings(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
- unsigned int port_num = mp->port_num;
int curr;
/* Stop RX Queues */
- mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num), 0x0000ff00);
+ mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(mp->port_num), 0x0000ff00);
/* Free preallocated skb's on RX rings */
for (curr = 0; mp->rx_ring_skbs && curr < mp->rx_ring_size; curr++) {
@@ -1165,7 +1161,7 @@
mv643xx_eth_free_tx_rings(dev);
mv643xx_eth_free_rx_rings(dev);
- eth_port_reset(mp->port_num);
+ eth_port_reset(dev);
/* Disable ethernet port interrupts */
mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
@@ -1200,7 +1196,7 @@
struct mv643xx_private *mp = netdev_priv(dev);
struct pkt_info pkt_info;
- while (eth_tx_return_desc(mp, &pkt_info) == 0) {
+ while (eth_tx_return_desc(dev, &pkt_info) == 0) {
if (pkt_info.return_info) {
if (skb_shinfo(pkt_info.return_info)->nr_frags)
dma_unmap_page(NULL, pkt_info.buf_ptr,
@@ -1351,7 +1347,7 @@
DMA_TO_DEVICE);
pkt_info.return_info = skb;
mp->tx_ring_skbs++;
- status = eth_port_send(mp, &pkt_info);
+ status = eth_port_send(dev, &pkt_info);
if (status < 0)
goto out;
@@ -1409,7 +1405,7 @@
}
}
- status = eth_port_send(mp, &pkt_info);
+ status = eth_port_send(dev, &pkt_info);
if (status < 0)
goto out;
@@ -1438,7 +1434,7 @@
this_frag->size,
DMA_TO_DEVICE);
- status = eth_port_send(mp, &pkt_info);
+ status = eth_port_send(dev, &pkt_info);
if (status < 0)
goto out;
@@ -1454,8 +1450,8 @@
DMA_TO_DEVICE);
pkt_info.return_info = skb;
mp->tx_ring_skbs++;
- status = eth_port_send(mp, &pkt_info);
- if (status == 0)
+ status = eth_port_send(dev, &pkt_info);
+ if (status < 0)
goto out;
stats->tx_bytes += pkt_info.byte_cnt;
@@ -1532,7 +1528,6 @@
dev_set_drvdata(ddev, dev);
mp = netdev_priv(dev);
- mp->netdev = dev;
/* By default, log probe, interface up/down and error events */
mp->msg_enable = NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN |
@@ -1624,7 +1619,7 @@
ADVERTISED_Autoneg |
ADVERTISED_MII;
- ethernet_phy_set(port_num, ecmd->phy_address);
+ ethernet_phy_set(dev, ecmd->phy_address);
memcpy(&mp->ethtool_cmd, ecmd, sizeof *ecmd);
mv643xx_eth_update_pscr(dev, ecmd);
}
@@ -1634,15 +1629,15 @@
mp->mii.dev = dev;
mp->mii.mdio_read = mv643xx_mdio_read;
mp->mii.mdio_write = mv643xx_mdio_write;
- mp->mii.phy_id = ethernet_phy_get(port_num);
+ mp->mii.phy_id = ethernet_phy_get(dev);
mp->mii.phy_id_mask = 0x3f;
mp->mii.reg_num_mask = 0x1f;
- err = ethernet_phy_detect(mp);
+ err = ethernet_phy_detect(dev);
if (err) {
printk(KERN_ERR "MV643xx ethernet port %d: "
"No PHY detected at addr %d\n",
- port_num, ethernet_phy_get(port_num));
+ port_num, ethernet_phy_get(dev));
return err;
}
@@ -1939,10 +1934,6 @@
/* locals */
-/* PHY routines */
-static int ethernet_phy_get(unsigned int eth_port_num);
-static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr);
-
/* Ethernet Port routines */
static int eth_port_uc_addr(unsigned int eth_port_num, unsigned char uc_nibble,
int option);
@@ -1963,7 +1954,7 @@
* struct.
*
* INPUT:
- * struct mv643xx_private *mp Ethernet port control struct
+ * struct net_device *dev Ethernet port control struct
*
* OUTPUT:
* See description.
@@ -1971,19 +1962,21 @@
* RETURN:
* None.
*/
-static void eth_port_init(struct mv643xx_private *mp)
+static void eth_port_init(struct net_device *dev)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
+
mp->port_rx_queue_command = 0;
mp->port_tx_queue_command = 0;
mp->rx_resource_err = 0;
mp->tx_resource_err = 0;
- eth_port_reset(mp->port_num);
+ eth_port_reset(dev);
- eth_port_init_mac_tables(mp->port_num);
+ eth_port_init_mac_tables(dev);
- ethernet_phy_reset(mp);
+ ethernet_phy_reset(dev);
}
/*
@@ -2005,7 +1998,7 @@
* and ether_init_rx_desc_ring for Rx queues).
*
* INPUT:
- * struct mv643xx_private *mp Ethernet port control struct
+ * struct net_device *dev Ethernet port control struct
*
* OUTPUT:
* Ethernet port is ready to receive and transmit.
@@ -2013,8 +2006,9 @@
* RETURN:
* None.
*/
-static void eth_port_start(struct mv643xx_private *mp)
+static void eth_port_start(struct net_device *dev)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
unsigned int port_num = mp->port_num;
int tx_curr_desc, rx_curr_desc;
@@ -2029,7 +2023,7 @@
(u32)((struct eth_rx_desc *)mp->rx_desc_dma + rx_curr_desc));
/* Add the assigned Ethernet address to the port's address table */
- eth_port_uc_addr_set(port_num, mp->port_mac_addr);
+ eth_port_uc_addr_set(dev, mp->port_mac_addr);
/* Assign port configuration and command. */
mv_write(MV643XX_ETH_PORT_CONFIG_REG(port_num),
@@ -2082,9 +2076,11 @@
* N/A.
*
*/
-static void eth_port_uc_addr_set(unsigned int eth_port_num,
- unsigned char *p_addr)
+static void eth_port_uc_addr_set(struct net_device *dev,
+ unsigned char *p_addr)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
+ unsigned int eth_port_num = mp->port_num;
unsigned int mac_h;
unsigned int mac_l;
@@ -2218,9 +2214,11 @@
* RETURN:
* None.
*/
-static void eth_port_init_mac_tables(unsigned int eth_port_num)
+static void eth_port_init_mac_tables(struct net_device *dev)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
int table_index;
+ unsigned int eth_port_num = mp->port_num;
/* Clear DA filter unicast table (Ex_dFUT) */
for (table_index = 0; table_index <= 0xC; table_index += 4)
@@ -2254,8 +2252,10 @@
* MIB counter value.
*
*/
-static void eth_clear_mib_counters(unsigned int eth_port_num)
+static void eth_clear_mib_counters(struct net_device *dev)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
+ unsigned int eth_port_num = mp->port_num;
int i;
/* Perform dummy reads from MIB counters */
@@ -2264,34 +2264,37 @@
mv_read(MV643XX_ETH_MIB_COUNTERS_BASE(eth_port_num) + i);
}
-static inline u32 read_mib(struct mv643xx_private *mp, int offset)
+static inline u32 read_mib(struct net_device *dev, int offset)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
+
return mv_read(MV643XX_ETH_MIB_COUNTERS_BASE(mp->port_num) + offset);
}
-static void eth_update_mib_counters(struct mv643xx_private *mp)
+static void eth_update_mib_counters(struct net_device *dev)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
struct mv643xx_mib_counters *p = &mp->mib_counters;
int offset;
p->good_octets_received +=
- read_mib(mp, ETH_MIB_GOOD_OCTETS_RECEIVED_LOW);
+ read_mib(dev, ETH_MIB_GOOD_OCTETS_RECEIVED_LOW);
p->good_octets_received +=
- (u64)read_mib(mp, ETH_MIB_GOOD_OCTETS_RECEIVED_HIGH) << 32;
+ (u64)read_mib(dev, ETH_MIB_GOOD_OCTETS_RECEIVED_HIGH) << 32;
for (offset = ETH_MIB_BAD_OCTETS_RECEIVED;
offset <= ETH_MIB_FRAMES_1024_TO_MAX_OCTETS;
offset += 4)
- *(u32 *)((char *)p + offset) = read_mib(mp, offset);
+ *(u32 *)((char *)p + offset) = read_mib(dev, offset);
- p->good_octets_sent += read_mib(mp, ETH_MIB_GOOD_OCTETS_SENT_LOW);
+ p->good_octets_sent += read_mib(dev, ETH_MIB_GOOD_OCTETS_SENT_LOW);
p->good_octets_sent +=
- (u64)read_mib(mp, ETH_MIB_GOOD_OCTETS_SENT_HIGH) << 32;
+ (u64)read_mib(dev, ETH_MIB_GOOD_OCTETS_SENT_HIGH) << 32;
for (offset = ETH_MIB_GOOD_FRAMES_SENT;
offset <= ETH_MIB_LATE_COLLISION;
offset += 4)
- *(u32 *)((char *)p + offset) = read_mib(mp, offset);
+ *(u32 *)((char *)p + offset) = read_mib(dev, offset);
}
/*
@@ -2312,22 +2315,22 @@
* -ENODEV on failure
*
*/
-static int ethernet_phy_detect(struct mv643xx_private *mp)
+static int ethernet_phy_detect(struct net_device *dev)
{
unsigned int phy_reg_data0;
int auto_neg;
- eth_port_read_smi_reg(mp, 0, &phy_reg_data0);
+ eth_port_read_smi_reg(dev, 0, &phy_reg_data0);
auto_neg = phy_reg_data0 & 0x1000;
phy_reg_data0 ^= 0x1000; /* invert auto_neg */
- eth_port_write_smi_reg(mp, 0, phy_reg_data0);
+ eth_port_write_smi_reg(dev, 0, phy_reg_data0);
- eth_port_read_smi_reg(mp, 0, &phy_reg_data0);
+ eth_port_read_smi_reg(dev, 0, &phy_reg_data0);
if ((phy_reg_data0 & 0x1000) == auto_neg)
return -ENODEV; /* change didn't take */
phy_reg_data0 ^= 0x1000;
- eth_port_write_smi_reg(mp, 0, phy_reg_data0);
+ eth_port_write_smi_reg(dev, 0, phy_reg_data0);
return 0;
}
@@ -2347,13 +2350,14 @@
* PHY address.
*
*/
-static int ethernet_phy_get(unsigned int eth_port_num)
+static int ethernet_phy_get(struct net_device *dev)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
unsigned int reg_data;
reg_data = mv_read(MV643XX_ETH_PHY_ADDR_REG);
- return ((reg_data >> (5 * eth_port_num)) & 0x1f);
+ return ((reg_data >> (5 * mp->port_num)) & 0x1f);
}
/*
@@ -2373,10 +2377,11 @@
* None.
*
*/
-static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr)
+static void ethernet_phy_set(struct net_device *dev, int phy_addr)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
u32 reg_data;
- int addr_shift = 5 * eth_port_num;
+ int addr_shift = 5 * mp->port_num;
reg_data = mv_read(MV643XX_ETH_PHY_ADDR_REG);
reg_data &= ~(0x1f << addr_shift);
@@ -2400,14 +2405,14 @@
* None.
*
*/
-static void ethernet_phy_reset(struct mv643xx_private *mp)
+static void ethernet_phy_reset(struct net_device *dev)
{
unsigned int phy_reg_data;
/* Reset the PHY */
- eth_port_read_smi_reg(mp, 0, &phy_reg_data);
+ eth_port_read_smi_reg(dev, 0, &phy_reg_data);
phy_reg_data |= 0x8000; /* Set bit 15 to reset the PHY */
- eth_port_write_smi_reg(mp, 0, phy_reg_data);
+ eth_port_write_smi_reg(dev, 0, phy_reg_data);
}
/*
@@ -2428,8 +2433,10 @@
* None.
*
*/
-static void eth_port_reset(unsigned int port_num)
+static void eth_port_reset(struct net_device *dev)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
+ unsigned int port_num = mp->port_num;
unsigned int reg_data;
/* Stop Tx port activity. Check port Tx activity. */
@@ -2463,7 +2470,7 @@
}
/* Clear all MIB counters */
- eth_clear_mib_counters(port_num);
+ eth_clear_mib_counters(dev);
/* Reset the Enable bit in the Configuration Register */
reg_data = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
@@ -2490,9 +2497,11 @@
* None.
*
*/
-static void ethernet_set_config_reg(unsigned int eth_port_num,
- unsigned int value)
+static void ethernet_set_config_reg(struct net_device *dev,
+ unsigned int value)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
+ unsigned int eth_port_num = mp->port_num;
unsigned int eth_config_reg;
eth_config_reg = mv_read(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num));
@@ -2516,12 +2525,13 @@
* RETURN:
* Port configuration register value.
*/
-static unsigned int ethernet_get_config_reg(unsigned int eth_port_num)
+static unsigned int ethernet_get_config_reg(struct net_device *dev)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
unsigned int eth_config_reg;
eth_config_reg = mv_read(MV643XX_ETH_PORT_CONFIG_EXTEND_REG
- (eth_port_num));
+ (mp->port_num));
return eth_config_reg;
}
@@ -2545,11 +2555,10 @@
* true otherwise.
*
*/
-static void eth_port_read_smi_reg(struct mv643xx_private *mp,
+static void eth_port_read_smi_reg(struct net_device *dev,
unsigned int phy_reg, unsigned int *value)
{
- unsigned int port_num = mp->port_num;
- int phy_addr = ethernet_phy_get(port_num);
+ int phy_addr = ethernet_phy_get(dev);
unsigned long flags;
int i;
@@ -2560,7 +2569,7 @@
for (i = 0; mv_read(MV643XX_ETH_SMI_REG) & ETH_SMI_BUSY; i++) {
if (i == PHY_WAIT_ITERATIONS) {
printk(KERN_ERR "%s: PHY busy timeout\n",
- mp->netdev->name);
+ dev->name);
goto out;
}
udelay(PHY_WAIT_MICRO_SECONDS);
@@ -2573,7 +2582,7 @@
for (i = 0; !(mv_read(MV643XX_ETH_SMI_REG) & ETH_SMI_READ_VALID); i++) {
if (i == PHY_WAIT_ITERATIONS) {
printk(KERN_ERR "%s: PHY read timeout\n",
- mp->netdev->name);
+ dev->name);
goto out;
}
udelay(PHY_WAIT_MICRO_SECONDS);
@@ -2604,15 +2613,14 @@
* true otherwise.
*
*/
-static void eth_port_write_smi_reg(struct mv643xx_private *mp,
+static void eth_port_write_smi_reg(struct net_device *dev,
unsigned int phy_reg, unsigned int value)
{
int phy_addr;
int i;
unsigned long flags;
- unsigned int eth_port_num = mp->port_num;
- phy_addr = ethernet_phy_get(eth_port_num);
+ phy_addr = ethernet_phy_get(dev);
/* the SMI register is a shared resource */
spin_lock_irqsave(&mv643xx_eth_phy_lock, flags);
@@ -2621,7 +2629,7 @@
for (i = 0; mv_read(MV643XX_ETH_SMI_REG) & ETH_SMI_BUSY; i++) {
if (i == PHY_WAIT_ITERATIONS) {
printk(KERN_ERR "%s: PHY busy timeout\n",
- mp->netdev->name);
+ dev->name);
goto out;
}
udelay(PHY_WAIT_MICRO_SECONDS);
@@ -2639,16 +2647,14 @@
static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location)
{
int val;
- struct mv643xx_private *mp = netdev_priv(dev);
- eth_port_read_smi_reg(mp, location, &val);
+ eth_port_read_smi_reg(dev, location, &val);
return val;
}
static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val)
{
- struct mv643xx_private *mp = netdev_priv(dev);
- eth_port_write_smi_reg(mp, location, val);
+ eth_port_write_smi_reg(dev, location, val);
}
/*
@@ -2682,7 +2688,7 @@
/*
* Modified to include the first descriptor pointer in case of SG
*/
-static int eth_port_send(struct mv643xx_private *mp,
+static int eth_port_send(struct net_device *dev,
struct pkt_info *p_pkt_info)
{
int tx_desc_curr, tx_desc_used, tx_first_desc, tx_next_desc;
@@ -2774,9 +2780,10 @@
return status;
}
#else
-static int eth_port_send(struct mv643xx_private *mp,
+static int eth_port_send(struct net_device *dev,
struct pkt_info *p_pkt_info)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
int tx_desc_curr;
int tx_desc_used;
struct eth_tx_desc *current_descriptor;
@@ -2801,7 +2808,7 @@
if (netif_msg_tx_queued(mp))
printk(KERN_DEBUG "%s: send pkt: desc=%d len=%d, f/l=%d/%d\n",
- mp->netdev->name, tx_desc_curr,
+ dev->name, tx_desc_curr,
p_pkt_info->byte_cnt,
((command_status & ETH_TX_FIRST_DESC) != 0),
((command_status & ETH_TX_LAST_DESC) != 0));
@@ -2831,7 +2838,7 @@
out:
if (status == -ENOBUFS)
- printk(KERN_ERR "%s: Error on Queue Full\n", mp->netdev->name);
+ printk(KERN_ERR "%s: Error on Queue Full\n", dev->name);
return status;
}
@@ -2861,9 +2868,10 @@
* ETH_OK otherwise.
*
*/
-static int eth_tx_return_desc(struct mv643xx_private *mp,
+static int eth_tx_return_desc(struct net_device *dev,
struct pkt_info *p_pkt_info)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
int tx_desc_used;
#ifdef MV643XX_CHECKSUM_OFFLOAD_TX
int tx_busy_desc = mp->tx_first_desc_q;
@@ -2929,9 +2937,10 @@
* ETH_END_OF_JOB if there is no received data.
* ETH_OK otherwise.
*/
-static int eth_port_receive(struct mv643xx_private *mp,
+static int eth_port_receive(struct net_device *dev,
struct pkt_info *p_pkt_info)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
int rx_next_curr_desc, rx_curr_desc, rx_used_desc;
volatile struct eth_rx_desc *p_rx_desc;
unsigned int command_status;
@@ -2962,7 +2971,7 @@
if (netif_msg_rx_status(mp))
printk(KERN_DEBUG "%s: rcv pkt: len=%d, desc=%d, f/l=%d/%d\n",
- mp->netdev->name,
+ dev->name,
p_pkt_info->byte_cnt, rx_curr_desc,
((command_status & ETH_RX_FIRST_DESC) != 0),
((command_status & ETH_RX_LAST_DESC) != 0));
@@ -3002,9 +3011,10 @@
* ETH_ERROR in case the routine can not access Rx desc ring.
* ETH_OK otherwise.
*/
-static void eth_rx_return_buff(struct mv643xx_private *mp,
+static void eth_rx_return_buff(struct net_device *dev,
struct pkt_info *p_pkt_info)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
int used_rx_desc; /* Where to return Rx resource */
volatile struct eth_rx_desc *p_used_rx_desc;
@@ -3018,7 +3028,7 @@
if (netif_msg_rx_status(mp))
printk(KERN_DEBUG "%s: rx done, len=%d, desc=%d, status=%08x\n",
- mp->netdev->name, p_pkt_info->byte_cnt, used_rx_desc,
+ dev->name, p_pkt_info->byte_cnt, used_rx_desc,
p_used_rx_desc->cmd_sts);
/* Flush the write pipe */
@@ -3131,7 +3141,7 @@
struct mv643xx_private *mp = netdev->priv;
int i;
- eth_update_mib_counters(mp);
+ eth_update_mib_counters(netdev);
for(i = 0; i < MV643XX_STATS_LEN; i++) {
char *p = (char *)mp+mv643xx_gstrings_stats[i].stat_offset;
Index: linux-2.5-enet/drivers/net/mv643xx_eth.h
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.h
+++ linux-2.5-enet/drivers/net/mv643xx_eth.h
@@ -547,7 +547,6 @@
u32 msg_enable;
struct mii_if_info mii;
- struct net_device *netdev;
};
#endif /* __MV643XX_ETH_H__ */
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(10/20): compile fix for non-NAPI case
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (8 preceding siblings ...)
2005-03-28 23:49 ` mv643xx(9/20): make internal functions take device pointer param consistently Dale Farnsworth
@ 2005-03-28 23:49 ` Dale Farnsworth
2005-03-28 23:51 ` mv643xx(11/20): rename all functions to have a common mv643xx_eth prefix Dale Farnsworth
` (9 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:49 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Compiles for the non-NAPI configuration were broken.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -561,9 +561,10 @@
(port_num), 0);
__netif_rx_schedule(dev);
}
+ }
#else
if (eth_int_cause & (BIT2 | BIT11))
- mv643xx_eth_receive_queue(dev, 0);
+ mv643xx_eth_receive_queue(dev);
/*
* After forwarded received packets to upper layer, add a task
@@ -580,7 +581,6 @@
mp->rx_task.func(dev);
#endif
#endif
- }
/* PHY status changed */
if (eth_int_cause_ext & (BIT16 | BIT20)) {
struct ethtool_cmd cmd;
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(11/20): rename all functions to have a common mv643xx_eth prefix
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (9 preceding siblings ...)
2005-03-28 23:49 ` mv643xx(10/20): compile fix for non-NAPI case Dale Farnsworth
@ 2005-03-28 23:51 ` Dale Farnsworth
2005-03-28 23:55 ` mv643xx(12/20): reorder code to avoid prototype function declarations Dale Farnsworth
` (8 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:51 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
This patch just establishes consistent function naming. No functional
changes here.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -74,57 +74,56 @@
#define PHY_WAIT_MICRO_SECONDS 10
/* Static function declarations */
-static void eth_port_uc_addr_get(struct net_device *dev,
- unsigned char *MacAddr);
static int mv643xx_eth_real_open(struct net_device *);
static int mv643xx_eth_real_stop(struct net_device *);
static int mv643xx_eth_change_mtu(struct net_device *, int);
static struct net_device_stats *mv643xx_eth_get_stats(struct net_device *);
-static void eth_port_init_mac_tables(struct net_device *dev);
+static void mv643xx_eth_port_init_mac_tables(struct net_device *dev);
#ifdef MV643XX_NAPI
-static int mv643xx_poll(struct net_device *dev, int *budget);
+static int mv643xx_eth_poll(struct net_device *dev, int *budget);
#endif
-static int ethernet_phy_get(struct net_device *dev);
-static void ethernet_phy_set(struct net_device *dev, int phy_addr);
-static void ethernet_phy_reset(struct net_device *dev);
-static int ethernet_phy_detect(struct net_device *dev);
-static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location);
-static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val);
+static int mv643xx_eth_phy_get(struct net_device *dev);
+static void mv643xx_eth_phy_set(struct net_device *dev, int phy_addr);
+static void mv643xx_eth_phy_reset(struct net_device *dev);
+static int mv643xx_eth_phy_detect(struct net_device *dev);
+static int mv643xx_eth_mdio_read(struct net_device *dev, int phy_id, int location);
+static void mv643xx_eth_mdio_write(struct net_device *dev, int phy_id, int location, int val);
static int mv643xx_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
static struct ethtool_ops mv643xx_ethtool_ops;
/* Port operation control routines */
-static void eth_port_init(struct net_device *dev);
-static void eth_port_reset(struct net_device *dev);
-static void eth_port_start(struct net_device *dev);
+static void mv643xx_eth_port_init(struct net_device *dev);
+static void mv643xx_eth_port_reset(struct net_device *dev);
+static void mv643xx_eth_port_start(struct net_device *dev);
-static void ethernet_set_config_reg(struct net_device *dev,
+static void mv643xx_eth_set_config_reg(struct net_device *dev,
unsigned int value);
-static unsigned int ethernet_get_config_reg(struct net_device *dev);
+static unsigned int mv643xx_eth_get_config_reg(struct net_device *dev);
/* Port MAC address routines */
-static void eth_port_uc_addr_set(struct net_device *dev,
+static void mv643xx_eth_port_mac_addr_get(struct net_device *dev, unsigned char *p_addr);
+static void mv643xx_eth_port_mac_addr_set(struct net_device *dev,
unsigned char *p_addr);
/* PHY and MIB routines */
-static void ethernet_phy_reset(struct net_device *dev);
+static void mv643xx_eth_phy_reset(struct net_device *dev);
-static void eth_port_write_smi_reg(struct net_device *dev,
+static void mv643xx_eth_write_smi_reg(struct net_device *dev,
unsigned int phy_reg, unsigned int value);
-static void eth_port_read_smi_reg(struct net_device *dev,
+static void mv643xx_eth_read_smi_reg(struct net_device *dev,
unsigned int phy_reg, unsigned int *value);
-static void eth_clear_mib_counters(struct net_device *dev);
+static void mv643xx_eth_clear_mib_counters(struct net_device *dev);
/* Port data flow control routines */
-static int eth_port_send(struct net_device *dev,
+static int mv643xx_eth_tx_packet(struct net_device *dev,
struct pkt_info *p_pkt_info);
-static int eth_tx_return_desc(struct net_device *dev,
+static int mv643xx_eth_tx_return_desc(struct net_device *dev,
struct pkt_info *p_pkt_info);
-static int eth_port_receive(struct net_device *dev,
+static int mv643xx_eth_rx_packet(struct net_device *dev,
struct pkt_info *p_pkt_info);
-static void eth_rx_return_buff(struct net_device *dev,
+static void mv643xx_eth_rx_return_buff(struct net_device *dev,
struct pkt_info *p_pkt_info);
static char mv643xx_driver_name[] = "mv643xx_eth";
@@ -135,7 +134,7 @@
/* used to protect MV643XX_ETH_SMI_REG, which is shared across ports */
static spinlock_t mv643xx_eth_phy_lock = SPIN_LOCK_UNLOCKED;
-static inline u32 mv_read(int offset)
+static inline u32 mv643xx_eth_read(int offset)
{
void *__iomem reg_base;
@@ -144,7 +143,7 @@
return readl(reg_base + offset);
}
-static inline void mv_write(int offset, u32 data)
+static inline void mv643xx_eth_write(int offset, u32 data)
{
void * __iomem reg_base;
@@ -221,7 +220,7 @@
pkt_info.buf_ptr = dma_map_single(NULL, skb->data, RX_SKB_SIZE,
DMA_FROM_DEVICE);
pkt_info.return_info = skb;
- eth_rx_return_buff(dev, &pkt_info);
+ mv643xx_eth_rx_return_buff(dev, &pkt_info);
skb_reserve(skb, 2);
}
clear_bit(0, &mp->rx_task_busy);
@@ -240,7 +239,7 @@
#ifdef MV643XX_RX_QUEUE_FILL_ON_TASK
else {
/* Return interrupts */
- mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(mp->port_num),
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_MASK_REG(mp->port_num),
INT_CAUSE_UNMASK_ALL);
}
#endif
@@ -277,9 +276,9 @@
{
struct mv643xx_private *mp = netdev_priv(dev);
- eth_port_init_mac_tables(dev);
+ mv643xx_eth_port_init_mac_tables(dev);
memcpy(mp->port_mac_addr, dev->dev_addr, 6);
- eth_port_uc_addr_set(dev, mp->port_mac_addr);
+ mv643xx_eth_port_mac_addr_set(dev, mp->port_mac_addr);
}
/*
@@ -294,12 +293,12 @@
{
u32 config_reg;
- config_reg = ethernet_get_config_reg(dev);
+ config_reg = mv643xx_eth_get_config_reg(dev);
if (dev->flags & IFF_PROMISC)
config_reg |= (u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
else
config_reg &= ~(u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
- ethernet_set_config_reg(dev, config_reg);
+ mv643xx_eth_set_config_reg(dev, config_reg);
}
/*
@@ -351,8 +350,8 @@
static void mv643xx_eth_tx_timeout_task(struct net_device *dev)
{
netif_device_detach(dev);
- eth_port_reset(dev);
- eth_port_start(dev);
+ mv643xx_eth_port_reset(dev);
+ mv643xx_eth_port_start(dev);
netif_device_attach(dev);
}
@@ -377,7 +376,7 @@
spin_lock(&mp->lock);
/* Check only queue 0 */
- while (eth_tx_return_desc(dev, &pkt_info) == 0) {
+ while (mv643xx_eth_tx_return_desc(dev, &pkt_info) == 0) {
if (pkt_info.cmd_sts & BIT0) {
if (netif_msg_tx_err(mp))
printk(KERN_WARNING "%s: Error in TX: cmd_sts=%08x\n",
@@ -446,9 +445,9 @@
struct pkt_info pkt_info;
#ifdef MV643XX_NAPI
- while (eth_port_receive(dev, &pkt_info) == 0 && budget > 0) {
+ while (mv643xx_eth_rx_packet(dev, &pkt_info) == 0 && budget > 0) {
#else
- while (eth_port_receive(dev, &pkt_info) == 0) {
+ while (mv643xx_eth_rx_packet(dev, &pkt_info) == 0) {
#endif
mp->rx_ring_skbs--;
received_packets++;
@@ -525,11 +524,11 @@
unsigned int port_num = mp->port_num;
/* Read interrupt cause registers */
- eth_int_cause = mv_read(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num)) &
+ eth_int_cause = mv643xx_eth_read(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num)) &
INT_CAUSE_UNMASK_ALL;
if (eth_int_cause & BIT1)
- eth_int_cause_ext = mv_read(
+ eth_int_cause_ext = mv643xx_eth_read(
MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num)) &
INT_CAUSE_UNMASK_ALL_EXT;
@@ -541,10 +540,10 @@
* Clear specific ethernet port intrerrupt registers by
* acknowleding relevant bits.
*/
- mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num),
~eth_int_cause);
if (eth_int_cause_ext != 0x0)
- mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG
(port_num), ~eth_int_cause_ext);
/* UDP change : We may need this */
@@ -556,8 +555,8 @@
} else {
if (netif_rx_schedule_prep(dev)) {
/* Mask all the interrupts */
- mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), 0);
- mv_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), 0);
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG
(port_num), 0);
__netif_rx_schedule(dev);
}
@@ -573,7 +572,7 @@
*/
#ifdef MV643XX_RX_QUEUE_FILL_ON_TASK
/* Unmask all interrupts on ethernet port */
- mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num),
INT_CAUSE_MASK_ALL);
queue_task(&mp->rx_task, &tq_immediate);
mark_bh(IMMEDIATE_BH);
@@ -606,7 +605,7 @@
netif_wake_queue(dev);
/* Start TX queue */
- mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num), 1);
+ mv643xx_eth_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num), 1);
} else if(!mii_link_ok(&mp->mii) && netif_carrier_ok(dev)) {
netif_stop_queue(dev);
@@ -652,15 +651,15 @@
* The interrupt coalescing value set in the gigE port.
*
*/
-static unsigned int eth_port_set_rx_coal(unsigned int eth_port_num,
+static unsigned int mv643xx_eth_port_set_rx_coal(unsigned int eth_port_num,
unsigned int t_clk, unsigned int delay)
{
unsigned int coal = ((t_clk / 1000000) * delay) / 64;
/* Set RX Coalescing mechanism */
- mv_write(MV643XX_ETH_SDMA_CONFIG_REG(eth_port_num),
+ mv643xx_eth_write(MV643XX_ETH_SDMA_CONFIG_REG(eth_port_num),
((coal & 0x3fff) << 8) |
- (mv_read(MV643XX_ETH_SDMA_CONFIG_REG(eth_port_num))
+ (mv643xx_eth_read(MV643XX_ETH_SDMA_CONFIG_REG(eth_port_num))
& 0xffc000ff));
return coal;
@@ -690,13 +689,13 @@
* The interrupt coalescing value set in the gigE port.
*
*/
-static unsigned int eth_port_set_tx_coal(unsigned int eth_port_num,
+static unsigned int mv643xx_eth_port_set_tx_coal(unsigned int eth_port_num,
unsigned int t_clk, unsigned int delay)
{
unsigned int coal;
coal = ((t_clk / 1000000) * delay) / 64;
/* Set TX Coalescing mechanism */
- mv_write(MV643XX_ETH_TX_FIFO_URGENT_THRESHOLD_REG(eth_port_num),
+ mv643xx_eth_write(MV643XX_ETH_TX_FIFO_URGENT_THRESHOLD_REG(eth_port_num),
coal << 4);
return coal;
}
@@ -727,7 +726,7 @@
mp->port_serial_control |= BIT23;
}
-static int mv643xx_set_settings(struct net_device *dev,
+static int mv643xx_eth_set_settings(struct net_device *dev,
struct ethtool_cmd *cmd)
{
struct mv643xx_private *mp = netdev_priv(dev);
@@ -849,7 +848,7 @@
spin_unlock_irq(&mp->lock);
if (mp->ethtool_cmd.autoneg || mp->ethtool_cmd.speed)
- mv643xx_set_settings(dev, &mp->ethtool_cmd);
+ mv643xx_eth_set_settings(dev, &mp->ethtool_cmd);
return 0;
@@ -884,7 +883,7 @@
* RETURN:
* None.
*/
-static void ether_init_rx_desc_ring(struct net_device *dev)
+static void mv643xx_eth_init_rx_desc_ring(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
volatile struct eth_rx_desc *p_rx_desc;
@@ -930,7 +929,7 @@
* RETURN:
* None.
*/
-static void ether_init_tx_desc_ring(struct net_device *dev)
+static void mv643xx_eth_init_tx_desc_ring(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
int tx_desc_num = mp->tx_ring_size;
@@ -964,24 +963,24 @@
unsigned int size;
/* Stop RX Queues */
- mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num), 0x0000ff00);
+ mv643xx_eth_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num), 0x0000ff00);
/* Clear the ethernet port interrupts */
- mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
- mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
/* Unmask RX buffer and TX end interrupt */
- mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num),
INT_CAUSE_UNMASK_ALL);
/* Unmask phy and link status changes interrupts */
- mv_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num),
INT_CAUSE_UNMASK_ALL_EXT);
/* Set the MAC Address */
memcpy(mp->port_mac_addr, dev->dev_addr, 6);
- eth_port_init(dev);
+ mv643xx_eth_port_init(dev);
INIT_WORK(&mp->rx_task, (void (*)(void *))mv643xx_eth_rx_task, dev);
@@ -1031,7 +1030,7 @@
BUG_ON((u32) mp->p_tx_desc_area & 0xf); /* check 16-byte alignment */
memset((void *)mp->p_tx_desc_area, 0, mp->tx_desc_area_size);
- ether_init_tx_desc_ring(dev);
+ mv643xx_eth_init_tx_desc_ring(dev);
/* Allocate RX ring */
mp->rx_ring_skbs = 0;
@@ -1061,21 +1060,21 @@
}
memset((void *)mp->p_rx_desc_area, 0, size);
- ether_init_rx_desc_ring(dev);
+ mv643xx_eth_init_rx_desc_ring(dev);
mv643xx_eth_rx_task(dev); /* Fill RX ring with skb's */
- eth_port_start(dev);
+ mv643xx_eth_port_start(dev);
/* Interrupt Coalescing */
#ifdef MV643XX_COAL
mp->rx_int_coal =
- eth_port_set_rx_coal(port_num, 133000000, MV643XX_RX_COAL);
+ mv643xx_eth_port_set_rx_coal(port_num, 133000000, MV643XX_RX_COAL);
#endif
mp->tx_int_coal =
- eth_port_set_tx_coal(port_num, 133000000, MV643XX_TX_COAL);
+ mv643xx_eth_port_set_tx_coal(port_num, 133000000, MV643XX_TX_COAL);
netif_start_queue(dev);
@@ -1088,7 +1087,7 @@
unsigned int curr;
/* Stop Tx Queues */
- mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(mp->port_num), 0x0000ff00);
+ mv643xx_eth_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(mp->port_num), 0x0000ff00);
/* Free outstanding skb's on TX rings */
for (curr = 0; mp->tx_ring_skbs && curr < mp->tx_ring_size; curr++) {
@@ -1115,7 +1114,7 @@
int curr;
/* Stop RX Queues */
- mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(mp->port_num), 0x0000ff00);
+ mv643xx_eth_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(mp->port_num), 0x0000ff00);
/* Free preallocated skb's on RX rings */
for (curr = 0; mp->rx_ring_skbs && curr < mp->rx_ring_size; curr++) {
@@ -1161,17 +1160,17 @@
mv643xx_eth_free_tx_rings(dev);
mv643xx_eth_free_rx_rings(dev);
- eth_port_reset(dev);
+ mv643xx_eth_port_reset(dev);
/* Disable ethernet port interrupts */
- mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
- mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
/* Mask RX buffer and TX end interrupt */
- mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), 0);
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), 0);
/* Mask phy and link status changes interrupts */
- mv_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num), 0);
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num), 0);
return 0;
}
@@ -1191,12 +1190,12 @@
}
#ifdef MV643XX_NAPI
-static void mv643xx_tx(struct net_device *dev)
+static void mv643xx_eth_tx(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
struct pkt_info pkt_info;
- while (eth_tx_return_desc(dev, &pkt_info) == 0) {
+ while (mv643xx_eth_tx_return_desc(dev, &pkt_info) == 0) {
if (pkt_info.return_info) {
if (skb_shinfo(pkt_info.return_info)->nr_frags)
dma_unmap_page(NULL, pkt_info.buf_ptr,
@@ -1226,7 +1225,7 @@
*
* This function is used in case of NAPI
*/
-static int mv643xx_poll(struct net_device *dev, int *budget)
+static int mv643xx_eth_poll(struct net_device *dev, int *budget)
{
struct mv643xx_private *mp = netdev_priv(dev);
int done = 1, orig_budget, work_done;
@@ -1236,13 +1235,13 @@
#ifdef MV643XX_TX_FAST_REFILL
if (++mp->tx_clean_threshold > 5) {
spin_lock_irqsave(&mp->lock, flags);
- mv643xx_tx(dev);
+ mv643xx_eth_tx(dev);
mp->tx_clean_threshold = 0;
spin_unlock_irqrestore(&mp->lock, flags);
}
#endif
- if ((mv_read(MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_0(port_num)))
+ if ((mv643xx_eth_read(MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_0(port_num)))
!= (u32) mp->rx_used_desc_q) {
orig_budget = *budget;
if (orig_budget > dev->quota)
@@ -1258,11 +1257,11 @@
if (done) {
spin_lock_irqsave(&mp->lock, flags);
__netif_rx_complete(dev);
- mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
- mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
- mv_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num),
INT_CAUSE_UNMASK_ALL);
- mv_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num),
INT_CAUSE_UNMASK_ALL_EXT);
spin_unlock_irqrestore(&mp->lock, flags);
}
@@ -1347,7 +1346,7 @@
DMA_TO_DEVICE);
pkt_info.return_info = skb;
mp->tx_ring_skbs++;
- status = eth_port_send(dev, &pkt_info);
+ status = mv643xx_eth_tx_packet(dev, &pkt_info);
if (status < 0)
goto out;
@@ -1405,7 +1404,7 @@
}
}
- status = eth_port_send(dev, &pkt_info);
+ status = mv643xx_eth_tx_packet(dev, &pkt_info);
if (status < 0)
goto out;
@@ -1434,7 +1433,7 @@
this_frag->size,
DMA_TO_DEVICE);
- status = eth_port_send(dev, &pkt_info);
+ status = mv643xx_eth_tx_packet(dev, &pkt_info);
if (status < 0)
goto out;
@@ -1450,7 +1449,7 @@
DMA_TO_DEVICE);
pkt_info.return_info = skb;
mp->tx_ring_skbs++;
- status = eth_port_send(dev, &pkt_info);
+ status = mv643xx_eth_tx_packet(dev, &pkt_info);
if (status < 0)
goto out;
@@ -1495,7 +1494,7 @@
return &mp->stats;
}
-/*/
+/*
* mv643xx_eth_probe
*
* First function called after registering the network device.
@@ -1549,7 +1548,7 @@
/* No need to Tx Timeout */
dev->tx_timeout = mv643xx_eth_tx_timeout;
#ifdef MV643XX_NAPI
- dev->poll = mv643xx_poll;
+ dev->poll = mv643xx_eth_poll;
dev->weight = 64;
#endif
@@ -1577,9 +1576,9 @@
spin_lock_init(&mp->lock);
/* set default config values */
- eth_port_uc_addr_get(dev, dev->dev_addr);
+ mv643xx_eth_port_mac_addr_get(dev, dev->dev_addr);
mp->port_serial_control =
- mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
+ mv643xx_eth_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
mp->port_serial_control &= ~MV643XX_ETH_SERIAL_PORT_ENABLE;
mp->port_serial_control |= MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL |
MV643XX_ETH_SERIAL_PORT_CONTROL_RESERVED |
@@ -1619,25 +1618,25 @@
ADVERTISED_Autoneg |
ADVERTISED_MII;
- ethernet_phy_set(dev, ecmd->phy_address);
+ mv643xx_eth_phy_set(dev, ecmd->phy_address);
memcpy(&mp->ethtool_cmd, ecmd, sizeof *ecmd);
mv643xx_eth_update_pscr(dev, ecmd);
}
}
-
/* Hook up MII support for ethtool */
mp->mii.dev = dev;
- mp->mii.mdio_read = mv643xx_mdio_read;
- mp->mii.mdio_write = mv643xx_mdio_write;
- mp->mii.phy_id = ethernet_phy_get(dev);
+ mp->mii.mdio_read = mv643xx_eth_mdio_read;
+ mp->mii.mdio_write = mv643xx_eth_mdio_write;
+ mp->mii.phy_id = mv643xx_eth_phy_get(dev);
mp->mii.phy_id_mask = 0x3f;
mp->mii.reg_num_mask = 0x1f;
- err = ethernet_phy_detect(dev);
+ err = mv643xx_eth_phy_detect(dev);
+
if (err) {
printk(KERN_ERR "MV643xx ethernet port %d: "
"No PHY detected at addr %d\n",
- port_num, ethernet_phy_get(dev));
+ port_num, mv643xx_eth_phy_get(dev));
return err;
}
@@ -1751,7 +1750,7 @@
*
* Output : N/A
*/
-static int __init mv643xx_init_module(void)
+static int __init mv643xx_eth_init_module(void)
{
int rc;
@@ -1773,14 +1772,14 @@
*
* Output : N/A
*/
-static void __exit mv643xx_cleanup_module(void)
+static void __exit mv643xx_eth_cleanup_module(void)
{
driver_unregister(&mv643xx_eth_driver);
driver_unregister(&mv643xx_eth_shared_driver);
}
-module_init(mv643xx_init_module);
-module_exit(mv643xx_cleanup_module);
+module_init(mv643xx_eth_init_module);
+module_exit(mv643xx_eth_cleanup_module);
MODULE_LICENSE("GPL");
MODULE_AUTHOR( "Rabeeh Khoury, Assaf Hoffman, Matthew Dharm, Manish Lachwani"
@@ -1930,12 +1929,10 @@
/* defines */
/* SDMA command macros */
#define ETH_ENABLE_TX_QUEUE(eth_port) \
- mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(eth_port), 1)
-
-/* locals */
+ mv643xx_eth_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(eth_port), 1)
/* Ethernet Port routines */
-static int eth_port_uc_addr(unsigned int eth_port_num, unsigned char uc_nibble,
+static int mv643xx_eth_port_mac_addr(unsigned int eth_port_num, unsigned char uc_nibble,
int option);
/*
@@ -1962,7 +1959,7 @@
* RETURN:
* None.
*/
-static void eth_port_init(struct net_device *dev)
+static void mv643xx_eth_port_init(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
@@ -1972,11 +1969,11 @@
mp->rx_resource_err = 0;
mp->tx_resource_err = 0;
- eth_port_reset(dev);
+ mv643xx_eth_port_reset(dev);
- eth_port_init_mac_tables(dev);
+ mv643xx_eth_port_init_mac_tables(dev);
- ethernet_phy_reset(dev);
+ mv643xx_eth_phy_reset(dev);
}
/*
@@ -2006,7 +2003,7 @@
* RETURN:
* None.
*/
-static void eth_port_start(struct net_device *dev)
+static void mv643xx_eth_port_start(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
unsigned int port_num = mp->port_num;
@@ -2014,47 +2011,46 @@
/* Assignment of Tx CTRP of given queue */
tx_curr_desc = mp->tx_curr_desc_q;
- mv_write(MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_0(port_num),
+ mv643xx_eth_write(MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_0(port_num),
(u32)((struct eth_tx_desc *)mp->tx_desc_dma + tx_curr_desc));
/* Assignment of Rx CRDP of given queue */
rx_curr_desc = mp->rx_curr_desc_q;
- mv_write(MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_0(port_num),
+ mv643xx_eth_write(MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_0(port_num),
(u32)((struct eth_rx_desc *)mp->rx_desc_dma + rx_curr_desc));
/* Add the assigned Ethernet address to the port's address table */
- eth_port_uc_addr_set(dev, mp->port_mac_addr);
+ mv643xx_eth_port_mac_addr_set(dev, mp->port_mac_addr);
/* Assign port configuration and command. */
- mv_write(MV643XX_ETH_PORT_CONFIG_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_PORT_CONFIG_REG(port_num),
MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE);
- mv_write(MV643XX_ETH_PORT_CONFIG_EXTEND_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_PORT_CONFIG_EXTEND_REG(port_num),
MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE);
/* the mv643xx users manual says the following read/write are needed */
- mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
- mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), 0);
-
+ mv643xx_eth_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
+ mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), 0);
/* Increase the Rx side buffer size if supporting GigE */
if (mp->port_serial_control & MV643XX_ETH_SET_GMII_SPEED_TO_1000)
- mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
(mp->port_serial_control & 0xfff1ffff) | (0x5 << 17));
else
- mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
mp->port_serial_control);
- mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
- mp->port_serial_control |
- MV643XX_ETH_SERIAL_PORT_ENABLE);
+ mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
+ mp->port_serial_control |
+ MV643XX_ETH_SERIAL_PORT_ENABLE);
/* Assign port SDMA configuration */
- mv_write(MV643XX_ETH_SDMA_CONFIG_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_SDMA_CONFIG_REG(port_num),
MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE);
/* Enable port Rx. */
- mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num),
mp->port_rx_queue_command);
}
@@ -2076,8 +2072,8 @@
* N/A.
*
*/
-static void eth_port_uc_addr_set(struct net_device *dev,
- unsigned char *p_addr)
+static void mv643xx_eth_port_mac_addr_set(struct net_device *dev,
+ unsigned char *p_addr)
{
struct mv643xx_private *mp = netdev_priv(dev);
unsigned int eth_port_num = mp->port_num;
@@ -2088,11 +2084,11 @@
mac_h = (p_addr[0] << 24) | (p_addr[1] << 16) | (p_addr[2] << 8) |
(p_addr[3] << 0);
- mv_write(MV643XX_ETH_MAC_ADDR_LOW(eth_port_num), mac_l);
- mv_write(MV643XX_ETH_MAC_ADDR_HIGH(eth_port_num), mac_h);
+ mv643xx_eth_write(MV643XX_ETH_MAC_ADDR_LOW(eth_port_num), mac_l);
+ mv643xx_eth_write(MV643XX_ETH_MAC_ADDR_HIGH(eth_port_num), mac_h);
/* Accept frames of this address */
- eth_port_uc_addr(eth_port_num, p_addr[5], ACCEPT_MAC_ADDR);
+ mv643xx_eth_port_mac_addr(eth_port_num, p_addr[5], ACCEPT_MAC_ADDR);
return;
}
@@ -2115,14 +2111,14 @@
* N/A.
*
*/
-static void eth_port_uc_addr_get(struct net_device *dev, unsigned char *p_addr)
+static void mv643xx_eth_port_mac_addr_get(struct net_device *dev, unsigned char *p_addr)
{
struct mv643xx_private *mp = netdev_priv(dev);
unsigned int mac_h;
unsigned int mac_l;
- mac_h = mv_read(MV643XX_ETH_MAC_ADDR_HIGH(mp->port_num));
- mac_l = mv_read(MV643XX_ETH_MAC_ADDR_LOW(mp->port_num));
+ mac_h = mv643xx_eth_read(MV643XX_ETH_MAC_ADDR_HIGH(mp->port_num));
+ mac_l = mv643xx_eth_read(MV643XX_ETH_MAC_ADDR_LOW(mp->port_num));
p_addr[0] = (mac_h >> 24) & 0xff;
p_addr[1] = (mac_h >> 16) & 0xff;
@@ -2154,7 +2150,7 @@
* false if option parameter is invalid.
*
*/
-static int eth_port_uc_addr(unsigned int eth_port_num, unsigned char uc_nibble,
+static int mv643xx_eth_port_mac_addr(unsigned int eth_port_num, unsigned char uc_nibble,
int option)
{
unsigned int unicast_reg;
@@ -2169,24 +2165,24 @@
switch (option) {
case REJECT_MAC_ADDR:
/* Clear accepts frame bit at given unicast DA table entry */
- unicast_reg = mv_read((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
+ unicast_reg = mv643xx_eth_read((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
(eth_port_num) + tbl_offset));
unicast_reg &= (0x0E << (8 * reg_offset));
- mv_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
+ mv643xx_eth_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
(eth_port_num) + tbl_offset), unicast_reg);
break;
case ACCEPT_MAC_ADDR:
/* Set accepts frame bit at unicast DA filter table entry */
unicast_reg =
- mv_read((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
+ mv643xx_eth_read((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
(eth_port_num) + tbl_offset));
unicast_reg |= (0x01 << (8 * reg_offset));
- mv_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
+ mv643xx_eth_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
(eth_port_num) + tbl_offset), unicast_reg);
break;
@@ -2214,7 +2210,7 @@
* RETURN:
* None.
*/
-static void eth_port_init_mac_tables(struct net_device *dev)
+static void mv643xx_eth_port_init_mac_tables(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
int table_index;
@@ -2222,15 +2218,15 @@
/* Clear DA filter unicast table (Ex_dFUT) */
for (table_index = 0; table_index <= 0xC; table_index += 4)
- mv_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
+ mv643xx_eth_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
(eth_port_num) + table_index), 0);
for (table_index = 0; table_index <= 0xFC; table_index += 4) {
/* Clear DA filter special multicast table (Ex_dFSMT) */
- mv_write((MV643XX_ETH_DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE
+ mv643xx_eth_write((MV643XX_ETH_DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE
(eth_port_num) + table_index), 0);
/* Clear DA filter other multicast table (Ex_dFOMT) */
- mv_write((MV643XX_ETH_DA_FILTER_OTHER_MULTICAST_TABLE_BASE
+ mv643xx_eth_write((MV643XX_ETH_DA_FILTER_OTHER_MULTICAST_TABLE_BASE
(eth_port_num) + table_index), 0);
}
}
@@ -2252,7 +2248,7 @@
* MIB counter value.
*
*/
-static void eth_clear_mib_counters(struct net_device *dev)
+static void mv643xx_eth_clear_mib_counters(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
unsigned int eth_port_num = mp->port_num;
@@ -2261,40 +2257,45 @@
/* Perform dummy reads from MIB counters */
for (i = ETH_MIB_GOOD_OCTETS_RECEIVED_LOW; i < ETH_MIB_LATE_COLLISION;
i += 4)
- mv_read(MV643XX_ETH_MIB_COUNTERS_BASE(eth_port_num) + i);
+ mv643xx_eth_read(MV643XX_ETH_MIB_COUNTERS_BASE(eth_port_num) + i);
}
-static inline u32 read_mib(struct net_device *dev, int offset)
+static inline u32 mv643xx_eth_read_mib_counter(struct net_device *dev,
+ int offset)
{
struct mv643xx_private *mp = netdev_priv(dev);
- return mv_read(MV643XX_ETH_MIB_COUNTERS_BASE(mp->port_num) + offset);
+ return mv643xx_eth_read(MV643XX_ETH_MIB_COUNTERS_BASE(mp->port_num) + offset);
}
-static void eth_update_mib_counters(struct net_device *dev)
+static void mv643xx_eth_update_mib_counters(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
struct mv643xx_mib_counters *p = &mp->mib_counters;
int offset;
p->good_octets_received +=
- read_mib(dev, ETH_MIB_GOOD_OCTETS_RECEIVED_LOW);
+ mv643xx_eth_read_mib_counter(dev, ETH_MIB_GOOD_OCTETS_RECEIVED_LOW);
p->good_octets_received +=
- (u64)read_mib(dev, ETH_MIB_GOOD_OCTETS_RECEIVED_HIGH) << 32;
-
+ (u64) mv643xx_eth_read_mib_counter(dev,
+ ETH_MIB_GOOD_OCTETS_RECEIVED_HIGH)
+ << 32;
for (offset = ETH_MIB_BAD_OCTETS_RECEIVED;
offset <= ETH_MIB_FRAMES_1024_TO_MAX_OCTETS;
offset += 4)
- *(u32 *)((char *)p + offset) = read_mib(dev, offset);
+ *(u32 *)((char *)p + offset) =
+ mv643xx_eth_read_mib_counter(dev, offset);
- p->good_octets_sent += read_mib(dev, ETH_MIB_GOOD_OCTETS_SENT_LOW);
p->good_octets_sent +=
- (u64)read_mib(dev, ETH_MIB_GOOD_OCTETS_SENT_HIGH) << 32;
+ mv643xx_eth_read_mib_counter(dev, ETH_MIB_GOOD_OCTETS_SENT_LOW);
+ p->good_octets_sent +=
+ (u64) mv643xx_eth_read_mib_counter(dev, ETH_MIB_GOOD_OCTETS_SENT_HIGH) << 32;
for (offset = ETH_MIB_GOOD_FRAMES_SENT;
offset <= ETH_MIB_LATE_COLLISION;
offset += 4)
- *(u32 *)((char *)p + offset) = read_mib(dev, offset);
+ *(u32 *)((char *)p + offset) =
+ mv643xx_eth_read_mib_counter(dev, offset);
}
/*
@@ -2315,22 +2316,22 @@
* -ENODEV on failure
*
*/
-static int ethernet_phy_detect(struct net_device *dev)
+static int mv643xx_eth_phy_detect(struct net_device *dev)
{
unsigned int phy_reg_data0;
int auto_neg;
- eth_port_read_smi_reg(dev, 0, &phy_reg_data0);
+ mv643xx_eth_read_smi_reg(dev, 0, &phy_reg_data0);
auto_neg = phy_reg_data0 & 0x1000;
phy_reg_data0 ^= 0x1000; /* invert auto_neg */
- eth_port_write_smi_reg(dev, 0, phy_reg_data0);
+ mv643xx_eth_write_smi_reg(dev, 0, phy_reg_data0);
- eth_port_read_smi_reg(dev, 0, &phy_reg_data0);
+ mv643xx_eth_read_smi_reg(dev, 0, &phy_reg_data0);
if ((phy_reg_data0 & 0x1000) == auto_neg)
return -ENODEV; /* change didn't take */
phy_reg_data0 ^= 0x1000;
- eth_port_write_smi_reg(dev, 0, phy_reg_data0);
+ mv643xx_eth_write_smi_reg(dev, 0, phy_reg_data0);
return 0;
}
@@ -2350,12 +2351,12 @@
* PHY address.
*
*/
-static int ethernet_phy_get(struct net_device *dev)
+static int mv643xx_eth_phy_get(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
unsigned int reg_data;
- reg_data = mv_read(MV643XX_ETH_PHY_ADDR_REG);
+ reg_data = mv643xx_eth_read(MV643XX_ETH_PHY_ADDR_REG);
return ((reg_data >> (5 * mp->port_num)) & 0x1f);
}
@@ -2377,16 +2378,16 @@
* None.
*
*/
-static void ethernet_phy_set(struct net_device *dev, int phy_addr)
+static void mv643xx_eth_phy_set(struct net_device *dev, int phy_addr)
{
struct mv643xx_private *mp = netdev_priv(dev);
u32 reg_data;
int addr_shift = 5 * mp->port_num;
- reg_data = mv_read(MV643XX_ETH_PHY_ADDR_REG);
+ reg_data = mv643xx_eth_read(MV643XX_ETH_PHY_ADDR_REG);
reg_data &= ~(0x1f << addr_shift);
reg_data |= (phy_addr & 0x1f) << addr_shift;
- mv_write(MV643XX_ETH_PHY_ADDR_REG, reg_data);
+ mv643xx_eth_write(MV643XX_ETH_PHY_ADDR_REG, reg_data);
}
/*
@@ -2405,14 +2406,14 @@
* None.
*
*/
-static void ethernet_phy_reset(struct net_device *dev)
+static void mv643xx_eth_phy_reset(struct net_device *dev)
{
unsigned int phy_reg_data;
/* Reset the PHY */
- eth_port_read_smi_reg(dev, 0, &phy_reg_data);
+ mv643xx_eth_read_smi_reg(dev, 0, &phy_reg_data);
phy_reg_data |= 0x8000; /* Set bit 15 to reset the PHY */
- eth_port_write_smi_reg(dev, 0, phy_reg_data);
+ mv643xx_eth_write_smi_reg(dev, 0, phy_reg_data);
}
/*
@@ -2433,49 +2434,49 @@
* None.
*
*/
-static void eth_port_reset(struct net_device *dev)
+static void mv643xx_eth_port_reset(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
unsigned int port_num = mp->port_num;
unsigned int reg_data;
/* Stop Tx port activity. Check port Tx activity. */
- reg_data = mv_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num));
+ reg_data = mv643xx_eth_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num));
if (reg_data & 0xFF) {
/* Issue stop command for active channels only */
- mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num),
(reg_data << 8));
/* Wait for all Tx activity to terminate. */
/* Check port cause register that all Tx queues are stopped */
- while (mv_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num))
+ while (mv643xx_eth_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num))
& 0xFF)
udelay(10);
}
/* Stop Rx port activity. Check port Rx activity. */
- reg_data = mv_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num));
+ reg_data = mv643xx_eth_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num));
if (reg_data & 0xFF) {
/* Issue stop command for active channels only */
- mv_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num),
+ mv643xx_eth_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num),
(reg_data << 8));
/* Wait for all Rx activity to terminate. */
/* Check port cause register that all Rx queues are stopped */
- while (mv_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num))
+ while (mv643xx_eth_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num))
& 0xFF)
udelay(10);
}
/* Clear all MIB counters */
- eth_clear_mib_counters(dev);
+ mv643xx_eth_clear_mib_counters(dev);
/* Reset the Enable bit in the Configuration Register */
- reg_data = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
+ reg_data = mv643xx_eth_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
reg_data &= ~MV643XX_ETH_SERIAL_PORT_ENABLE;
- mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), reg_data);
+ mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), reg_data);
}
/*
@@ -2497,16 +2498,16 @@
* None.
*
*/
-static void ethernet_set_config_reg(struct net_device *dev,
- unsigned int value)
+static void mv643xx_eth_set_config_reg(struct net_device *dev,
+ unsigned int value)
{
struct mv643xx_private *mp = netdev_priv(dev);
unsigned int eth_port_num = mp->port_num;
unsigned int eth_config_reg;
- eth_config_reg = mv_read(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num));
+ eth_config_reg = mv643xx_eth_read(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num));
eth_config_reg |= value;
- mv_write(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num), eth_config_reg);
+ mv643xx_eth_write(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num), eth_config_reg);
}
/*
@@ -2525,12 +2526,12 @@
* RETURN:
* Port configuration register value.
*/
-static unsigned int ethernet_get_config_reg(struct net_device *dev)
+static unsigned int mv643xx_eth_get_config_reg(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
unsigned int eth_config_reg;
- eth_config_reg = mv_read(MV643XX_ETH_PORT_CONFIG_EXTEND_REG
+ eth_config_reg = mv643xx_eth_read(MV643XX_ETH_PORT_CONFIG_EXTEND_REG
(mp->port_num));
return eth_config_reg;
}
@@ -2555,10 +2556,10 @@
* true otherwise.
*
*/
-static void eth_port_read_smi_reg(struct net_device *dev,
+static void mv643xx_eth_read_smi_reg(struct net_device *dev,
unsigned int phy_reg, unsigned int *value)
{
- int phy_addr = ethernet_phy_get(dev);
+ int phy_addr = mv643xx_eth_phy_get(dev);
unsigned long flags;
int i;
@@ -2566,7 +2567,7 @@
spin_lock_irqsave(&mv643xx_eth_phy_lock, flags);
/* wait for the SMI register to become available */
- for (i = 0; mv_read(MV643XX_ETH_SMI_REG) & ETH_SMI_BUSY; i++) {
+ for (i = 0; mv643xx_eth_read(MV643XX_ETH_SMI_REG) & ETH_SMI_BUSY; i++) {
if (i == PHY_WAIT_ITERATIONS) {
printk(KERN_ERR "%s: PHY busy timeout\n",
dev->name);
@@ -2575,11 +2576,11 @@
udelay(PHY_WAIT_MICRO_SECONDS);
}
- mv_write(MV643XX_ETH_SMI_REG,
+ mv643xx_eth_write(MV643XX_ETH_SMI_REG,
(phy_addr << 16) | (phy_reg << 21) | ETH_SMI_OPCODE_READ);
/* now wait for the data to be valid */
- for (i = 0; !(mv_read(MV643XX_ETH_SMI_REG) & ETH_SMI_READ_VALID); i++) {
+ for (i = 0; !(mv643xx_eth_read(MV643XX_ETH_SMI_REG) & ETH_SMI_READ_VALID); i++) {
if (i == PHY_WAIT_ITERATIONS) {
printk(KERN_ERR "%s: PHY read timeout\n",
dev->name);
@@ -2588,7 +2589,7 @@
udelay(PHY_WAIT_MICRO_SECONDS);
}
- *value = mv_read(MV643XX_ETH_SMI_REG) & 0xffff;
+ *value = mv643xx_eth_read(MV643XX_ETH_SMI_REG) & 0xffff;
out:
spin_unlock_irqrestore(&mv643xx_eth_phy_lock, flags);
}
@@ -2613,20 +2614,20 @@
* true otherwise.
*
*/
-static void eth_port_write_smi_reg(struct net_device *dev,
- unsigned int phy_reg, unsigned int value)
+static void mv643xx_eth_write_smi_reg(struct net_device *dev,
+ unsigned int phy_reg, unsigned int value)
{
int phy_addr;
int i;
unsigned long flags;
- phy_addr = ethernet_phy_get(dev);
+ phy_addr = mv643xx_eth_phy_get(dev);
/* the SMI register is a shared resource */
spin_lock_irqsave(&mv643xx_eth_phy_lock, flags);
/* wait for the SMI register to become available */
- for (i = 0; mv_read(MV643XX_ETH_SMI_REG) & ETH_SMI_BUSY; i++) {
+ for (i = 0; mv643xx_eth_read(MV643XX_ETH_SMI_REG) & ETH_SMI_BUSY; i++) {
if (i == PHY_WAIT_ITERATIONS) {
printk(KERN_ERR "%s: PHY busy timeout\n",
dev->name);
@@ -2635,7 +2636,7 @@
udelay(PHY_WAIT_MICRO_SECONDS);
}
- mv_write(MV643XX_ETH_SMI_REG, (phy_addr << 16) | (phy_reg << 21) |
+ mv643xx_eth_write(MV643XX_ETH_SMI_REG, (phy_addr << 16) | (phy_reg << 21) |
ETH_SMI_OPCODE_WRITE | (value & 0xffff));
out:
spin_unlock_irqrestore(&mv643xx_eth_phy_lock, flags);
@@ -2644,17 +2645,17 @@
/*
* Wrappers for MII support library.
*/
-static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location)
+static int mv643xx_eth_mdio_read(struct net_device *dev, int phy_id, int location)
{
int val;
- eth_port_read_smi_reg(dev, location, &val);
+ mv643xx_eth_read_smi_reg(dev, location, &val);
return val;
}
-static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val)
+static void mv643xx_eth_mdio_write(struct net_device *dev, int phy_id, int location, int val)
{
- eth_port_write_smi_reg(dev, location, val);
+ mv643xx_eth_write_smi_reg(dev, location, val);
}
/*
@@ -2688,9 +2689,10 @@
/*
* Modified to include the first descriptor pointer in case of SG
*/
-static int eth_port_send(struct net_device *dev,
+static int mv643xx_eth_tx_packet(struct net_device *dev,
struct pkt_info *p_pkt_info)
{
+ struct mv643xx_private *mp = netdev_priv(dev);
int tx_desc_curr, tx_desc_used, tx_first_desc, tx_next_desc;
struct eth_tx_desc *current_descriptor;
struct eth_tx_desc *first_descriptor;
@@ -2780,8 +2782,8 @@
return status;
}
#else
-static int eth_port_send(struct net_device *dev,
- struct pkt_info *p_pkt_info)
+static int mv643xx_eth_tx_packet(struct net_device *dev,
+ struct pkt_info *p_pkt_info)
{
struct mv643xx_private *mp = netdev_priv(dev);
int tx_desc_curr;
@@ -2808,8 +2810,7 @@
if (netif_msg_tx_queued(mp))
printk(KERN_DEBUG "%s: send pkt: desc=%d len=%d, f/l=%d/%d\n",
- dev->name, tx_desc_curr,
- p_pkt_info->byte_cnt,
+ dev->name, tx_desc_curr, p_pkt_info->byte_cnt,
((command_status & ETH_TX_FIRST_DESC) != 0),
((command_status & ETH_TX_LAST_DESC) != 0));
@@ -2868,8 +2869,8 @@
* ETH_OK otherwise.
*
*/
-static int eth_tx_return_desc(struct net_device *dev,
- struct pkt_info *p_pkt_info)
+static int mv643xx_eth_tx_return_desc(struct net_device *dev,
+ struct pkt_info *p_pkt_info)
{
struct mv643xx_private *mp = netdev_priv(dev);
int tx_desc_used;
@@ -2937,8 +2938,8 @@
* ETH_END_OF_JOB if there is no received data.
* ETH_OK otherwise.
*/
-static int eth_port_receive(struct net_device *dev,
- struct pkt_info *p_pkt_info)
+static int mv643xx_eth_rx_packet(struct net_device *dev,
+ struct pkt_info *p_pkt_info)
{
struct mv643xx_private *mp = netdev_priv(dev);
int rx_next_curr_desc, rx_curr_desc, rx_used_desc;
@@ -2971,8 +2972,7 @@
if (netif_msg_rx_status(mp))
printk(KERN_DEBUG "%s: rcv pkt: len=%d, desc=%d, f/l=%d/%d\n",
- dev->name,
- p_pkt_info->byte_cnt, rx_curr_desc,
+ dev->name, p_pkt_info->byte_cnt, rx_curr_desc,
((command_status & ETH_RX_FIRST_DESC) != 0),
((command_status & ETH_RX_LAST_DESC) != 0));
@@ -3011,8 +3011,8 @@
* ETH_ERROR in case the routine can not access Rx desc ring.
* ETH_OK otherwise.
*/
-static void eth_rx_return_buff(struct net_device *dev,
- struct pkt_info *p_pkt_info)
+static void mv643xx_eth_rx_return_buff(struct net_device *dev,
+ struct pkt_info *p_pkt_info)
{
struct mv643xx_private *mp = netdev_priv(dev);
int used_rx_desc; /* Where to return Rx resource */
@@ -3102,7 +3102,7 @@
sizeof(mv643xx_gstrings_stats) / sizeof(struct mv643xx_stats)
static int
-mv643xx_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
+mv643xx_eth_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
{
int rc;
struct mv643xx_private *mp = netdev_priv(netdev);
@@ -3118,7 +3118,7 @@
}
static void
-mv643xx_get_drvinfo(struct net_device *netdev,
+mv643xx_eth_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *drvinfo)
{
strncpy(drvinfo->driver, mv643xx_driver_name, 32);
@@ -3129,19 +3129,18 @@
}
static int
-mv643xx_get_stats_count(struct net_device *netdev)
+mv643xx_eth_get_stats_count(struct net_device *netdev)
{
return MV643XX_STATS_LEN;
}
-static void
-mv643xx_get_ethtool_stats(struct net_device *netdev,
- struct ethtool_stats *stats, uint64_t *data)
+static void mv643xx_eth_get_ethtool_stats(struct net_device *dev,
+ struct ethtool_stats *stats, uint64_t *data)
{
- struct mv643xx_private *mp = netdev->priv;
+ struct mv643xx_private *mp = netdev_priv(dev);
int i;
- eth_update_mib_counters(netdev);
+ mv643xx_eth_update_mib_counters(dev);
for(i = 0; i < MV643XX_STATS_LEN; i++) {
char *p = (char *)mp+mv643xx_gstrings_stats[i].stat_offset;
@@ -3151,7 +3150,7 @@
}
static void
-mv643xx_get_strings(struct net_device *netdev, uint32_t stringset, uint8_t *data)
+mv643xx_eth_get_strings(struct net_device *netdev, uint32_t stringset, uint8_t *data)
{
int i;
@@ -3199,18 +3198,15 @@
}
static struct ethtool_ops mv643xx_ethtool_ops = {
- .get_settings = mv643xx_get_settings,
- .set_settings = mv643xx_set_settings,
- .get_drvinfo = mv643xx_get_drvinfo,
- .get_link = mv643xx_eth_get_link,
+ .get_settings = mv643xx_eth_get_settings,
+ .set_settings = mv643xx_eth_set_settings,
+ .get_drvinfo = mv643xx_eth_get_drvinfo,
+ .get_link = mv643xx_eth_get_link,
.get_sg = ethtool_op_get_sg,
.set_sg = ethtool_op_set_sg,
- .get_strings = mv643xx_get_strings,
- .get_stats_count = mv643xx_get_stats_count,
- .get_ethtool_stats = mv643xx_get_ethtool_stats,
- .get_strings = mv643xx_get_strings,
- .get_stats_count = mv643xx_get_stats_count,
- .get_ethtool_stats = mv643xx_get_ethtool_stats,
+ .get_strings = mv643xx_eth_get_strings,
+ .get_stats_count = mv643xx_eth_get_stats_count,
+ .get_ethtool_stats = mv643xx_eth_get_ethtool_stats,
.get_msglevel = mv643xx_eth_get_msglevel,
.set_msglevel = mv643xx_eth_set_msglevel,
.nway_reset = mv643xx_eth_nway_restart,
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(12/20): reorder code to avoid prototype function declarations
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (10 preceding siblings ...)
2005-03-28 23:51 ` mv643xx(11/20): rename all functions to have a common mv643xx_eth prefix Dale Farnsworth
@ 2005-03-28 23:55 ` Dale Farnsworth
2005-03-28 23:55 ` mv643xx(13/20): remove useless function header block comments Dale Farnsworth
` (7 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:55 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
This patch reorders functions to avoid the need for function
prototypes. In practice, low-level routines are moved to the top of
the file and driver API functions to the bottom. This is how most
Linux drivers are laid out.
There are no functional changes here.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
[I have omitted the patch because it's twice the size of the original
file, drivers/net/mv643xx_eth.c, and not useful for analyzing changes
since so many functions were moved. Again, the code is unchanged
other than changing the order of the functions in the source file.]
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(13/20): remove useless function header block comments
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (11 preceding siblings ...)
2005-03-28 23:55 ` mv643xx(12/20): reorder code to avoid prototype function declarations Dale Farnsworth
@ 2005-03-28 23:55 ` Dale Farnsworth
2005-03-28 23:56 ` mv643xx(14/20): whitespace and indentation cleanup Dale Farnsworth
` (6 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:55 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
This driver was full of big function header block comments with Name,
Description, Parameter, Input, Output and ReturnValue clauses, most of
which were completely useless. The parameter tables made the code
difficult to maintain and they added no value anyway. Where the
description text was useful, I retained it in a simple comment block
above the function but (as in most cases) where even the description
added no value, I simply deleted the whole comment block.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -115,9 +115,6 @@
* driver internal data needed for its operations.
*
* Supported Features:
- * - This low level driver is OS independent. Allocating memory for
- * the descriptor rings and buffers are not within the scope of
- * this driver.
* - The user is free from Rx/Tx queue managing.
* - This low level driver introduce functionality API that enable
* the to operate Marvell's Gigabit Ethernet Controller in a
@@ -194,7 +191,7 @@
* this packet.
*
* Receive operation:
- * The eth_port_receive API set the packet information struct,
+ * The mv643xx_eth_port_receive API set the packet information struct,
* passed by the caller, with received information from the
* 'current' SDMA descriptor.
* It is the user responsibility to return this resource back
@@ -202,7 +199,7 @@
* Return Rx resource is done using the eth_rx_return_buff API.
*
* Transmit operation:
- * The eth_port_send API supports Scatter-Gather which enables to
+ * The mv643xx_eth_tx_packet API supports Scatter-Gather which enables to
* send a packet spanned over multiple buffers. This means that
* for each packet info structure given by the user and put into
* the Tx descriptors ring, will be transmitted only if the 'LAST'
@@ -217,7 +214,7 @@
*
* EXTERNAL INTERFACE
*
- * Prior to calling the initialization routine eth_port_init() the user
+ * Prior to calling the initialization routine mv643xx_eth_port_init() the user
* must set the following fields under mv643xx_private struct:
* port_num User Ethernet port number.
* port_mac_addr[6] User defined port MAC address.
@@ -246,28 +243,6 @@
* Ethernet port setup routines
*****************************************************************************/
-/*
- * eth_port_uc_addr - This function Set the port unicast address table
- *
- * DESCRIPTION:
- * This function locates the proper entry in the Unicast table for the
- * specified MAC nibble and sets its properties according to function
- * parameters.
- *
- * INPUT:
- * unsigned int eth_port_num Port number.
- * unsigned char uc_nibble Unicast MAC Address last nibble.
- * int option 0 = Add, 1 = remove address.
- *
- * OUTPUT:
- * This function add/removes MAC addresses from the port unicast address
- * table.
- *
- * RETURN:
- * true is output succeeded.
- * false if option parameter is invalid.
- *
- */
static int mv643xx_eth_port_mac_addr(unsigned int eth_port_num, unsigned char uc_nibble,
int option)
{
@@ -312,24 +287,6 @@
return 1;
}
-/*
- * eth_port_uc_addr_get - This function retrieves the port Unicast address
- * (MAC address) from the ethernet hw registers.
- *
- * DESCRIPTION:
- * This function retrieves the port Ethernet MAC address.
- *
- * INPUT:
- * unsigned int eth_port_num Port number.
- * char *MacAddr pointer where the MAC address is stored
- *
- * OUTPUT:
- * Copy the MAC address to the location pointed to by MacAddr
- *
- * RETURN:
- * N/A.
- *
- */
static void mv643xx_eth_port_mac_addr_get(struct net_device *dev, unsigned char *p_addr)
{
struct mv643xx_private *mp = netdev_priv(dev);
@@ -347,24 +304,6 @@
p_addr[5] = mac_l & 0xff;
}
-/*
- * eth_port_uc_addr_set - This function Set the port Unicast address.
- *
- * DESCRIPTION:
- * This function Set the port Ethernet MAC address.
- *
- * INPUT:
- * unsigned int eth_port_num Port number.
- * char * p_addr Address to be set
- *
- * OUTPUT:
- * Set MAC address low and high registers. also calls eth_port_uc_addr()
- * To set the unicast table with the proper information.
- *
- * RETURN:
- * N/A.
- *
- */
static void mv643xx_eth_port_mac_addr_set(struct net_device *dev,
unsigned char *p_addr)
{
@@ -386,22 +325,6 @@
return;
}
-/*
- * eth_port_init_mac_tables - Clear all entrance in the UC, SMC and OMC tables
- *
- * DESCRIPTION:
- * Go through all the DA filter tables (Unicast, Special Multicast &
- * Other Multicast) and set each entry to 0.
- *
- * INPUT:
- * unsigned int eth_port_num Ethernet Port number.
- *
- * OUTPUT:
- * Multicast and Unicast packets are rejected.
- *
- * RETURN:
- * None.
- */
static void mv643xx_eth_port_init_mac_tables(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
@@ -424,9 +347,6 @@
}
/*
- * eth_port_start - Start the Ethernet port activity.
- *
- * DESCRIPTION:
* This routine prepares the Ethernet port for Rx and Tx activity:
* 1. Initialize Tx and Rx Current Descriptor Pointer for each queue that
* has been initialized a descriptor's ring (using
@@ -438,17 +358,8 @@
* the ethernet port SDMA can starts to perform Rx and Tx activities.
*
* Note: Each Rx and Tx queue descriptor's list must be initialized prior
- * to calling this function (use ether_init_tx_desc_ring for Tx queues
- * and ether_init_rx_desc_ring for Rx queues).
- *
- * INPUT:
- * struct net_device *dev Ethernet port control struct
- *
- * OUTPUT:
- * Ethernet port is ready to receive and transmit.
- *
- * RETURN:
- * None.
+ * to calling this function (use mv643xx_eth_init_tx_desc_ring for Tx queues
+ * and mv643xx_eth_init_rx_desc_ring for Rx queues).
*/
static void mv643xx_eth_port_start(struct net_device *dev)
{
@@ -502,21 +413,8 @@
}
/*
- * eth_clear_mib_counters - Clear all MIB counters
- *
- * DESCRIPTION:
* This function clears all MIB counters of a specific ethernet port.
* A read from the MIB counter will reset the counter.
- *
- * INPUT:
- * unsigned int eth_port_num Ethernet Port number.
- *
- * OUTPUT:
- * After reading all MIB counters, the counters resets.
- *
- * RETURN:
- * MIB counter value.
- *
*/
static void mv643xx_eth_clear_mib_counters(struct net_device *dev)
{
@@ -531,22 +429,9 @@
}
/*
- * eth_port_reset - Reset Ethernet port
- *
- * DESCRIPTION:
* This routine resets the chip by aborting any SDMA engine activity and
* clearing the MIB counters. The Receiver and the Transmit unit are in
* idle state after this command is performed and the port is disabled.
- *
- * INPUT:
- * unsigned int eth_port_num Ethernet Port number.
- *
- * OUTPUT:
- * Channel activity is halted.
- *
- * RETURN:
- * None.
- *
*/
static void mv643xx_eth_port_reset(struct net_device *dev)
{
@@ -593,22 +478,6 @@
mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), reg_data);
}
-/*
- * ethernet_phy_get - Get the ethernet port PHY address.
- *
- * DESCRIPTION:
- * This routine returns the given ethernet port PHY address.
- *
- * INPUT:
- * unsigned int eth_port_num Ethernet Port number.
- *
- * OUTPUT:
- * None.
- *
- * RETURN:
- * PHY address.
- *
- */
static int mv643xx_eth_phy_get(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
@@ -619,23 +488,6 @@
return ((reg_data >> (5 * mp->port_num)) & 0x1f);
}
-/*
- * ethernet_phy_set - Set the ethernet port PHY address.
- *
- * DESCRIPTION:
- * This routine sets the given ethernet port PHY address.
- *
- * INPUT:
- * unsigned int eth_port_num Ethernet Port number.
- * int phy_addr PHY address.
- *
- * OUTPUT:
- * None.
- *
- * RETURN:
- * None.
- *
- */
static void mv643xx_eth_phy_set(struct net_device *dev, int phy_addr)
{
struct mv643xx_private *mp = netdev_priv(dev);
@@ -648,26 +500,6 @@
mv643xx_eth_write(MV643XX_ETH_PHY_ADDR_REG, reg_data);
}
-/*
- * eth_port_read_smi_reg - Read PHY registers
- *
- * DESCRIPTION:
- * This routine utilize the SMI interface to interact with the PHY in
- * order to perform PHY register read.
- *
- * INPUT:
- * unsigned int port_num Ethernet Port number.
- * unsigned int phy_reg PHY register address offset.
- * unsigned int *value Register value buffer.
- *
- * OUTPUT:
- * Write the value of a specified PHY register into given buffer.
- *
- * RETURN:
- * false if the PHY is busy or read data is not in valid state.
- * true otherwise.
- *
- */
static void mv643xx_eth_read_smi_reg(struct net_device *dev,
unsigned int phy_reg, unsigned int *value)
{
@@ -706,26 +538,6 @@
spin_unlock_irqrestore(&mv643xx_eth_phy_lock, flags);
}
-/*
- * eth_port_write_smi_reg - Write to PHY registers
- *
- * DESCRIPTION:
- * This routine utilize the SMI interface to interact with the PHY in
- * order to perform writes to PHY registers.
- *
- * INPUT:
- * unsigned int eth_port_num Ethernet Port number.
- * unsigned int phy_reg PHY register address offset.
- * unsigned int value Register value.
- *
- * OUTPUT:
- * Write the given value to the specified PHY register.
- *
- * RETURN:
- * false if the PHY is busy.
- * true otherwise.
- *
- */
static void mv643xx_eth_write_smi_reg(struct net_device *dev,
unsigned int phy_reg, unsigned int value)
{
@@ -754,22 +566,6 @@
spin_unlock_irqrestore(&mv643xx_eth_phy_lock, flags);
}
-/*
- * ethernet_phy_reset - Reset Ethernet port PHY.
- *
- * DESCRIPTION:
- * This routine utilizes the SMI interface to reset the ethernet port PHY.
- *
- * INPUT:
- * unsigned int eth_port_num Ethernet Port number.
- *
- * OUTPUT:
- * The PHY is reset.
- *
- * RETURN:
- * None.
- *
- */
static void mv643xx_eth_phy_reset(struct net_device *dev)
{
unsigned int phy_reg_data;
@@ -781,9 +577,6 @@
}
/*
- * eth_port_init - Initialize the Ethernet port driver
- *
- * DESCRIPTION:
* This function prepares the ethernet port to start its activity:
* 1) Completes the ethernet port driver struct initialization toward port
* start routine.
@@ -794,15 +587,6 @@
* Note: Call this routine prior to eth_port_start routine and after
* setting user values in the user fields of Ethernet port control
* struct.
- *
- * INPUT:
- * struct net_device *dev Ethernet port control struct
- *
- * OUTPUT:
- * See description.
- *
- * RETURN:
- * None.
*/
static void mv643xx_eth_port_init(struct net_device *dev)
{
@@ -861,22 +645,8 @@
}
/*
- * ethernet_phy_detect - Detect whether a phy is present
- *
- * DESCRIPTION:
* This function tests whether there is a PHY present on
* the specified port.
- *
- * INPUT:
- * unsigned int eth_port_num Ethernet Port number.
- *
- * OUTPUT:
- * None
- *
- * RETURN:
- * 0 on success
- * -ENODEV on failure
- *
*/
static int mv643xx_eth_phy_detect(struct net_device *dev)
{
@@ -898,23 +668,8 @@
}
/*
- * ethernet_set_config_reg - Set specified bits in configuration register.
- *
- * DESCRIPTION:
* This function sets specified bits in the given ethernet
* configuration register.
- *
- * INPUT:
- * unsigned int eth_port_num Ethernet Port number.
- * unsigned int value 32 bit value.
- *
- * OUTPUT:
- * The set bits in the value parameter are set in the configuration
- * register.
- *
- * RETURN:
- * None.
- *
*/
static void mv643xx_eth_set_config_reg(struct net_device *dev,
unsigned int value)
@@ -929,20 +684,8 @@
}
/*
- * ethernet_get_config_reg - Get the port configuration register
- *
- * DESCRIPTION:
* This function returns the configuration register value of the given
* ethernet port.
- *
- * INPUT:
- * unsigned int eth_port_num Ethernet Port number.
- *
- * OUTPUT:
- * None.
- *
- * RETURN:
- * Port configuration register value.
*/
static unsigned int mv643xx_eth_get_config_reg(struct net_device *dev)
{
@@ -959,9 +702,6 @@
*****************************************************************************/
/*
- * ether_init_rx_desc_ring - Curve a Rx chain desc list and buffer in memory.
- *
- * DESCRIPTION:
* This function prepares a Rx chained list of descriptors and packet
* buffers in a form of a ring. The routine must be called after port
* initialization routine and before port start routine.
@@ -969,16 +709,6 @@
* devices in the system (i.e. DRAM). This function uses the ethernet
* struct 'virtual to physical' routine (set by the user) to set the ring
* with physical addresses.
- *
- * INPUT:
- * struct net_device *dev Ethernet Port Control srtuct.
- *
- * OUTPUT:
- * The routine updates the Ethernet port control struct with information
- * regarding the Rx descriptors and buffers.
- *
- * RETURN:
- * None.
*/
static void mv643xx_eth_init_rx_desc_ring(struct net_device *dev)
{
@@ -1005,9 +735,6 @@
}
/*
- * ether_init_tx_desc_ring - Curve a Tx chain desc list and buffer in memory.
- *
- * DESCRIPTION:
* This function prepares a Tx chained list of descriptors and packet
* buffers in a form of a ring. The routine must be called after port
* initialization routine and before port start routine.
@@ -1015,16 +742,6 @@
* devices in the system (i.e. DRAM). This function uses the ethernet
* struct 'virtual to physical' routine (set by the user) to set the ring
* with physical addresses.
- *
- * INPUT:
- * struct net_device *dev Ethernet Port Control srtuct.
- *
- * OUTPUT:
- * The routine updates the Ethernet port control struct with information
- * regarding the Tx descriptors and buffers.
- *
- * RETURN:
- * None.
*/
static void mv643xx_eth_init_tx_desc_ring(struct net_device *dev)
{
@@ -1111,27 +828,12 @@
#ifdef MV643XX_COAL
/*
- * eth_port_set_rx_coal - Sets coalescing interrupt mechanism on RX path
- *
- * DESCRIPTION:
* This routine sets the RX coalescing interrupt mechanism parameter.
* This parameter is a timeout counter, that counts in 64 t_clk
* chunks ; that when timeout event occurs a maskable interrupt
* occurs.
* The parameter is calculated using the tClk of the MV-643xx chip
- * , and the required delay of the interrupt in usec.
- *
- * INPUT:
- * unsigned int eth_port_num Ethernet port number
- * unsigned int t_clk t_clk of the MV-643xx chip in HZ units
- * unsigned int delay Delay in usec
- *
- * OUTPUT:
- * Interrupt coalescing mechanism value is set in MV-643xx chip.
- *
- * RETURN:
- * The interrupt coalescing value set in the gigE port.
- *
+ * and the required delay of the interrupt in usec.
*/
static unsigned int mv643xx_eth_port_set_rx_coal(unsigned int eth_port_num,
unsigned int t_clk, unsigned int delay)
@@ -1149,27 +851,12 @@
#endif
/*
- * eth_port_set_tx_coal - Sets coalescing interrupt mechanism on TX path
- *
- * DESCRIPTION:
* This routine sets the TX coalescing interrupt mechanism parameter.
* This parameter is a timeout counter, that counts in 64 t_clk
* chunks ; that when timeout event occurs a maskable interrupt
* occurs.
* The parameter is calculated using the t_cLK frequency of the
* MV-643xx chip and the required delay in the interrupt in uSec
- *
- * INPUT:
- * unsigned int eth_port_num Ethernet port number
- * unsigned int t_clk t_clk of the MV-643xx chip in HZ units
- * unsigned int delay Delay in uSeconds
- *
- * OUTPUT:
- * Interrupt coalescing mechanism value is set in MV-643xx chip.
- *
- * RETURN:
- * The interrupt coalescing value set in the gigE port.
- *
*/
static unsigned int mv643xx_eth_port_set_tx_coal(unsigned int eth_port_num,
unsigned int t_clk, unsigned int delay)
@@ -1187,9 +874,6 @@
*****************************************************************************/
/*
- * eth_port_send - Send an Ethernet packet
- *
- * DESCRIPTION:
* This routine send a given packet described by p_pktinfo parameter. It
* supports transmitting of a packet spaned over multiple buffers. The
* routine updates 'curr' and 'first' indexes according to the packet
@@ -1198,20 +882,6 @@
* If the routine get into Tx resource error it assigns 'curr' index as
* 'first'. This way the function can abort Tx process of multiple
* descriptors per packet.
- *
- * INPUT:
- * struct mv643xx_private *mp Ethernet Port Control srtuct.
- * struct pkt_info *p_pkt_info User packet buffer.
- *
- * OUTPUT:
- * Tx ring 'curr' and 'first' indexes are updated.
- *
- * RETURN:
- * ETH_QUEUE_FULL in case of Tx resource error.
- * ETH_ERROR in case the routine can not access Tx desc ring.
- * ETH_QUEUE_LAST_RESOURCE if the routine uses the last Tx resource.
- * ETH_OK otherwise.
- *
*/
#ifdef MV643XX_CHECKSUM_OFFLOAD_TX
/*
@@ -1374,28 +1044,11 @@
#endif
/*
- * eth_tx_return_desc - Free all used Tx descriptors
- *
- * DESCRIPTION:
* This routine returns the transmitted packet information to the caller.
* It uses the 'first' index to support Tx desc return in case a transmit
* of a packet spanned over multiple buffer still in process.
* In case the Tx queue was in "resource error" condition, where there are
* no available Tx resources, the function resets the resource error flag.
- *
- * INPUT:
- * struct mv643xx_private *mp Ethernet Port Control srtuct.
- * struct pkt_info *p_pkt_info User packet buffer.
- *
- * OUTPUT:
- * Tx ring 'first' and 'used' indexes are updated.
- *
- * RETURN:
- * ETH_ERROR in case the routine can not access Tx desc ring.
- * ETH_RETRY in case there is transmission in process.
- * ETH_END_OF_JOB if the routine has nothing to release.
- * ETH_OK otherwise.
- *
*/
static int mv643xx_eth_tx_return_desc(struct net_device *dev,
struct pkt_info *p_pkt_info)
@@ -1444,27 +1097,11 @@
}
/*
- * eth_port_receive - Get received information from Rx ring.
- *
- * DESCRIPTION:
* This routine returns the received data to the caller. There is no
* data copying during routine operation. All information is returned
* using pointer to packet information struct passed from the caller.
* If the routine exhausts Rx ring resources then the resource error flag
* is set.
- *
- * INPUT:
- * struct mv643xx_private *mp Ethernet Port Control srtuct.
- * struct pkt_info *p_pkt_info User packet buffer.
- *
- * OUTPUT:
- * Rx ring current and used indexes are updated.
- *
- * RETURN:
- * ETH_ERROR in case the routine can not access Rx desc ring.
- * ETH_QUEUE_FULL if Rx ring resources are exhausted.
- * ETH_END_OF_JOB if there is no received data.
- * ETH_OK otherwise.
*/
static int mv643xx_eth_rx_packet(struct net_device *dev,
struct pkt_info *p_pkt_info)
@@ -1520,24 +1157,10 @@
}
/*
- * eth_rx_return_buff - Returns a Rx buffer back to the Rx ring.
- *
- * DESCRIPTION:
* This routine returns a Rx buffer back to the Rx ring. It retrieves the
* next 'used' descriptor and attached the returned buffer to it.
* In case the Rx ring was in "resource error" condition, where there are
* no available Rx resources, the function resets the resource error flag.
- *
- * INPUT:
- * struct mv643xx_private *mp Ethernet Port Control srtuct.
- * struct pkt_info *p_pkt_info Information on returned buffer.
- *
- * OUTPUT:
- * New available Rx resource in Rx descriptor ring.
- *
- * RETURN:
- * ETH_ERROR in case the routine can not access Rx desc ring.
- * ETH_OK otherwise.
*/
static void mv643xx_eth_rx_return_buff(struct net_device *dev,
struct pkt_info *p_pkt_info)
@@ -1575,14 +1198,9 @@
}
/*
- * mv643xx_eth_rx_task_timer_wrapper
- *
* Timer routine to wake up RX queue filling task. This function is
* used only in case the RX queue is empty, and all alloc_skb has
* failed (due to out of memory event).
- *
- * Input : pointer to ethernet interface network device structure
- * Output : N/A
*/
static void mv643xx_eth_rx_task_timer_wrapper(unsigned long data)
{
@@ -1594,12 +1212,7 @@
}
/*
- * mv643xx_eth_rx_task
- *
* Fills / refills RX queue on a certain gigabit ethernet port
- *
- * Input : pointer to ethernet interface network device structure
- * Output : N/A
*/
static void mv643xx_eth_rx_task(void *data)
{
@@ -1647,12 +1260,7 @@
}
/*
- * mv643xx_eth_tx_timeout
- *
* Called upon a timeout on transmitting a packet
- *
- * Input : pointer to ethernet interface network device structure.
- * Output : N/A
*/
static void mv643xx_eth_tx_timeout(struct net_device *dev)
{
@@ -1666,8 +1274,6 @@
}
/*
- * mv643xx_eth_tx_timeout_task
- *
* Actual routine to reset the adapter when a timeout on Tx has occurred
*/
static void mv643xx_eth_tx_timeout_task(struct net_device *dev)
@@ -1678,13 +1284,6 @@
netif_device_attach(dev);
}
-/*
- * mv643xx_eth_free_tx_queue
- *
- * Input : dev - a pointer to the required interface
- *
- * Output : 0 if was able to release skb , nonzero otherwise
- */
static int mv643xx_eth_free_tx_queue(struct net_device *dev,
unsigned int eth_int_cause_ext)
{
@@ -1745,15 +1344,8 @@
}
/*
- * mv643xx_eth_receive
- *
* This function is forward packets that are received from the port's
- * queues toward kernel core or FastRoute them to another interface.
- *
- * Input : dev - a pointer to the required interface
- * max - maximum number to receive (0 means unlimted)
- *
- * Output : number of served packets
+ * queues toward kernel core.
*/
#ifdef MV643XX_NAPI
static int mv643xx_eth_receive_queue(struct net_device *dev, int budget)
@@ -1828,16 +1420,8 @@
}
/*
- * mv643xx_eth_int_handler
- *
* Main interrupt handler for the gigbit ethernet ports
- *
- * Input : irq - irq number (not used)
- * dev_id - a pointer to the required interface's data structure
- * regs - not used
- * Output : N/A
*/
-
static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id,
struct pt_regs *regs)
{
@@ -1981,8 +1565,6 @@
}
/*
- * mv643xx_poll
- *
* This function is used in case of NAPI
*/
static int mv643xx_eth_poll(struct net_device *dev, int *budget)
@@ -2031,15 +1613,8 @@
#endif
/*
- * mv643xx_eth_start_xmit
- *
* This function is queues a packet in the Tx descriptor for
* required port.
- *
- * Input : skb - a pointer to socket buffer
- * dev - a pointer to the required port
- *
- * Output : zero upon success
*/
static int mv643xx_eth_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
@@ -2241,7 +1816,9 @@
* net_device interface functions
*****************************************************************************/
-/* Helper function for mv643xx_eth_open */
+/*
+ * Helper function for mv643xx_eth_open
+ */
static int mv643xx_eth_real_open(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
@@ -2368,17 +1945,10 @@
}
/*
- * mv643xx_eth_stop
- *
* This function is used when closing the network device.
* It updates the hardware,
* release all memory that holds buffers and descriptors and release the IRQ.
- * Input : a pointer to the device structure
- * Output : zero if success , nonzero if fails
*/
-
-/* Helper function for mv643xx_eth_stop */
-
static int mv643xx_eth_real_stop(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
@@ -2405,14 +1975,6 @@
return 0;
}
-/*
- * mv643xx_eth_update_mac_address
- *
- * Update the MAC address of the port in the address table
- *
- * Input : pointer to ethernet interface network device structure
- * Output : N/A
- */
static void mv643xx_eth_update_mac_address(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
@@ -2422,14 +1984,6 @@
mv643xx_eth_port_mac_addr_set(dev, mp->port_mac_addr);
}
-/*
- * mv643xx_eth_set_rx_mode
- *
- * Change from promiscuos to regular rx mode
- *
- * Input : pointer to ethernet interface network device structure
- * Output : N/A
- */
static void mv643xx_eth_set_rx_mode(struct net_device *dev)
{
u32 config_reg;
@@ -2443,15 +1997,9 @@
}
/*
- * mv643xx_eth_set_mac_address
- *
* Change the interface's mac address.
* No special hardware thing should be done because interface is always
* put in promiscuous mode.
- *
- * Input : pointer to ethernet interface network device structure and
- * a pointer to the designated entry to be added to the cache.
- * Output : zero upon success, negative upon failure
*/
static int mv643xx_eth_set_mac_address(struct net_device *dev, void *addr)
{
@@ -2574,18 +2122,11 @@
}
/*
- * mv643xx_eth_open
- *
* This function is called when openning the network device. The function
* should initialize all the hardware, initialize cyclic Rx/Tx
* descriptors chain and buffers and allocate an IRQ to the network
* device.
- *
- * Input : a pointer to the network device structure
- *
- * Output : zero of success , nonzero if fails.
*/
-
static int mv643xx_eth_open(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
@@ -2639,16 +2180,6 @@
return 0;
}
-/*
- * mv643xx_eth_get_stats
- *
- * Returns a pointer to the interface statistics.
- *
- * Input : dev - a pointer to the required interface
- *
- * Output : a pointer to the interface's statistics
- */
-
static struct net_device_stats *mv643xx_eth_get_stats(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
@@ -2658,10 +2189,6 @@
/*
* Changes MTU (maximum transfer unit) of the gigabit ethenret port
- *
- * Input : pointer to ethernet interface network device structure
- * new mtu size
- * Output : 0 upon success, -EINVAL upon failure
*/
static int mv643xx_eth_change_mtu(struct net_device *dev, int new_mtu)
{
@@ -2754,9 +2281,6 @@
#define MV643XX_STATS_LEN \
sizeof(mv643xx_gstrings_stats) / sizeof(struct mv643xx_stats)
-/*
- * Wrappers for MII support library.
- */
static int mv643xx_eth_mdio_read(struct net_device *dev, int phy_id, int location)
{
int val;
@@ -2882,15 +2406,10 @@
};
/*
- * mv643xx_eth_probe
- *
* First function called after registering the network device.
* It's purpose is to initialize the device as an ethernet device,
* fill the ethernet device structure with pointers * to functions,
* and set the MAC address of the interface
- *
- * Input : struct device *
- * Output : -ENOMEM if failed , 0 if success
*/
static int mv643xx_eth_probe(struct device *ddev)
{
@@ -3130,15 +2649,6 @@
.remove = mv643xx_eth_shared_remove,
};
-/*
- * mv643xx_init_module
- *
- * Registers the network drivers into the Linux kernel
- *
- * Input : N/A
- *
- * Output : N/A
- */
static int __init mv643xx_eth_init_module(void)
{
int rc;
@@ -3152,15 +2662,6 @@
return rc;
}
-/*
- * mv643xx_cleanup_module
- *
- * Registers the network drivers into the Linux kernel
- *
- * Input : N/A
- *
- * Output : N/A
- */
static void __exit mv643xx_eth_cleanup_module(void)
{
driver_unregister(&mv643xx_eth_driver);
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(14/20): whitespace and indentation cleanup
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (12 preceding siblings ...)
2005-03-28 23:55 ` mv643xx(13/20): remove useless function header block comments Dale Farnsworth
@ 2005-03-28 23:56 ` Dale Farnsworth
2005-03-28 23:57 ` mv643xx(15/20): Add James Chapman to copyright statement and author list Dale Farnsworth
` (5 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:56 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Code passed through Lindent to fixup some broken indentation and to
force consistent use of tabs. Unfortunately, very long macro names
used for register accesses mean keeping to the 80 char line length
constraint is impossible so several lines have been manually fixed up
and are longer than 80 chars.
There are no functional changes in this patch.
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -46,10 +46,6 @@
#include <asm/delay.h>
#include "mv643xx_eth.h"
-/*
- * The first part is the high level driver of the gigE ethernet ports.
- */
-
/* Constants */
#define VLAN_HLEN 4
#define FCS_LEN 4
@@ -95,7 +91,7 @@
static inline void mv643xx_eth_write(int offset, u32 data)
{
- void * __iomem reg_base;
+ void *__iomem reg_base;
reg_base = mv643xx_eth_shared_base - MV643XX_ETH_SHARED_REGS;
writel(data, reg_base + offset);
@@ -106,116 +102,117 @@
*
* DESCRIPTION:
* This file introduce low level API to Marvell's Gigabit Ethernet
- * controller. This Gigabit Ethernet Controller driver API controls
- * 1) Operations (i.e. port init, start, reset etc').
- * 2) Data flow (i.e. port send, receive etc').
- * Each Gigabit Ethernet port is controlled via
- * struct mv643xx_private.
- * This struct includes user configuration information as well as
- * driver internal data needed for its operations.
+ * controller. This Gigabit Ethernet Controller driver API controls
+ * 1) Operations (i.e. port init, start, reset etc').
+ * 2) Data flow (i.e. port send, receive etc').
+ * Each Gigabit Ethernet port is controlled via
+ * struct mv643xx_private.
+ * This struct includes user configuration information as well as
+ * driver internal data needed for its operations.
*
- * Supported Features:
- * - The user is free from Rx/Tx queue managing.
- * - This low level driver introduce functionality API that enable
- * the to operate Marvell's Gigabit Ethernet Controller in a
- * convenient way.
- * - Simple Gigabit Ethernet port operation API.
- * - Simple Gigabit Ethernet port data flow API.
- * - Data flow and operation API support per queue functionality.
- * - Support cached descriptors for better performance.
- * - Enable access to all four DRAM banks and internal SRAM memory
- * spaces.
- * - PHY access and control API.
- * - Port control register configuration API.
- * - Full control over Unicast and Multicast MAC configurations.
+ * Supported Features:
+ * - The user is free from Rx/Tx queue managing.
+ * - This low level driver introduce functionality API that enable
+ * the to operate Marvell's Gigabit Ethernet Controller in a
+ * convenient way.
+ * - Simple Gigabit Ethernet port operation API.
+ * - Simple Gigabit Ethernet port data flow API.
+ * - Data flow and operation API support per queue functionality.
+ * - Support cached descriptors for better performance.
+ * - Enable access to all four DRAM banks and internal SRAM memory
+ * spaces.
+ * - PHY access and control API.
+ * - Port control register configuration API.
+ * - Full control over Unicast and Multicast MAC configurations.
*
- * Operation flow:
+ * Operation flow:
*
- * Initialization phase
- * This phase complete the initialization of the the
- * mv643xx_private struct.
- * User information regarding port configuration has to be set
- * prior to calling the port initialization routine.
+ * Initialization phase
+ * This phase complete the initialization of the the
+ * mv643xx_private struct.
+ * User information regarding port configuration has to be set
+ * prior to calling the port initialization routine.
*
- * In this phase any port Tx/Rx activity is halted, MIB counters
- * are cleared, PHY address is set according to user parameter and
- * access to DRAM and internal SRAM memory spaces.
+ * In this phase any port Tx/Rx activity is halted, MIB counters
+ * are cleared, PHY address is set according to user parameter and
+ * access to DRAM and internal SRAM memory spaces.
*
- * Driver ring initialization
- * Allocating memory for the descriptor rings and buffers is not
- * within the scope of this driver. Thus, the user is required to
- * allocate memory for the descriptors ring and buffers. Those
- * memory parameters are used by the Rx and Tx ring initialization
- * routines in order to curve the descriptor linked list in a form
- * of a ring.
- * Note: Pay special attention to alignment issues when using
- * cached descriptors/buffers. In this phase the driver store
- * information in the mv643xx_private struct regarding each queue
- * ring.
+ * Driver ring initialization
+ * Allocating memory for the descriptor rings and buffers is not
+ * within the scope of this driver. Thus, the user is required to
+ * allocate memory for the descriptors ring and buffers. Those
+ * memory parameters are used by the Rx and Tx ring initialization
+ * routines in order to curve the descriptor linked list in a form
+ * of a ring.
+ * Note: Pay special attention to alignment issues when using
+ * cached descriptors/buffers. In this phase the driver store
+ * information in the mv643xx_private struct regarding each queue
+ * ring.
*
- * Driver start
- * This phase prepares the Ethernet port for Rx and Tx activity.
- * It uses the information stored in the mv643xx_private struct to
- * initialize the various port registers.
+ * Driver start
+ * This phase prepares the Ethernet port for Rx and Tx activity.
+ * It uses the information stored in the mv643xx_private struct to
+ * initialize the various port registers.
*
- * Data flow:
- * All packet references to/from the driver are done using
- * struct pkt_info.
- * This struct is a unified struct used with Rx and Tx operations.
- * This way the user is not required to be familiar with neither
- * Tx nor Rx descriptors structures.
- * The driver's descriptors rings are management by indexes.
- * Those indexes controls the ring resources and used to indicate
- * a SW resource error:
- * 'current'
- * This index points to the current available resource for use. For
- * example in Rx process this index will point to the descriptor
- * that will be passed to the user upon calling the receive
- * routine. In Tx process, this index will point to the descriptor
- * that will be assigned with the user packet info and transmitted.
- * 'used'
- * This index points to the descriptor that need to restore its
- * resources. For example in Rx process, using the Rx buffer return
- * API will attach the buffer returned in packet info to the
- * descriptor pointed by 'used'. In Tx process, using the Tx
- * descriptor return will merely return the user packet info with
- * the command status of the transmitted buffer pointed by the
- * 'used' index. Nevertheless, it is essential to use this routine
- * to update the 'used' index.
- * 'first'
- * This index supports Tx Scatter-Gather. It points to the first
- * descriptor of a packet assembled of multiple buffers. For
- * example when in middle of Such packet we have a Tx resource
- * error the 'curr' index get the value of 'first' to indicate
- * that the ring returned to its state before trying to transmit
- * this packet.
+ * Data flow:
+ * All packet references to/from the driver are done using
+ * struct pkt_info.
+ * This struct is a unified struct used with Rx and Tx operations.
+ * This way the user is not required to be familiar with neither
+ * Tx nor Rx descriptors structures.
+ * The driver's descriptors rings are management by indexes.
+ * Those indexes controls the ring resources and used to indicate
+ * a SW resource error:
+ * 'current'
+ * This index points to the current available resource for use. For
+ * example in Rx process this index will point to the descriptor
+ * that will be passed to the user upon calling the receive
+ * routine. In Tx process, this index will point to the descriptor
+ * that will be assigned with the user packet info and transmitted.
+ * 'used'
+ * This index points to the descriptor that need to restore its
+ * resources. For example in Rx process, using the Rx buffer return
+ * API will attach the buffer returned in packet info to the
+ * descriptor pointed by 'used'. In Tx process, using the Tx
+ * descriptor return will merely return the user packet info with
+ * the command status of the transmitted buffer pointed by the
+ * 'used' index. Nevertheless, it is essential to use this routine
+ * to update the 'used' index.
+ * 'first'
+ * This index supports Tx Scatter-Gather. It points to the first
+ * descriptor of a packet assembled of multiple buffers. For
+ * example when in middle of Such packet we have a Tx resource
+ * error the 'curr' index get the value of 'first' to indicate
+ * that the ring returned to its state before trying to transmit
+ * this packet.
*
- * Receive operation:
- * The mv643xx_eth_port_receive API set the packet information struct,
- * passed by the caller, with received information from the
- * 'current' SDMA descriptor.
- * It is the user responsibility to return this resource back
- * to the Rx descriptor ring to enable the reuse of this source.
- * Return Rx resource is done using the eth_rx_return_buff API.
+ * Receive operation:
+ * The mv643xx_eth_port_receive API set the packet information struct,
+ * passed by the caller, with received information from the
+ * 'current' SDMA descriptor.
+ * It is the user responsibility to return this resource back
+ * to the Rx descriptor ring to enable the reuse of this source.
+ * Return Rx resource is done using the eth_rx_return_buff API.
*
- * Transmit operation:
- * The mv643xx_eth_tx_packet API supports Scatter-Gather which enables to
- * send a packet spanned over multiple buffers. This means that
- * for each packet info structure given by the user and put into
- * the Tx descriptors ring, will be transmitted only if the 'LAST'
- * bit will be set in the packet info command status field. This
- * API also consider restriction regarding buffer alignments and
- * sizes.
- * The user must return a Tx resource after ensuring the buffer
- * has been transmitted to enable the Tx ring indexes to update.
+ * Transmit operation:
+ * The mv643xx_eth_tx_packet API supports Scatter-Gather which enables to
+ * send a packet spanned over multiple buffers. This means that
+ * for each packet info structure given by the user and put into
+ * the Tx descriptors ring, will be transmitted only if the 'LAST'
+ * bit will be set in the packet info command status field. This
+ * API also consider restriction regarding buffer alignments and
+ * sizes.
+ * The user must return a Tx resource after ensuring the buffer
+ * has been transmitted to enable the Tx ring indexes to update.
*
- * BOARD LAYOUT
- * This device is on-board. No jumper diagram is necessary.
+ * BOARD LAYOUT
+ * This device is on-board. No jumper diagram is necessary.
*
- * EXTERNAL INTERFACE
+ * EXTERNAL INTERFACE
*
- * Prior to calling the initialization routine mv643xx_eth_port_init() the user
- * must set the following fields under mv643xx_private struct:
+ * Prior to calling the initialization routine
+ * mv643xx_eth_port_init() the user must set the following fields
+ * under mv643xx_private struct:
* port_num User Ethernet port number.
* port_mac_addr[6] User defined port MAC address.
* port_config User port configuration value.
@@ -223,15 +220,15 @@
* port_sdma_config User port SDMA config value.
* port_serial_control User port serial control value.
*
- * This driver data flow is done using the struct pkt_info which
- * is a unified struct for Rx and Tx operations:
+ * This driver data flow is done using the struct pkt_info which
+ * is a unified struct for Rx and Tx operations:
*
- * byte_cnt Tx/Rx descriptor buffer byte count.
- * l4i_chk CPU provided TCP Checksum. For Tx operation
+ * byte_cnt Tx/Rx descriptor buffer byte count.
+ * l4i_chk CPU provided TCP Checksum. For Tx operation
* only.
- * cmd_sts Tx/Rx descriptor command status.
- * buf_ptr Tx/Rx descriptor buffer pointer.
- * return_info Tx/Rx user resource return information.
+ * cmd_sts Tx/Rx descriptor command status.
+ * buf_ptr Tx/Rx descriptor buffer pointer.
+ * return_info Tx/Rx user resource return information.
*/
/* defines */
@@ -243,8 +240,8 @@
* Ethernet port setup routines
*****************************************************************************/
-static int mv643xx_eth_port_mac_addr(unsigned int eth_port_num, unsigned char uc_nibble,
- int option)
+static int mv643xx_eth_port_mac_addr(unsigned int eth_port_num,
+ unsigned char uc_nibble, int option)
{
unsigned int unicast_reg;
unsigned int tbl_offset;
@@ -252,31 +249,35 @@
/* Locate the Unicast table entry */
uc_nibble = (0xf & uc_nibble);
- tbl_offset = (uc_nibble / 4) * 4; /* Register offset from unicast table base */
- reg_offset = uc_nibble % 4; /* Entry offset within the above register */
-
+ tbl_offset = (uc_nibble / 4) * 4; /* Register offset from unicast
+ * table base
+ */
+ reg_offset = uc_nibble % 4; /* Entry offset within the
+ * above register
+ */
switch (option) {
case REJECT_MAC_ADDR:
/* Clear accepts frame bit at given unicast DA table entry */
- unicast_reg = mv643xx_eth_read((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
- (eth_port_num) + tbl_offset));
+ unicast_reg =
+ mv643xx_eth_read(MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE(eth_port_num) +
+ tbl_offset);
unicast_reg &= (0x0E << (8 * reg_offset));
- mv643xx_eth_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
- (eth_port_num) + tbl_offset), unicast_reg);
+ mv643xx_eth_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE(eth_port_num) +
+ tbl_offset), unicast_reg);
break;
case ACCEPT_MAC_ADDR:
/* Set accepts frame bit at unicast DA filter table entry */
unicast_reg =
- mv643xx_eth_read((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
- (eth_port_num) + tbl_offset));
+ mv643xx_eth_read(MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE(eth_port_num) +
+ tbl_offset);
unicast_reg |= (0x01 << (8 * reg_offset));
- mv643xx_eth_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
- (eth_port_num) + tbl_offset), unicast_reg);
+ mv643xx_eth_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE(eth_port_num) +
+ tbl_offset), unicast_reg);
break;
@@ -287,7 +288,8 @@
return 1;
}
-static void mv643xx_eth_port_mac_addr_get(struct net_device *dev, unsigned char *p_addr)
+static void mv643xx_eth_port_mac_addr_get(struct net_device *dev,
+ unsigned char *p_addr)
{
struct mv643xx_private *mp = netdev_priv(dev);
unsigned int mac_h;
@@ -314,7 +316,7 @@
mac_l = (p_addr[4] << 8) | (p_addr[5]);
mac_h = (p_addr[0] << 24) | (p_addr[1] << 16) | (p_addr[2] << 8) |
- (p_addr[3] << 0);
+ (p_addr[3] << 0);
mv643xx_eth_write(MV643XX_ETH_MAC_ADDR_LOW(eth_port_num), mac_l);
mv643xx_eth_write(MV643XX_ETH_MAC_ADDR_HIGH(eth_port_num), mac_h);
@@ -333,33 +335,33 @@
/* Clear DA filter unicast table (Ex_dFUT) */
for (table_index = 0; table_index <= 0xC; table_index += 4)
- mv643xx_eth_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE
- (eth_port_num) + table_index), 0);
+ mv643xx_eth_write((MV643XX_ETH_DA_FILTER_UNICAST_TABLE_BASE(eth_port_num) +
+ table_index), 0);
for (table_index = 0; table_index <= 0xFC; table_index += 4) {
/* Clear DA filter special multicast table (Ex_dFSMT) */
- mv643xx_eth_write((MV643XX_ETH_DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE
- (eth_port_num) + table_index), 0);
+ mv643xx_eth_write((MV643XX_ETH_DA_FILTER_SPECIAL_MULTICAST_TABLE_BASE(eth_port_num) +
+ table_index), 0);
/* Clear DA filter other multicast table (Ex_dFOMT) */
- mv643xx_eth_write((MV643XX_ETH_DA_FILTER_OTHER_MULTICAST_TABLE_BASE
- (eth_port_num) + table_index), 0);
+ mv643xx_eth_write((MV643XX_ETH_DA_FILTER_OTHER_MULTICAST_TABLE_BASE(eth_port_num) +
+ table_index), 0);
}
}
/*
- * This routine prepares the Ethernet port for Rx and Tx activity:
- * 1. Initialize Tx and Rx Current Descriptor Pointer for each queue that
- * has been initialized a descriptor's ring (using
- * ether_init_tx_desc_ring for Tx and ether_init_rx_desc_ring for Rx)
- * 2. Initialize and enable the Ethernet configuration port by writing to
- * the port's configuration and command registers.
- * 3. Initialize and enable the SDMA by writing to the SDMA's
- * configuration and command registers. After completing these steps,
- * the ethernet port SDMA can starts to perform Rx and Tx activities.
+ * This routine prepares the Ethernet port for Rx and Tx activity:
+ * 1. Initialize Tx and Rx Current Descriptor Pointer for each queue that
+ * has been initialized a descriptor's ring (using
+ * ether_init_tx_desc_ring for Tx and ether_init_rx_desc_ring for Rx)
+ * 2. Initialize and enable the Ethernet configuration port by writing to
+ * the port's configuration and command registers.
+ * 3. Initialize and enable the SDMA by writing to the SDMA's
+ * configuration and command registers. After completing these steps,
+ * the ethernet port SDMA can starts to perform Rx and Tx activities.
*
- * Note: Each Rx and Tx queue descriptor's list must be initialized prior
- * to calling this function (use mv643xx_eth_init_tx_desc_ring for Tx queues
- * and mv643xx_eth_init_rx_desc_ring for Rx queues).
+ * Note: Each Rx and Tx queue descriptor's list must be initialized prior
+ * to calling this function (use mv643xx_eth_init_tx_desc_ring for Tx queues
+ * and mv643xx_eth_init_rx_desc_ring for Rx queues).
*/
static void mv643xx_eth_port_start(struct net_device *dev)
{
@@ -370,12 +372,14 @@
/* Assignment of Tx CTRP of given queue */
tx_curr_desc = mp->tx_curr_desc_q;
mv643xx_eth_write(MV643XX_ETH_TX_CURRENT_QUEUE_DESC_PTR_0(port_num),
- (u32)((struct eth_tx_desc *)mp->tx_desc_dma + tx_curr_desc));
+ (u32) ((struct eth_tx_desc *)mp->tx_desc_dma +
+ tx_curr_desc));
/* Assignment of Rx CRDP of given queue */
rx_curr_desc = mp->rx_curr_desc_q;
mv643xx_eth_write(MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_0(port_num),
- (u32)((struct eth_rx_desc *)mp->rx_desc_dma + rx_curr_desc));
+ (u32) ((struct eth_rx_desc *)mp->rx_desc_dma +
+ rx_curr_desc));
/* Add the assigned Ethernet address to the port's address table */
mv643xx_eth_port_mac_addr_set(dev, mp->port_mac_addr);
@@ -394,10 +398,11 @@
/* Increase the Rx side buffer size if supporting GigE */
if (mp->port_serial_control & MV643XX_ETH_SET_GMII_SPEED_TO_1000)
mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
- (mp->port_serial_control & 0xfff1ffff) | (0x5 << 17));
+ (mp->port_serial_control & 0xfff1ffff) |
+ (0x5 << 17));
else
mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
- mp->port_serial_control);
+ mp->port_serial_control);
mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
mp->port_serial_control |
@@ -409,12 +414,12 @@
/* Enable port Rx. */
mv643xx_eth_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num),
- mp->port_rx_queue_command);
+ mp->port_rx_queue_command);
}
/*
- * This function clears all MIB counters of a specific ethernet port.
- * A read from the MIB counter will reset the counter.
+ * This function clears all MIB counters of a specific ethernet port.
+ * A read from the MIB counter will reset the counter.
*/
static void mv643xx_eth_clear_mib_counters(struct net_device *dev)
{
@@ -423,15 +428,16 @@
int i;
/* Perform dummy reads from MIB counters */
- for (i = ETH_MIB_GOOD_OCTETS_RECEIVED_LOW; i < ETH_MIB_LATE_COLLISION;
- i += 4)
- mv643xx_eth_read(MV643XX_ETH_MIB_COUNTERS_BASE(eth_port_num) + i);
+ for (i = ETH_MIB_GOOD_OCTETS_RECEIVED_LOW;
+ i < ETH_MIB_LATE_COLLISION; i += 4)
+ mv643xx_eth_read(MV643XX_ETH_MIB_COUNTERS_BASE(eth_port_num) +
+ i);
}
/*
- * This routine resets the chip by aborting any SDMA engine activity and
- * clearing the MIB counters. The Receiver and the Transmit unit are in
- * idle state after this command is performed and the port is disabled.
+ * This routine resets the chip by aborting any SDMA engine activity and
+ * clearing the MIB counters. The Receiver and the Transmit unit are in
+ * idle state after this command is performed and the port is disabled.
*/
static void mv643xx_eth_port_reset(struct net_device *dev)
{
@@ -440,32 +446,32 @@
unsigned int reg_data;
/* Stop Tx port activity. Check port Tx activity. */
- reg_data = mv643xx_eth_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num));
+ reg_data =
+ mv643xx_eth_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num));
if (reg_data & 0xFF) {
/* Issue stop command for active channels only */
- mv643xx_eth_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num),
- (reg_data << 8));
+ mv643xx_eth_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num),
+ (reg_data << 8));
/* Wait for all Tx activity to terminate. */
/* Check port cause register that all Tx queues are stopped */
- while (mv643xx_eth_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num))
- & 0xFF)
+ while (mv643xx_eth_read(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num)) & 0xFF)
udelay(10);
}
/* Stop Rx port activity. Check port Rx activity. */
- reg_data = mv643xx_eth_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num));
+ reg_data =
+ mv643xx_eth_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num));
if (reg_data & 0xFF) {
/* Issue stop command for active channels only */
mv643xx_eth_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num),
- (reg_data << 8));
+ (reg_data << 8));
/* Wait for all Rx activity to terminate. */
/* Check port cause register that all Rx queues are stopped */
- while (mv643xx_eth_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num))
- & 0xFF)
+ while (mv643xx_eth_read(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num)) & 0xFF)
udelay(10);
}
@@ -473,9 +479,11 @@
mv643xx_eth_clear_mib_counters(dev);
/* Reset the Enable bit in the Configuration Register */
- reg_data = mv643xx_eth_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
+ reg_data =
+ mv643xx_eth_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
reg_data &= ~MV643XX_ETH_SERIAL_PORT_ENABLE;
- mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), reg_data);
+ mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
+ reg_data);
}
static int mv643xx_eth_phy_get(struct net_device *dev)
@@ -501,7 +509,7 @@
}
static void mv643xx_eth_read_smi_reg(struct net_device *dev,
- unsigned int phy_reg, unsigned int *value)
+ unsigned int phy_reg, unsigned int *value)
{
int phy_addr = mv643xx_eth_phy_get(dev);
unsigned long flags;
@@ -520,11 +528,13 @@
udelay(PHY_WAIT_MICRO_SECONDS);
}
- mv643xx_eth_write(MV643XX_ETH_SMI_REG,
- (phy_addr << 16) | (phy_reg << 21) | ETH_SMI_OPCODE_READ);
+ mv643xx_eth_write(MV643XX_ETH_SMI_REG,
+ (phy_addr << 16) | (phy_reg << 21) |
+ ETH_SMI_OPCODE_READ);
/* now wait for the data to be valid */
- for (i = 0; !(mv643xx_eth_read(MV643XX_ETH_SMI_REG) & ETH_SMI_READ_VALID); i++) {
+ for (i = 0; !(mv643xx_eth_read(MV643XX_ETH_SMI_REG) &
+ ETH_SMI_READ_VALID); i++) {
if (i == PHY_WAIT_ITERATIONS) {
printk(KERN_ERR "%s: PHY read timeout\n",
dev->name);
@@ -560,8 +570,9 @@
udelay(PHY_WAIT_MICRO_SECONDS);
}
- mv643xx_eth_write(MV643XX_ETH_SMI_REG, (phy_addr << 16) | (phy_reg << 21) |
- ETH_SMI_OPCODE_WRITE | (value & 0xffff));
+ mv643xx_eth_write(MV643XX_ETH_SMI_REG,
+ (phy_addr << 16) | (phy_reg << 21) |
+ ETH_SMI_OPCODE_WRITE | (value & 0xffff));
out:
spin_unlock_irqrestore(&mv643xx_eth_phy_lock, flags);
}
@@ -577,16 +588,16 @@
}
/*
- * This function prepares the ethernet port to start its activity:
- * 1) Completes the ethernet port driver struct initialization toward port
- * start routine.
- * 2) Resets the device to a quiescent state in case of warm reboot.
- * 3) Enable SDMA access to all four DRAM banks as well as internal SRAM.
- * 4) Clean MAC tables. The reset status of those tables is unknown.
- * 5) Set PHY address.
- * Note: Call this routine prior to eth_port_start routine and after
- * setting user values in the user fields of Ethernet port control
- * struct.
+ * This function prepares the ethernet port to start its activity:
+ * 1) Completes the ethernet port driver struct initialization toward port
+ * start routine.
+ * 2) Resets the device to a quiescent state in case of warm reboot.
+ * 3) Enable SDMA access to all four DRAM banks as well as internal SRAM.
+ * 4) Clean MAC tables. The reset status of those tables is unknown.
+ * 5) Set PHY address.
+ * Note: Call this routine prior to eth_port_start routine and after
+ * setting user values in the user fields of Ethernet port control
+ * struct.
*/
static void mv643xx_eth_port_init(struct net_device *dev)
{
@@ -610,7 +621,8 @@
{
struct mv643xx_private *mp = netdev_priv(dev);
- return mv643xx_eth_read(MV643XX_ETH_MIB_COUNTERS_BASE(mp->port_num) + offset);
+ return mv643xx_eth_read(MV643XX_ETH_MIB_COUNTERS_BASE(mp->port_num) +
+ offset);
}
static void mv643xx_eth_update_mib_counters(struct net_device *dev)
@@ -622,15 +634,12 @@
p->good_octets_received +=
mv643xx_eth_read_mib_counter(dev, ETH_MIB_GOOD_OCTETS_RECEIVED_LOW);
p->good_octets_received +=
- (u64) mv643xx_eth_read_mib_counter(dev,
- ETH_MIB_GOOD_OCTETS_RECEIVED_HIGH)
- << 32;
+ (u64) mv643xx_eth_read_mib_counter(dev, ETH_MIB_GOOD_OCTETS_RECEIVED_HIGH) << 32;
for (offset = ETH_MIB_BAD_OCTETS_RECEIVED;
- offset <= ETH_MIB_FRAMES_1024_TO_MAX_OCTETS;
- offset += 4)
- *(u32 *)((char *)p + offset) =
- mv643xx_eth_read_mib_counter(dev, offset);
+ offset <= ETH_MIB_FRAMES_1024_TO_MAX_OCTETS; offset += 4)
+ *(u32 *) ((char *)p + offset) =
+ mv643xx_eth_read_mib_counter(dev, offset);
p->good_octets_sent +=
mv643xx_eth_read_mib_counter(dev, ETH_MIB_GOOD_OCTETS_SENT_LOW);
@@ -638,15 +647,14 @@
(u64) mv643xx_eth_read_mib_counter(dev, ETH_MIB_GOOD_OCTETS_SENT_HIGH) << 32;
for (offset = ETH_MIB_GOOD_FRAMES_SENT;
- offset <= ETH_MIB_LATE_COLLISION;
- offset += 4)
- *(u32 *)((char *)p + offset) =
- mv643xx_eth_read_mib_counter(dev, offset);
+ offset <= ETH_MIB_LATE_COLLISION; offset += 4)
+ *(u32 *) ((char *)p + offset) =
+ mv643xx_eth_read_mib_counter(dev, offset);
}
/*
- * This function tests whether there is a PHY present on
- * the specified port.
+ * This function tests whether there is a PHY present on
+ * the specified port.
*/
static int mv643xx_eth_phy_detect(struct net_device *dev)
{
@@ -660,7 +668,7 @@
mv643xx_eth_read_smi_reg(dev, 0, &phy_reg_data0);
if ((phy_reg_data0 & 0x1000) == auto_neg)
- return -ENODEV; /* change didn't take */
+ return -ENODEV; /* change didn't take */
phy_reg_data0 ^= 0x1000;
mv643xx_eth_write_smi_reg(dev, 0, phy_reg_data0);
@@ -668,8 +676,8 @@
}
/*
- * This function sets specified bits in the given ethernet
- * configuration register.
+ * This function sets specified bits in the given ethernet
+ * configuration register.
*/
static void mv643xx_eth_set_config_reg(struct net_device *dev,
unsigned int value)
@@ -678,22 +686,24 @@
unsigned int eth_port_num = mp->port_num;
unsigned int eth_config_reg;
- eth_config_reg = mv643xx_eth_read(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num));
+ eth_config_reg =
+ mv643xx_eth_read(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num));
eth_config_reg |= value;
- mv643xx_eth_write(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num), eth_config_reg);
+ mv643xx_eth_write(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num),
+ eth_config_reg);
}
/*
- * This function returns the configuration register value of the given
- * ethernet port.
+ * This function returns the configuration register value of the given
+ * ethernet port.
*/
static unsigned int mv643xx_eth_get_config_reg(struct net_device *dev)
{
struct mv643xx_private *mp = netdev_priv(dev);
unsigned int eth_config_reg;
- eth_config_reg = mv643xx_eth_read(MV643XX_ETH_PORT_CONFIG_EXTEND_REG
- (mp->port_num));
+ eth_config_reg =
+ mv643xx_eth_read(MV643XX_ETH_PORT_CONFIG_EXTEND_REG(mp->port_num));
return eth_config_reg;
}
@@ -702,13 +712,13 @@
*****************************************************************************/
/*
- * This function prepares a Rx chained list of descriptors and packet
- * buffers in a form of a ring. The routine must be called after port
- * initialization routine and before port start routine.
- * The Ethernet SDMA engine uses CPU bus addresses to access the various
- * devices in the system (i.e. DRAM). This function uses the ethernet
- * struct 'virtual to physical' routine (set by the user) to set the ring
- * with physical addresses.
+ * This function prepares a Rx chained list of descriptors and packet
+ * buffers in a form of a ring. The routine must be called after port
+ * initialization routine and before port start routine.
+ * The Ethernet SDMA engine uses CPU bus addresses to access the various
+ * devices in the system (i.e. DRAM). This function uses the ethernet
+ * struct 'virtual to physical' routine (set by the user) to set the ring
+ * with physical addresses.
*/
static void mv643xx_eth_init_rx_desc_ring(struct net_device *dev)
{
@@ -735,13 +745,13 @@
}
/*
- * This function prepares a Tx chained list of descriptors and packet
- * buffers in a form of a ring. The routine must be called after port
- * initialization routine and before port start routine.
- * The Ethernet SDMA engine uses CPU bus addresses to access the various
- * devices in the system (i.e. DRAM). This function uses the ethernet
- * struct 'virtual to physical' routine (set by the user) to set the ring
- * with physical addresses.
+ * This function prepares a Tx chained list of descriptors and packet
+ * buffers in a form of a ring. The routine must be called after port
+ * initialization routine and before port start routine.
+ * The Ethernet SDMA engine uses CPU bus addresses to access the various
+ * devices in the system (i.e. DRAM). This function uses the ethernet
+ * struct 'virtual to physical' routine (set by the user) to set the ring
+ * with physical addresses.
*/
static void mv643xx_eth_init_tx_desc_ring(struct net_device *dev)
{
@@ -775,7 +785,8 @@
unsigned int curr;
/* Stop Tx Queues */
- mv643xx_eth_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(mp->port_num), 0x0000ff00);
+ mv643xx_eth_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(mp->port_num),
+ 0x0000ff00);
/* Free outstanding skb's on TX rings */
for (curr = 0; mp->tx_ring_skbs && curr < mp->tx_ring_size; curr++) {
@@ -793,7 +804,7 @@
iounmap(mp->p_tx_desc_area);
else
dma_free_coherent(NULL, mp->tx_desc_area_size,
- mp->p_tx_desc_area, mp->tx_desc_dma);
+ mp->p_tx_desc_area, mp->tx_desc_dma);
}
static void mv643xx_eth_free_rx_rings(struct net_device *dev)
@@ -802,7 +813,8 @@
int curr;
/* Stop RX Queues */
- mv643xx_eth_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(mp->port_num), 0x0000ff00);
+ mv643xx_eth_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(mp->port_num),
+ 0x0000ff00);
/* Free preallocated skb's on RX rings */
for (curr = 0; mp->rx_ring_skbs && curr < mp->rx_ring_size; curr++) {
@@ -822,50 +834,52 @@
iounmap(mp->p_rx_desc_area);
else
dma_free_coherent(NULL, mp->rx_desc_area_size,
- mp->p_rx_desc_area, mp->rx_desc_dma);
+ mp->p_rx_desc_area, mp->rx_desc_dma);
}
#ifdef MV643XX_COAL
/*
- * This routine sets the RX coalescing interrupt mechanism parameter.
- * This parameter is a timeout counter, that counts in 64 t_clk
- * chunks ; that when timeout event occurs a maskable interrupt
- * occurs.
- * The parameter is calculated using the tClk of the MV-643xx chip
- * and the required delay of the interrupt in usec.
+ * This routine sets the RX coalescing interrupt mechanism parameter.
+ * This parameter is a timeout counter, that counts in 64 t_clk
+ * chunks ; that when timeout event occurs a maskable interrupt
+ * occurs.
+ * The parameter is calculated using the tClk of the MV-643xx chip
+ * and the required delay of the interrupt in usec.
*/
static unsigned int mv643xx_eth_port_set_rx_coal(unsigned int eth_port_num,
- unsigned int t_clk, unsigned int delay)
+ unsigned int t_clk,
+ unsigned int delay)
{
unsigned int coal = ((t_clk / 1000000) * delay) / 64;
/* Set RX Coalescing mechanism */
mv643xx_eth_write(MV643XX_ETH_SDMA_CONFIG_REG(eth_port_num),
- ((coal & 0x3fff) << 8) |
- (mv643xx_eth_read(MV643XX_ETH_SDMA_CONFIG_REG(eth_port_num))
- & 0xffc000ff));
+ ((coal & 0x3fff) << 8) |
+ (mv643xx_eth_read(MV643XX_ETH_SDMA_CONFIG_REG(eth_port_num))
+ & 0xffc000ff));
return coal;
}
#endif
/*
- * This routine sets the TX coalescing interrupt mechanism parameter.
- * This parameter is a timeout counter, that counts in 64 t_clk
- * chunks ; that when timeout event occurs a maskable interrupt
- * occurs.
- * The parameter is calculated using the t_cLK frequency of the
- * MV-643xx chip and the required delay in the interrupt in uSec
+ * This routine sets the TX coalescing interrupt mechanism parameter.
+ * This parameter is a timeout counter, that counts in 64 t_clk
+ * chunks ; that when timeout event occurs a maskable interrupt
+ * occurs.
+ * The parameter is calculated using the t_cLK frequency of the
+ * MV-643xx chip and the required delay in the interrupt in uSec
*/
static unsigned int mv643xx_eth_port_set_tx_coal(unsigned int eth_port_num,
- unsigned int t_clk, unsigned int delay)
+ unsigned int t_clk,
+ unsigned int delay)
{
unsigned int coal;
coal = ((t_clk / 1000000) * delay) / 64;
/* Set TX Coalescing mechanism */
mv643xx_eth_write(MV643XX_ETH_TX_FIFO_URGENT_THRESHOLD_REG(eth_port_num),
- coal << 4);
+ coal << 4);
return coal;
}
@@ -874,21 +888,21 @@
*****************************************************************************/
/*
- * This routine send a given packet described by p_pktinfo parameter. It
- * supports transmitting of a packet spaned over multiple buffers. The
- * routine updates 'curr' and 'first' indexes according to the packet
- * segment passed to the routine. In case the packet segment is first,
- * the 'first' index is update. In any case, the 'curr' index is updated.
- * If the routine get into Tx resource error it assigns 'curr' index as
- * 'first'. This way the function can abort Tx process of multiple
- * descriptors per packet.
+ * This routine sends a given packet described by p_pktinfo parameter. It
+ * supports transmitting of a packet spaned over multiple buffers. The
+ * routine updates 'curr' and 'first' indexes according to the packet
+ * segment passed to the routine. In case the packet segment is first,
+ * the 'first' index is update. In any case, the 'curr' index is updated.
+ * If the routine get into Tx resource error it assigns 'curr' index as
+ * 'first'. This way the function can abort Tx process of multiple
+ * descriptors per packet.
*/
#ifdef MV643XX_CHECKSUM_OFFLOAD_TX
/*
* Modified to include the first descriptor pointer in case of SG
*/
static int mv643xx_eth_tx_packet(struct net_device *dev,
- struct pkt_info *p_pkt_info)
+ struct pkt_info *p_pkt_info)
{
struct mv643xx_private *mp = netdev_priv(dev);
int tx_desc_curr, tx_desc_used, tx_first_desc, tx_next_desc;
@@ -928,7 +942,7 @@
mp->tx_skb[tx_desc_curr] = p_pkt_info->return_info;
command = p_pkt_info->cmd_sts | ETH_ZERO_PADDING | ETH_GEN_CRC |
- ETH_BUFFER_OWNED_BY_DMA;
+ ETH_BUFFER_OWNED_BY_DMA;
if (command & ETH_TX_FIRST_DESC) {
tx_first_desc = tx_desc_curr;
mp->tx_first_desc_q = tx_first_desc;
@@ -942,11 +956,11 @@
}
if (netif_msg_txqueued(mp))
- printk( KERN_DEBUG "%s: send pkt: len=%d, desc=%d, "
- "f/l=%d/%d\n", dev->name,
- p_pkt_info->byte_cnt, tx_desc_curr,
- ((command & ETH_TX_FIRST_DESC) != 0),
- ((command & ETH_TX_LAST_DESC) != 0));
+ printk(KERN_DEBUG "%s: send pkt: len=%d, desc=%d, "
+ "f/l=%d/%d\n", dev->name,
+ p_pkt_info->byte_cnt, tx_desc_curr,
+ ((command & ETH_TX_FIRST_DESC) != 0),
+ ((command & ETH_TX_LAST_DESC) != 0));
if (command & ETH_TX_LAST_DESC) {
wmb();
@@ -981,7 +995,7 @@
}
#else
static int mv643xx_eth_tx_packet(struct net_device *dev,
- struct pkt_info *p_pkt_info)
+ struct pkt_info *p_pkt_info)
{
struct mv643xx_private *mp = netdev_priv(dev);
int tx_desc_curr;
@@ -1015,7 +1029,7 @@
/* Set last desc with DMA ownership and interrupt enable. */
wmb();
current_descriptor->cmd_sts = command_status |
- ETH_BUFFER_OWNED_BY_DMA | ETH_TX_ENABLE_INTERRUPT;
+ ETH_BUFFER_OWNED_BY_DMA | ETH_TX_ENABLE_INTERRUPT;
wmb();
ETH_ENABLE_TX_QUEUE(mp->port_num);
@@ -1044,11 +1058,11 @@
#endif
/*
- * This routine returns the transmitted packet information to the caller.
- * It uses the 'first' index to support Tx desc return in case a transmit
- * of a packet spanned over multiple buffer still in process.
- * In case the Tx queue was in "resource error" condition, where there are
- * no available Tx resources, the function resets the resource error flag.
+ * This routine returns the transmitted packet information to the caller.
+ * It uses the 'first' index to support Tx desc return in case a transmit
+ * of a packet spanned over multiple buffer still in process.
+ * In case the Tx queue was in "resource error" condition, where there are
+ * no available Tx resources, the function resets the resource error flag.
*/
static int mv643xx_eth_tx_return_desc(struct net_device *dev,
struct pkt_info *p_pkt_info)
@@ -1097,11 +1111,11 @@
}
/*
- * This routine returns the received data to the caller. There is no
- * data copying during routine operation. All information is returned
- * using pointer to packet information struct passed from the caller.
- * If the routine exhausts Rx ring resources then the resource error flag
- * is set.
+ * This routine returns the received data to the caller. There is no
+ * data copying during routine operation. All information is returned
+ * using pointer to packet information struct passed from the caller.
+ * If the routine exhausts Rx ring resources then the resource error flag
+ * is set.
*/
static int mv643xx_eth_rx_packet(struct net_device *dev,
struct pkt_info *p_pkt_info)
@@ -1141,8 +1155,10 @@
((command_status & ETH_RX_FIRST_DESC) != 0),
((command_status & ETH_RX_LAST_DESC) != 0));
- /* Clean the return info field to indicate that the packet has been */
- /* moved to the upper layers */
+ /*
+ * Clean the return info field to indicate that the packet has been
+ * moved to the upper layers
+ */
mp->rx_skb[rx_curr_desc] = NULL;
/* Update current index in data structure */
@@ -1157,10 +1173,10 @@
}
/*
- * This routine returns a Rx buffer back to the Rx ring. It retrieves the
- * next 'used' descriptor and attached the returned buffer to it.
- * In case the Rx ring was in "resource error" condition, where there are
- * no available Rx resources, the function resets the resource error flag.
+ * This routine returns a Rx buffer back to the Rx ring. It retrieves the
+ * next 'used' descriptor and attached the returned buffer to it.
+ * In case the Rx ring was in "resource error" condition, where there are
+ * no available Rx resources, the function resets the resource error flag.
*/
static void mv643xx_eth_rx_return_buff(struct net_device *dev,
struct pkt_info *p_pkt_info)
@@ -1186,8 +1202,8 @@
/* Return the descriptor to DMA ownership */
wmb();
- p_used_rx_desc->cmd_sts =
- ETH_BUFFER_OWNED_BY_DMA | ETH_RX_ENABLE_INTERRUPT;
+ p_used_rx_desc->cmd_sts = ETH_BUFFER_OWNED_BY_DMA |
+ ETH_RX_ENABLE_INTERRUPT;
wmb();
/* Move the used descriptor pointer to the next descriptor */
@@ -1232,7 +1248,7 @@
pkt_info.cmd_sts = ETH_RX_ENABLE_INTERRUPT;
pkt_info.byte_cnt = RX_SKB_SIZE;
pkt_info.buf_ptr = dma_map_single(NULL, skb->data, RX_SKB_SIZE,
- DMA_FROM_DEVICE);
+ DMA_FROM_DEVICE);
pkt_info.return_info = skb;
mv643xx_eth_rx_return_buff(dev, &pkt_info);
skb_reserve(skb, 2);
@@ -1254,7 +1270,7 @@
else {
/* Return interrupts */
mv643xx_eth_write(MV643XX_ETH_INTERRUPT_MASK_REG(mp->port_num),
- INT_CAUSE_UNMASK_ALL);
+ INT_CAUSE_UNMASK_ALL);
}
#endif
}
@@ -1285,7 +1301,7 @@
}
static int mv643xx_eth_free_tx_queue(struct net_device *dev,
- unsigned int eth_int_cause_ext)
+ unsigned int eth_int_cause_ext)
{
struct mv643xx_private *mp = netdev_priv(dev);
struct net_device_stats *stats = &mp->stats;
@@ -1301,7 +1317,8 @@
while (mv643xx_eth_tx_return_desc(dev, &pkt_info) == 0) {
if (pkt_info.cmd_sts & BIT0) {
if (netif_msg_tx_err(mp))
- printk(KERN_WARNING "%s: Error in TX: cmd_sts=%08x\n",
+ printk(KERN_WARNING "%s: Error in TX: "
+ "cmd_sts=%08x\n",
dev->name, pkt_info.cmd_sts);
stats->tx_errors++;
}
@@ -1315,12 +1332,12 @@
if (pkt_info.return_info) {
if (skb_shinfo(pkt_info.return_info)->nr_frags)
dma_unmap_page(NULL, pkt_info.buf_ptr,
- pkt_info.byte_cnt,
- DMA_TO_DEVICE);
+ pkt_info.byte_cnt,
+ DMA_TO_DEVICE);
else
dma_unmap_single(NULL, pkt_info.buf_ptr,
- pkt_info.byte_cnt,
- DMA_TO_DEVICE);
+ pkt_info.byte_cnt,
+ DMA_TO_DEVICE);
dev_kfree_skb_irq(pkt_info.return_info);
released = 0;
@@ -1331,11 +1348,11 @@
*/
if (mp->tx_ring_skbs == 0)
panic("ERROR - TX outstanding SKBs"
- " counter is corrupted");
+ " counter is corrupted");
mp->tx_ring_skbs--;
} else
dma_unmap_page(NULL, pkt_info.buf_ptr,
- pkt_info.byte_cnt, DMA_TO_DEVICE);
+ pkt_info.byte_cnt, DMA_TO_DEVICE);
}
spin_unlock(&mp->lock);
@@ -1369,7 +1386,9 @@
#ifdef MV643XX_NAPI
budget--;
#endif
- /* Update statistics. Note byte count includes 4 byte CRC count */
+ /* Update statistics. Note byte count includes 4 byte CRC
+ * count
+ */
stats->rx_packets++;
stats->rx_bytes += pkt_info.byte_cnt;
skb = pkt_info.return_info;
@@ -1378,13 +1397,13 @@
* the error summary bit is on, the packets needs to be dropeed.
*/
if (((pkt_info.cmd_sts
- & (ETH_RX_FIRST_DESC | ETH_RX_LAST_DESC)) !=
- (ETH_RX_FIRST_DESC | ETH_RX_LAST_DESC))
- || (pkt_info.cmd_sts & ETH_ERROR_SUMMARY)) {
+ & (ETH_RX_FIRST_DESC | ETH_RX_LAST_DESC)) !=
+ (ETH_RX_FIRST_DESC | ETH_RX_LAST_DESC))
+ || (pkt_info.cmd_sts & ETH_ERROR_SUMMARY)) {
stats->rx_dropped++;
if ((pkt_info.cmd_sts & (ETH_RX_FIRST_DESC |
- ETH_RX_LAST_DESC)) !=
- (ETH_RX_FIRST_DESC | ETH_RX_LAST_DESC)) {
+ ETH_RX_LAST_DESC)) !=
+ (ETH_RX_FIRST_DESC | ETH_RX_LAST_DESC)) {
if (net_ratelimit() && netif_msg_rx_err(mp))
printk(KERN_WARNING "%s: Received "
"packet spread on multiple "
@@ -1404,8 +1423,8 @@
if (pkt_info.cmd_sts & ETH_LAYER_4_CHECKSUM_OK) {
skb->ip_summed = CHECKSUM_UNNECESSARY;
- skb->csum = htons(
- (pkt_info.cmd_sts & 0x0007fff8) >> 3);
+ skb->csum = htons((pkt_info.cmd_sts &
+ 0x0007fff8) >> 3);
}
skb->protocol = eth_type_trans(skb, dev);
#ifdef MV643XX_NAPI
@@ -1423,7 +1442,7 @@
* Main interrupt handler for the gigbit ethernet ports
*/
static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id,
- struct pt_regs *regs)
+ struct pt_regs *regs)
{
struct net_device *dev = (struct net_device *)dev_id;
struct mv643xx_private *mp = netdev_priv(dev);
@@ -1431,13 +1450,14 @@
unsigned int port_num = mp->port_num;
/* Read interrupt cause registers */
- eth_int_cause = mv643xx_eth_read(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num)) &
- INT_CAUSE_UNMASK_ALL;
+ eth_int_cause =
+ mv643xx_eth_read(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num)) &
+ INT_CAUSE_UNMASK_ALL;
if (eth_int_cause & BIT1)
- eth_int_cause_ext = mv643xx_eth_read(
- MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num)) &
- INT_CAUSE_UNMASK_ALL_EXT;
+ eth_int_cause_ext =
+ mv643xx_eth_read(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num)) &
+ INT_CAUSE_UNMASK_ALL_EXT;
#ifdef MV643XX_NAPI
if (!(eth_int_cause & 0x0007fffd)) {
@@ -1448,10 +1468,10 @@
* acknowleding relevant bits.
*/
mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num),
- ~eth_int_cause);
+ ~eth_int_cause);
if (eth_int_cause_ext != 0x0)
- mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG
- (port_num), ~eth_int_cause_ext);
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num),
+ ~eth_int_cause_ext);
/* UDP change : We may need this */
if ((eth_int_cause_ext & 0x0000ffff) &&
@@ -1463,28 +1483,27 @@
if (netif_rx_schedule_prep(dev)) {
/* Mask all the interrupts */
mv643xx_eth_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num), 0);
- mv643xx_eth_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG
- (port_num), 0);
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num), 0);
__netif_rx_schedule(dev);
}
}
#else
- if (eth_int_cause & (BIT2 | BIT11))
- mv643xx_eth_receive_queue(dev);
+ if (eth_int_cause & (BIT2 | BIT11))
+ mv643xx_eth_receive_queue(dev);
- /*
- * After forwarded received packets to upper layer, add a task
- * in an interrupts enabled context that refills the RX ring
- * with skb's.
- */
+ /*
+ * After forwarded received packets to upper layer, add a task
+ * in an interrupts enabled context that refills the RX ring
+ * with skb's.
+ */
#ifdef MV643XX_RX_QUEUE_FILL_ON_TASK
- /* Unmask all interrupts on ethernet port */
- mv643xx_eth_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num),
- INT_CAUSE_MASK_ALL);
- queue_task(&mp->rx_task, &tq_immediate);
- mark_bh(IMMEDIATE_BH);
+ /* Unmask all interrupts on ethernet port */
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num),
+ INT_CAUSE_MASK_ALL);
+ queue_task(&mp->rx_task, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
#else
- mp->rx_task.func(dev);
+ mp->rx_task.func(dev);
#endif
#endif
/* PHY status changed */
@@ -1498,23 +1517,24 @@
printk(KERN_DEBUG "%s: link phy regs: "
"supported=%x advert=%x "
"autoneg=%x speed=%d duplex=%d\n",
- dev->name,
+ dev->name,
cmd.supported, cmd.advertising,
cmd.autoneg, cmd.speed, cmd.duplex);
- if(mii_link_ok(&mp->mii) && !netif_carrier_ok(dev)) {
+ if (mii_link_ok(&mp->mii) && !netif_carrier_ok(dev)) {
if (netif_msg_ifup(mp))
- printk(KERN_INFO "%s: link up, %sMbps, %s-duplex\n",
- dev->name,
+ printk(KERN_INFO "%s: link up, %sMbps, "
+ "%s-duplex\n", dev->name,
cmd.speed == SPEED_1000 ? "1000" :
cmd.speed == SPEED_100 ? "100" : "10",
- cmd.duplex == DUPLEX_FULL ? "full" : "half");
+ cmd.duplex == DUPLEX_FULL ? "full" :
+ "half");
netif_wake_queue(dev);
/* Start TX queue */
mv643xx_eth_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num), 1);
- } else if(!mii_link_ok(&mp->mii) && netif_carrier_ok(dev)) {
+ } else if (!mii_link_ok(&mp->mii) && netif_carrier_ok(dev)) {
netif_stop_queue(dev);
if (netif_msg_ifdown(mp))
printk(KERN_INFO "%s: link down\n", dev->name);
@@ -1543,12 +1563,12 @@
if (pkt_info.return_info) {
if (skb_shinfo(pkt_info.return_info)->nr_frags)
dma_unmap_page(NULL, pkt_info.buf_ptr,
- pkt_info.byte_cnt,
- DMA_TO_DEVICE);
+ pkt_info.byte_cnt,
+ DMA_TO_DEVICE);
else
dma_unmap_single(NULL, pkt_info.buf_ptr,
- pkt_info.byte_cnt,
- DMA_TO_DEVICE);
+ pkt_info.byte_cnt,
+ DMA_TO_DEVICE);
dev_kfree_skb_irq(pkt_info.return_info);
@@ -1556,11 +1576,11 @@
mp->tx_ring_skbs--;
} else
dma_unmap_page(NULL, pkt_info.buf_ptr,
- pkt_info.byte_cnt, DMA_TO_DEVICE);
+ pkt_info.byte_cnt, DMA_TO_DEVICE);
}
if (netif_queue_stopped(dev) &&
- mp->tx_ring_size > mp->tx_ring_skbs + MAX_DESCS_PER_SKB)
+ mp->tx_ring_size > mp->tx_ring_skbs + MAX_DESCS_PER_SKB)
netif_wake_queue(dev);
}
@@ -1583,8 +1603,8 @@
}
#endif
- if ((mv643xx_eth_read(MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_0(port_num)))
- != (u32) mp->rx_used_desc_q) {
+ if ((mv643xx_eth_read(MV643XX_ETH_RX_CURRENT_QUEUE_DESC_PTR_0(port_num))) !=
+ (u32) mp->rx_used_desc_q) {
orig_budget = *budget;
if (orig_budget > dev->quota)
orig_budget = dev->quota;
@@ -1602,9 +1622,9 @@
mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
mv643xx_eth_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num),
- INT_CAUSE_UNMASK_ALL);
+ INT_CAUSE_UNMASK_ALL);
mv643xx_eth_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num),
- INT_CAUSE_UNMASK_ALL_EXT);
+ INT_CAUSE_UNMASK_ALL_EXT);
spin_unlock_irqrestore(&mp->lock, flags);
}
@@ -1632,7 +1652,7 @@
/* This is a hard error, log it. */
if ((mp->tx_ring_size - mp->tx_ring_skbs) <=
- (skb_shinfo(skb)->nr_frags + 1)) {
+ (skb_shinfo(skb)->nr_frags + 1)) {
netif_stop_queue(dev);
printk(KERN_ERR "%s: Trying to transmit when queue full!\n",
dev->name);
@@ -1651,18 +1671,20 @@
/* Update packet info data structure -- DMA owned, first last */
#ifdef MV643XX_CHECKSUM_OFFLOAD_TX
if (!skb_shinfo(skb)->nr_frags) {
-linear:
+ linear:
if (skb->ip_summed != CHECKSUM_HW) {
pkt_info.cmd_sts = ETH_TX_ENABLE_INTERRUPT |
- ETH_TX_FIRST_DESC | ETH_TX_LAST_DESC;
+ ETH_TX_FIRST_DESC | ETH_TX_LAST_DESC;
pkt_info.l4i_chk = 0;
} else {
u32 ipheader = skb->nh.iph->ihl << 11;
pkt_info.cmd_sts = ETH_TX_ENABLE_INTERRUPT |
- ETH_TX_FIRST_DESC | ETH_TX_LAST_DESC |
- ETH_GEN_TCP_UDP_CHECKSUM |
- ETH_GEN_IP_V_4_CHECKSUM | ipheader;
+ ETH_TX_FIRST_DESC |
+ ETH_TX_LAST_DESC |
+ ETH_GEN_TCP_UDP_CHECKSUM |
+ ETH_GEN_IP_V_4_CHECKSUM |
+ ipheader;
/* CPU already calculated pseudo header checksum. */
if (skb->nh.iph->protocol == IPPROTO_UDP) {
pkt_info.cmd_sts |= ETH_UDP_FRAME;
@@ -1678,7 +1700,7 @@
}
pkt_info.byte_cnt = skb->len;
pkt_info.buf_ptr = dma_map_single(NULL, skb->data, skb->len,
- DMA_TO_DEVICE);
+ DMA_TO_DEVICE);
pkt_info.return_info = skb;
mp->tx_ring_skbs++;
status = mv643xx_eth_tx_packet(dev, &pkt_info);
@@ -1715,8 +1737,8 @@
/* first frag which is skb header */
pkt_info.byte_cnt = skb_headlen(skb);
pkt_info.buf_ptr = dma_map_single(NULL, skb->data,
- skb_headlen(skb),
- DMA_TO_DEVICE);
+ skb_headlen(skb),
+ DMA_TO_DEVICE);
pkt_info.l4i_chk = 0;
pkt_info.return_info = 0;
pkt_info.cmd_sts = ETH_TX_FIRST_DESC;
@@ -1724,7 +1746,8 @@
if (skb->ip_summed == CHECKSUM_HW) {
ipheader = skb->nh.iph->ihl << 11;
pkt_info.cmd_sts |= ETH_GEN_TCP_UDP_CHECKSUM |
- ETH_GEN_IP_V_4_CHECKSUM | ipheader;
+ ETH_GEN_IP_V_4_CHECKSUM |
+ ipheader;
/* CPU already calculated pseudo header checksum. */
if (skb->nh.iph->protocol == IPPROTO_UDP) {
pkt_info.cmd_sts |= ETH_UDP_FRAME;
@@ -1754,7 +1777,7 @@
/* Last Frag enables interrupt and frees the skb */
if (frag == (skb_shinfo(skb)->nr_frags - 1)) {
pkt_info.cmd_sts |= ETH_TX_ENABLE_INTERRUPT |
- ETH_TX_LAST_DESC;
+ ETH_TX_LAST_DESC;
pkt_info.return_info = skb;
mp->tx_ring_skbs++;
} else {
@@ -1777,11 +1800,11 @@
}
#else
pkt_info.cmd_sts = ETH_TX_ENABLE_INTERRUPT | ETH_TX_FIRST_DESC |
- ETH_TX_LAST_DESC;
+ ETH_TX_LAST_DESC;
pkt_info.l4i_chk = 0;
pkt_info.byte_cnt = skb->len;
pkt_info.buf_ptr = dma_map_single(NULL, skb->data, skb->len,
- DMA_TO_DEVICE);
+ DMA_TO_DEVICE);
pkt_info.return_info = skb;
mp->tx_ring_skbs++;
status = mv643xx_eth_tx_packet(dev, &pkt_info);
@@ -1826,7 +1849,8 @@
unsigned int size;
/* Stop RX Queues */
- mv643xx_eth_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num), 0x0000ff00);
+ mv643xx_eth_write(MV643XX_ETH_RECEIVE_QUEUE_COMMAND_REG(port_num),
+ 0x0000ff00);
/* Clear the ethernet port interrupts */
mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
@@ -1834,11 +1858,11 @@
/* Unmask RX buffer and TX end interrupt */
mv643xx_eth_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num),
- INT_CAUSE_UNMASK_ALL);
+ INT_CAUSE_UNMASK_ALL);
/* Unmask phy and link status changes interrupts */
mv643xx_eth_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num),
- INT_CAUSE_UNMASK_ALL_EXT);
+ INT_CAUSE_UNMASK_ALL_EXT);
/* Set the MAC Address */
memcpy(mp->port_mac_addr, dev->dev_addr, 6);
@@ -1856,13 +1880,13 @@
/* Allocate RX and TX skb rings */
mp->rx_skb = kmalloc(sizeof(*mp->rx_skb) * mp->rx_ring_size,
- GFP_KERNEL);
+ GFP_KERNEL);
if (!mp->rx_skb) {
printk(KERN_ERR "%s: Cannot allocate Rx skb ring\n", dev->name);
return -ENOMEM;
}
mp->tx_skb = kmalloc(sizeof(*mp->tx_skb) * mp->tx_ring_size,
- GFP_KERNEL);
+ GFP_KERNEL);
if (!mp->tx_skb) {
printk(KERN_ERR "%s: Cannot allocate Tx skb ring\n", dev->name);
kfree(mp->rx_skb);
@@ -1876,7 +1900,7 @@
if (mp->tx_sram_size) {
mp->p_tx_desc_area = ioremap(mp->tx_sram_addr,
- mp->tx_sram_size);
+ mp->tx_sram_size);
mp->tx_desc_dma = mp->tx_sram_addr;
} else
mp->p_tx_desc_area = dma_alloc_coherent(NULL, size,
@@ -1885,7 +1909,7 @@
if (!mp->p_tx_desc_area) {
printk(KERN_ERR "%s: Cannot allocate Tx Ring (size %d bytes)\n",
- dev->name, size);
+ dev->name, size);
kfree(mp->rx_skb);
kfree(mp->tx_skb);
return -ENOMEM;
@@ -1902,7 +1926,7 @@
if (mp->rx_sram_size) {
mp->p_rx_desc_area = ioremap(mp->rx_sram_addr,
- mp->rx_sram_size);
+ mp->rx_sram_size);
mp->rx_desc_dma = mp->rx_sram_addr;
} else
mp->p_rx_desc_area = dma_alloc_coherent(NULL, size,
@@ -1911,12 +1935,12 @@
if (!mp->p_rx_desc_area) {
printk(KERN_ERR "%s: Cannot allocate Rx ring (size %d bytes)\n",
- dev->name, size);
+ dev->name, size);
if (mp->rx_sram_size)
iounmap(mp->p_rx_desc_area);
else
dma_free_coherent(NULL, mp->tx_desc_area_size,
- mp->p_tx_desc_area, mp->tx_desc_dma);
+ mp->p_tx_desc_area, mp->tx_desc_dma);
kfree(mp->rx_skb);
kfree(mp->tx_skb);
return -ENOMEM;
@@ -1933,11 +1957,11 @@
#ifdef MV643XX_COAL
mp->rx_int_coal =
- mv643xx_eth_port_set_rx_coal(port_num, 133000000, MV643XX_RX_COAL);
+ mv643xx_eth_port_set_rx_coal(port_num, 133000000, MV643XX_RX_COAL);
#endif
mp->tx_int_coal =
- mv643xx_eth_port_set_tx_coal(port_num, 133000000, MV643XX_TX_COAL);
+ mv643xx_eth_port_set_tx_coal(port_num, 133000000, MV643XX_TX_COAL);
netif_start_queue(dev);
@@ -2135,11 +2159,10 @@
spin_lock_irq(&mp->lock);
err = request_irq(dev->irq, mv643xx_eth_int_handler,
- SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
+ SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
if (err) {
- printk(KERN_ERR "%s: Cannot assign IRQ number\n",
- dev->name);
+ printk(KERN_ERR "%s: Cannot assign IRQ number\n", dev->name);
err = -EAGAIN;
goto out;
}
@@ -2212,12 +2235,12 @@
if (netif_running(dev)) {
if (mv643xx_eth_real_stop(dev))
printk(KERN_ERR
- "%s: Fatal error on stopping device\n",
- dev->name);
+ "%s: Fatal error on stopping device\n",
+ dev->name);
if (mv643xx_eth_real_open(dev))
printk(KERN_ERR
- "%s: Fatal error on opening device\n",
- dev->name);
+ "%s: Fatal error on opening device\n",
+ dev->name);
}
spin_unlock_irqrestore(&mp->lock, flags);
@@ -2235,53 +2258,68 @@
};
#define MV643XX_STAT(m) sizeof(((struct mv643xx_private *)0)->m), \
- offsetof(struct mv643xx_private, m)
+ offsetof(struct mv643xx_private, m)
static const struct mv643xx_stats mv643xx_gstrings_stats[] = {
- { "rx_packets", MV643XX_STAT(stats.rx_packets) },
- { "tx_packets", MV643XX_STAT(stats.tx_packets) },
- { "rx_bytes", MV643XX_STAT(stats.rx_bytes) },
- { "tx_bytes", MV643XX_STAT(stats.tx_bytes) },
- { "rx_errors", MV643XX_STAT(stats.rx_errors) },
- { "tx_errors", MV643XX_STAT(stats.tx_errors) },
- { "rx_dropped", MV643XX_STAT(stats.rx_dropped) },
- { "tx_dropped", MV643XX_STAT(stats.tx_dropped) },
- { "good_octets_received", MV643XX_STAT(mib_counters.good_octets_received) },
- { "bad_octets_received", MV643XX_STAT(mib_counters.bad_octets_received) },
- { "internal_mac_transmit_err", MV643XX_STAT(mib_counters.internal_mac_transmit_err) },
- { "good_frames_received", MV643XX_STAT(mib_counters.good_frames_received) },
- { "bad_frames_received", MV643XX_STAT(mib_counters.bad_frames_received) },
- { "broadcast_frames_received", MV643XX_STAT(mib_counters.broadcast_frames_received) },
- { "multicast_frames_received", MV643XX_STAT(mib_counters.multicast_frames_received) },
- { "frames_64_octets", MV643XX_STAT(mib_counters.frames_64_octets) },
- { "frames_65_to_127_octets", MV643XX_STAT(mib_counters.frames_65_to_127_octets) },
- { "frames_128_to_255_octets", MV643XX_STAT(mib_counters.frames_128_to_255_octets) },
- { "frames_256_to_511_octets", MV643XX_STAT(mib_counters.frames_256_to_511_octets) },
- { "frames_512_to_1023_octets", MV643XX_STAT(mib_counters.frames_512_to_1023_octets) },
- { "frames_1024_to_max_octets", MV643XX_STAT(mib_counters.frames_1024_to_max_octets) },
- { "good_octets_sent", MV643XX_STAT(mib_counters.good_octets_sent) },
- { "good_frames_sent", MV643XX_STAT(mib_counters.good_frames_sent) },
- { "excessive_collision", MV643XX_STAT(mib_counters.excessive_collision) },
- { "multicast_frames_sent", MV643XX_STAT(mib_counters.multicast_frames_sent) },
- { "broadcast_frames_sent", MV643XX_STAT(mib_counters.broadcast_frames_sent) },
- { "unrec_mac_control_received", MV643XX_STAT(mib_counters.unrec_mac_control_received) },
- { "fc_sent", MV643XX_STAT(mib_counters.fc_sent) },
- { "good_fc_received", MV643XX_STAT(mib_counters.good_fc_received) },
- { "bad_fc_received", MV643XX_STAT(mib_counters.bad_fc_received) },
- { "undersize_received", MV643XX_STAT(mib_counters.undersize_received) },
- { "fragments_received", MV643XX_STAT(mib_counters.fragments_received) },
- { "oversize_received", MV643XX_STAT(mib_counters.oversize_received) },
- { "jabber_received", MV643XX_STAT(mib_counters.jabber_received) },
- { "mac_receive_error", MV643XX_STAT(mib_counters.mac_receive_error) },
- { "bad_crc_event", MV643XX_STAT(mib_counters.bad_crc_event) },
- { "collision", MV643XX_STAT(mib_counters.collision) },
- { "late_collision", MV643XX_STAT(mib_counters.late_collision) },
+ {"rx_packets", MV643XX_STAT(stats.rx_packets)},
+ {"tx_packets", MV643XX_STAT(stats.tx_packets)},
+ {"rx_bytes", MV643XX_STAT(stats.rx_bytes)},
+ {"tx_bytes", MV643XX_STAT(stats.tx_bytes)},
+ {"rx_errors", MV643XX_STAT(stats.rx_errors)},
+ {"tx_errors", MV643XX_STAT(stats.tx_errors)},
+ {"rx_dropped", MV643XX_STAT(stats.rx_dropped)},
+ {"tx_dropped", MV643XX_STAT(stats.tx_dropped)},
+ {"good_octets_received",
+ MV643XX_STAT(mib_counters.good_octets_received)},
+ {"bad_octets_received",
+ MV643XX_STAT(mib_counters.bad_octets_received)},
+ {"internal_mac_transmit_err",
+ MV643XX_STAT(mib_counters.internal_mac_transmit_err)},
+ {"good_frames_received",
+ MV643XX_STAT(mib_counters.good_frames_received)},
+ {"bad_frames_received", MV643XX_STAT(mib_counters.bad_frames_received)},
+ {"broadcast_frames_received",
+ MV643XX_STAT(mib_counters.broadcast_frames_received)},
+ {"multicast_frames_received",
+ MV643XX_STAT(mib_counters.multicast_frames_received)},
+ {"frames_64_octets", MV643XX_STAT(mib_counters.frames_64_octets)},
+ {"frames_65_to_127_octets",
+ MV643XX_STAT(mib_counters.frames_65_to_127_octets)},
+ {"frames_128_to_255_octets",
+ MV643XX_STAT(mib_counters.frames_128_to_255_octets)},
+ {"frames_256_to_511_octets",
+ MV643XX_STAT(mib_counters.frames_256_to_511_octets)},
+ {"frames_512_to_1023_octets",
+ MV643XX_STAT(mib_counters.frames_512_to_1023_octets)},
+ {"frames_1024_to_max_octets",
+ MV643XX_STAT(mib_counters.frames_1024_to_max_octets)},
+ {"good_octets_sent", MV643XX_STAT(mib_counters.good_octets_sent)},
+ {"good_frames_sent", MV643XX_STAT(mib_counters.good_frames_sent)},
+ {"excessive_collision", MV643XX_STAT(mib_counters.excessive_collision)},
+ {"multicast_frames_sent",
+ MV643XX_STAT(mib_counters.multicast_frames_sent)},
+ {"broadcast_frames_sent",
+ MV643XX_STAT(mib_counters.broadcast_frames_sent)},
+ {"unrec_mac_control_received",
+ MV643XX_STAT(mib_counters.unrec_mac_control_received)},
+ {"fc_sent", MV643XX_STAT(mib_counters.fc_sent)},
+ {"good_fc_received", MV643XX_STAT(mib_counters.good_fc_received)},
+ {"bad_fc_received", MV643XX_STAT(mib_counters.bad_fc_received)},
+ {"undersize_received", MV643XX_STAT(mib_counters.undersize_received)},
+ {"fragments_received", MV643XX_STAT(mib_counters.fragments_received)},
+ {"oversize_received", MV643XX_STAT(mib_counters.oversize_received)},
+ {"jabber_received", MV643XX_STAT(mib_counters.jabber_received)},
+ {"mac_receive_error", MV643XX_STAT(mib_counters.mac_receive_error)},
+ {"bad_crc_event", MV643XX_STAT(mib_counters.bad_crc_event)},
+ {"collision", MV643XX_STAT(mib_counters.collision)},
+ {"late_collision", MV643XX_STAT(mib_counters.late_collision)},
};
#define MV643XX_STATS_LEN \
sizeof(mv643xx_gstrings_stats) / sizeof(struct mv643xx_stats)
-static int mv643xx_eth_mdio_read(struct net_device *dev, int phy_id, int location)
+static int mv643xx_eth_mdio_read(struct net_device *dev, int phy_id,
+ int location)
{
int val;
@@ -2289,13 +2327,14 @@
return val;
}
-static void mv643xx_eth_mdio_write(struct net_device *dev, int phy_id, int location, int val)
+static void mv643xx_eth_mdio_write(struct net_device *dev, int phy_id,
+ int location, int val)
{
mv643xx_eth_write_smi_reg(dev, location, val);
}
-static int
-mv643xx_eth_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
+static int mv643xx_eth_get_settings(struct net_device *netdev,
+ struct ethtool_cmd *ecmd)
{
int rc;
struct mv643xx_private *mp = netdev_priv(netdev);
@@ -2310,19 +2349,17 @@
return rc;
}
-static void
-mv643xx_eth_get_drvinfo(struct net_device *netdev,
- struct ethtool_drvinfo *drvinfo)
+static void mv643xx_eth_get_drvinfo(struct net_device *netdev,
+ struct ethtool_drvinfo *drvinfo)
{
- strncpy(drvinfo->driver, mv643xx_driver_name, 32);
+ strncpy(drvinfo->driver, mv643xx_driver_name, 32);
strncpy(drvinfo->version, mv643xx_driver_version, 32);
strncpy(drvinfo->fw_version, "N/A", 32);
strncpy(drvinfo->bus_info, "mv643xx", 32);
drvinfo->n_stats = MV643XX_STATS_LEN;
}
-static int
-mv643xx_eth_get_stats_count(struct net_device *netdev)
+static int mv643xx_eth_get_stats_count(struct net_device *netdev)
{
return MV643XX_STATS_LEN;
}
@@ -2335,25 +2372,24 @@
mv643xx_eth_update_mib_counters(dev);
- for(i = 0; i < MV643XX_STATS_LEN; i++) {
- char *p = (char *)mp+mv643xx_gstrings_stats[i].stat_offset;
- data[i] = (mv643xx_gstrings_stats[i].sizeof_stat ==
- sizeof(uint64_t)) ? *(uint64_t *)p : *(uint32_t *)p;
+ for (i = 0; i < MV643XX_STATS_LEN; i++) {
+ char *p = (char *)mp + mv643xx_gstrings_stats[i].stat_offset;
+ data[i] = (mv643xx_gstrings_stats[i].sizeof_stat ==
+ sizeof(uint64_t)) ? *(uint64_t *) p : *(uint32_t *) p;
}
}
-static void
-mv643xx_eth_get_strings(struct net_device *netdev, uint32_t stringset, uint8_t *data)
+static void mv643xx_eth_get_strings(struct net_device *netdev,
+ uint32_t stringset, uint8_t *data)
{
int i;
- switch(stringset) {
+ switch (stringset) {
case ETH_SS_STATS:
- for (i=0; i < MV643XX_STATS_LEN; i++) {
- memcpy(data + i * ETH_GSTRING_LEN,
- mv643xx_gstrings_stats[i].stat_string,
- ETH_GSTRING_LEN);
- }
+ for (i = 0; i < MV643XX_STATS_LEN; i++)
+ memcpy(data + i * ETH_GSTRING_LEN,
+ mv643xx_gstrings_stats[i].stat_string,
+ ETH_GSTRING_LEN);
break;
}
}
@@ -2383,7 +2419,8 @@
return mii_nway_restart(&mp->mii);
}
-static int mv643xx_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+static int mv643xx_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr,
+ int cmd)
{
struct mv643xx_private *mp = netdev_priv(dev);
@@ -2391,18 +2428,18 @@
}
static struct ethtool_ops mv643xx_ethtool_ops = {
- .get_settings = mv643xx_eth_get_settings,
- .set_settings = mv643xx_eth_set_settings,
- .get_drvinfo = mv643xx_eth_get_drvinfo,
- .get_link = mv643xx_eth_get_link,
- .get_sg = ethtool_op_get_sg,
- .set_sg = ethtool_op_set_sg,
- .get_strings = mv643xx_eth_get_strings,
- .get_stats_count = mv643xx_eth_get_stats_count,
- .get_ethtool_stats = mv643xx_eth_get_ethtool_stats,
- .get_msglevel = mv643xx_eth_get_msglevel,
- .set_msglevel = mv643xx_eth_set_msglevel,
- .nway_reset = mv643xx_eth_nway_restart,
+ .get_settings = mv643xx_eth_get_settings,
+ .set_settings = mv643xx_eth_set_settings,
+ .get_drvinfo = mv643xx_eth_get_drvinfo,
+ .get_link = mv643xx_eth_get_link,
+ .get_sg = ethtool_op_get_sg,
+ .set_sg = ethtool_op_set_sg,
+ .get_strings = mv643xx_eth_get_strings,
+ .get_stats_count = mv643xx_eth_get_stats_count,
+ .get_ethtool_stats = mv643xx_eth_get_ethtool_stats,
+ .get_msglevel = mv643xx_eth_get_msglevel,
+ .set_msglevel = mv643xx_eth_set_msglevel,
+ .nway_reset = mv643xx_eth_nway_restart,
};
/*
@@ -2436,7 +2473,7 @@
/* By default, log probe, interface up/down and error events */
mp->msg_enable = NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN |
- NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR;
+ NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR;
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
BUG_ON(!res);
@@ -2479,7 +2516,7 @@
/* Configure the timeout task */
INIT_WORK(&mp->tx_timeout_task,
- (void (*)(void *))mv643xx_eth_tx_timeout_task, dev);
+ (void (*)(void *))mv643xx_eth_tx_timeout_task, dev);
spin_lock_init(&mp->lock);
@@ -2562,17 +2599,17 @@
if (dev->features & NETIF_F_SG)
if (netif_msg_probe(mp))
- printk(KERN_NOTICE "%s: Scatter Gather Enabled\n",
+ printk(KERN_NOTICE "%s: Scatter Gather Enabled\n",
dev->name);
if (dev->features & NETIF_F_IP_CSUM)
if (netif_msg_probe(mp))
- printk(KERN_NOTICE "%s: TX TCP/IP Checksumming Supported\n",
- dev->name);
+ printk(KERN_NOTICE "%s: TX TCP/IP Checksumming "
+ "Supported\n", dev->name);
#ifdef MV643XX_CHECKSUM_OFFLOAD_TX
if (netif_msg_probe(mp))
- printk(KERN_NOTICE "%s: RX TCP/UDP Checksum Offload ON\n",
+ printk(KERN_NOTICE "%s: RX TCP/UDP Checksum Offload ON\n",
dev->name);
#endif
@@ -2619,7 +2656,7 @@
return -ENODEV;
mv643xx_eth_shared_base = ioremap(res->start,
- MV643XX_ETH_SHARED_REGS_SIZE);
+ MV643XX_ETH_SHARED_REGS_SIZE);
if (mv643xx_eth_shared_base == NULL)
return -ENOMEM;
@@ -2672,6 +2709,6 @@
module_exit(mv643xx_eth_cleanup_module);
MODULE_LICENSE("GPL");
-MODULE_AUTHOR( "Rabeeh Khoury, Assaf Hoffman, Matthew Dharm, Manish Lachwani"
- " and Dale Farnsworth");
+MODULE_AUTHOR("Rabeeh Khoury, Assaf Hoffman, Matthew Dharm, Manish Lachwani"
+ " and Dale Farnsworth");
MODULE_DESCRIPTION("Ethernet driver for Marvell MV643XX");
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(15/20): Add James Chapman to copyright statement and author list
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (13 preceding siblings ...)
2005-03-28 23:56 ` mv643xx(14/20): whitespace and indentation cleanup Dale Farnsworth
@ 2005-03-28 23:57 ` Dale Farnsworth
2005-03-28 23:57 ` mv643xx(16/20): Limit MTU to 1500 bytes unless connected at GigE speed Dale Farnsworth
` (4 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:57 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -10,11 +10,14 @@
*
* Copyright (C) 2003 Ralf Baechle <ralf@linux-mips.org>
*
+ * Copyright (C) 2004 Steven J. Hill <sjhill1@rockwellcollins.com>
+ * <sjhill@realitydiluted.com>
+ *
* Copyright (C) 2004-2005 MontaVista Software, Inc.
* Dale Farnsworth <dale@farnsworth.org>
*
- * Copyright (C) 2004 Steven J. Hill <sjhill1@rockwellcollins.com>
- * <sjhill@realitydiluted.com>
+ * Copyright (C) 2005 Katalix Systems Ltd
+ * James Chapman <jchapman@katalix.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -2710,5 +2713,5 @@
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Rabeeh Khoury, Assaf Hoffman, Matthew Dharm, Manish Lachwani"
- " and Dale Farnsworth");
+ ", Dale Farnsworth and James Chapman");
MODULE_DESCRIPTION("Ethernet driver for Marvell MV643XX");
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(16/20): Limit MTU to 1500 bytes unless connected at GigE speed
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (14 preceding siblings ...)
2005-03-28 23:57 ` mv643xx(15/20): Add James Chapman to copyright statement and author list Dale Farnsworth
@ 2005-03-28 23:57 ` Dale Farnsworth
2005-03-30 20:09 ` Jeff Garzik
2005-03-28 23:58 ` mv643xx(17/20): Reset the PHY only at driver open time Dale Farnsworth
` (3 subsequent siblings)
19 siblings, 1 reply; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:57 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -371,6 +371,7 @@
struct mv643xx_private *mp = netdev_priv(dev);
unsigned int port_num = mp->port_num;
int tx_curr_desc, rx_curr_desc;
+ int rx_buffer_size_index;
/* Assignment of Tx CTRP of given queue */
tx_curr_desc = mp->tx_curr_desc_q;
@@ -398,14 +399,16 @@
mv643xx_eth_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), 0);
- /* Increase the Rx side buffer size if supporting GigE */
- if (mp->port_serial_control & MV643XX_ETH_SET_GMII_SPEED_TO_1000)
- mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
- (mp->port_serial_control & 0xfff1ffff) |
- (0x5 << 17));
+ /* Adjust Rx side buffer size based on mtu */
+ if (dev->mtu <= 1500)
+ rx_buffer_size_index = 1;
else
- mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
- mp->port_serial_control);
+ rx_buffer_size_index = 5;
+ mp->port_serial_control &= 0xfff1ffff;
+ mp->port_serial_control |= rx_buffer_size_index << 17;
+
+ mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
+ mp->port_serial_control);
mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
mp->port_serial_control |
@@ -1289,13 +1292,13 @@
printk(KERN_INFO "%s: TX timeout ", dev->name);
/* Do the reset outside of interrupt context */
- schedule_work(&mp->tx_timeout_task);
+ schedule_work(&mp->reset_task);
}
/*
* Actual routine to reset the adapter when a timeout on Tx has occurred
*/
-static void mv643xx_eth_tx_timeout_task(struct net_device *dev)
+static void mv643xx_eth_reset_task(struct net_device *dev)
{
netif_device_detach(dev);
mv643xx_eth_port_reset(dev);
@@ -1536,6 +1539,15 @@
netif_wake_queue(dev);
/* Start TX queue */
mv643xx_eth_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num), 1);
+ /* Chip only supports jumbo frames at 1Gb/S */
+ if (cmd.speed != SPEED_1000 && dev->mtu > 1500) {
+ dev->mtu = 1500;
+ mp->port_serial_control &= 0xfff1ffff;
+ mp->port_serial_control |= 1 << 17;
+
+ /* Do the reset outside of interrupt context */
+ schedule_work(&mp->reset_task);
+ }
} else if (!mii_link_ok(&mp->mii) && netif_carrier_ok(dev)) {
netif_stop_queue(dev);
@@ -2220,10 +2232,22 @@
{
struct mv643xx_private *mp = netdev_priv(dev);
unsigned long flags;
+ int max_mtu;
+ u32 port_status;
spin_lock_irqsave(&mp->lock, flags);
- if ((new_mtu > 9500) || (new_mtu < 64)) {
+ /* Jumbo frames are not supported when connected at less than 1Gb/S */
+ port_status =
+ mv643xx_eth_read(MV643XX_ETH_PORT_STATUS_REG(mp->port_num));
+ if ((port_status & (MV643XX_ETH_PORT_STATUS_LINK_UP |
+ MV643XX_ETH_PORT_STATUS_GMII_1000)) ==
+ (MV643XX_ETH_PORT_STATUS_LINK_UP))
+ max_mtu = 1500;
+ else
+ max_mtu = 9500;
+
+ if ((new_mtu > max_mtu) || (new_mtu < 64)) {
spin_unlock_irqrestore(&mp->lock, flags);
return -EINVAL;
}
@@ -2517,9 +2541,9 @@
#endif
#endif
- /* Configure the timeout task */
- INIT_WORK(&mp->tx_timeout_task,
- (void (*)(void *))mv643xx_eth_tx_timeout_task, dev);
+ /* Configure the reset task */
+ INIT_WORK(&mp->reset_task,
+ (void (*)(void *))mv643xx_eth_reset_task, dev);
spin_lock_init(&mp->lock);
Index: linux-2.5-enet/drivers/net/mv643xx_eth.h
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.h
+++ linux-2.5-enet/drivers/net/mv643xx_eth.h
@@ -512,7 +512,7 @@
unsigned int tx_desc_area_size;
struct sk_buff **tx_skb;
- struct work_struct tx_timeout_task;
+ struct work_struct reset_task;
/*
* Former struct mv643xx_eth_priv members start here
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(17/20): Reset the PHY only at driver open time
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (15 preceding siblings ...)
2005-03-28 23:57 ` mv643xx(16/20): Limit MTU to 1500 bytes unless connected at GigE speed Dale Farnsworth
@ 2005-03-28 23:58 ` Dale Farnsworth
2005-03-28 23:59 ` mv643xx(18/20): Isolate the PHY at device close Dale Farnsworth
` (2 subsequent siblings)
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:58 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -587,10 +587,8 @@
{
unsigned int phy_reg_data;
- /* Reset the PHY */
- mv643xx_eth_read_smi_reg(dev, 0, &phy_reg_data);
- phy_reg_data |= 0x8000; /* Set bit 15 to reset the PHY */
- mv643xx_eth_write_smi_reg(dev, 0, phy_reg_data);
+ mv643xx_eth_read_smi_reg(dev, MII_BMCR, &phy_reg_data);
+ mv643xx_eth_write_smi_reg(dev, MII_BMCR, phy_reg_data | BMCR_RESET);
}
/*
@@ -618,8 +616,6 @@
mv643xx_eth_port_reset(dev);
mv643xx_eth_port_init_mac_tables(dev);
-
- mv643xx_eth_phy_reset(dev);
}
static inline u32 mv643xx_eth_read_mib_counter(struct net_device *dev,
@@ -2173,6 +2169,8 @@
spin_lock_irq(&mp->lock);
+ mv643xx_eth_phy_reset(dev);
+
err = request_irq(dev->irq, mv643xx_eth_int_handler,
SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(18/20): Isolate the PHY at device close
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (16 preceding siblings ...)
2005-03-28 23:58 ` mv643xx(17/20): Reset the PHY only at driver open time Dale Farnsworth
@ 2005-03-28 23:59 ` Dale Farnsworth
2005-03-29 0:00 ` mv643xx(19/20): Ensure NAPI poll routine only clears IRQs it handles Dale Farnsworth
2005-03-29 0:01 ` mv643xx(20/20): Fix promiscuous mode handling Dale Farnsworth
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-28 23:59 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Signed-off-by: James Chapman <jchapman@katalix.com>
Acked-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -591,6 +591,12 @@
mv643xx_eth_write_smi_reg(dev, MII_BMCR, phy_reg_data | BMCR_RESET);
}
+static void mv643xx_eth_phy_isolate(struct net_device *dev)
+{
+ /* Isolate the PHY (force link down) */
+ mv643xx_eth_write_smi_reg(dev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE);
+}
+
/*
* This function prepares the ethernet port to start its activity:
* 1) Completes the ethernet port driver struct initialization toward port
@@ -2210,6 +2216,9 @@
mv643xx_eth_real_stop(dev);
+ /* Isolate the PHY from the network (force link down) */
+ mv643xx_eth_phy_isolate(dev);
+
free_irq(dev->irq, dev);
spin_unlock_irq(&mp->lock);
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(19/20): Ensure NAPI poll routine only clears IRQs it handles
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (17 preceding siblings ...)
2005-03-28 23:59 ` mv643xx(18/20): Isolate the PHY at device close Dale Farnsworth
@ 2005-03-29 0:00 ` Dale Farnsworth
2005-03-29 0:01 ` mv643xx(20/20): Fix promiscuous mode handling Dale Farnsworth
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-29 0:00 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -1635,9 +1635,9 @@
if (done) {
spin_lock_irqsave(&mp->lock, flags);
+ mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num),
+ ~0x0007fffd);
__netif_rx_complete(dev);
- mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
- mv643xx_eth_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
mv643xx_eth_write(MV643XX_ETH_INTERRUPT_MASK_REG(port_num),
INT_CAUSE_UNMASK_ALL);
mv643xx_eth_write(MV643XX_ETH_INTERRUPT_EXTEND_MASK_REG(port_num),
^ permalink raw reply [flat|nested] 25+ messages in thread
* mv643xx(20/20): Fix promiscuous mode handling
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
` (18 preceding siblings ...)
2005-03-29 0:00 ` mv643xx(19/20): Ensure NAPI poll routine only clears IRQs it handles Dale Farnsworth
@ 2005-03-29 0:01 ` Dale Farnsworth
19 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-29 0:01 UTC (permalink / raw)
To: Netdev, Jeff Garzik
Cc: Ralf Baechle, Manish Lachwani, Brian Waite, Steven J. Hill,
Benjamin Herrenschmidt, James Chapman
mv643xx_eth_get_config_reg() was reading the wrong register.
mv643xx_eth_set_config_reg() was or'ing instead of setting the
register. These functions are trivial and both are called only from
mv643xx_eth_set_rx_mode() when changing the promiscuous mode. Remove both
functions and do the operations directly in mv643xx_eth_set_rx_mode().
Also, maintain promiscuous mode setting across port resets.
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.h
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.h
+++ linux-2.5-enet/drivers/net/mv643xx_eth.h
@@ -474,6 +474,7 @@
int port_num; /* User Ethernet port number */
u8 port_mac_addr[6]; /* User defined port MAC address.*/
u32 port_serial_control; /* Port serial control value */
+ u32 port_config; /* Port config register value */
struct ethtool_cmd ethtool_cmd; /* ethtool_cmd used at open */
u32 port_tx_queue_command; /* Port active Tx queues summary*/
u32 port_rx_queue_command; /* Port active Rx queues summary*/
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -390,7 +390,7 @@
/* Assign port configuration and command. */
mv643xx_eth_write(MV643XX_ETH_PORT_CONFIG_REG(port_num),
- MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE);
+ mp->port_config);
mv643xx_eth_write(MV643XX_ETH_PORT_CONFIG_EXTEND_REG(port_num),
MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE);
@@ -683,38 +683,6 @@
return 0;
}
-/*
- * This function sets specified bits in the given ethernet
- * configuration register.
- */
-static void mv643xx_eth_set_config_reg(struct net_device *dev,
- unsigned int value)
-{
- struct mv643xx_private *mp = netdev_priv(dev);
- unsigned int eth_port_num = mp->port_num;
- unsigned int eth_config_reg;
-
- eth_config_reg =
- mv643xx_eth_read(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num));
- eth_config_reg |= value;
- mv643xx_eth_write(MV643XX_ETH_PORT_CONFIG_REG(eth_port_num),
- eth_config_reg);
-}
-
-/*
- * This function returns the configuration register value of the given
- * ethernet port.
- */
-static unsigned int mv643xx_eth_get_config_reg(struct net_device *dev)
-{
- struct mv643xx_private *mp = netdev_priv(dev);
- unsigned int eth_config_reg;
-
- eth_config_reg =
- mv643xx_eth_read(MV643XX_ETH_PORT_CONFIG_EXTEND_REG(mp->port_num));
- return eth_config_reg;
-}
-
/*****************************************************************************
* Device init and shutdown
*****************************************************************************/
@@ -2027,14 +1995,14 @@
static void mv643xx_eth_set_rx_mode(struct net_device *dev)
{
- u32 config_reg;
+ struct mv643xx_private *mp = netdev_priv(dev);
- config_reg = mv643xx_eth_get_config_reg(dev);
if (dev->flags & IFF_PROMISC)
- config_reg |= (u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
+ mp->port_config |= MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
else
- config_reg &= ~(u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
- mv643xx_eth_set_config_reg(dev, config_reg);
+ mp->port_config &= ~MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
+ mv643xx_eth_write(MV643XX_ETH_PORT_CONFIG_REG(mp->port_num),
+ mp->port_config);
}
/*
@@ -2562,6 +2530,7 @@
mp->port_serial_control |= MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL |
MV643XX_ETH_SERIAL_PORT_CONTROL_RESERVED |
MV643XX_ETH_DO_NOT_FORCE_LINK_FAIL;
+ mp->port_config = MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE;
mp->rx_ring_size = MV643XX_ETH_PORT_DEFAULT_RECEIVE_QUEUE_SIZE;
mp->tx_ring_size = MV643XX_ETH_PORT_DEFAULT_TRANSMIT_QUEUE_SIZE;
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: mv643xx(16/20): Limit MTU to 1500 bytes unless connected at GigE speed
2005-03-28 23:57 ` mv643xx(16/20): Limit MTU to 1500 bytes unless connected at GigE speed Dale Farnsworth
@ 2005-03-30 20:09 ` Jeff Garzik
2005-03-30 21:46 ` Dale Farnsworth
0 siblings, 1 reply; 25+ messages in thread
From: Jeff Garzik @ 2005-03-30 20:09 UTC (permalink / raw)
To: Dale Farnsworth
Cc: Netdev, Ralf Baechle, Manish Lachwani, Brian Waite,
Steven J. Hill, Benjamin Herrenschmidt, James Chapman
Explanation?
I see no inherent reason to disallow jumbo frames at slower speeds.
Jeff
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: mv643xx(16/20): Limit MTU to 1500 bytes unless connected at GigE speed
2005-03-30 20:09 ` Jeff Garzik
@ 2005-03-30 21:46 ` Dale Farnsworth
0 siblings, 0 replies; 25+ messages in thread
From: Dale Farnsworth @ 2005-03-30 21:46 UTC (permalink / raw)
To: Jeff Garzik, Netdev
On Wed, Mar 30, 2005 at 08:09:18PM +0000, Jeff Garzik wrote:
> Explanation?
>
> I see no inherent reason to disallow jumbo frames at slower speeds.
Neither do I, but Marvell chips aren't always reasonable.
I guess my comments in the code:
/* Chip only supports jumbo frames at 1Gb/S */
and
/* Jumbo frames are not supported when connected at less than 1Gb/S */
may have been a bit too terse. :)
I expanded on the comments and rebuilt the repository. The new version
of this patch is included below. (No code has changed, only comments.)
I have found no other mention of this limitation in the Marvell
documentation other than what is found below.
Thanks,
-Dale
mv643xx: Limit MTU to 1500 bytes unless connected at GigE speed
It's weird, but the user manual says that jumbo frames are not
supported at less than 1Gb/S. From the description of the MRU
field of the PSCR:
The Maximal Receive Packet Size:
0 = Accept packets up to 1518 bytes in length
1 = Accept packets up to 1522 bytes in length
2 = Accept packets up to 1558 bytes in length
3 = Accept packets up to 9022 bytes in length
4 = Accept packets up to 9192 bytes in length
5 = Accept packets up to 9700 bytes in length
6-7 = Reserved
Note: Modes 3-5 are supported only when operating in 1000 Mbps.
Receiving 9700 byte frames is supported only during 1000
Mbps operation. Receiving frames over 2KB during 100 Mbps
operation may result in overrun/underrun in some cases.
In this patch, we only permit jumbo frames when connecting/connected
at 1Gb/S.
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
+++ linux-2.5-enet/drivers/net/mv643xx_eth.c
@@ -371,6 +371,7 @@
struct mv643xx_private *mp = netdev_priv(dev);
unsigned int port_num = mp->port_num;
int tx_curr_desc, rx_curr_desc;
+ int rx_buffer_size_index;
/* Assignment of Tx CTRP of given queue */
tx_curr_desc = mp->tx_curr_desc_q;
@@ -398,14 +399,16 @@
mv643xx_eth_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), 0);
- /* Increase the Rx side buffer size if supporting GigE */
- if (mp->port_serial_control & MV643XX_ETH_SET_GMII_SPEED_TO_1000)
- mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
- (mp->port_serial_control & 0xfff1ffff) |
- (0x5 << 17));
+ /* Adjust Rx side buffer size based on mtu */
+ if (dev->mtu <= 1500)
+ rx_buffer_size_index = 1;
else
- mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
- mp->port_serial_control);
+ rx_buffer_size_index = 5;
+ mp->port_serial_control &= 0xfff1ffff;
+ mp->port_serial_control |= rx_buffer_size_index << 17;
+
+ mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
+ mp->port_serial_control);
mv643xx_eth_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num),
mp->port_serial_control |
@@ -1289,13 +1292,13 @@
printk(KERN_INFO "%s: TX timeout ", dev->name);
/* Do the reset outside of interrupt context */
- schedule_work(&mp->tx_timeout_task);
+ schedule_work(&mp->reset_task);
}
/*
* Actual routine to reset the adapter when a timeout on Tx has occurred
*/
-static void mv643xx_eth_tx_timeout_task(struct net_device *dev)
+static void mv643xx_eth_reset_task(struct net_device *dev)
{
netif_device_detach(dev);
mv643xx_eth_port_reset(dev);
@@ -1536,6 +1539,19 @@
netif_wake_queue(dev);
/* Start TX queue */
mv643xx_eth_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num), 1);
+ /*
+ * The mv643xx user manuals (in the PSCR MRU field
+ * description) say that jumbo frames are not reliable
+ * at 10Mb/S or 100Mb/S, so we disallow them.
+ */
+ if (cmd.speed != SPEED_1000 && dev->mtu > 1500) {
+ dev->mtu = 1500;
+ mp->port_serial_control &= 0xfff1ffff;
+ mp->port_serial_control |= 1 << 17;
+
+ /* Do the reset outside of interrupt context */
+ schedule_work(&mp->reset_task);
+ }
} else if (!mii_link_ok(&mp->mii) && netif_carrier_ok(dev)) {
netif_stop_queue(dev);
@@ -2220,10 +2236,26 @@
{
struct mv643xx_private *mp = netdev_priv(dev);
unsigned long flags;
+ int max_mtu;
+ u32 port_status;
spin_lock_irqsave(&mp->lock, flags);
- if ((new_mtu > 9500) || (new_mtu < 64)) {
+ /*
+ * The mv643xx user manuals (in the PSCR MRU field
+ * description) say that jumbo frames are not reliable
+ * at 10Mb/S or 100Mb/S, so we disallow them.
+ */
+ port_status =
+ mv643xx_eth_read(MV643XX_ETH_PORT_STATUS_REG(mp->port_num));
+ if ((port_status & (MV643XX_ETH_PORT_STATUS_LINK_UP |
+ MV643XX_ETH_PORT_STATUS_GMII_1000)) ==
+ (MV643XX_ETH_PORT_STATUS_LINK_UP))
+ max_mtu = 1500;
+ else
+ max_mtu = 9500;
+
+ if ((new_mtu > max_mtu) || (new_mtu < 64)) {
spin_unlock_irqrestore(&mp->lock, flags);
return -EINVAL;
}
@@ -2517,9 +2549,9 @@
#endif
#endif
- /* Configure the timeout task */
- INIT_WORK(&mp->tx_timeout_task,
- (void (*)(void *))mv643xx_eth_tx_timeout_task, dev);
+ /* Configure the reset task */
+ INIT_WORK(&mp->reset_task,
+ (void (*)(void *))mv643xx_eth_reset_task, dev);
spin_lock_init(&mp->lock);
Index: linux-2.5-enet/drivers/net/mv643xx_eth.h
===================================================================
--- linux-2.5-enet.orig/drivers/net/mv643xx_eth.h
+++ linux-2.5-enet/drivers/net/mv643xx_eth.h
@@ -512,7 +512,7 @@
unsigned int tx_desc_area_size;
struct sk_buff **tx_skb;
- struct work_struct tx_timeout_task;
+ struct work_struct reset_task;
/*
* Former struct mv643xx_eth_priv members start here
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: mv643xx(2/20): use MII library for PHY management
2005-08-24 0:34 ` Mark Huth
@ 2005-08-24 0:33 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 25+ messages in thread
From: Benjamin Herrenschmidt @ 2005-08-24 0:33 UTC (permalink / raw)
To: Mark Huth
Cc: Dale Farnsworth, Netdev, Jeff Garzik, Ralf Baechle,
Manish Lachwani, Brian Waite, Steven J. Hill, James Chapman
On Tue, 2005-08-23 at 17:34 -0700, Mark Huth wrote:
> It's good to use the abstractions and common code, but in this case
> there is a significant performance difference. The MDIO read/write on
> this family does a cpu spin wait for the mdio operation to complete.
> Last time I measured this (back when fixing up a 2.4.20 implementation)
> I got around 100 us for the mii_ioctl path, of which a good bit was in
> the spin loop waiting for the MDIO operation to complete. A quick look
> seems to indicate the spin loop is still in this version of the driver.
>
> Given that the NIC chip gives cheap access to the link status and a
> couple of other interesting bits, the change to use the mii library has
> a performance impact.
Is it possible to implement the mdio functions without a spin loop ?
Also, it might be a good idea to use the PHY driver model (a-la sungem)
rather than miilib...
Ben.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: mv643xx(2/20): use MII library for PHY management
2005-03-28 23:42 ` mv643xx(2/20): use MII library for PHY management Dale Farnsworth
@ 2005-08-24 0:34 ` Mark Huth
2005-08-24 0:33 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 25+ messages in thread
From: Mark Huth @ 2005-08-24 0:34 UTC (permalink / raw)
To: Dale Farnsworth
Cc: Netdev, Jeff Garzik, Ralf Baechle, Manish Lachwani, Brian Waite,
Steven J. Hill, Benjamin Herrenschmidt, James Chapman
It's good to use the abstractions and common code, but in this case
there is a significant performance difference. The MDIO read/write on
this family does a cpu spin wait for the mdio operation to complete.
Last time I measured this (back when fixing up a 2.4.20 implementation)
I got around 100 us for the mii_ioctl path, of which a good bit was in
the spin loop waiting for the MDIO operation to complete. A quick look
seems to indicate the spin loop is still in this version of the driver.
Given that the NIC chip gives cheap access to the link status and a
couple of other interesting bits, the change to use the mii library has
a performance impact.
Mark Huth
Dale Farnsworth wrote:
> Modify link up/down handling to use the functions from the MII
> library. Note that I track link state using the MII PHY registers
> rather than the mv643xx chip's link state registers because I think
> it's cleaner to use the MII library code rather than writing local
> driver support code. It is also useful to make the actual MII
> registers available to the user with maskable kernel printk messages
> so the MII registers are being read anyway
>
> Signed-off-by: James Chapman <jchapman@katalix.com>
> Acked-by: Dale Farnsworth <dale@farnsworth.org>
>
> Index: linux-2.5-enet/drivers/net/mv643xx_eth.h
> ===================================================================
> --- linux-2.5-enet.orig/drivers/net/mv643xx_eth.h
> +++ linux-2.5-enet/drivers/net/mv643xx_eth.h
> @@ -6,6 +6,7 @@
> #include <linux/kernel.h>
> #include <linux/spinlock.h>
> #include <linux/workqueue.h>
> +#include <linux/mii.h>
>
> #include <linux/mv643xx.h>
>
> @@ -397,6 +398,9 @@
>
> u32 rx_int_coal;
> u32 tx_int_coal;
> +
> + u32 msg_enable;
> + struct mii_if_info mii;
> };
>
> /* ethernet.h API list */
> Index: linux-2.5-enet/drivers/net/mv643xx_eth.c
> ===================================================================
> --- linux-2.5-enet.orig/drivers/net/mv643xx_eth.c
> +++ linux-2.5-enet/drivers/net/mv643xx_eth.c
> @@ -74,7 +74,6 @@
> #define PHY_WAIT_MICRO_SECONDS 10
>
> /* Static function declarations */
> -static int eth_port_link_is_up(unsigned int eth_port_num);
> static void eth_port_uc_addr_get(struct net_device *dev,
> unsigned char *MacAddr);
> static int mv643xx_eth_real_open(struct net_device *);
> @@ -85,8 +84,11 @@
> #ifdef MV643XX_NAPI
> static int mv643xx_poll(struct net_device *dev, int *budget);
> #endif
> +static int ethernet_phy_get(unsigned int eth_port_num);
> static void ethernet_phy_set(unsigned int eth_port_num, int phy_addr);
> static int ethernet_phy_detect(unsigned int eth_port_num);
> +static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location);
> +static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val);
> static struct ethtool_ops mv643xx_ethtool_ops;
>
> static char mv643xx_driver_name[] = "mv643xx_eth";
> @@ -550,16 +552,38 @@
> }
> /* PHY status changed */
> if (eth_int_cause_ext & (BIT16 | BIT20)) {
> - if (eth_port_link_is_up(port_num)) {
> - netif_carrier_on(dev);
> + struct ethtool_cmd cmd;
> +
> + /* mii library handles link maintenance tasks */
> +
> + mii_ethtool_gset(&mp->mii, &cmd);
> + if (netif_msg_link(mp))
> + printk(KERN_DEBUG "%s: link phy regs: "
> + "supported=%x advert=%x "
> + "autoneg=%x speed=%d duplex=%d\n",
> + dev->name,
> + cmd.supported, cmd.advertising,
> + cmd.autoneg, cmd.speed, cmd.duplex);
> +
> + if(mii_link_ok(&mp->mii) && !netif_carrier_ok(dev)) {
> + if (netif_msg_ifup(mp))
> + printk(KERN_INFO "%s: link up, %sMbps, %s-duplex\n",
> + dev->name,
> + cmd.speed == SPEED_1000 ? "1000" :
> + cmd.speed == SPEED_100 ? "100" : "10",
> + cmd.duplex == DUPLEX_FULL ? "full" : "half");
> +
> netif_wake_queue(dev);
> /* Start TX queue */
> - mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG
> - (port_num), 1);
> - } else {
> - netif_carrier_off(dev);
> + mv_write(MV643XX_ETH_TRANSMIT_QUEUE_COMMAND_REG(port_num), 1);
> +
> + } else if(!mii_link_ok(&mp->mii) && netif_carrier_ok(dev)) {
> netif_stop_queue(dev);
> + if (netif_msg_ifdown(mp))
> + printk(KERN_INFO "%s: link down\n", dev->name);
> }
> +
> + mii_check_link(&mp->mii);
> }
>
> /*
> @@ -1379,6 +1403,10 @@
>
> mp = netdev_priv(dev);
>
> + /* By default, log probe, interface up/down and error events */
> + mp->msg_enable = NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN |
> + NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR;
> +
> res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> BUG_ON(!res);
> dev->irq = res->start;
> @@ -1415,6 +1443,15 @@
> #endif
> #endif
>
> + /* Hook up MII support for ethtool */
> + mp->mii.dev = dev;
> + mp->mii.mdio_read = mv643xx_mdio_read;
> + mp->mii.mdio_write = mv643xx_mdio_write;
> + mp->mii.phy_id = ethernet_phy_get(mp->port_num);
> + mp->mii.phy_id_mask = 0x3f;
> + mp->mii.reg_num_mask = 0x1f;
> + mp->mii.supports_gmii = 1;
> +
> /* Configure the timeout task */
> INIT_WORK(&mp->tx_timeout_task,
> (void (*)(void *))mv643xx_eth_tx_timeout_task, dev);
> @@ -2323,21 +2360,6 @@
> return phy_reg_data0 & 0x1000;
> }
>
> -static int eth_port_link_is_up(unsigned int eth_port_num)
> -{
> - unsigned int phy_reg_data1;
> -
> - eth_port_read_smi_reg(eth_port_num, 1, &phy_reg_data1);
> -
> - if (eth_port_autoneg_supported(eth_port_num)) {
> - if (phy_reg_data1 & 0x20) /* auto-neg complete */
> - return 1;
> - } else if (phy_reg_data1 & 0x4) /* link up */
> - return 1;
> -
> - return 0;
> -}
> -
> /*
> * ethernet_get_config_reg - Get the port configuration register
> *
> @@ -2468,6 +2490,24 @@
> }
>
> /*
> + * Wrappers for MII support library.
> + */
> +static int mv643xx_mdio_read(struct net_device *dev, int phy_id, int location)
> +{
> + int val;
> + struct mv643xx_private *mp = netdev_priv(dev);
> +
> + eth_port_read_smi_reg(mp->port_num, location, &val);
> + return val;
> +}
> +
> +static void mv643xx_mdio_write(struct net_device *dev, int phy_id, int location, int val)
> +{
> + struct mv643xx_private *mp = netdev_priv(dev);
> + eth_port_write_smi_reg(mp->port_num, location, val);
> +}
> +
> +/*
> * eth_port_send - Send an Ethernet packet
> *
> * DESCRIPTION:
>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2005-08-24 0:34 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-28 23:38 [PATCH: 2.6.12-rc1] mv643xx: ethernet driver updates Dale Farnsworth
2005-03-28 23:40 ` mv643xx(1/20): Add mv643xx_enet support for PPC Pegasos platform Dale Farnsworth
2005-03-28 23:42 ` mv643xx(2/20): use MII library for PHY management Dale Farnsworth
2005-08-24 0:34 ` Mark Huth
2005-08-24 0:33 ` Benjamin Herrenschmidt
2005-03-28 23:43 ` mv643xx(3/20): use MII library for ethtool functions Dale Farnsworth
2005-03-28 23:44 ` mv643xx(4/20): Update the Artesyn katana mv643xx ethernet platform data Dale Farnsworth
2005-03-28 23:45 ` mv643xx(5/20): update ppc7d platform for new mv643xx_eth " Dale Farnsworth
2005-03-28 23:46 ` mv643xx(6/20): use netif_msg_xxx() to control log messages where appropriate Dale Farnsworth
2005-03-28 23:47 ` mv643xx(7/20): move static prototypes from header file into driver C file Dale Farnsworth
2005-03-28 23:48 ` mv643xx(8/20): remove ETH_FUNC_RET_STATUS and unused ETH_TARGET enums Dale Farnsworth
2005-03-28 23:49 ` mv643xx(9/20): make internal functions take device pointer param consistently Dale Farnsworth
2005-03-28 23:49 ` mv643xx(10/20): compile fix for non-NAPI case Dale Farnsworth
2005-03-28 23:51 ` mv643xx(11/20): rename all functions to have a common mv643xx_eth prefix Dale Farnsworth
2005-03-28 23:55 ` mv643xx(12/20): reorder code to avoid prototype function declarations Dale Farnsworth
2005-03-28 23:55 ` mv643xx(13/20): remove useless function header block comments Dale Farnsworth
2005-03-28 23:56 ` mv643xx(14/20): whitespace and indentation cleanup Dale Farnsworth
2005-03-28 23:57 ` mv643xx(15/20): Add James Chapman to copyright statement and author list Dale Farnsworth
2005-03-28 23:57 ` mv643xx(16/20): Limit MTU to 1500 bytes unless connected at GigE speed Dale Farnsworth
2005-03-30 20:09 ` Jeff Garzik
2005-03-30 21:46 ` Dale Farnsworth
2005-03-28 23:58 ` mv643xx(17/20): Reset the PHY only at driver open time Dale Farnsworth
2005-03-28 23:59 ` mv643xx(18/20): Isolate the PHY at device close Dale Farnsworth
2005-03-29 0:00 ` mv643xx(19/20): Ensure NAPI poll routine only clears IRQs it handles Dale Farnsworth
2005-03-29 0:01 ` mv643xx(20/20): Fix promiscuous mode handling Dale Farnsworth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).