Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1502400 > unrolled thread

[PATCH net-next 09/15] ethernet/dlink: use core min/max MTU checking

Started byJarod Wilson <jarod@redhat.com>
First post2016-10-17 22:00 +0200
Last post2016-10-22 12:00 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH net-next 09/15] ethernet/dlink: use core min/max MTU checking Jarod Wilson <jarod@redhat.com> - 2016-10-17 22:00 +0200
    Re: [PATCH net-next 09/15] ethernet/dlink: use core min/max MTU checking Denis Kirjanov <kda@linux-powerpc.org> - 2016-10-18 15:50 +0200
      Re: [PATCH net-next 09/15] ethernet/dlink: use core min/max MTU  checking Jarod Wilson <jarod@redhat.com> - 2016-10-18 17:10 +0200
        Re: [PATCH net-next 09/15] ethernet/dlink: use core min/max MTU  checking Stefan Richter <stefanr@s5r6.in-berlin.de> - 2016-10-22 12:00 +0200

#1502400 — [PATCH net-next 09/15] ethernet/dlink: use core min/max MTU checking

FromJarod Wilson <jarod@redhat.com>
Date2016-10-17 22:00 +0200
Subject[PATCH net-next 09/15] ethernet/dlink: use core min/max MTU checking
Message-ID<stmeJ-7YZ-15@gated-at.bofh.it>
dl2k: min_mtu 68, max_mtu 1536 or 8000, depending on hardware
- Removed change_mtu, does nothing productive anymore

sundance: min_mtu 68, max_mtu 8191

CC: netdev@vger.kernel.org
CC: Denis Kirjanov <kda@linux-powerpc.org>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
---
 drivers/net/ethernet/dlink/dl2k.c     | 22 ++++------------------
 drivers/net/ethernet/dlink/sundance.c |  6 ++++--
 2 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c
index 78f1446..8c95a8a 100644
--- a/drivers/net/ethernet/dlink/dl2k.c
+++ b/drivers/net/ethernet/dlink/dl2k.c
@@ -76,7 +76,6 @@ static void rio_free_tx (struct net_device *dev, int irq);
 static void tx_error (struct net_device *dev, int tx_status);
 static int receive_packet (struct net_device *dev);
 static void rio_error (struct net_device *dev, int int_status);
-static int change_mtu (struct net_device *dev, int new_mtu);
 static void set_multicast (struct net_device *dev);
 static struct net_device_stats *get_stats (struct net_device *dev);
 static int clear_stats (struct net_device *dev);
@@ -106,7 +105,6 @@ static const struct net_device_ops netdev_ops = {
 	.ndo_set_rx_mode	= set_multicast,
 	.ndo_do_ioctl		= rio_ioctl,
 	.ndo_tx_timeout		= rio_tx_timeout,
-	.ndo_change_mtu		= change_mtu,
 };
 
 static int
@@ -230,6 +228,10 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
 #if 0
 	dev->features = NETIF_F_IP_CSUM;
 #endif
+	/* MTU range: 68 - 1536 or 8000 */
+	dev->min_mtu = ETH_MIN_MTU;
+	dev->max_mtu = np->jumbo ? MAX_JUMBO : PACKET_SIZE;
+
 	pci_set_drvdata (pdev, dev);
 
 	ring_space = pci_alloc_consistent (pdev, TX_TOTAL_SIZE, &ring_dma);
@@ -1198,22 +1200,6 @@ clear_stats (struct net_device *dev)
 	return 0;
 }
 
