netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "David Gómez" <david@pleyades.net>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Francois Romieu <romieu@fr.zoreil.com>,
	David Vrabel <dvrabel@cantab.net>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH] ipg: removing more dead code
Date: Wed, 3 May 2006 00:30:48 +0200	[thread overview]
Message-ID: <20060502223048.GA32038@fargo> (raw)
In-Reply-To: <1146596687.13675.1.camel@localhost>

Hi Pekka,

On May 02 at 10:04:47, Pekka Enberg wrote:
> OK. David & David, would appreciate if either you could give the patch a
> spin with Francois' changes. Thanks.

I'll test it tomorrow ASAP. For now, here is another patch removing
more dead code. This code is never reached (NOTGRACE is not defined)
and the *fiber_detect functions are subsequently never used.

--- drivers/net/ipg.c.old	2006-05-03 00:16:47.000000000 +0200
+++ drivers/net/ipg.c	2006-05-03 00:28:02.000000000 +0200
@@ -461,43 +461,6 @@
 	return 0;
 }
 
-#ifdef IPG_TMI_FIBER_DETECT
-static int ipg_sti_fiber_detect(struct net_device *dev)
-{
-	/* Determine if NIC is fiber based by reading the PhyMedia
-	 * bit in the AsicCtrl register.
-	 */
-
-	u32 asicctrl;
-	void __iomem *ioaddr = ipg_ioaddr(dev);
-
-	IPG_DEBUG_MSG("_sti_fiber_detect\n");
-
-	asicctrl = ioread32(ioaddr + IPG_ASICCTRL);
-
-	return asicctrl & IPG_AC_PHY_MEDIA;
-}
-
-static int ipg_tmi_fiber_detect(struct net_device *dev, int phyaddr)
-{
-	/* Determine if NIC is fiber based by reading the ID register
-	 * of the PHY and the GMII address.
-	 */
-
-	u16 phyid;
-
-	IPG_DEBUG_MSG("_tmi_fiber_detect\n");
-
-	phyid = read_phy_register(dev, phyaddr, GMII_PHY_ID_1);
-
-	IPG_DEBUG_MSG("PHY ID = %x\n", phyid);
-
-	/* We conclude the mode is fiber if the GMII address
-	 * is 0x1 and the PHY ID is 0x0000.
-	 */
-	return (phyaddr == 0x1) && (phyid == 0x0000);
-}
-#endif
 
 static int ipg_find_phyaddr(struct net_device *dev)
 {
@@ -524,434 +487,6 @@
 	return -1;
 }
 
