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]
Message-ID: <20201029130147.GL933237@lunn.ch>
Date:   Thu, 29 Oct 2020 14:01:47 +0100
From:   Andrew Lunn <andrew@...n.ch>
To:     DENG Qingfang <dqfext@...il.com>
Cc:     netdev@...r.kernel.org, Felix Fietkau <nbd@....name>,
        John Crispin <john@...ozen.org>,
        Sean Wang <sean.wang@...iatek.com>,
        Mark Lee <Mark-MC.Lee@...iatek.com>,
        Landen Chao <landen.chao@...iatek.com>,
        Jakub Kicinski <kuba@...nel.org>,
        "David S . Miller" <davem@...emloft.net>,
        Matthias Brugger <matthias.bgg@...il.com>,
        René van Dorst <opensource@...rst.com>,
        David Woodhouse <dwmw2@...radead.org>,
        Frank Wunderlich <frank-w@...lic-files.de>
Subject: Re: [RFC PATCH net-next] net: ethernet: mediatek: support setting MTU

On Thu, Oct 29, 2020 at 02:39:15PM +0800, DENG Qingfang wrote:
> MT762x HW supports frame length up to 2048 (maximum length on GDM),
> so allow setting MTU up to 2030.
> 
> Signed-off-by: DENG Qingfang <dqfext@...il.com>
> ---
> 
> I only tested this on MT7621, no sure if it is applicable for other SoCs
> especially MT7628, which has an old IP.
> 
> ---
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 31 ++++++++++++++++++++-
>  drivers/net/ethernet/mediatek/mtk_eth_soc.h | 11 ++++++--
>  2 files changed, 38 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index 6d2d60675ffd..a0c56d9be1d5 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -353,7 +353,7 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode,
>  	/* Setup gmac */
>  	mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
>  	mcr_new = mcr_cur;
> -	mcr_new |= MAC_MCR_MAX_RX_1536 | MAC_MCR_IPG_CFG | MAC_MCR_FORCE_MODE |
> +	mcr_new |= MAC_MCR_IPG_CFG | MAC_MCR_FORCE_MODE |
>  		   MAC_MCR_BACKOFF_EN | MAC_MCR_BACKPR_EN | MAC_MCR_FORCE_LINK;

Since you no longer set MAC_MCR_MAX_RX_1536, what does the hardware
default to?

>  	/* Only update control register when needed! */
> @@ -2499,6 +2499,34 @@ static void mtk_uninit(struct net_device *dev)
>  	mtk_rx_irq_disable(eth, ~0);
>  }
>  
> +static int mtk_change_mtu(struct net_device *dev, int new_mtu)
> +{
> +	struct mtk_mac *mac = netdev_priv(dev);
> +	u32 mcr_cur, mcr_new;
> +	int length;
> +
> +	mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
> +	mcr_new = mcr_cur & ~MAC_MCR_MAX_RX_LEN_MASK;
> +	length = new_mtu + MTK_RX_ETH_HLEN;
> +
> +	if (length <= 1518)
> +		mcr_new |= MAC_MCR_MAX_RX_LEN(MAC_MCR_MAX_RX_LEN_1518);
> +	else if (length <= 1536)
> +		mcr_new |= MAC_MCR_MAX_RX_LEN(MAC_MCR_MAX_RX_LEN_1536);
> +	else if (length <= 1552)
> +		mcr_new |= MAC_MCR_MAX_RX_LEN(MAC_MCR_MAX_RX_LEN_1552);
> +	else
> +		mcr_new |= MAC_MCR_MAX_RX_LEN(MAC_MCR_MAX_RX_LEN_2048);

You should have another if here, and return -EIVAL is the user asked
for an MTU of 2049 of greater.

    Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