* [PATCH V3 net-next] net: hns3: Add support to change MTU in HNS3 hardware
@ 2017-08-21 10:12 Salil Mehta
2017-08-21 10:32 ` Leon Romanovsky
2017-08-21 14:29 ` Andrew Lunn
0 siblings, 2 replies; 7+ messages in thread
From: Salil Mehta @ 2017-08-21 10:12 UTC (permalink / raw)
To: davem
Cc: salil.mehta, yisen.zhuang, lipeng321, mehta.salil.lnk, netdev,
linux-kernel, linux-rdma, linuxarm
This patch adds the following support to the HNS3 driver:
1. Support to change the Maximum Transmission Unit of a
of a port in the HNS NIC hardware.
2. Initializes the supported MTU range for the netdevice.
Signed-off-by: lipeng <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
PATCH V3: Addressed some minor comments Leon Romanovsky
1. https://lkml.org/lkml/2017/8/20/27
PATCH V2: Addresses comments given by Andrew Lunn
1. https://lkml.org/lkml/2017/8/18/282
PATCH V1: Initial Submit
---
.../net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 36 ++++++++++++++++++++++
.../net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h | 1 +
2 files changed, 37 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
index e731f87..c087a9f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
@@ -1278,11 +1278,44 @@ static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan,
return ret;
}
+static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu)
+{
+ struct hns3_nic_priv *priv = netdev_priv(netdev);
+ struct hnae3_handle *h = priv->ae_handle;
+ bool if_running = netif_running(netdev);
+ int ret;
+
+ if (!h->ae_algo->ops->set_mtu)
+ return -ENOTSUPP;
+
+ /* if this was called with netdev up then bring netdevice down */
+ if (if_running) {
+ (void)hns3_nic_net_stop(netdev);
+ msleep(100);
+ }
+
+ ret = h->ae_algo->ops->set_mtu(h, new_mtu);
+ if (ret) {
+ netdev_err(netdev, "failed to change MTU in hardware %d\n",
+ ret);
+ return ret;
+ }
+
+ /* if the netdev was running earlier, bring it up again */
+ if (if_running) {
+ if (hns3_nic_net_open(netdev))
+ ret = -EINVAL;
+ }
+
+ return ret;
+}
+
static const struct net_device_ops hns3_nic_netdev_ops = {
.ndo_open = hns3_nic_net_open,
.ndo_stop = hns3_nic_net_stop,
.ndo_start_xmit = hns3_nic_net_xmit,
.ndo_set_mac_address = hns3_nic_net_set_mac_address,
+ .ndo_change_mtu = hns3_nic_change_mtu,
.ndo_set_features = hns3_nic_set_features,
.ndo_get_stats64 = hns3_nic_get_stats64,
.ndo_setup_tc = hns3_nic_setup_tc,
@@ -2752,6 +2785,9 @@ static int hns3_client_init(struct hnae3_handle *handle)
goto out_reg_netdev_fail;
}
+ /* MTU range: (ETH_MIN_MTU(kernel default) - 9706) */
+ netdev->max_mtu = HNS3_MAX_MTU - (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN);
+
return ret;
out_reg_netdev_fail:
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h
index a6e8f15..7e87461 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h
@@ -76,6 +76,7 @@ enum hns3_nic_state {
#define HNS3_RING_NAME_LEN 16
#define HNS3_BUFFER_SIZE_2048 2048
#define HNS3_RING_MAX_PENDING 32768
+#define HNS3_MAX_MTU 9728
#define HNS3_BD_SIZE_512_TYPE 0
#define HNS3_BD_SIZE_1024_TYPE 1
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH V3 net-next] net: hns3: Add support to change MTU in HNS3 hardware
2017-08-21 10:12 [PATCH V3 net-next] net: hns3: Add support to change MTU in HNS3 hardware Salil Mehta
@ 2017-08-21 10:32 ` Leon Romanovsky
2017-08-21 10:43 ` Salil Mehta
2017-08-21 14:29 ` Andrew Lunn
1 sibling, 1 reply; 7+ messages in thread
From: Leon Romanovsky @ 2017-08-21 10:32 UTC (permalink / raw)
To: Salil Mehta
Cc: davem, yisen.zhuang, lipeng321, mehta.salil.lnk, netdev,
linux-kernel, linux-rdma, linuxarm
[-- Attachment #1: Type: text/plain, Size: 3725 bytes --]
On Mon, Aug 21, 2017 at 11:12:23AM +0100, Salil Mehta wrote:
> This patch adds the following support to the HNS3 driver:
> 1. Support to change the Maximum Transmission Unit of a
> of a port in the HNS NIC hardware.
> 2. Initializes the supported MTU range for the netdevice.
>
> Signed-off-by: lipeng <lipeng321@huawei.com>
> Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
> ---
> PATCH V3: Addressed some minor comments Leon Romanovsky
> 1. https://lkml.org/lkml/2017/8/20/27
> PATCH V2: Addresses comments given by Andrew Lunn
> 1. https://lkml.org/lkml/2017/8/18/282
> PATCH V1: Initial Submit
> ---
> .../net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 36 ++++++++++++++++++++++
> .../net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h | 1 +
> 2 files changed, 37 insertions(+)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
> index e731f87..c087a9f 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
> @@ -1278,11 +1278,44 @@ static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan,
> return ret;
> }
>
> +static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu)
> +{
> + struct hns3_nic_priv *priv = netdev_priv(netdev);
> + struct hnae3_handle *h = priv->ae_handle;
> + bool if_running = netif_running(netdev);
> + int ret;
> +
> + if (!h->ae_algo->ops->set_mtu)
> + return -ENOTSUPP;
Sorry for not spotting this before, but it should be -EOPNOTSUPP and not -ENOTSUPP.
> +
> + /* if this was called with netdev up then bring netdevice down */
> + if (if_running) {
> + (void)hns3_nic_net_stop(netdev);
> + msleep(100);
> + }
> +
> + ret = h->ae_algo->ops->set_mtu(h, new_mtu);
> + if (ret) {
> + netdev_err(netdev, "failed to change MTU in hardware %d\n",
> + ret);
> + return ret;
> + }
> +
> + /* if the netdev was running earlier, bring it up again */
> + if (if_running) {
> + if (hns3_nic_net_open(netdev))
> + ret = -EINVAL;
> + }
Anyway, you will resubmit because of wrong error code.
if (if_running && hns3_nic_net_open(netdev))
ret = -EINVAL
Thanks
> +
> + return ret;
> +}
> +
> static const struct net_device_ops hns3_nic_netdev_ops = {
> .ndo_open = hns3_nic_net_open,
> .ndo_stop = hns3_nic_net_stop,
> .ndo_start_xmit = hns3_nic_net_xmit,
> .ndo_set_mac_address = hns3_nic_net_set_mac_address,
> + .ndo_change_mtu = hns3_nic_change_mtu,
> .ndo_set_features = hns3_nic_set_features,
> .ndo_get_stats64 = hns3_nic_get_stats64,
> .ndo_setup_tc = hns3_nic_setup_tc,
> @@ -2752,6 +2785,9 @@ static int hns3_client_init(struct hnae3_handle *handle)
> goto out_reg_netdev_fail;
> }
>
> + /* MTU range: (ETH_MIN_MTU(kernel default) - 9706) */
> + netdev->max_mtu = HNS3_MAX_MTU - (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN);
> +
> return ret;
>
> out_reg_netdev_fail:
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h
> index a6e8f15..7e87461 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h
> @@ -76,6 +76,7 @@ enum hns3_nic_state {
> #define HNS3_RING_NAME_LEN 16
> #define HNS3_BUFFER_SIZE_2048 2048
> #define HNS3_RING_MAX_PENDING 32768
> +#define HNS3_MAX_MTU 9728
>
> #define HNS3_BD_SIZE_512_TYPE 0
> #define HNS3_BD_SIZE_1024_TYPE 1
> --
> 2.7.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread* RE: [PATCH V3 net-next] net: hns3: Add support to change MTU in HNS3 hardware
2017-08-21 10:32 ` Leon Romanovsky
@ 2017-08-21 10:43 ` Salil Mehta
0 siblings, 0 replies; 7+ messages in thread
From: Salil Mehta @ 2017-08-21 10:43 UTC (permalink / raw)
To: Leon Romanovsky
Cc: davem@davemloft.net, Zhuangyuzeng (Yisen), lipeng (Y),
mehta.salil.lnk@gmail.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org,
Linuxarm
Hi Leon,
-----Original Message-----
> From: Leon Romanovsky [mailto:leon@kernel.org]
> Sent: Monday, August 21, 2017 11:32 AM
> To: Salil Mehta
> Cc: davem@davemloft.net; Zhuangyuzeng (Yisen); lipeng (Y);
> mehta.salil.lnk@gmail.com; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; linux-rdma@vger.kernel.org; Linuxarm
> Subject: Re: [PATCH V3 net-next] net: hns3: Add support to change MTU
> in HNS3 hardware
>
> On Mon, Aug 21, 2017 at 11:12:23AM +0100, Salil Mehta wrote:
> > This patch adds the following support to the HNS3 driver:
> > 1. Support to change the Maximum Transmission Unit of a
> > of a port in the HNS NIC hardware.
Typo-->Will also delete duplicate 'of a'
> > 2. Initializes the supported MTU range for the netdevice.
> >
> > Signed-off-by: lipeng <lipeng321@huawei.com>
> > Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
> > ---
> > PATCH V3: Addressed some minor comments Leon Romanovsky
> > 1. https://lkml.org/lkml/2017/8/20/27
> > PATCH V2: Addresses comments given by Andrew Lunn
> > 1. https://lkml.org/lkml/2017/8/18/282
> > PATCH V1: Initial Submit
> > ---
> > .../net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 36
> ++++++++++++++++++++++
> > .../net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h | 1 +
> > 2 files changed, 37 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
> b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
> > index e731f87..c087a9f 100644
> > --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
> > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
> > @@ -1278,11 +1278,44 @@ static int hns3_ndo_set_vf_vlan(struct
> net_device *netdev, int vf, u16 vlan,
> > return ret;
> > }
> >
> > +static int hns3_nic_change_mtu(struct net_device *netdev, int
> new_mtu)
> > +{
> > + struct hns3_nic_priv *priv = netdev_priv(netdev);
> > + struct hnae3_handle *h = priv->ae_handle;
> > + bool if_running = netif_running(netdev);
> > + int ret;
> > +
> > + if (!h->ae_algo->ops->set_mtu)
> > + return -ENOTSUPP;
>
> Sorry for not spotting this before, but it should be -EOPNOTSUPP and
> not -ENOTSUPP.
Yes, Maybe I should have seen it earlier as well :(
I Will rectify this.
Thanks
>
> > +
> > + /* if this was called with netdev up then bring netdevice down */
> > + if (if_running) {
> > + (void)hns3_nic_net_stop(netdev);
> > + msleep(100);
> > + }
> > +
> > + ret = h->ae_algo->ops->set_mtu(h, new_mtu);
> > + if (ret) {
> > + netdev_err(netdev, "failed to change MTU in hardware %d\n",
> > + ret);
> > + return ret;
> > + }
> > +
> > + /* if the netdev was running earlier, bring it up again */
> > + if (if_running) {
> > + if (hns3_nic_net_open(netdev))
> > + ret = -EINVAL;
> > + }
>
> Anyway, you will resubmit because of wrong error code.
> if (if_running && hns3_nic_net_open(netdev))
> ret = -EINVAL
>
> Thanks
>
> > +
> > + return ret;
> > +}
> > +
> > static const struct net_device_ops hns3_nic_netdev_ops = {
> > .ndo_open = hns3_nic_net_open,
> > .ndo_stop = hns3_nic_net_stop,
> > .ndo_start_xmit = hns3_nic_net_xmit,
> > .ndo_set_mac_address = hns3_nic_net_set_mac_address,
> > + .ndo_change_mtu = hns3_nic_change_mtu,
> > .ndo_set_features = hns3_nic_set_features,
> > .ndo_get_stats64 = hns3_nic_get_stats64,
> > .ndo_setup_tc = hns3_nic_setup_tc,
> > @@ -2752,6 +2785,9 @@ static int hns3_client_init(struct hnae3_handle
> *handle)
> > goto out_reg_netdev_fail;
> > }
> >
> > + /* MTU range: (ETH_MIN_MTU(kernel default) - 9706) */
> > + netdev->max_mtu = HNS3_MAX_MTU - (ETH_HLEN + ETH_FCS_LEN +
> VLAN_HLEN);
> > +
> > return ret;
> >
> > out_reg_netdev_fail:
> > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h
> b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h
> > index a6e8f15..7e87461 100644
> > --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h
> > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h
> > @@ -76,6 +76,7 @@ enum hns3_nic_state {
> > #define HNS3_RING_NAME_LEN 16
> > #define HNS3_BUFFER_SIZE_2048 2048
> > #define HNS3_RING_MAX_PENDING 32768
> > +#define HNS3_MAX_MTU 9728
> >
> > #define HNS3_BD_SIZE_512_TYPE 0
> > #define HNS3_BD_SIZE_1024_TYPE 1
> > --
> > 2.7.4
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-rdma"
> in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH V3 net-next] net: hns3: Add support to change MTU in HNS3 hardware
2017-08-21 10:12 [PATCH V3 net-next] net: hns3: Add support to change MTU in HNS3 hardware Salil Mehta
2017-08-21 10:32 ` Leon Romanovsky
@ 2017-08-21 14:29 ` Andrew Lunn
[not found] ` <20170821142939.GG1703-g2DYL2Zd6BY@public.gmane.org>
1 sibling, 1 reply; 7+ messages in thread
From: Andrew Lunn @ 2017-08-21 14:29 UTC (permalink / raw)
To: Salil Mehta
Cc: davem, yisen.zhuang, lipeng321, mehta.salil.lnk, netdev,
linux-kernel, linux-rdma, linuxarm
On Mon, Aug 21, 2017 at 11:12:23AM +0100, Salil Mehta wrote:
> This patch adds the following support to the HNS3 driver:
> 1. Support to change the Maximum Transmission Unit of a
> of a port in the HNS NIC hardware.
> 2. Initializes the supported MTU range for the netdevice.
>
> Signed-off-by: lipeng <lipeng321@huawei.com>
> Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Hi Salil
Apart from Leon comments.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-08-21 15:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-21 10:12 [PATCH V3 net-next] net: hns3: Add support to change MTU in HNS3 hardware Salil Mehta
2017-08-21 10:32 ` Leon Romanovsky
2017-08-21 10:43 ` Salil Mehta
2017-08-21 14:29 ` Andrew Lunn
[not found] ` <20170821142939.GG1703-g2DYL2Zd6BY@public.gmane.org>
2017-08-21 14:32 ` Salil Mehta
[not found] ` <F4CC6FACFEB3C54C9141D49AD221F7F93B875655-WFPaWmAhWqtUuCJht5byYAK1hpo4iccwjNknBlVQO8k@public.gmane.org>
2017-08-21 14:47 ` Leon Romanovsky
[not found] ` <20170821144741.GN1724-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-08-21 15:05 ` Salil Mehta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox