diff options
Diffstat (limited to 'drivers/net/mii.c')
-rw-r--r-- | drivers/net/mii.c | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/drivers/net/mii.c b/drivers/net/mii.c index 210b2b164b30..c62e7816d548 100644 --- a/drivers/net/mii.c +++ b/drivers/net/mii.c | |||
@@ -49,6 +49,10 @@ static u32 mii_get_an(struct mii_if_info *mii, u16 addr) | |||
49 | result |= ADVERTISED_100baseT_Half; | 49 | result |= ADVERTISED_100baseT_Half; |
50 | if (advert & ADVERTISE_100FULL) | 50 | if (advert & ADVERTISE_100FULL) |
51 | result |= ADVERTISED_100baseT_Full; | 51 | result |= ADVERTISED_100baseT_Full; |
52 | if (advert & ADVERTISE_PAUSE_CAP) | ||
53 | result |= ADVERTISED_Pause; | ||
54 | if (advert & ADVERTISE_PAUSE_ASYM) | ||
55 | result |= ADVERTISED_Asym_Pause; | ||
52 | 56 | ||
53 | return result; | 57 | return result; |
54 | } | 58 | } |
@@ -58,6 +62,9 @@ static u32 mii_get_an(struct mii_if_info *mii, u16 addr) | |||
58 | * @mii: MII interface | 62 | * @mii: MII interface |
59 | * @ecmd: requested ethtool_cmd | 63 | * @ecmd: requested ethtool_cmd |
60 | * | 64 | * |
65 | * The @ecmd parameter is expected to have been cleared before calling | ||
66 | * mii_ethtool_gset(). | ||
67 | * | ||
61 | * Returns 0 for success, negative on error. | 68 | * Returns 0 for success, negative on error. |
62 | */ | 69 | */ |
63 | int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) | 70 | int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) |
@@ -118,22 +125,25 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) | |||
118 | 125 | ||
119 | if (nego & (ADVERTISED_1000baseT_Full | | 126 | if (nego & (ADVERTISED_1000baseT_Full | |
120 | ADVERTISED_1000baseT_Half)) { | 127 | ADVERTISED_1000baseT_Half)) { |
121 | ecmd->speed = SPEED_1000; | 128 | ethtool_cmd_speed_set(ecmd, SPEED_1000); |
122 | ecmd->duplex = !!(nego & ADVERTISED_1000baseT_Full); | 129 | ecmd->duplex = !!(nego & ADVERTISED_1000baseT_Full); |
123 | } else if (nego & (ADVERTISED_100baseT_Full | | 130 | } else if (nego & (ADVERTISED_100baseT_Full | |
124 | ADVERTISED_100baseT_Half)) { | 131 | ADVERTISED_100baseT_Half)) { |
125 | ecmd->speed = SPEED_100; | 132 | ethtool_cmd_speed_set(ecmd, SPEED_100); |
126 | ecmd->duplex = !!(nego & ADVERTISED_100baseT_Full); | 133 | ecmd->duplex = !!(nego & ADVERTISED_100baseT_Full); |
127 | } else { | 134 | } else { |
128 | ecmd->speed = SPEED_10; | 135 | ethtool_cmd_speed_set(ecmd, SPEED_10); |
129 | ecmd->duplex = !!(nego & ADVERTISED_10baseT_Full); | 136 | ecmd->duplex = !!(nego & ADVERTISED_10baseT_Full); |
130 | } | 137 | } |
131 | } else { | 138 | } else { |
132 | ecmd->autoneg = AUTONEG_DISABLE; | 139 | ecmd->autoneg = AUTONEG_DISABLE; |
133 | 140 | ||
134 | ecmd->speed = ((bmcr & BMCR_SPEED1000 && | 141 | ethtool_cmd_speed_set(ecmd, |
135 | (bmcr & BMCR_SPEED100) == 0) ? SPEED_1000 : | 142 | ((bmcr & BMCR_SPEED1000 && |
136 | (bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10); | 143 | (bmcr & BMCR_SPEED100) == 0) ? |
144 | SPEED_1000 : | ||
145 | ((bmcr & BMCR_SPEED100) ? | ||
146 | SPEED_100 : SPEED_10))); | ||
137 | ecmd->duplex = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF; | 147 | ecmd->duplex = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF; |
138 | } | 148 | } |
139 | 149 | ||
@@ -154,10 +164,11 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) | |||
154 | int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) | 164 | int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) |
155 | { | 165 | { |
156 | struct net_device *dev = mii->dev; | 166 | struct net_device *dev = mii->dev; |
167 | u32 speed = ethtool_cmd_speed(ecmd); | ||
157 | 168 | ||
158 | if (ecmd->speed != SPEED_10 && | 169 | if (speed != SPEED_10 && |
159 | ecmd->speed != SPEED_100 && | 170 | speed != SPEED_100 && |
160 | ecmd->speed != SPEED_1000) | 171 | speed != SPEED_1000) |
161 | return -EINVAL; | 172 | return -EINVAL; |
162 | if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL) | 173 | if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL) |
163 | return -EINVAL; | 174 | return -EINVAL; |
@@ -169,7 +180,7 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) | |||
169 | return -EINVAL; | 180 | return -EINVAL; |
170 | if (ecmd->autoneg != AUTONEG_DISABLE && ecmd->autoneg != AUTONEG_ENABLE) | 181 | if (ecmd->autoneg != AUTONEG_DISABLE && ecmd->autoneg != AUTONEG_ENABLE) |
171 | return -EINVAL; | 182 | return -EINVAL; |
172 | if ((ecmd->speed == SPEED_1000) && (!mii->supports_gmii)) | 183 | if ((speed == SPEED_1000) && (!mii->supports_gmii)) |
173 | return -EINVAL; | 184 | return -EINVAL; |
174 | 185 | ||
175 | /* ignore supported, maxtxpkt, maxrxpkt */ | 186 | /* ignore supported, maxtxpkt, maxrxpkt */ |
@@ -227,9 +238,9 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) | |||
227 | bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR); | 238 | bmcr = mii->mdio_read(dev, mii->phy_id, MII_BMCR); |
228 | tmp = bmcr & ~(BMCR_ANENABLE | BMCR_SPEED100 | | 239 | tmp = bmcr & ~(BMCR_ANENABLE | BMCR_SPEED100 | |
229 | BMCR_SPEED1000 | BMCR_FULLDPLX); | 240 | BMCR_SPEED1000 | BMCR_FULLDPLX); |
230 | if (ecmd->speed == SPEED_1000) | 241 | if (speed == SPEED_1000) |
231 | tmp |= BMCR_SPEED1000; | 242 | tmp |= BMCR_SPEED1000; |
232 | else if (ecmd->speed == SPEED_100) | 243 | else if (speed == SPEED_100) |
233 | tmp |= BMCR_SPEED100; | 244 | tmp |= BMCR_SPEED100; |
234 | if (ecmd->duplex == DUPLEX_FULL) { | 245 | if (ecmd->duplex == DUPLEX_FULL) { |
235 | tmp |= BMCR_FULLDPLX; | 246 | tmp |= BMCR_FULLDPLX; |
@@ -354,7 +365,7 @@ unsigned int mii_check_media (struct mii_if_info *mii, | |||
354 | if (!new_carrier) { | 365 | if (!new_carrier) { |
355 | netif_carrier_off(mii->dev); | 366 | netif_carrier_off(mii->dev); |
356 | if (ok_to_print) | 367 | if (ok_to_print) |
357 | printk(KERN_INFO "%s: link down\n", mii->dev->name); | 368 | netdev_info(mii->dev, "link down\n"); |
358 | return 0; /* duplex did not change */ | 369 | return 0; /* duplex did not change */ |
359 | } | 370 | } |
360 | 371 | ||
@@ -381,12 +392,12 @@ unsigned int mii_check_media (struct mii_if_info *mii, | |||
381 | duplex = 1; | 392 | duplex = 1; |
382 | 393 | ||
383 | if (ok_to_print) | 394 | if (ok_to_print) |
384 | printk(KERN_INFO "%s: link up, %sMbps, %s-duplex, lpa 0x%04X\n", | 395 | netdev_info(mii->dev, "link up, %uMbps, %s-duplex, lpa 0x%04X\n", |
385 | mii->dev->name, | 396 | lpa2 & (LPA_1000FULL | LPA_1000HALF) ? 1000 : |
386 | lpa2 & (LPA_1000FULL | LPA_1000HALF) ? "1000" : | 397 | media & (ADVERTISE_100FULL | ADVERTISE_100HALF) ? |
387 | media & (ADVERTISE_100FULL | ADVERTISE_100HALF) ? "100" : "10", | 398 | 100 : 10, |
388 | duplex ? "full" : "half", | 399 | duplex ? "full" : "half", |
389 | lpa); | 400 | lpa); |
390 | 401 | ||
391 | if ((init_media) || (mii->full_duplex != duplex)) { | 402 | if ((init_media) || (mii->full_duplex != duplex)) { |
392 | mii->full_duplex = duplex; | 403 | mii->full_duplex = duplex; |