-
-static int
-change_mtu (struct net_device *dev, int new_mtu)
-{
-	struct netdev_private *np = netdev_priv(dev);
-	int max = (np->jumbo) ? MAX_JUMBO : 1536;
-
-	if ((new_mtu < 68) || (new_mtu > max)) {
-		return -EINVAL;
-	}
-
-	dev->mtu = new_mtu;
-
-	return 0;
-}
-
 static void
 set_multicast (struct net_device *dev)
 {
diff --git a/drivers/net/ethernet/dlink/sundance.c b/drivers/net/ethernet/dlink/sundance.c
index 79d8009..eab36ac 100644
--- a/drivers/net/ethernet/dlink/sundance.c
+++ b/drivers/net/ethernet/dlink/sundance.c
@@ -580,6 +580,10 @@ static int sundance_probe1(struct pci_dev *pdev,
 	dev->ethtool_ops = &ethtool_ops;
 	dev->watchdog_timeo = TX_TIMEOUT;
 
+	/* MTU range: 68 - 8191 */
+	dev->min_mtu = ETH_MIN_MTU;
+	dev->max_mtu = 8191;
+
 	pci_set_drvdata(pdev, dev);
 
 	i = register_netdev(dev);
@@ -713,8 +717,6 @@ static int sundance_probe1(struct pci_dev *pdev,
 
 static int change_mtu(struct net_device *dev, int new_mtu)
 {
-	if ((new_mtu < 68) || (new_mtu > 8191)) /* Set by RxDMAFrameLen */
-		return -EINVAL;
 	if (netif_running(dev))
 		return -EBUSY;
 	dev->mtu = new_mtu;
-- 
2.10.0

[toc] | [next] | [standalone]


#1503001

FromDenis Kirjanov <kda@linux-powerpc.org>
Date2016-10-18 15:50 +0200
Message-ID<stCWe-2lM-45@gated-at.bofh.it>
In reply to#1502400
On 10/17/16, Jarod Wilson <jarod@redhat.com> wrote:
> dl2k: min_mtu 68, max_mtu 1536 or 8000, depending on hardware
> - Removed change_mtu, does nothing productive anymore
>
> sundance: min_mtu 68, max_mtu 8191
>
> CC: netdev@vger.kernel.org
> CC: Denis Kirjanov <kda@linux-powerpc.org>
> Signed-off-by: Jarod Wilson <jarod@redhat.com>
> ---
>  drivers/net/ethernet/dlink/dl2k.c     | 22 ++++------------------
>  drivers/net/ethernet/dlink/sundance.c |  6 ++++--
>  2 files changed, 8 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/ethernet/dlink/dl2k.c
> b/drivers/net/ethernet/dlink/dl2k.c
> index 78f1446..8c95a8a 100644
> --- a/drivers/net/ethernet/dlink/dl2k.c
> +++ b/drivers/net/ethernet/dlink/dl2k.c
> @@ -76,7 +76,6 @@ static void rio_free_tx (struct net_device *dev, int
> irq);
>  static void tx_error (struct net_device *dev, int tx_status);
>  static int receive_packet (struct net_device *dev);
>  static void rio_error (struct net_device *dev, int int_status);
> -static int change_mtu (struct net_device *dev, int new_mtu);
>  static void set_multicast (struct net_device *dev);
>  static struct net_device_stats *get_stats (struct net_device *dev);
>  static int clear_stats (struct net_device *dev);
> @@ -106,7 +105,6 @@ static const struct net_device_ops netdev_ops = {
>  	.ndo_set_rx_mode	= set_multicast,
>  	.ndo_do_ioctl		= rio_ioctl,
>  	.ndo_tx_timeout		= rio_tx_timeout,
> -	.ndo_change_mtu		= change_mtu,
>  };
>
>  static int
> @@ -230,6 +228,10 @@ rio_probe1 (struct pci_dev *pdev, const struct
> pci_device_id *ent)
>  #if 0
>  	dev->features = NETIF_F_IP_CSUM;
>  #endif
> +	/* MTU range: 68 - 1536 or 8000 */
> +	dev->min_mtu = ETH_MIN_MTU;
> +	dev->max_mtu = np->jumbo ? MAX_JUMBO : PACKET_SIZE;
> +
>  	pci_set_drvdata (pdev, dev);
>
>  	ring_space = pci_alloc_consistent (pdev, TX_TOTAL_SIZE, &ring_dma);
> @@ -1198,22 +1200,6 @@ clear_stats (struct net_device *dev)
>  	return 0;
>  }
>
> -
> -static int
> -change_mtu (struct net_device *dev, int new_mtu)
> -{
> -	struct netdev_private *np = netdev_priv(dev);
> -	int max = (np->jumbo) ? MAX_JUMBO : 1536;
> -
> -	if ((new_mtu < 68) || (new_mtu > max)) {
> -		return -EINVAL;
> -	}
> -
> -	dev->mtu = new_mtu;
> -
> -	return 0;
> -}
> -
>  static void
>  set_multicast (struct net_device *dev)
>  {
> diff --git a/drivers/net/ethernet/dlink/sundance.c
> b/drivers/net/ethernet/dlink/sundance.c
> index 79d8009..eab36ac 100644
> --- a/drivers/net/ethernet/dlink/sundance.c
> +++ b/drivers/net/ethernet/dlink/sundance.c
> @@ -580,6 +580,10 @@ static int sundance_probe1(struct pci_dev *pdev,
>  	dev->ethtool_ops = &ethtool_ops;
>  	dev->watchdog_timeo = TX_TIMEOUT;
>
> +	/* MTU range: 68 - 8191 */
> +	dev->min_mtu = ETH_MIN_MTU;
> +	dev->max_mtu = 8191;
> +
ICPlus datasheet defines the max frame size like 0x1514 or 0x4491
based on the RcvLargeFrames bit in the MACCtrl0 register

>  	pci_set_drvdata(pdev, dev);
>
>  	i = register_netdev(dev);
> @@ -713,8 +717,6 @@ static int sundance_probe1(struct pci_dev *pdev,
>
>  static int change_mtu(struct net_device *dev, int new_mtu)
>  {
> -	if ((new_mtu < 68) || (new_mtu > 8191)) /* Set by RxDMAFrameLen */
> -		return -EINVAL;
>  	if (netif_running(dev))
>  		return -EBUSY;
>  	dev->mtu = new_mtu;
> --
> 2.10.0
>
>

[toc] | [prev] | [next] | [standalone]


#1503089 — Re: [PATCH net-next 09/15] ethernet/dlink: use core min/max MTU checking

FromJarod Wilson <jarod@redhat.com>
Date2016-10-18 17:10 +0200
SubjectRe: [PATCH net-next 09/15] ethernet/dlink: use core min/max MTU checking
Message-ID<stEbE-3pl-41@gated-at.bofh.it>
In reply to#1503001
On Tue, Oct 18, 2016 at 04:45:51PM +0300, Denis Kirjanov wrote:
> On 10/17/16, Jarod Wilson <jarod@redhat.com> wrote:
> > dl2k: min_mtu 68, max_mtu 1536 or 8000, depending on hardware
> > - Removed change_mtu, does nothing productive anymore
> >
> > sundance: min_mtu 68, max_mtu 8191
> >
> > CC: netdev@vger.kernel.org
> > CC: Denis Kirjanov <kda@linux-powerpc.org>
> > Signed-off-by: Jarod Wilson <jarod@redhat.com>
> > ---
> >  drivers/net/ethernet/dlink/dl2k.c     | 22 ++++------------------
> >  drivers/net/ethernet/dlink/sundance.c |  6 ++++--
> >  2 files changed, 8 insertions(+), 20 deletions(-)
...
> > diff --git a/drivers/net/ethernet/dlink/sundance.c
> > b/drivers/net/ethernet/dlink/sundance.c
> > index 79d8009..eab36ac 100644
> > --- a/drivers/net/ethernet/dlink/sundance.c
> > +++ b/drivers/net/ethernet/dlink/sundance.c
> > @@ -580,6 +580,10 @@ static int sundance_probe1(struct pci_dev *pdev,
> >  	dev->ethtool_ops = &ethtool_ops;
> >  	dev->watchdog_timeo = TX_TIMEOUT;
> >
> > +	/* MTU range: 68 - 8191 */
> > +	dev->min_mtu = ETH_MIN_MTU;
> > +	dev->max_mtu = 8191;
> > +
> ICPlus datasheet defines the max frame size like 0x1514 or 0x4491
> based on the RcvLargeFrames bit in the MACCtrl0 register

I do anticipate this patchset might bring to light some inaccuracies in
min/max mtu values currently implemented in various drivers, but for the
moment, I'm going for 100% identical behavior with what's currently in the
driver, and if you'll look down below...

> >  	pci_set_drvdata(pdev, dev);
> >
> >  	i = register_netdev(dev);
> > @@ -713,8 +717,6 @@ static int sundance_probe1(struct pci_dev *pdev,
> >
> >  static int change_mtu(struct net_device *dev, int new_mtu)
> >  {
> > -	if ((new_mtu < 68) || (new_mtu > 8191)) /* Set by RxDMAFrameLen */

                                         ^^^^
The 8191 was simply transplanted from right here. I think altering the
value should be the subject of a separate patch.

-- 
Jarod Wilson
jarod@redhat.com

[toc] | [prev] | [next] | [standalone]


#1506484 — Re: [PATCH net-next 09/15] ethernet/dlink: use core min/max MTU checking

FromStefan Richter <stefanr@s5r6.in-berlin.de>
Date2016-10-22 12:00 +0200
SubjectRe: [PATCH net-next 09/15] ethernet/dlink: use core min/max MTU checking
Message-ID<sv1fQ-1I3-19@gated-at.bofh.it>
In reply to#1503089
On Oct 18 Jarod Wilson wrote:
> On Tue, Oct 18, 2016 at 04:45:51PM +0300, Denis Kirjanov wrote:
> > On 10/17/16, Jarod Wilson <jarod@redhat.com> wrote:
[...]
> > > --- a/drivers/net/ethernet/dlink/sundance.c
> > > +++ b/drivers/net/ethernet/dlink/sundance.c
> > > @@ -580,6 +580,10 @@ static int sundance_probe1(struct pci_dev *pdev,
> > >  	dev->ethtool_ops = &ethtool_ops;
> > >  	dev->watchdog_timeo = TX_TIMEOUT;
> > >
> > > +	/* MTU range: 68 - 8191 */
> > > +	dev->min_mtu = ETH_MIN_MTU;
> > > +	dev->max_mtu = 8191;
> > > +  
> > ICPlus datasheet defines the max frame size like 0x1514 or 0x4491
> > based on the RcvLargeFrames bit in the MACCtrl0 register  
> 
> I do anticipate this patchset might bring to light some inaccuracies in
> min/max mtu values currently implemented in various drivers, but for the
> moment, I'm going for 100% identical behavior with what's currently in the
> driver, and if you'll look down below...
> 
> > >  	pci_set_drvdata(pdev, dev);
> > >
> > >  	i = register_netdev(dev);
> > > @@ -713,8 +717,6 @@ static int sundance_probe1(struct pci_dev *pdev,
> > >
> > >  static int change_mtu(struct net_device *dev, int new_mtu)
> > >  {
> > > -	if ((new_mtu < 68) || (new_mtu > 8191)) /* Set by RxDMAFrameLen */  
> 
>                                          ^^^^
> The 8191 was simply transplanted from right here. I think altering the
> value should be the subject of a separate patch.

You transplanted the value but dropped the comment.  Though Denis' reply
sounds like the comment should have been /* FIXME, set by RxDMAFrameLen */.
-- 
Stefan Richter
-======----- =-=- =-==-
http://arcgraph.de/sr/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web