From: Amir Noam <amir.noam@intel.com>
To: Jay Vosburgh <fubar@us.ibm.com>, jgarzik@pobox.com
Cc: bonding-devel@lists.sourceforge.net, netdev@oss.sgi.com
Subject: [PATCH 3/3][bonding 2.6] Add support for slaves that use ethtool_ops
Date: Thu, 25 Dec 2003 17:05:36 +0200 [thread overview]
Message-ID: <200312251705.36958.amir.noam@intel.com> (raw)
When collecting link information from slaves via ETHTOOL, first try
using the relevant ethtool_ops functions.
diff -Nuarp a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
--- a/drivers/net/bonding/bond_main.c Thu Dec 25 15:31:08 2003
+++ b/drivers/net/bonding/bond_main.c Thu Dec 25 15:31:10 2003
@@ -623,44 +623,55 @@ static int bond_update_speed_duplex(stru
struct ifreq ifr;
struct ethtool_cmd etool;
- ioctl = slave_dev->do_ioctl;
- if (ioctl) {
- etool.cmd = ETHTOOL_GSET;
- ifr.ifr_data = (char*)&etool;
- if (IOCTL(slave_dev, &ifr, SIOCETHTOOL) == 0) {
- slave->speed = etool.speed;
- slave->duplex = etool.duplex;
- } else {
- goto err_out;
+ /* Fake speed and duplex */
+ slave->speed = SPEED_100;
+ slave->duplex = DUPLEX_FULL;
+
+ if (slave_dev->ethtool_ops) {
+ u32 res;
+
+ if (!slave_dev->ethtool_ops->get_settings) {
+ return -1;
+ }
+
+ res = slave_dev->ethtool_ops->get_settings(slave_dev, &etool);
+ if (res < 0) {
+ return -1;
}
- } else {
- goto err_out;
+
+ goto verify;
}
- switch (slave->speed) {
+ ioctl = slave_dev->do_ioctl;
+ strncpy(ifr.ifr_name, slave_dev->name, IFNAMSIZ);
+ etool.cmd = ETHTOOL_GSET;
+ ifr.ifr_data = (char*)&etool;
+ if (!ioctl || (IOCTL(slave_dev, &ifr, SIOCETHTOOL) < 0)) {
+ return -1;
+ }
+
+verify:
+ switch (etool.speed) {
case SPEED_10:
case SPEED_100:
case SPEED_1000:
break;
default:
- goto err_out;
+ return -1;
}
- switch (slave->duplex) {
+ switch (etool.duplex) {
case DUPLEX_FULL:
case DUPLEX_HALF:
break;
default:
- goto err_out;
+ return -1;
}
- return 0;
+ slave->speed = etool.speed;
+ slave->duplex = etool.duplex;
-err_out:
- /* Fake speed and duplex */
- slave->speed = SPEED_100;
- slave->duplex = DUPLEX_FULL;
- return -1;
+ return 0;
}
/*
@@ -705,6 +716,7 @@ static int bond_check_dev_link(struct ne
*/
/* Yes, the mii is overlaid on the ifreq.ifr_ifru */
+ strncpy(ifr.ifr_name, slave_dev->name, IFNAMSIZ);
mii = (struct mii_ioctl_data *)&ifr.ifr_data;
if (IOCTL(slave_dev, &ifr, SIOCGMIIPHY) == 0) {
mii->reg_num = MII_BMSR;
@@ -712,10 +724,23 @@ static int bond_check_dev_link(struct ne
return (mii->val_out & BMSR_LSTATUS);
}
}
+ }
- /* try SIOCETHTOOL ioctl, some drivers cache ETHTOOL_GLINK */
- /* for a period of time so we attempt to get link status */
- /* from it last if the above MII ioctls fail... */
+ /* try SIOCETHTOOL ioctl, some drivers cache ETHTOOL_GLINK */
+ /* for a period of time so we attempt to get link status */
+ /* from it last if the above MII ioctls fail... */
+ if (slave_dev->ethtool_ops) {
+ if (slave_dev->ethtool_ops->get_link) {
+ u32 link;
+
+ link = slave_dev->ethtool_ops->get_link(slave_dev);
+
+ return link ? BMSR_LSTATUS : 0;
+ }
+ }
+
+ if (ioctl) {
+ strncpy(ifr.ifr_name, slave_dev->name, IFNAMSIZ);
etool.cmd = ETHTOOL_GLINK;
ifr.ifr_data = (char*)&etool;
if (IOCTL(slave_dev, &ifr, SIOCETHTOOL) == 0) {
reply other threads:[~2003-12-25 15:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200312251705.36958.amir.noam@intel.com \
--to=amir.noam@intel.com \
--cc=bonding-devel@lists.sourceforge.net \
--cc=fubar@us.ibm.com \
--cc=jgarzik@pobox.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).