netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] Misc. Bug fixes for HNS3 Ethernet Driver
@ 2017-08-18 11:31 Salil Mehta
  2017-08-18 11:31 ` [PATCH net-next 1/3] net: hns3: Fixes the missing u64_stats_fetch_begin_irq in 64-bit stats fetch Salil Mehta
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Salil Mehta @ 2017-08-18 11:31 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
  Cc: salil.mehta-hv44wF8Li93QT0dZR+AlfA,
	yisen.zhuang-hv44wF8Li93QT0dZR+AlfA,
	lipeng321-hv44wF8Li93QT0dZR+AlfA,
	dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA,
	mehta.salil.lnk-Re5JQEeQqe8AvxtiuMwx3w,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linuxarm-hv44wF8Li93QT0dZR+AlfA

This patch-set fixes various bugs reported by community.

Salil Mehta (3):
  net: hns3: Fixes the missing u64_stats_fetch_begin_irq in 64-bit stats
    fetch
  net: hns3: Fixes the static checker error warning in
    hns3_get_link_ksettings()
  net: hns3: Fixes the static check warning due to missing unsupp L3
    proto check

 .../net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 16 +++-
 .../ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c  | 85 ++++++++++++----------
 2 files changed, 60 insertions(+), 41 deletions(-)

-- 
2.7.4


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next 1/3] net: hns3: Fixes the missing u64_stats_fetch_begin_irq in 64-bit stats fetch
  2017-08-18 11:31 [PATCH net-next 0/3] Misc. Bug fixes for HNS3 Ethernet Driver Salil Mehta
@ 2017-08-18 11:31 ` Salil Mehta
  2017-08-18 11:31 ` [PATCH net-next 2/3] net: hns3: Fixes the static checker error warning in hns3_get_link_ksettings() Salil Mehta
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Salil Mehta @ 2017-08-18 11:31 UTC (permalink / raw)
  To: davem
  Cc: salil.mehta, yisen.zhuang, lipeng321, dan.carpenter,
	mehta.salil.lnk, netdev, linux-kernel, linux-rdma, linuxarm

This patch fixes the missing u64_stats_fetch_begin_irq() while trying to
atomically do 64-bit RX/TX fetch. We did not get any error during test
as our SoC is 64-bit so all of these seq/lock operations results in NOOP.

As such, this seq lock supports has been added for the sake of completion
if this code ever runs on 32-bit platform and we are trying to do 64-bit
stats fetch.

Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for
hip08 SoC")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
index 9589b7e..b12730a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
@@ -1054,6 +1054,7 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
 		/* fetch the tx stats */
 		ring = priv->ring_data[idx].ring;
 		do {
+			start = u64_stats_fetch_begin_irq(&ring->syncp);
 			tx_bytes += ring->stats.tx_bytes;
 			tx_pkts += ring->stats.tx_pkts;
 		} while (u64_stats_fetch_retry_irq(&ring->syncp, start));
@@ -1061,6 +1062,7 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
 		/* fetch the rx stats */
 		ring = priv->ring_data[idx + queue_num].ring;
 		do {
+			start = u64_stats_fetch_begin_irq(&ring->syncp);
 			rx_bytes += ring->stats.rx_bytes;
 			rx_pkts += ring->stats.rx_pkts;
 		} while (u64_stats_fetch_retry_irq(&ring->syncp, start));
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 2/3] net: hns3: Fixes the static checker error warning in hns3_get_link_ksettings()
  2017-08-18 11:31 [PATCH net-next 0/3] Misc. Bug fixes for HNS3 Ethernet Driver Salil Mehta
  2017-08-18 11:31 ` [PATCH net-next 1/3] net: hns3: Fixes the missing u64_stats_fetch_begin_irq in 64-bit stats fetch Salil Mehta
