Message ID | 1483776634-13095-1-git-send-email-hock.leong.kweh@intel.com |
---|---|
State | Superseded, archived |
Delegated to: | David Miller |
Headers | show |
On Sat, Jan 7, 2017 at 10:10 AM, Kweh, Hock Leong <hock.leong.kweh@intel.com> wrote: > From: "Kweh, Hock Leong" <hock.leong.kweh@intel.com> > > There is no checking valid value of maxmtu when getting it from device tree. > This resolution added the checking condition to ensure the assignment is > made within a valid range. > changelog v4: > * add print warning message when maxmtu > max_mtu as well Yep. > * add maxmtu = JUMBO_LEN into each *_default_data() at stmmac_pci.c Yep. But see comment below. P.S. And perhaps next time send into our internal mailing list first for review. > @@ -3345,8 +3345,14 @@ int stmmac_dvr_probe(struct device *device, > ndev->max_mtu = JUMBO_LEN; > else > ndev->max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN); > - if (priv->plat->maxmtu < ndev->max_mtu) > + if ((priv->plat->maxmtu < ndev->max_mtu) && > + (priv->plat->maxmtu >= ndev->min_mtu)) > ndev->max_mtu = priv->plat->maxmtu; > + else if ((priv->plat->maxmtu < ndev->min_mtu) || > + (priv->plat->maxmtu > ndev->max_mtu)) > + netdev_warn(priv->dev, What is the difference to just 'else'? (Returning back to my initial proposal, I don't remember telling anything about 'else if' concept) > + "%s: warning: maxmtu having invalid value (%d)\n", > + __func__, priv->plat->maxmtu);
> -----Original Message----- > From: Andy Shevchenko [mailto:andy.shevchenko@gmail.com] > Sent: Saturday, January 07, 2017 8:12 AM > To: Kweh, Hock Leong <hock.leong.kweh@intel.com> > Cc: David S. Miller <davem@davemloft.net>; Joao Pinto > <Joao.Pinto@synopsys.com>; Giuseppe CAVALLARO <peppe.cavallaro@st.com>; > seraphin.bonnaffe@st.com; Jarod Wilson <jarod@redhat.com>; Alexandre > TORGUE <alexandre.torgue@gmail.com>; Joachim Eastwood > <manabian@gmail.com>; Niklas Cassel <niklas.cassel@axis.com>; Johan Hovold > <johan@kernel.org>; Pavel Machek <pavel@ucw.cz>; lars.persson@axis.com; > netdev <netdev@vger.kernel.org>; LKML <linux-kernel@vger.kernel.org> > Subject: Re: [PATCH v4] net: stmmac: fix maxmtu assignment to be within valid > range > > On Sat, Jan 7, 2017 at 10:10 AM, Kweh, Hock Leong > <hock.leong.kweh@intel.com> wrote: > > From: "Kweh, Hock Leong" <hock.leong.kweh@intel.com> > > > > There is no checking valid value of maxmtu when getting it from device tree. > > This resolution added the checking condition to ensure the assignment is > > made within a valid range. > > > changelog v4: > > * add print warning message when maxmtu > max_mtu as well > > Yep. > > > * add maxmtu = JUMBO_LEN into each *_default_data() at stmmac_pci.c > > Yep. > > But see comment below. > > P.S. And perhaps next time send into our internal mailing list first for review. > > > @@ -3345,8 +3345,14 @@ int stmmac_dvr_probe(struct device *device, > > ndev->max_mtu = JUMBO_LEN; > > else > > ndev->max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN); > > - if (priv->plat->maxmtu < ndev->max_mtu) > > + if ((priv->plat->maxmtu < ndev->max_mtu) && > > + (priv->plat->maxmtu >= ndev->min_mtu)) > > ndev->max_mtu = priv->plat->maxmtu; > > > + else if ((priv->plat->maxmtu < ndev->min_mtu) || > > + (priv->plat->maxmtu > ndev->max_mtu)) > > + netdev_warn(priv->dev, > > What is the difference to just 'else'? (Returning back to my initial > proposal, I don't remember telling anything about 'else if' concept) > When priv->plat->maxmtu == ndev->max_mtu will not be a warning message. Oh NO ... it is a valid case for priv->plat->maxmtu > ndev->max_mtu if the assignment of ndev->max_mtu is using SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN), which is < JUMBO_LEN, then priv->plat->maxmtu > ndev->max_mtu is valid. Revert back and submit V5. Thanks. > > + "%s: warning: maxmtu having invalid value (%d)\n", > > + __func__, priv->plat->maxmtu); > > -- > With Best Regards, > Andy Shevchenko
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 92ac006..f2a352f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3345,8 +3345,14 @@ int stmmac_dvr_probe(struct device *device, ndev->max_mtu = JUMBO_LEN; else ndev->max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN); - if (priv->plat->maxmtu < ndev->max_mtu) + if ((priv->plat->maxmtu < ndev->max_mtu) && + (priv->plat->maxmtu >= ndev->min_mtu)) ndev->max_mtu = priv->plat->maxmtu; + else if ((priv->plat->maxmtu < ndev->min_mtu) || + (priv->plat->maxmtu > ndev->max_mtu)) + netdev_warn(priv->dev, + "%s: warning: maxmtu having invalid value (%d)\n", + __func__, priv->plat->maxmtu); if (flow_ctrl) priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c index a283177..3da4737 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c @@ -89,6 +89,9 @@ static void stmmac_default_data(struct plat_stmmacenet_data *plat) /* Set default value for unicast filter entries */ plat->unicast_filter_entries = 1; + + /* Set the maxmtu to a default of JUMBO_LEN */ + plat->maxmtu = JUMBO_LEN; } static int quark_default_data(struct plat_stmmacenet_data *plat, @@ -126,6 +129,9 @@ static int quark_default_data(struct plat_stmmacenet_data *plat, /* Set default value for unicast filter entries */ plat->unicast_filter_entries = 1; + /* Set the maxmtu to a default of JUMBO_LEN */ + plat->maxmtu = JUMBO_LEN; + return 0; }