-#ifdef NOTGRACE
-static int ipg_config_autoneg(struct net_device *dev)
-{
-	/* Configure IPG based on result of IEEE 802.3 PHY
-	 * auto-negotiation.
-	 */
-
-	int phyaddr = 0;
-	u8 phyctrl;
-	u32 asicctrl;
-	void __iomem *ioaddr = ipg_ioaddr(dev);
-	u16 status = 0;
-	u16 advertisement;
-	u16 linkpartner_ability;
-	u16 gigadvertisement;
-	u16 giglinkpartner_ability;
-	u16 techabilities;
-	int fiber;
-	int gig;
-	int fullduplex;
-	int txflowcontrol;
-	int rxflowcontrol;
-	struct ipg_nic_private *sp = netdev_priv(dev);
-
-	IPG_DEBUG_MSG("_config_autoneg\n");
-
-	asicctrl = ioread32(ioaddr + IPG_ASICCTRL);
-	phyctrl = ioread8(ioaddr + IPG_PHYCTRL);
-
-	/* Set flags for use in resolving auto-negotation, assuming
-	 * non-1000Mbps, half duplex, no flow control.
-	 */
-	fiber = 0;
-	fullduplex = 0;
-	txflowcontrol = 0;
-	rxflowcontrol = 0;
-	gig = 0;
-
-	/* To accomodate a problem in 10Mbps operation,
-	 * set a global flag if PHY running in 10Mbps mode.
-	 */
-	sp->tenmbpsmode = 0;
-
-	printk("Link speed = ");
-
-	/* Determine actual speed of operation. */
-	switch (phyctrl & IPG_PC_LINK_SPEED) {
-	case IPG_PC_LINK_SPEED_10MBPS:
-		printk("10Mbps.\n");
-		printk(KERN_INFO "%s: 10Mbps operational mode enabled.\n",
-		       dev->name);
-		sp->tenmbpsmode = 1;
-		break;
-	case IPG_PC_LINK_SPEED_100MBPS:
-		printk("100Mbps.\n");
-		break;
-	case IPG_PC_LINK_SPEED_1000MBPS:
-		printk("1000Mbps.\n");
-		gig = 1;
-		break;
-	default:
-		printk("undefined!\n");
-	}
-
-#ifndef IPG_TMI_FIBER_DETECT
-	fiber = ipg_sti_fiber_detect(dev);
-
-	/* Determine if auto-negotiation resolution is necessary.
-	 * First check for fiber based media 10/100 media.
-	 */
-	if ((fiber == 1) && (asicctrl &
-			     (IPG_AC_PHY_SPEED10 | IPG_AC_PHY_SPEED100))) {
-		printk(KERN_INFO
-		       "%s: Fiber based PHY, setting full duplex, no flow control.\n",
-		       dev->name);
-		return -EILSEQ;
-		iowrite32(IPG_MC_RSVD_MASK &
-			  ((ioread32(ioaddr + IPG_MACCTRL) |
-			    IPG_MC_DUPLEX_SELECT_FD) &
-			   ~IPG_MC_TX_FLOW_CONTROL_ENABLE &
-			   ~IPG_MC_RX_FLOW_CONTROL_ENABLE),
-			  ioaddr + IPG_MACCTRL);
-
-		return 0;
-	}
-#endif
-
-	/* Determine if PHY is auto-negotiation capable. */
-	phyaddr = ipg_find_phyaddr(dev);
-
-	if (phyaddr == -1) {
-		printk(KERN_INFO
-		       "%s: Error on read to GMII/MII Status register.\n",
-		       dev->name);
-		return -EILSEQ;
-	}
-
-	IPG_DEBUG_MSG("GMII/MII PHY address = %x\n", phyaddr);
-
-	status = read_phy_register(dev, phyaddr, GMII_PHY_STATUS);
-
-	printk("PHYStatus = %x \n", status);
-	if ((status & GMII_PHY_STATUS_AUTONEG_ABILITY) == 0) {
-		printk(KERN_INFO
-		       "%s: Error PHY unable to perform auto-negotiation.\n",
-		       dev->name);
-		return -EILSEQ;
-	}
-
-	advertisement = read_phy_register(dev, phyaddr,
-					  GMII_PHY_AUTONEGADVERTISEMENT);
-	linkpartner_ability = read_phy_register(dev, phyaddr,
-						GMII_PHY_AUTONEGLINKPARTABILITY);
-
-	printk("PHYadvertisement=%x LinkPartner=%x \n", advertisement,
-	       linkpartner_ability);
-	if ((advertisement == 0xFFFF) || (linkpartner_ability == 0xFFFF)) {
-		printk(KERN_INFO
-		       "%s: Error on read to GMII/MII registers 4 and/or 5.\n",
-		       dev->name);
-		return -EILSEQ;
-	}
-#ifdef IPG_TMI_FIBER_DETECT
-	fiber = ipg_tmi_fiber_detect(dev, phyaddr);
-#endif
-
-	/* Resolve full/half duplex if 1000BASE-X. */
-	if ((gig == 1) && (fiber == 1)) {
-		/* Compare the full duplex bits in the GMII registers
-		 * for the local device, and the link partner. If these
-		 * bits are logic 1 in both registers, configure the
-		 * IPG for full duplex operation.
-		 */
-		if ((advertisement & GMII_PHY_ADV_FULL_DUPLEX) ==
-		    (linkpartner_ability & GMII_PHY_ADV_FULL_DUPLEX)) {
-			fullduplex = 1;
-
-			/* In 1000BASE-X using IPG's internal PCS
-			 * layer, so write to the GMII duplex bit.
-			 */
-			write_phy_register(dev,
-					   phyaddr,
-					   GMII_PHY_CONTROL,
-					   read_phy_register
-					   (dev, phyaddr,
-					    GMII_PHY_CONTROL) |
-					   GMII_PHY_CONTROL_FULL_DUPLEX);
-
-		} else {
-			fullduplex = 0;
-
-			/* In 1000BASE-X using IPG's internal PCS
-			 * layer, so write to the GMII duplex bit.
-			 */
-			write_phy_register(dev,
-					   phyaddr,
-					   GMII_PHY_CONTROL,
-					   read_phy_register
-					   (dev, phyaddr,
-					    GMII_PHY_CONTROL) &
-					   ~GMII_PHY_CONTROL_FULL_DUPLEX);
-		}
-	}
-
-	/* Resolve full/half duplex if 1000BASE-T. */
-	if ((gig == 1) && (fiber == 0)) {
-		/* Read the 1000BASE-T "Control" and "Status"
-		 * registers which represent the advertised and
-		 * link partner abilities exchanged via next page
-		 * transfers.
-		 */
-		gigadvertisement = read_phy_register(dev,
-						     phyaddr,
-						     GMII_PHY_1000BASETCONTROL);
-		giglinkpartner_ability = read_phy_register(dev,
-							   phyaddr,
-							   GMII_PHY_1000BASETSTATUS);
-
-		/* Compare the full duplex bits in the 1000BASE-T GMII
-		 * registers for the local device, and the link partner.
-		 * If these bits are logic 1 in both registers, configure
-		 * the IPG for full duplex operation.
-		 */
-		if ((gigadvertisement & GMII_PHY_1000BASETCONTROL_FULL_DUPLEX)
-		    && (giglinkpartner_ability &
-			GMII_PHY_1000BASETSTATUS_FULL_DUPLEX)) {
-			fullduplex = 1;
-		} else {
-			fullduplex = 0;
-		}
-	}
-
-	/* Resolve full/half duplex for 10/100BASE-T. */
-	if (gig == 0) {
-		/* Autonegotiation Priority Resolution algorithm, as defined in
-		 * IEEE 802.3 Annex 28B.
-		 */
-		if (((advertisement & MII_PHY_SELECTORFIELD) ==
-		     MII_PHY_SELECTOR_IEEE8023) &&
-		    ((linkpartner_ability & MII_PHY_SELECTORFIELD) ==
-		     MII_PHY_SELECTOR_IEEE8023)) {
-			techabilities = (advertisement & linkpartner_ability &
-					 MII_PHY_TECHABILITYFIELD);
-
-			fullduplex = 0;
-
-			/* 10BASE-TX half duplex is lowest priority. */
-			if (techabilities & MII_PHY_TECHABILITY_10BT) {
-				fullduplex = 0;
-			}
-
-			if (techabilities & MII_PHY_TECHABILITY_10BTFD) {
-				fullduplex = 1;
-			}
-
-			if (techabilities & MII_PHY_TECHABILITY_100BTX) {
-				fullduplex = 0;
-			}
-
-			if (techabilities & MII_PHY_TECHABILITY_100BT4) {
-				fullduplex = 0;
-			}
-
-			/* 100BASE-TX half duplex is highest priority. *///Sorbica full duplex ?
-			if (techabilities & MII_PHY_TECHABILITY_100BTXFD) {
-				fullduplex = 1;
-			}
-
-			if (fullduplex == 1) {
-				/* If in full duplex mode, determine if PAUSE
-				 * functionality is supported by the local
-				 * device, and the link partner.
-				 */
-				if (techabilities & MII_PHY_TECHABILITY_PAUSE) {
-					txflowcontrol = 1;
-					rxflowcontrol = 1;
-				} else {
-					txflowcontrol = 0;
-					rxflowcontrol = 0;
-				}
-			}
-		}
-	}
-
-	/* If in 1000Mbps, fiber, and full duplex mode, resolve
-	 * 1000BASE-X PAUSE capabilities. */
-	if ((fullduplex == 1) && (fiber == 1) && (gig == 1)) {
-		/* In full duplex mode, resolve PAUSE
-		 * functionality.
-		 */
-		switch (((advertisement & GMII_PHY_ADV_PAUSE) >> 5) |
-			((linkpartner_ability & GMII_PHY_ADV_PAUSE) >> 7)) {
-		case 0x7:
-			txflowcontrol = 1;
-			rxflowcontrol = 0;
-			break;
-
-		case 0xA:
-		case 0xB:
-		case 0xE:
-		case 0xF:
-			txflowcontrol = 1;
-			rxflowcontrol = 1;
-			break;
-
-		case 0xD:
-			txflowcontrol = 0;
-			rxflowcontrol = 1;
-			break;
-
-		default:
-			txflowcontrol = 0;
-			rxflowcontrol = 0;
-		}
-	}
-
-	/* If in 1000Mbps, non-fiber, full duplex mode, resolve
-	 * 1000BASE-T PAUSE capabilities. */
-	if ((fullduplex == 1) && (fiber == 0) && (gig == 1)) {
-		/* Make sure the PHY is advertising we are PAUSE
-		 * capable.
-		 */
-		if (!(advertisement & (MII_PHY_TECHABILITY_PAUSE |
-				       MII_PHY_TECHABILITY_ASM_DIR))) {
-			/* PAUSE is not being advertised. Advertise
-			 * PAUSE and restart auto-negotiation.
-			 */
-			write_phy_register(dev,
-					   phyaddr,
-					   MII_PHY_AUTONEGADVERTISEMENT,
-					   (advertisement |
-					    MII_PHY_TECHABILITY_PAUSE |
-					    MII_PHY_TECHABILITY_ASM_DIR));
-			write_phy_register(dev,
-					   phyaddr,
-					   MII_PHY_CONTROL,
-					   MII_PHY_CONTROL_RESTARTAN);
-
-			return -EAGAIN;
-		}
-
-		/* In full duplex mode, resolve PAUSE
-		 * functionality.
-		 */
-		switch (((advertisement &
-			  MII_PHY_TECHABILITY_PAUSE_FIELDS) >> 0x8) |
-			((linkpartner_ability &
-			  MII_PHY_TECHABILITY_PAUSE_FIELDS) >> 0xA)) {
-		case 0x7:
-			txflowcontrol = 1;
-			rxflowcontrol = 0;
-			break;
-
-		case 0xA:
-		case 0xB:
-		case 0xE:
-		case 0xF:
-			txflowcontrol = 1;
-			rxflowcontrol = 1;
-			break;
-
-		case 0xD:
-			txflowcontrol = 0;
-			rxflowcontrol = 1;
-			break;
-
-		default:
-			txflowcontrol = 0;
-			rxflowcontrol = 0;
-		}
-	}
-
-	/* If in 10/100Mbps, non-fiber, full duplex mode, assure
-	 * 10/100BASE-T PAUSE capabilities are advertised. */
-	if ((fullduplex == 1) && (fiber == 0) && (gig == 0)) {
-		/* Make sure the PHY is advertising we are PAUSE
-		 * capable.
-		 */
-		if (!(advertisement & (MII_PHY_TECHABILITY_PAUSE))) {
-			/* PAUSE is not being advertised. Advertise
-			 * PAUSE and restart auto-negotiation.
-			 */
-			write_phy_register(dev,
-					   phyaddr,
-					   MII_PHY_AUTONEGADVERTISEMENT,
-					   (advertisement |
-					    MII_PHY_TECHABILITY_PAUSE));
-			write_phy_register(dev,
-					   phyaddr,
-					   MII_PHY_CONTROL,
-					   MII_PHY_CONTROL_RESTARTAN);
-
-			return -EAGAIN;
-		}
-
-	}
-
-	if (fiber == 1) {
-		printk(KERN_INFO "%s: Fiber based PHY, ", dev->name);
-	} else {
-		printk(KERN_INFO "%s: Copper based PHY, ", dev->name);
-	}
-
-	/* Configure full duplex, and flow control. */
-	if (fullduplex == 1) {
-		/* Configure IPG for full duplex operation. */
-		printk("setting full duplex, ");
-
-		iowrite32(IPG_MC_RSVD_MASK &
-			  (ioread32(ioaddr + IPG_MACCTRL) |
-			   IPG_MC_DUPLEX_SELECT_FD), ioaddr + IPG_MACCTRL);
-
-		if (txflowcontrol == 1) {
-			printk("TX flow control");
-			iowrite32(IPG_MC_RSVD_MASK &
-				  (ioread32(ioaddr + IPG_MACCTRL) |
-				   IPG_MC_TX_FLOW_CONTROL_ENABLE),
-				  ioaddr + IPG_MACCTRL);
-		} else {
-			printk("no TX flow control");
-			iowrite32(IPG_MC_RSVD_MASK &
-				  (ioread32(ioaddr + IPG_MACCTRL) &
-				   ~IPG_MC_TX_FLOW_CONTROL_ENABLE),
-				  ioaddr + IPG_MACCTRL);
-		}
-
-		if (rxflowcontrol == 1) {
-			printk(", RX flow control.");
-			iowrite32(IPG_MC_RSVD_MASK &
-				  (ioread32(ioaddr + IPG_MACCTRL) |
-				   IPG_MC_RX_FLOW_CONTROL_ENABLE),
-				  ioaddr + IPG_MACCTRL);
-		} else {
-			printk(", no RX flow control.");
-			iowrite32(IPG_MC_RSVD_MASK &
-				  (ioread32(ioaddr + IPG_MACCTRL) &
-				   ~IPG_MC_RX_FLOW_CONTROL_ENABLE),
-				  ioaddr + IPG_MACCTRL);
-		}
-
-		printk("\n");
-	} else {
-		/* Configure IPG for half duplex operation. */
-		printk
-		    ("setting half duplex, no TX flow control, no RX flow control.\n");
-
-		iowrite32(IPG_MC_RSVD_MASK &
-			  (ioread32(ioaddr + IPG_MACCTRL) &
-			   ~IPG_MC_DUPLEX_SELECT_FD &
-			   ~IPG_MC_TX_FLOW_CONTROL_ENABLE &
-			   ~IPG_MC_RX_FLOW_CONTROL_ENABLE),
-			  ioaddr + IPG_MACCTRL);
-	}
-
-	IPG_DEBUG_MSG("G/MII reg 4 (advertisement) = %4.4x\n", advertisement);
-	IPG_DEBUG_MSG("G/MII reg 5 (link partner)  = %4.4x\n",
-		      linkpartner_ability);
-	IPG_DEBUG_MSG("G/MII reg 9 (1000BASE-T control) = %4.4x\n",
-		      advertisement);
-	IPG_DEBUG_MSG("G/MII reg 10 (1000BASE-T status) = %4.4x\n",
-		      linkpartner_ability);
-
-	IPG_DEBUG_MSG("Auto-neg complete, MACCTRL = %8.8x\n",
-		      ioread32(ioaddr + IPG_MACCTRL));
-
-	return 0;
-}
-#else
 static int ipg_config_autoneg(struct net_device *dev)
 {
 	/* Configure IPG based on result of IEEE 802.3 PHY
@@ -1072,7 +607,6 @@
 	return 0;
 }
 
-#endif
 
 static int ipg_io_config(struct net_device *dev)
 {

  reply	other threads:[~2006-05-02 22:29 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20060427142939.GA31473@fargo>
2006-04-27 18:56 ` IP1000 gigabit nic driver Francois Romieu
2006-04-27 22:26   ` David Vrabel
2006-04-28  7:57     ` David Gómez
2006-04-28 10:58       ` Pekka Enberg
2006-04-28 11:37         ` David Gómez
2006-04-28 11:51           ` Pekka J Enberg
2006-04-28 11:59           ` Pekka J Enberg
2006-04-28 21:58             ` David Gómez
2006-04-29 10:29             ` Pekka Enberg
2006-04-29 10:35               ` Arjan van de Ven
2006-04-29 12:21               ` David Gómez
2006-04-29 20:35                 ` Pekka Enberg
2006-04-30  9:26                   ` Pekka Enberg
2006-04-30 23:40                     ` David Vrabel
2006-05-01  9:31                       ` Pekka Enberg
2006-05-03 12:43                         ` Andrew Morton
2006-05-03 13:06                           ` Pekka J Enberg
2006-05-03 14:15                             ` David Vrabel
2006-05-01  9:43                       ` Pekka Enberg
2006-05-01 11:32                       ` David Vrabel
2006-05-01 18:08                         ` Pekka Enberg
2006-05-01 23:10                           ` [PATCH 1/3] ipg: removal of unreachable code Francois Romieu
2006-05-02  6:36                             ` Pekka J Enberg
2006-05-01 23:10                           ` [PATCH 2/3] ipg: leaks in ipg_probe Francois Romieu
2006-05-02  6:41                             ` Pekka J Enberg
2006-05-02 18:33                               ` Francois Romieu
2006-05-02 19:04                                 ` Pekka Enberg
2006-05-02 22:30                                   ` David Gómez [this message]
2006-05-03 13:12                                     ` [PATCH] ipg: removing more dead code Pekka J Enberg
2006-05-03 21:00                                   ` [PATCH 2/3] ipg: leaks in ipg_probe David Gómez
2006-05-01 23:12                           ` [PATCH 3/3] ipg: plug leaks in the error path of ipg_nic_open Francois Romieu
2006-05-02  6:45                             ` Pekka J Enberg
2006-05-02 21:44                               ` [PATCH 1/2] ipg: sanitize the pci device table Francois Romieu
2006-05-02 21:45                               ` [PATCH 2/2] ipg: redundancy with mii.h Francois Romieu
2006-05-02 21:55                                 ` Francois Romieu
2006-05-03  6:16                                   ` Pekka J Enberg
2006-05-03 23:35                                     ` Francois Romieu
2006-05-04  6:52                                       ` David Vrabel
2006-05-05  0:24                                         ` Francois Romieu
2006-05-04 13:44                                       ` Pekka Enberg
2006-05-04 23:55                                         ` Francois Romieu
2006-05-20 21:03                                           ` David Vrabel
2006-05-21  7:23                                             ` Pekka Enberg
2006-05-21 10:16                                             ` Francois Romieu
2006-05-22  3:22                                               ` jesse\(建興\)
2006-05-23  6:50                                               ` jesse\(建興\)
2006-05-01 20:38                         ` IP1000 gigabit nic driver Francois Romieu
2006-05-01 20:41                           ` Lennert Buytenhek
2006-05-02  0:36                             ` David Vrabel
2006-05-01 19:39                   ` David Gómez
2006-04-29 12:58               ` David Vrabel
2006-04-28 11:59           ` Ingo Oeser
2006-04-28  7:54   ` David Gómez

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=20060502223048.GA32038@fargo \
    --to=david@pleyades.net \
    --cc=dvrabel@cantab.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=romieu@fr.zoreil.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).