From: Joe Perches <joe@perches.com>
To: Claudiu Manoil <claudiu.manoil@freescale.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Ben Hutchings <bhutchings@solarflare.com>,
Lutz Jaenicke <ljaenicke@innominate.com>
Subject: Re: [PATCH][net-next v1] gianfar: Add flow control support
Date: Fri, 09 Aug 2013 12:09:56 -0700 [thread overview]
Message-ID: <1376075396.2087.148.camel@joe-AO722> (raw)
In-Reply-To: <1376068786-29868-1-git-send-email-claudiu.manoil@freescale.com>
On Fri, 2013-08-09 at 20:19 +0300, Claudiu Manoil wrote:
> eTSEC has Rx and Tx flow control capabilities that may be enabled
> through MACCFG1[Rx_Flow, Tx_Flow] bits.
Trivial note:
> diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
[]
> @@ -3043,6 +3050,7 @@ static void adjust_link(struct net_device *dev)
[]
> + u32 tempval1 = gfar_read(®s->maccfg1);
[]
> @@ -3091,6 +3099,32 @@ static void adjust_link(struct net_device *dev)
> priv->oldspeed = phydev->speed;
> }
>
> + tempval1 &= ~(MACCFG1_TX_FLOW | MACCFG1_RX_FLOW);
> + if (phydev->duplex) {
> + if (!priv->pause_aneg_en) {
> + if (priv->tx_pause_en)
> + tempval1 |= MACCFG1_TX_FLOW;
> + if (priv->rx_pause_en)
> + tempval1 |= MACCFG1_RX_FLOW;
> + } else {
> + u8 flowctrl;
> + u16 lcl_adv = mii_advertise_flowctrl(
> + phydev->advertising);
> + u16 rmt_adv = 0;
> + if (phydev->pause)
> + rmt_adv = LPA_PAUSE_CAP;
> + if (phydev->asym_pause)
> + rmt_adv |= LPA_PAUSE_ASYM;
> + flowctrl = mii_resolve_flowctrl_fdx(
> + lcl_adv, rmt_adv);
> + if (flowctrl & FLOW_CTRL_TX)
> + tempval1 |= MACCFG1_TX_FLOW;
> + if (flowctrl & FLOW_CTRL_RX)
> + tempval1 |= MACCFG1_RX_FLOW;
> + }
> + }
I think this bit would be nicer as a static function.
Something like: (uncompiled/untested)
static int gfar_get_cfg1(struct net_device *dev)
{
struct gfar_private *priv = netdev_priv(dev);
struct gfar __iomem *regs = priv->gfargrp[0].regs;
struct phy_device *phydev = priv->phydev;
int val;
val = gfar_read(®s->maccfg1);
val &= ~(MACCFG1_TX_FLOW | MACCFG1_RX_FLOW);
if (!phydev->duplex)
return val;
if (!priv->pause_aneg_en) {
if (priv->tx_pause_en)
val |= MACCFG1_TX_FLOW;
if (priv->rx_pause_en)
val |= MACCFG1_RX_FLOW;
} else {
u8 flowctrl;
u16 lcl_adv = mii_advertise_flowctrl(phydev->advertising);
u16 rmt_adv = 0;
if (phydev->pause)
rmt_adv = LPA_PAUSE_CAP;
if (phydev->asym_pause)
rmt_adv |= LPA_PAUSE_ASYM;
flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
if (flowctrl & FLOW_CTRL_TX)
val |= MACCFG1_TX_FLOW;
if (flowctrl & FLOW_CTRL_RX)
val |= MACCFG1_RX_FLOW;
}
return val;
}
next prev parent reply other threads:[~2013-08-09 19:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-07 10:24 [PATCH 1/2][net-next] gianfar: Fix pause frame handling for half duplex links Claudiu Manoil
2013-08-07 10:24 ` [PATCH 2/2][net-next] gianfar: Add ethtool -A support for pause frame Claudiu Manoil
2013-08-07 19:12 ` Ben Hutchings
2013-08-08 17:10 ` Claudiu Manoil
2013-08-08 18:45 ` Ben Hutchings
2013-08-09 8:26 ` Lutz Jaenicke
2013-08-09 8:26 ` [PATCH] gianfar: implement flow control handling Lutz Jaenicke
2013-08-09 17:19 ` [PATCH][net-next v1] gianfar: Add flow control support Claudiu Manoil
2013-08-09 17:36 ` Fabio Estevam
2013-08-12 7:09 ` Claudiu Manoil
2013-08-09 19:09 ` Joe Perches [this message]
2013-08-12 7:08 ` Claudiu Manoil
2013-08-12 10:53 ` [PATCH][net-next v2] " Claudiu Manoil
2013-08-13 22:29 ` David Miller
2013-08-09 8:26 ` [PATCH] gianfar: add support for LFC (Lossless Flow Control) Lutz Jaenicke
2013-08-09 8:39 ` Joe Perches
2013-08-09 10:12 ` [PATCH 2/2][net-next] gianfar: Add ethtool -A support for pause frame Claudiu Manoil
2013-08-09 10:15 ` Lutz Jaenicke
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=1376075396.2087.148.camel@joe-AO722 \
--to=joe@perches.com \
--cc=bhutchings@solarflare.com \
--cc=claudiu.manoil@freescale.com \
--cc=davem@davemloft.net \
--cc=ljaenicke@innominate.com \
--cc=netdev@vger.kernel.org \
/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).