netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe W Damasio <felipewd@terra.com.br>
To: Jeff Garzik <jgarzik@mandrakesoft.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	netdev@oss.sgi.com
Subject: Re: ALTPATCH: 8139cp: LinkChg support
Date: 20 Sep 2002 04:09:43 +0000	[thread overview]
Message-ID: <1032494983.247.70.camel@tank> (raw)
In-Reply-To: <3D8ABCEF.9060207@mandrakesoft.com>

On Fri, 2002-09-20 at 06:15, Jeff Garzik wrote:
> diff -Nru a/drivers/net/mii.c b/drivers/net/mii.c
> --- a/drivers/net/mii.c	Fri Sep 20 02:13:15 2002
> +++ b/drivers/net/mii.c	Fri Sep 20 02:13:15 2002
> @@ -170,6 +170,75 @@
>  	return r;
>  }
>  
> +void mii_check_link (struct mii_if_info *mii)
> +{
> +	if (mii_link_ok(mii))
> +		netif_carrier_on(mii->dev);
> +	else
> +		netif_carrier_off(mii->dev);
> +}
> +
> +unsigned int mii_check_media (struct mii_if_info *mii, unsigned int ok_to_print)
> +{
> +	unsigned int old_carrier, new_carrier;
> +	int advertise, lpa, media, duplex;

	Shouldn't advertise and lpa be either "unsigned short" or u16?

> +
> +	/* if forced media, go no further */
> +	if (mii->duplex_lock)
> +		return 0; /* duplex did not change */
> +
> +	/* check current and old link status */
> +	old_carrier = netif_carrier_ok(mii->dev) ? 1 : 0;
> +	new_carrier = (unsigned int) mii_link_ok(mii);
> +
> +	/* if carrier state did not change, this is a "bounce",
> +	 * just exit as everything is already set correctly
> +	 */
> +	if (old_carrier == new_carrier)
> +		return 0; /* duplex did not change */
> +
> +	/* no carrier, nothing much to do */
> +	if (!new_carrier) {
> +		netif_carrier_off(mii->dev);
> +		if (ok_to_print)
> +			printk(KERN_INFO "%s: link down\n", mii->dev->name);
> +		return 0; /* duplex did not change */
> +	}
> +
> +	/*
> +	 * we have carrier, see who's on the other end
> +	 */
> +	netif_carrier_on(mii->dev);
> +
> +	/* get MII advertise and LPA values */
> +	if (mii->advertising)
> +		advertise = mii->advertising;
> +	else {
> +		advertise = mii->mdio_read(mii->dev, mii->phy_id, MII_ADVERTISE);
> +		mii->advertising = advertise;
> +	}
> +	lpa = mii->mdio_read(mii->dev, mii->phy_id, MII_LPA);
> +
> +	/* figure out media and duplex from advertise and LPA values */
> +	media = mii_nway_result(lpa & advertise);
        ^^^^^^^^^^^^^^^^^^^^^^^ 

	mii_nway_result returns a "unsigned int", so media also doesn't look
good.

> +	duplex = (media & (ADVERTISE_100FULL | ADVERTISE_10FULL)) ? 1 : 0;

	Or we could do

	duplex = (media & ADVERTISE_FULL) ? 1 : 0;

Felipe

  reply	other threads:[~2002-09-20  4:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1032487254.247.7.camel@tank>
2002-09-20  6:15 ` ALTPATCH: 8139cp: LinkChg support Jeff Garzik
2002-09-20  4:09   ` Felipe W Damasio [this message]
2002-09-20 13:21     ` Jeff Garzik

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=1032494983.247.70.camel@tank \
    --to=felipewd@terra.com.br \
    --cc=jgarzik@mandrakesoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --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).