aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/mii.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/drivers/net/mii.c b/drivers/net/mii.c
index 2912a34f597b..92056051f269 100644
--- a/drivers/net/mii.c
+++ b/drivers/net/mii.c
@@ -33,6 +33,13 @@
33#include <linux/ethtool.h> 33#include <linux/ethtool.h>
34#include <linux/mii.h> 34#include <linux/mii.h>
35 35
36/**
37 * mii_ethtool_gset - get settings that are specified in @ecmd
38 * @mii: MII interface
39 * @ecmd: requested ethtool_cmd
40 *
41 * Returns 0 for success, negative on error.
42 */
36int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) 43int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
37{ 44{
38 struct net_device *dev = mii->dev; 45 struct net_device *dev = mii->dev;
@@ -114,6 +121,13 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
114 return 0; 121 return 0;
115} 122}
116 123
124/**
125 * mii_ethtool_sset - set settings that are specified in @ecmd
126 * @mii: MII interface
127 * @ecmd: requested ethtool_cmd
128 *
129 * Returns 0 for success, negative on error.
130 */
117int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) 131int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
118{ 132{
119 struct net_device *dev = mii->dev; 133 struct net_device *dev = mii->dev;
@@ -207,6 +221,10 @@ int mii_ethtool_sset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)
207 return 0; 221 return 0;
208} 222}
209 223
224/**
225 * mii_check_gmii_support - check if the MII supports Gb interfaces
226 * @mii: the MII interface
227 */
210int mii_check_gmii_support(struct mii_if_info *mii) 228int mii_check_gmii_support(struct mii_if_info *mii)
211{ 229{
212 int reg; 230 int reg;
@@ -221,6 +239,12 @@ int mii_check_gmii_support(struct mii_if_info *mii)
221 return 0; 239 return 0;
222} 240}
223 241
242/**
243 * mii_link_ok - is link status up/ok
244 * @mii: the MII interface
245 *
246 * Returns 1 if the MII reports link status up/ok, 0 otherwise.
247 */
224int mii_link_ok (struct mii_if_info *mii) 248int mii_link_ok (struct mii_if_info *mii)
225{ 249{
226 /* first, a dummy read, needed to latch some MII phys */ 250 /* first, a dummy read, needed to latch some MII phys */
@@ -230,6 +254,12 @@ int mii_link_ok (struct mii_if_info *mii)
230 return 0; 254 return 0;
231} 255}
232 256
257/**
258 * mii_nway_restart - restart NWay (autonegotiation) for this interface
259 * @mii: the MII interface
260 *
261 * Returns 0 on success, negative on error.
262 */
233int mii_nway_restart (struct mii_if_info *mii) 263int mii_nway_restart (struct mii_if_info *mii)
234{ 264{
235 int bmcr; 265 int bmcr;
@@ -247,6 +277,14 @@ int mii_nway_restart (struct mii_if_info *mii)
247 return r; 277 return r;
248} 278}
249 279
280/**
281 * mii_check_link - check MII link status
282 * @mii: MII interface
283 *
284 * If the link status changed (previous != current), call
285 * netif_carrier_on() if current link status is Up or call
286 * netif_carrier_off() if current link status is Down.
287 */
250void mii_check_link (struct mii_if_info *mii) 288void mii_check_link (struct mii_if_info *mii)
251{ 289{
252 int cur_link = mii_link_ok(mii); 290 int cur_link = mii_link_ok(mii);
@@ -258,6 +296,15 @@ void mii_check_link (struct mii_if_info *mii)
258 netif_carrier_off(mii->dev); 296 netif_carrier_off(mii->dev);
259} 297}
260 298
299/**
300 * mii_check_media - check the MII interface for a duplex change
301 * @mii: the MII interface
302 * @ok_to_print: OK to print link up/down messages
303 * @init_media: OK to save duplex mode in @mii
304 *
305 * Returns 1 if the duplex mode changed, 0 if not.
306 * If the media type is forced, always returns 0.
307 */
261unsigned int mii_check_media (struct mii_if_info *mii, 308unsigned int mii_check_media (struct mii_if_info *mii,
262 unsigned int ok_to_print, 309 unsigned int ok_to_print,
263 unsigned int init_media) 310 unsigned int init_media)
@@ -326,6 +373,16 @@ unsigned int mii_check_media (struct mii_if_info *mii,
326 return 0; /* duplex did not change */ 373 return 0; /* duplex did not change */
327} 374}
328 375
376/**
377 * generic_mii_ioctl - main MII ioctl interface
378 * @mii_if: the MII interface
379 * @mii_data: MII ioctl data structure
380 * @cmd: MII ioctl command
381 * @duplex_chg_out: pointer to @duplex_changed status if there was no
382 * ioctl error
383 *
384 * Returns 0 on success, negative on error.
385 */
329int generic_mii_ioctl(struct mii_if_info *mii_if, 386int generic_mii_ioctl(struct mii_if_info *mii_if,
330 struct mii_ioctl_data *mii_data, int cmd, 387 struct mii_ioctl_data *mii_data, int cmd,
331 unsigned int *duplex_chg_out) 388 unsigned int *duplex_chg_out)