From: Mark Huth <mhuth@mvista.com>
To: Dale Farnsworth <dale@farnsworth.org>
Cc: Netdev <netdev@oss.sgi.com>, Jeff Garzik <jgarzik@pobox.com>,
Ralf Baechle <ralf@linux-mips.org>,
Manish Lachwani <mlachwani@mvista.com>,
Brian Waite <brian@waitefamily.us>,
"Steven J. Hill" <sjhill@realitydiluted.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
James Chapman <jchapman@katalix.com>
Subject: Re: mv643xx(2/20): use MII library for PHY management
Date: Tue, 23 Aug 2005 17:34:34 -0700 [thread overview]
Message-ID: <430BC09A.3090401@mvista.com> (raw)
In-Reply-To: 20050328234225.GB29098@xyzzy
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:
>
>
next prev parent reply other threads:[~2005-08-24 0:34 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=430BC09A.3090401@mvista.com \
--to=mhuth@mvista.com \
--cc=benh@kernel.crashing.org \
--cc=brian@waitefamily.us \
--cc=dale@farnsworth.org \
--cc=jchapman@katalix.com \
--cc=jgarzik@pobox.com \
--cc=mlachwani@mvista.com \
--cc=netdev@oss.sgi.com \
--cc=ralf@linux-mips.org \
--cc=sjhill@realitydiluted.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).