netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Francois Romieu <romieu@fr.zoreil.com>
To: jgarzik@pobox.com
Cc: Andy Lutomirski <luto@myrealbox.com>,
	Jon D Mason <jonmason@us.ibm.com>,
	netdev@oss.sgi.com
Subject: [patch 4/7] 2.6.6-rc3-mm1 - r8169 ethtool .set_settings
Date: Sat, 1 May 2004 02:28:08 +0200	[thread overview]
Message-ID: <20040501022808.D500@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <20040501022654.C500@electric-eye.fr.zoreil.com>; from romieu@fr.zoreil.com on Sat, May 01, 2004 at 02:26:54AM +0200


ethtool set_settings support (Andy Lutomirski <luto@myrealbox.com>).


diff -puN drivers/net/r8169.c~r8169-ethtool-set_settings drivers/net/r8169.c
--- linux-2.6.6-rc3/drivers/net/r8169.c~r8169-ethtool-set_settings	2004-05-01 01:46:36.000000000 +0200
+++ linux-2.6.6-rc3-fr/drivers/net/r8169.c	2004-05-01 01:46:36.000000000 +0200
@@ -413,8 +413,68 @@ static void rtl8169_get_drvinfo(struct n
 	strcpy(info->bus_info, pci_name(tp->pci_dev));
 }
 
+static void rtl8169_set_speed(struct net_device *dev,
+			      u8 autoneg, u16 speed, u8 duplex)
+{
+	struct rtl8169_private *tp = netdev_priv(dev);
+	void *ioaddr = tp->mmio_addr;
+	int auto_nego, giga_ctrl;
+	u8 status;
+
+	status = RTL_R8(PHYstatus);
+	if ((status & TBI_Enable) && (autoneg == AUTONEG_DISABLE)) {
+		autoneg = AUTONEG_ENABLE;
+		printk(KERN_WARNING PFX
+		       "%s: ignoring request to force speed in TBI mode\n",
+		       dev->name);
+	}
+
+	auto_nego = mdio_read(ioaddr, PHY_AUTO_NEGO_REG);
+	auto_nego &= ~(PHY_Cap_10_Half | PHY_Cap_10_Full |
+		       PHY_Cap_100_Half | PHY_Cap_100_Full);
+	giga_ctrl = mdio_read(ioaddr, PHY_1000_CTRL_REG);
+	giga_ctrl &= ~(PHY_Cap_1000_Full | PHY_Cap_Null);
+
+	if (autoneg == AUTONEG_ENABLE) {
+		auto_nego |= (PHY_Cap_10_Half | PHY_Cap_10_Full |
+			      PHY_Cap_100_Half | PHY_Cap_100_Full);
+		giga_ctrl |= PHY_Cap_1000_Full;
+	} else {
+		if (speed == SPEED_10)
+			auto_nego |= PHY_Cap_10_Half | PHY_Cap_10_Full;
+		else if (speed == SPEED_100)
+			auto_nego |= PHY_Cap_100_Half | PHY_Cap_100_Full;
+		else if (speed == SPEED_1000)
+			giga_ctrl |= PHY_Cap_1000_Full;
+
+		if (duplex == DUPLEX_HALF)
+			auto_nego &= ~(PHY_Cap_10_Full | PHY_Cap_100_Full);
+	}
+
+	if (!(status & TBI_Enable)) {
+		mdio_write(ioaddr, PHY_AUTO_NEGO_REG, auto_nego);
+		mdio_write(ioaddr, PHY_1000_CTRL_REG, giga_ctrl);
+	}
+
+	mdio_write(ioaddr, PHY_CTRL_REG,
+		   PHY_Enable_Auto_Nego | PHY_Restart_Auto_Nego);
+}
+
+static int rtl8169_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+	struct rtl8169_private *tp = netdev_priv(dev);
+	unsigned long flags;
+
+	spin_lock_irqsave(&tp->lock, flags);
+	rtl8169_set_speed(dev, cmd->autoneg, cmd->speed, cmd->duplex);
+	spin_unlock_irqrestore(&tp->lock, flags);
+	
+	return 0;
+}
+
 static struct ethtool_ops rtl8169_ethtool_ops = {
 	.get_drvinfo		= rtl8169_get_drvinfo,
+	.set_settings		= rtl8169_set_settings,
 };
 
 static void rtl8169_write_gmii_reg_bit(void *ioaddr, int reg, int bitnum,

_

  reply	other threads:[~2004-05-01  0:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-01  0:23 [patch 0/7] 2.6.6-rc3-mm1 - description of the r8169 queue Francois Romieu
2004-05-01  0:24 ` [patch 1/7] 2.6.6-rc3-mm1 - r8169 napi Francois Romieu
2004-05-01  0:25   ` [patch 2/7] 2.6.6-rc3-mm1 - r8169 janitoring Francois Romieu
2004-05-01  0:26     ` [patch 3/7] 2.6.6-rc3-mm1 - r8169 register rename Francois Romieu
2004-05-01  0:28       ` Francois Romieu [this message]
2004-05-01  0:29         ` [patch 5/7] 2.6.6-rc3-mm1 - r8169 ethtool .get_settings Francois Romieu
2004-05-01  0:30           ` [patch 6/7] 2.6.6-rc3-mm1 - r8169 link handling rework (1/2) Francois Romieu
2004-05-01  0:31             ` [patch 7/7] 2.6.6-rc3-mm1 - r8169 link handling rework (2/2) Francois Romieu
2004-05-01  6:32 ` [patch 0/7] 2.6.6-rc3-mm1 - description of the r8169 queue Andy Lutomirski
     [not found] ` <40954DE9.3020209@myrealbox.com>
2004-05-02 20:51   ` Francois Romieu
2004-05-02 22:34 ` [patch 0/7] 2.6.6-rc3-mm1 - description of the r8169 queue [resend] Andy Lutomirski

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=20040501022808.D500@electric-eye.fr.zoreil.com \
    --to=romieu@fr.zoreil.com \
    --cc=jgarzik@pobox.com \
    --cc=jonmason@us.ibm.com \
    --cc=luto@myrealbox.com \
    --cc=netdev@oss.sgi.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).