lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 09 Aug 2013 12:09:56 -0700
From:	Joe Perches <joe@...ches.com>
To:	Claudiu Manoil <claudiu.manoil@...escale.com>
Cc:	netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
	Ben Hutchings <bhutchings@...arflare.com>,
	Lutz Jaenicke <ljaenicke@...ominate.com>
Subject: Re: [PATCH][net-next v1] gianfar: Add flow control support

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(&regs->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(&regs->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;
}


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