@ 2017-08-18 11:31 ` Salil Mehta
  2017-08-18 11:31 ` [PATCH net-next 3/3] net: hns3: Fixes the static check warning due to missing unsupp L3 proto check Salil Mehta
  2017-08-18 17:32 ` [PATCH net-next 0/3] Misc. Bug fixes for HNS3 Ethernet Driver David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Salil Mehta @ 2017-08-18 11:31 UTC (permalink / raw)
  To: davem
  Cc: salil.mehta, yisen.zhuang, lipeng321, dan.carpenter,
	mehta.salil.lnk, netdev, linux-kernel, linux-rdma, linuxarm

This patch fixes the static check error warning in hns3_get_link_ksettings()
function by re-arranging the code.

Fixes: 496d03e960ae ("net: hns3: Add Ethtool support to HNS3 Driver")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 .../ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c  | 85 ++++++++++++----------
 1 file changed, 48 insertions(+), 37 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
index 0ad65e4..ffc837b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
@@ -313,7 +313,7 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
 	if (!h->ae_algo || !h->ae_algo->ops)
 		return -EOPNOTSUPP;
 
-	/* 1.auto_neg&speed&duplex from cmd */
+	/* 1.auto_neg & speed & duplex from cmd */
 	if (h->ae_algo->ops->get_ksettings_an_result) {
 		h->ae_algo->ops->get_ksettings_an_result(h, &auto_neg,
 							 &speed, &duplex);
@@ -329,50 +329,61 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
 	}
 
 	/* 2.media_type get from bios parameter block */
-	if (h->ae_algo->ops->get_media_type)
+	if (h->ae_algo->ops->get_media_type) {
 		h->ae_algo->ops->get_media_type(h, &media_type);
 
-	switch (media_type) {
-	case HNAE3_MEDIA_TYPE_FIBER:
-		cmd->base.port = PORT_FIBRE;
-		supported_caps = HNS3_LM_FIBRE_BIT | HNS3_LM_AUTONEG_BIT |
-			HNS3_LM_PAUSE_BIT | HNS3_LM_1000BASET_FULL_BIT;
+		switch (media_type) {
+		case HNAE3_MEDIA_TYPE_FIBER:
+			cmd->base.port = PORT_FIBRE;
+			supported_caps = HNS3_LM_FIBRE_BIT |
+					 HNS3_LM_AUTONEG_BIT |
+					 HNS3_LM_PAUSE_BIT |
+					 HNS3_LM_1000BASET_FULL_BIT;
+
+			advertised_caps = supported_caps;
+			break;
+		case HNAE3_MEDIA_TYPE_COPPER:
+			cmd->base.port = PORT_TP;
+			supported_caps = HNS3_LM_TP_BIT |
+					 HNS3_LM_AUTONEG_BIT |
+					 HNS3_LM_PAUSE_BIT |
+					 HNS3_LM_1000BASET_FULL_BIT |
+					 HNS3_LM_100BASET_FULL_BIT |
+					 HNS3_LM_100BASET_HALF_BIT |
+					 HNS3_LM_10BASET_FULL_BIT |
+					 HNS3_LM_10BASET_HALF_BIT;
+			advertised_caps = supported_caps;
+			break;
+		case HNAE3_MEDIA_TYPE_BACKPLANE:
+			cmd->base.port = PORT_NONE;
+			supported_caps = HNS3_LM_BACKPLANE_BIT |
+					 HNS3_LM_PAUSE_BIT |
+					 HNS3_LM_AUTONEG_BIT |
+					 HNS3_LM_1000BASET_FULL_BIT |
+					 HNS3_LM_100BASET_FULL_BIT |
+					 HNS3_LM_100BASET_HALF_BIT |
+					 HNS3_LM_10BASET_FULL_BIT |
+					 HNS3_LM_10BASET_HALF_BIT;
+
+			advertised_caps = supported_caps;
+			break;
+		case HNAE3_MEDIA_TYPE_UNKNOWN:
+		default:
+			cmd->base.port = PORT_OTHER;
+			supported_caps = 0;
+			advertised_caps = 0;
+			break;
+		}
 
-		advertised_caps = supported_caps;
-		break;
-	case HNAE3_MEDIA_TYPE_COPPER:
-		cmd->base.port = PORT_TP;
-		supported_caps = HNS3_LM_TP_BIT | HNS3_LM_AUTONEG_BIT |
-			HNS3_LM_PAUSE_BIT | HNS3_LM_1000BASET_FULL_BIT |
-			HNS3_LM_100BASET_FULL_BIT | HNS3_LM_100BASET_HALF_BIT |
-			HNS3_LM_10BASET_FULL_BIT | HNS3_LM_10BASET_HALF_BIT;
-		advertised_caps = supported_caps;
-		break;
-	case HNAE3_MEDIA_TYPE_BACKPLANE:
-		cmd->base.port = PORT_NONE;
-		supported_caps = HNS3_LM_BACKPLANE_BIT | HNS3_LM_PAUSE_BIT |
-			HNS3_LM_AUTONEG_BIT | HNS3_LM_1000BASET_FULL_BIT |
-			HNS3_LM_100BASET_FULL_BIT | HNS3_LM_100BASET_HALF_BIT |
-			HNS3_LM_10BASET_FULL_BIT | HNS3_LM_10BASET_HALF_BIT;
-
-		advertised_caps = supported_caps;
-		break;
-	case HNAE3_MEDIA_TYPE_UNKNOWN:
-	default:
-		cmd->base.port = PORT_OTHER;
-		supported_caps = 0;
-		advertised_caps = 0;
-		break;
+		/* now, map driver link modes to ethtool link modes */
+		hns3_driv_to_eth_caps(supported_caps, cmd, false);
+		hns3_driv_to_eth_caps(advertised_caps, cmd, true);
 	}
 
-	/* now, map driver link modes to ethtool link modes */
-	hns3_driv_to_eth_caps(supported_caps, cmd, false);
-	hns3_driv_to_eth_caps(advertised_caps, cmd, true);
-
 	/* 3.mdix_ctrl&mdix get from phy reg */
 	if (h->ae_algo->ops->get_mdix_mode)
 		h->ae_algo->ops->get_mdix_mode(h, &cmd->base.eth_tp_mdix_ctrl,
-			&cmd->base.eth_tp_mdix);
+					       &cmd->base.eth_tp_mdix);
 	/* 4.mdio_support */
 	cmd->base.mdio_support = ETH_MDIO_SUPPORTS_C22;
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 3/3] net: hns3: Fixes the static check warning due to missing unsupp L3 proto check
  2017-08-18 11:31 [PATCH net-next 0/3] Misc. Bug fixes for HNS3 Ethernet Driver Salil Mehta
  2017-08-18 11:31 ` [PATCH net-next 1/3] net: hns3: Fixes the missing u64_stats_fetch_begin_irq in 64-bit stats fetch Salil Mehta
  2017-08-18 11:31 ` [PATCH net-next 2/3] net: hns3: Fixes the static checker error warning in hns3_get_link_ksettings() Salil Mehta
@ 2017-08-18 11:31 ` Salil Mehta
  2017-08-18 17:32 ` [PATCH net-next 0/3] Misc. Bug fixes for HNS3 Ethernet Driver David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Salil Mehta @ 2017-08-18 11:31 UTC (permalink / raw)
  To: davem
  Cc: salil.mehta, yisen.zhuang, lipeng321, dan.carpenter,
	mehta.salil.lnk, netdev, linux-kernel, linux-rdma, linuxarm

This patch fixes the static check warning due to missing handling leg of
unsupported L3 protocol type in the hns3_get_l4_protocol() function.

Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for
hip08 SoC")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
index b12730a..e731f87 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
@@ -436,8 +436,8 @@ static int hns3_set_tso(struct sk_buff *skb, u32 *paylen,
 	return 0;
 }
 
-static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto,
-				 u8 *il4_proto)
+static int hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto,
+				u8 *il4_proto)
 {
 	union {
 		struct iphdr *v4;
@@ -461,6 +461,8 @@ static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto,
 					 &l4_proto_tmp, &frag_off);
 	} else if (skb->protocol == htons(ETH_P_IP)) {
 		l4_proto_tmp = l3.v4->protocol;
+	} else {
+		return -EINVAL;
 	}
 
 	*ol4_proto = l4_proto_tmp;
@@ -468,7 +470,7 @@ static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto,
 	/* tunnel packet */
 	if (!skb->encapsulation) {
 		*il4_proto = 0;
-		return;
+		return 0;
 	}
 
 	/* find inner header point */
@@ -486,6 +488,8 @@ static void hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto,
 	}
 
 	*il4_proto = l4_proto_tmp;
+
+	return 0;
 }
 
 static void hns3_set_l2l3l4_len(struct sk_buff *skb, u8 ol4_proto,
@@ -757,7 +761,9 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
 				protocol = vlan_get_protocol(skb);
 				skb->protocol = protocol;
 			}
-			hns3_get_l4_protocol(skb, &ol4_proto, &il4_proto);
+			ret = hns3_get_l4_protocol(skb, &ol4_proto, &il4_proto);
+			if (ret)
+				return ret;
 			hns3_set_l2l3l4_len(skb, ol4_proto, il4_proto,
 					    &type_cs_vlan_tso,
 					    &ol_type_vlan_len_msec);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 0/3] Misc. Bug fixes for HNS3 Ethernet Driver
  2017-08-18 11:31 [PATCH net-next 0/3] Misc. Bug fixes for HNS3 Ethernet Driver Salil Mehta
                   ` (2 preceding siblings ...)
  2017-08-18 11:31 ` [PATCH net-next 3/3] net: hns3: Fixes the static check warning due to missing unsupp L3 proto check Salil Mehta
@ 2017-08-18 17:32 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-08-18 17:32 UTC (permalink / raw)
  To: salil.mehta
  Cc: yisen.zhuang, lipeng321, dan.carpenter, mehta.salil.lnk, netdev,
	linux-kernel, linux-rdma, linuxarm

From: Salil Mehta <salil.mehta@huawei.com>
Date: Fri, 18 Aug 2017 12:31:36 +0100

> This patch-set fixes various bugs reported by community.

Series applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-18 17:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-18 11:31 [PATCH net-next 0/3] Misc. Bug fixes for HNS3 Ethernet Driver Salil Mehta
2017-08-18 11:31 ` [PATCH net-next 1/3] net: hns3: Fixes the missing u64_stats_fetch_begin_irq in 64-bit stats fetch Salil Mehta
2017-08-18 11:31 ` [PATCH net-next 2/3] net: hns3: Fixes the static checker error warning in hns3_get_link_ksettings() Salil Mehta
2017-08-18 11:31 ` [PATCH net-next 3/3] net: hns3: Fixes the static check warning due to missing unsupp L3 proto check Salil Mehta
2017-08-18 17:32 ` [PATCH net-next 0/3] Misc. Bug fixes for HNS3 Ethernet Driver David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).