All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver
@ 2018-01-05 10:18 Peng Li
  2018-01-05 10:18 ` [PATCH net-next 01/20] net: hns3: Add ethtool interface for vlan filter Peng Li
                   ` (20 more replies)
  0 siblings, 21 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

This patchset adds some new features support and fixes some bugs:
[Patch 1/20] adds support to enable/disable vlan filter with ethtool
[Patch 2/20] disables VFs change rxvlan offload status
[Patch 3/20 - 13/120 fix bugs and refine some codes for packet
statistics, support query with both ifconfig and ethtool.
[Patch 14/20 - 20/20] fix some other bugs.

Fuyun Liang (5):
  net: hns3: fix for updating fc_mode_last_time
  net: hns3: fix for setting MTU
  net: hns3: fix for changing MTU
  net: hns3: add MTU initialization for hardware
  net: hns3: fix for not setting pause parameters

Jian Shen (14):
  net: hns3: Add ethtool interface for vlan filter
  net: hns3: Disable VFs change rxvlan offload status
  net: hns3: Unify the strings display of packet statistics
  net: hns3: Fix spelling errors
  net: hns3: Remove repeat statistic of rx_errors
  net: hns3: Modify the update period of packet statistics
  net: hns3: Mask the packet statistics query when NIC is down
  net: hns3: Fix an error of total drop packet statistics
  net: hns3: Fix a loop index error of tqp statistics query
  net: hns3: Fix an error macro definition of HNS3_TQP_STAT
  net: hns3: Remove a useless member of struct hns3_stats
  net: hns3: Add packet statistics of netdev
  net: hns3: Fix a response data read error of tqp statistics query
  net: hns3: Add more packet size statisctics

Peng Li (1):
  net: hns3: remove redundant semicolon

 drivers/net/ethernet/hisilicon/hns3/hnae3.h        |   3 +
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c    |  38 +++-
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 148 ++++++++++---
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h |   2 -
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c    | 232 +++++++++++++++------
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h    |  59 ++++--
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c  |  58 +++++-
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h  |  11 +
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c  |  10 +-
 9 files changed, 431 insertions(+), 130 deletions(-)

-- 
1.9.1

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

* [PATCH net-next 01/20] net: hns3: Add ethtool interface for vlan filter
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 02/20] net: hns3: Disable VFs change rxvlan offload status Peng Li
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

This patch adds vlan filter enable switch to
support ethtool -K ethX rx-vlan-filter on/off.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hnae3.h             |  3 +++
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c         | 11 ++++++++++-
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 14 ++++++++++++--
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
index 82e9a80..adec88d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h
@@ -274,6 +274,8 @@ struct hnae3_ae_dev {
  *   Get firmware version
  * get_mdix_mode()
  *   Get media typr of phy
+ * enable_vlan_filter()
+ *   Enable vlan filter
  * set_vlan_filter()
  *   Set vlan filter config of Ports
  * set_vf_vlan_filter()
@@ -382,6 +384,7 @@ struct hnae3_ae_ops {
 	void (*get_mdix_mode)(struct hnae3_handle *handle,
 			      u8 *tp_mdix_ctrl, u8 *tp_mdix);
 
+	void (*enable_vlan_filter)(struct hnae3_handle *handle, bool enable);
 	int (*set_vlan_filter)(struct hnae3_handle *handle, __be16 proto,
 			       u16 vlan_id, bool is_kill);
 	int (*set_vf_vlan_filter)(struct hnae3_handle *handle, int vfid,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 320ae88..8e37689 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1101,6 +1101,11 @@ static int hns3_nic_set_features(struct net_device *netdev,
 		priv->ops.maybe_stop_tx = hns3_nic_maybe_stop_tx;
 	}
 
+	if (features & NETIF_F_HW_VLAN_CTAG_FILTER)
+		h->ae_algo->ops->enable_vlan_filter(h, true);
+	else
+		h->ae_algo->ops->enable_vlan_filter(h, false);
+
 	changed = netdev->features ^ features;
 	if (changed & NETIF_F_HW_VLAN_CTAG_RX) {
 		if (features & NETIF_F_HW_VLAN_CTAG_RX)
@@ -1549,6 +1554,8 @@ static void hns3_remove(struct pci_dev *pdev)
 /* set default feature to hns3 */
 static void hns3_set_default_feature(struct net_device *netdev)
 {
+	struct hnae3_handle *h = hns3_get_handle(netdev);
+
 	netdev->priv_flags |= IFF_UNICAST_FLT;
 
 	netdev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
@@ -1577,12 +1584,14 @@ static void hns3_set_default_feature(struct net_device *netdev)
 		NETIF_F_GSO_UDP_TUNNEL_CSUM;
 
 	netdev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
-		NETIF_F_HW_VLAN_CTAG_FILTER |
 		NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
 		NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_GSO |
 		NETIF_F_GRO | NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_GSO_GRE |
 		NETIF_F_GSO_GRE_CSUM | NETIF_F_GSO_UDP_TUNNEL |
 		NETIF_F_GSO_UDP_TUNNEL_CSUM;
+
+	if (!(h->flags & HNAE3_SUPPORT_VF))
+		netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
 }
 
 static int hns3_alloc_buffer(struct hns3_enet_ring *ring,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 0874acf..93fe870 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -4241,6 +4241,17 @@ static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type,
 	return 0;
 }
 
+#define HCLGE_FILTER_TYPE_VF		0
+#define HCLGE_FILTER_TYPE_PORT		1
+
+static void hclge_enable_vlan_filter(struct hnae3_handle *handle, bool enable)
+{
+	struct hclge_vport *vport = hclge_get_vport(handle);
+	struct hclge_dev *hdev = vport->back;
+
+	hclge_set_vlan_filter_ctrl(hdev, HCLGE_FILTER_TYPE_VF, enable);
+}
+
 int hclge_set_vf_vlan_common(struct hclge_dev *hdev, int vfid,
 			     bool is_kill, u16 vlan, u8 qos, __be16 proto)
 {
@@ -4469,8 +4480,6 @@ static int hclge_set_vlan_protocol_type(struct hclge_dev *hdev)
 
 static int hclge_init_vlan_config(struct hclge_dev *hdev)
 {
-#define HCLGE_FILTER_TYPE_VF		0
-#define HCLGE_FILTER_TYPE_PORT		1
 #define HCLGE_DEF_VLAN_TYPE		0x8100
 
 	struct hnae3_handle *handle;
@@ -5482,6 +5491,7 @@ static int hclge_set_channels(struct hnae3_handle *handle, u32 new_tqps_num)
 	.get_sset_count = hclge_get_sset_count,
 	.get_fw_version = hclge_get_fw_version,
 	.get_mdix_mode = hclge_get_mdix_mode,
+	.enable_vlan_filter = hclge_enable_vlan_filter,
 	.set_vlan_filter = hclge_set_port_vlan_filter,
 	.set_vf_vlan_filter = hclge_set_vf_vlan_filter,
 	.enable_hw_strip_rxvtag = hclge_en_hw_strip_rxvtag,
-- 
1.9.1

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

* [PATCH net-next 02/20] net: hns3: Disable VFs change rxvlan offload status
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
  2018-01-05 10:18 ` [PATCH net-next 01/20] net: hns3: Add ethtool interface for vlan filter Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 03/20] net: hns3: Unify the strings display of packet statistics Peng Li
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

Rxvlan offload status can only be changed by PF. Initialize
the value of NETIF_F_HW_VLAN_CTAG_RX bit of hw_features for
VFS to false, make sure user can't be able to change it.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 8e37689..565d85d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1584,14 +1584,15 @@ static void hns3_set_default_feature(struct net_device *netdev)
 		NETIF_F_GSO_UDP_TUNNEL_CSUM;
 
 	netdev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
-		NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
+		NETIF_F_HW_VLAN_CTAG_TX |
 		NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_GSO |
 		NETIF_F_GRO | NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_GSO_GRE |
 		NETIF_F_GSO_GRE_CSUM | NETIF_F_GSO_UDP_TUNNEL |
 		NETIF_F_GSO_UDP_TUNNEL_CSUM;
 
 	if (!(h->flags & HNAE3_SUPPORT_VF))
-		netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
+		netdev->hw_features |=
+			NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_CTAG_RX;
 }
 
 static int hns3_alloc_buffer(struct hns3_enet_ring *ring,
-- 
1.9.1

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

* [PATCH net-next 03/20] net: hns3: Unify the strings display of packet statistics
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
  2018-01-05 10:18 ` [PATCH net-next 01/20] net: hns3: Add ethtool interface for vlan filter Peng Li
  2018-01-05 10:18 ` [PATCH net-next 02/20] net: hns3: Disable VFs change rxvlan offload status Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 04/20] net: hns3: Fix spelling errors Peng Li
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

Some members of packet statistics are named in different styles.
This patch unifies them with new internal name rules, the main
modification are below:
trans --> tx
rcv --> rx
rcb_q%d_tx -->  txq#%d
rcb_q%d_rx -->  rxq#%d
sw_err_cnt(tx side) --> tx_dropped
sw_err_cnt(rx side) --> rx_dropped
pkts --> packets
tx_err_cnt --> errors
rx_err_cnt --> errors

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 51 ++++++++++----------
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c    | 56 +++++++++++-----------
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h    | 24 +++++-----
 .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c  |  4 +-
 4 files changed, 69 insertions(+), 66 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 379c01d..c96ef40 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -28,13 +28,13 @@ struct hns3_stats {
 
 static const struct hns3_stats hns3_txq_stats[] = {
 	/* Tx per-queue statistics */
-	HNS3_TQP_STAT("tx_io_err_cnt", io_err_cnt),
-	HNS3_TQP_STAT("tx_sw_err_cnt", sw_err_cnt),
-	HNS3_TQP_STAT("tx_seg_pkt_cnt", seg_pkt_cnt),
-	HNS3_TQP_STAT("tx_pkts", tx_pkts),
-	HNS3_TQP_STAT("tx_bytes", tx_bytes),
-	HNS3_TQP_STAT("tx_err_cnt", tx_err_cnt),
-	HNS3_TQP_STAT("tx_restart_queue", restart_queue),
+	HNS3_TQP_STAT("io_err_cnt", io_err_cnt),
+	HNS3_TQP_STAT("tx_dropped", sw_err_cnt),
+	HNS3_TQP_STAT("seg_pkt_cnt", seg_pkt_cnt),
+	HNS3_TQP_STAT("packets", tx_pkts),
+	HNS3_TQP_STAT("bytes", tx_bytes),
+	HNS3_TQP_STAT("errors", tx_err_cnt),
+	HNS3_TQP_STAT("tx_wake", restart_queue),
 	HNS3_TQP_STAT("tx_busy", tx_busy),
 };
 
@@ -42,18 +42,18 @@ struct hns3_stats {
 
 static const struct hns3_stats hns3_rxq_stats[] = {
 	/* Rx per-queue statistics */
-	HNS3_TQP_STAT("rx_io_err_cnt", io_err_cnt),
-	HNS3_TQP_STAT("rx_sw_err_cnt", sw_err_cnt),
-	HNS3_TQP_STAT("rx_seg_pkt_cnt", seg_pkt_cnt),
-	HNS3_TQP_STAT("rx_pkts", rx_pkts),
-	HNS3_TQP_STAT("rx_bytes", rx_bytes),
-	HNS3_TQP_STAT("rx_err_cnt", rx_err_cnt),
-	HNS3_TQP_STAT("rx_reuse_pg_cnt", reuse_pg_cnt),
-	HNS3_TQP_STAT("rx_err_pkt_len", err_pkt_len),
-	HNS3_TQP_STAT("rx_non_vld_descs", non_vld_descs),
-	HNS3_TQP_STAT("rx_err_bd_num", err_bd_num),
-	HNS3_TQP_STAT("rx_l2_err", l2_err),
-	HNS3_TQP_STAT("rx_l3l4_csum_err", l3l4_csum_err),
+	HNS3_TQP_STAT("io_err_cnt", io_err_cnt),
+	HNS3_TQP_STAT("rx_dropped", sw_err_cnt),
+	HNS3_TQP_STAT("seg_pkt_cnt", seg_pkt_cnt),
+	HNS3_TQP_STAT("packets", rx_pkts),
+	HNS3_TQP_STAT("bytes", rx_bytes),
+	HNS3_TQP_STAT("errors", rx_err_cnt),
+	HNS3_TQP_STAT("reuse_pg_cnt", reuse_pg_cnt),
+	HNS3_TQP_STAT("err_pkt_len", err_pkt_len),
+	HNS3_TQP_STAT("non_vld_descs", non_vld_descs),
+	HNS3_TQP_STAT("err_bd_num", err_bd_num),
+	HNS3_TQP_STAT("l2_err", l2_err),
+	HNS3_TQP_STAT("l3l4_csum_err", l3l4_csum_err),
 };
 
 #define HNS3_RXQ_STATS_COUNT ARRAY_SIZE(hns3_rxq_stats)
@@ -389,9 +389,9 @@ static int hns3_get_sset_count(struct net_device *netdev, int stringset)
 }
 
 static void *hns3_update_strings(u8 *data, const struct hns3_stats *stats,
-				 u32 stat_count, u32 num_tqps)
+		u32 stat_count, u32 num_tqps, const char *prefix)
 {
-#define MAX_PREFIX_SIZE (8 + 4)
+#define MAX_PREFIX_SIZE (6 + 4)
 	u32 size_left;
 	u32 i, j;
 	u32 n1;
@@ -401,7 +401,8 @@ static void *hns3_update_strings(u8 *data, const struct hns3_stats *stats,
 			data[ETH_GSTRING_LEN - 1] = '\0';
 
 			/* first, prepend the prefix string */
-			n1 = snprintf(data, MAX_PREFIX_SIZE, "rcb_q%d_", i);
+			n1 = snprintf(data, MAX_PREFIX_SIZE, "%s#%d_",
+				      prefix, i);
 			n1 = min_t(uint, n1, MAX_PREFIX_SIZE - 1);
 			size_left = (ETH_GSTRING_LEN - 1) - n1;
 
@@ -417,14 +418,16 @@ static void *hns3_update_strings(u8 *data, const struct hns3_stats *stats,
 static u8 *hns3_get_strings_tqps(struct hnae3_handle *handle, u8 *data)
 {
 	struct hnae3_knic_private_info *kinfo = &handle->kinfo;
+	const char tx_prefix[] = "txq";
+	const char rx_prefix[] = "rxq";
 
 	/* get strings for Tx */
 	data = hns3_update_strings(data, hns3_txq_stats, HNS3_TXQ_STATS_COUNT,
-				   kinfo->num_tqps);
+				   kinfo->num_tqps, tx_prefix);
 
 	/* get strings for Rx */
 	data = hns3_update_strings(data, hns3_rxq_stats, HNS3_RXQ_STATS_COUNT,
-				   kinfo->num_tqps);
+				   kinfo->num_tqps, rx_prefix);
 
 	return data;
 }
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 93fe870..3a6ec8d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -332,30 +332,30 @@ static int hclge_set_mta_filter_mode(struct hclge_dev *hdev,
 	{"mac_rx_1519_max_oct_pkt_num",
 		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_1519_max_oct_pkt_num)},
 
-	{"mac_trans_fragment_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_trans_fragment_pkt_num)},
-	{"mac_trans_undermin_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_trans_undermin_pkt_num)},
-	{"mac_trans_jabber_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_trans_jabber_pkt_num)},
-	{"mac_trans_err_all_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_trans_err_all_pkt_num)},
-	{"mac_trans_from_app_good_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_trans_from_app_good_pkt_num)},
-	{"mac_trans_from_app_bad_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_trans_from_app_bad_pkt_num)},
-	{"mac_rcv_fragment_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_rcv_fragment_pkt_num)},
-	{"mac_rcv_undermin_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_rcv_undermin_pkt_num)},
-	{"mac_rcv_jabber_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_rcv_jabber_pkt_num)},
-	{"mac_rcv_fcs_err_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_rcv_fcs_err_pkt_num)},
-	{"mac_rcv_send_app_good_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_rcv_send_app_good_pkt_num)},
-	{"mac_rcv_send_app_bad_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_rcv_send_app_bad_pkt_num)}
+	{"mac_tx_fragment_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_fragment_pkt_num)},
+	{"mac_tx_undermin_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_undermin_pkt_num)},
+	{"mac_tx_jabber_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_jabber_pkt_num)},
+	{"mac_tx_err_all_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_err_all_pkt_num)},
+	{"mac_tx_from_app_good_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_from_app_good_pkt_num)},
+	{"mac_tx_from_app_bad_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_from_app_bad_pkt_num)},
+	{"mac_rx_fragment_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_fragment_pkt_num)},
+	{"mac_rx_undermin_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_undermin_pkt_num)},
+	{"mac_rx_jabber_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_jabber_pkt_num)},
+	{"mac_rx_fcs_err_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_fcs_err_pkt_num)},
+	{"mac_rx_send_app_good_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_send_app_good_pkt_num)},
+	{"mac_rx_send_app_bad_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_send_app_bad_pkt_num)}
 };
 
 static int hclge_64_bit_update_stats(struct hclge_dev *hdev)
@@ -587,7 +587,7 @@ static u8 *hclge_tqps_get_strings(struct hnae3_handle *handle, u8 *data)
 	for (i = 0; i < kinfo->num_tqps; i++) {
 		struct hclge_tqp *tqp = container_of(handle->kinfo.tqp[i],
 			struct hclge_tqp, q);
-		snprintf(buff, ETH_GSTRING_LEN, "rcb_q%d_tx_pktnum_rcd",
+		snprintf(buff, ETH_GSTRING_LEN, "txq#%d_pktnum_rcd",
 			 tqp->index);
 		buff = buff + ETH_GSTRING_LEN;
 	}
@@ -595,7 +595,7 @@ static u8 *hclge_tqps_get_strings(struct hnae3_handle *handle, u8 *data)
 	for (i = 0; i < kinfo->num_tqps; i++) {
 		struct hclge_tqp *tqp = container_of(kinfo->tqp[i],
 			struct hclge_tqp, q);
-		snprintf(buff, ETH_GSTRING_LEN, "rcb_q%d_rx_pktnum_rcd",
+		snprintf(buff, ETH_GSTRING_LEN, "rxq#%d_pktnum_rcd",
 			 tqp->index);
 		buff = buff + ETH_GSTRING_LEN;
 	}
@@ -648,12 +648,12 @@ static void hclge_update_netstat(struct hclge_hw_stats *hw_stats,
 	net_stats->rx_errors += hw_stats->all_32_bit_stats.igu_rx_err_pkt;
 	net_stats->rx_errors += hw_stats->all_32_bit_stats.igu_rx_no_eof_pkt;
 	net_stats->rx_errors += hw_stats->all_32_bit_stats.igu_rx_no_sof_pkt;
-	net_stats->rx_errors += hw_stats->mac_stats.mac_rcv_fcs_err_pkt_num;
+	net_stats->rx_errors += hw_stats->mac_stats.mac_rx_fcs_err_pkt_num;
 
 	net_stats->multicast = hw_stats->mac_stats.mac_tx_multi_pkt_num;
 	net_stats->multicast += hw_stats->mac_stats.mac_rx_multi_pkt_num;
 
-	net_stats->rx_crc_errors = hw_stats->mac_stats.mac_rcv_fcs_err_pkt_num;
+	net_stats->rx_crc_errors = hw_stats->mac_stats.mac_rx_fcs_err_pkt_num;
 	net_stats->rx_length_errors =
 		hw_stats->mac_stats.mac_rx_undersize_pkt_num;
 	net_stats->rx_length_errors +=
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 28cc063..70f121d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -408,18 +408,18 @@ struct hclge_mac_stats {
 	u64 mac_rx_1024_1518_oct_pkt_num;
 	u64 mac_rx_1519_max_oct_pkt_num;
 
-	u64 mac_trans_fragment_pkt_num;
-	u64 mac_trans_undermin_pkt_num;
-	u64 mac_trans_jabber_pkt_num;
-	u64 mac_trans_err_all_pkt_num;
-	u64 mac_trans_from_app_good_pkt_num;
-	u64 mac_trans_from_app_bad_pkt_num;
-	u64 mac_rcv_fragment_pkt_num;
-	u64 mac_rcv_undermin_pkt_num;
-	u64 mac_rcv_jabber_pkt_num;
-	u64 mac_rcv_fcs_err_pkt_num;
-	u64 mac_rcv_send_app_good_pkt_num;
-	u64 mac_rcv_send_app_bad_pkt_num;
+	u64 mac_tx_fragment_pkt_num;
+	u64 mac_tx_undermin_pkt_num;
+	u64 mac_tx_jabber_pkt_num;
+	u64 mac_tx_err_all_pkt_num;
+	u64 mac_tx_from_app_good_pkt_num;
+	u64 mac_tx_from_app_bad_pkt_num;
+	u64 mac_rx_fragment_pkt_num;
+	u64 mac_rx_undermin_pkt_num;
+	u64 mac_rx_jabber_pkt_num;
+	u64 mac_rx_fcs_err_pkt_num;
+	u64 mac_rx_send_app_good_pkt_num;
+	u64 mac_rx_send_app_bad_pkt_num;
 };
 
 struct hclge_hw_stats {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 3186605..46f6c53 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -105,7 +105,7 @@ static u8 *hclgevf_tqps_get_strings(struct hnae3_handle *handle, u8 *data)
 	for (i = 0; i < hdev->num_tqps; i++) {
 		struct hclgevf_tqp *tqp = container_of(handle->kinfo.tqp[i],
 			struct hclgevf_tqp, q);
-		snprintf(buff, ETH_GSTRING_LEN, "rcb_q%d_tx_pktnum_rcd",
+		snprintf(buff, ETH_GSTRING_LEN, "txq#%d_pktnum_rcd",
 			 tqp->index);
 		buff += ETH_GSTRING_LEN;
 	}
@@ -113,7 +113,7 @@ static u8 *hclgevf_tqps_get_strings(struct hnae3_handle *handle, u8 *data)
 	for (i = 0; i < hdev->num_tqps; i++) {
 		struct hclgevf_tqp *tqp = container_of(handle->kinfo.tqp[i],
 			struct hclgevf_tqp, q);
-		snprintf(buff, ETH_GSTRING_LEN, "rcb_q%d_rx_pktnum_rcd",
+		snprintf(buff, ETH_GSTRING_LEN, "rxq#%d_pktnum_rcd",
 			 tqp->index);
 		buff += ETH_GSTRING_LEN;
 	}
-- 
1.9.1

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

* [PATCH net-next 04/20] net: hns3: Fix spelling errors
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (2 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 03/20] net: hns3: Unify the strings display of packet statistics Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 05/20] net: hns3: Remove repeat statistic of rx_errors Peng Li
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

Fix spelling error "overrsize" --> "oversize".

Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 14 +++++++-------
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 3a6ec8d..3b13b41a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -279,8 +279,8 @@ static int hclge_set_mta_filter_mode(struct hclge_dev *hdev,
 		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_broad_pkt_num)},
 	{"mac_tx_undersize_pkt_num",
 		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_undersize_pkt_num)},
-	{"mac_tx_overrsize_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_overrsize_pkt_num)},
+	{"mac_tx_oversize_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_oversize_pkt_num)},
 	{"mac_tx_64_oct_pkt_num",
 		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_64_oct_pkt_num)},
 	{"mac_tx_65_127_oct_pkt_num",
@@ -315,8 +315,8 @@ static int hclge_set_mta_filter_mode(struct hclge_dev *hdev,
 		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_broad_pkt_num)},
 	{"mac_rx_undersize_pkt_num",
 		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_undersize_pkt_num)},
-	{"mac_rx_overrsize_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_overrsize_pkt_num)},
+	{"mac_rx_oversize_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_oversize_pkt_num)},
 	{"mac_rx_64_oct_pkt_num",
 		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_64_oct_pkt_num)},
 	{"mac_rx_65_127_oct_pkt_num",
@@ -643,7 +643,7 @@ static void hclge_update_netstat(struct hclge_hw_stats *hw_stats,
 	net_stats->rx_dropped += hw_stats->all_32_bit_stats.ppp_key_drop_num;
 	net_stats->rx_dropped += hw_stats->all_32_bit_stats.ssu_key_drop_num;
 
-	net_stats->rx_errors = hw_stats->mac_stats.mac_rx_overrsize_pkt_num;
+	net_stats->rx_errors = hw_stats->mac_stats.mac_rx_oversize_pkt_num;
 	net_stats->rx_errors += hw_stats->mac_stats.mac_rx_undersize_pkt_num;
 	net_stats->rx_errors += hw_stats->all_32_bit_stats.igu_rx_err_pkt;
 	net_stats->rx_errors += hw_stats->all_32_bit_stats.igu_rx_no_eof_pkt;
@@ -657,9 +657,9 @@ static void hclge_update_netstat(struct hclge_hw_stats *hw_stats,
 	net_stats->rx_length_errors =
 		hw_stats->mac_stats.mac_rx_undersize_pkt_num;
 	net_stats->rx_length_errors +=
-		hw_stats->mac_stats.mac_rx_overrsize_pkt_num;
+		hw_stats->mac_stats.mac_rx_oversize_pkt_num;
 	net_stats->rx_over_errors =
-		hw_stats->mac_stats.mac_rx_overrsize_pkt_num;
+		hw_stats->mac_stats.mac_rx_oversize_pkt_num;
 }
 
 static void hclge_update_stats_for_all(struct hclge_dev *hdev)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 70f121d..15ca95f 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -381,7 +381,7 @@ struct hclge_mac_stats {
 	u64 mac_tx_multi_pkt_num;
 	u64 mac_tx_broad_pkt_num;
 	u64 mac_tx_undersize_pkt_num;
-	u64 mac_tx_overrsize_pkt_num;
+	u64 mac_tx_oversize_pkt_num;
 	u64 mac_tx_64_oct_pkt_num;
 	u64 mac_tx_65_127_oct_pkt_num;
 	u64 mac_tx_128_255_oct_pkt_num;
@@ -399,7 +399,7 @@ struct hclge_mac_stats {
 	u64 mac_rx_multi_pkt_num;
 	u64 mac_rx_broad_pkt_num;
 	u64 mac_rx_undersize_pkt_num;
-	u64 mac_rx_overrsize_pkt_num;
+	u64 mac_rx_oversize_pkt_num;
 	u64 mac_rx_64_oct_pkt_num;
 	u64 mac_rx_65_127_oct_pkt_num;
 	u64 mac_rx_128_255_oct_pkt_num;
-- 
1.9.1

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

* [PATCH net-next 05/20] net: hns3: Remove repeat statistic of rx_errors
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (3 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 04/20] net: hns3: Fix spelling errors Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 06/20] net: hns3: Modify the update period of packet statistics Peng Li
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

The igu_rx_err_pkt indicates the same error with
mac_rx_fcs_err_pkt_num, so remove it.

Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 3b13b41a..2cca37c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -645,7 +645,6 @@ static void hclge_update_netstat(struct hclge_hw_stats *hw_stats,
 
 	net_stats->rx_errors = hw_stats->mac_stats.mac_rx_oversize_pkt_num;
 	net_stats->rx_errors += hw_stats->mac_stats.mac_rx_undersize_pkt_num;
-	net_stats->rx_errors += hw_stats->all_32_bit_stats.igu_rx_err_pkt;
 	net_stats->rx_errors += hw_stats->all_32_bit_stats.igu_rx_no_eof_pkt;
 	net_stats->rx_errors += hw_stats->all_32_bit_stats.igu_rx_no_sof_pkt;
 	net_stats->rx_errors += hw_stats->mac_stats.mac_rx_fcs_err_pkt_num;
-- 
1.9.1

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

* [PATCH net-next 06/20] net: hns3: Modify the update period of packet statistics
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (4 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 05/20] net: hns3: Remove repeat statistic of rx_errors Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 14:54   ` Andrew Lunn
  2018-01-05 10:18 ` [PATCH net-next 07/20] net: hns3: Mask the packet statistics query when NIC is down Peng Li
                   ` (14 subsequent siblings)
  20 siblings, 1 reply; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

It takes more than 200 query response messages between
driver and IMP, while updating the packet statistics.
It's too heavy for IMP to update it per second.

Extend the update period of packet statistics data from
1 second to 300 seconds(if too long, the statistics may
overflow).

As a result, we need to update it while querying with
ifconfig tool to keep the statistics data fresh.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c         |  3 +++
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 12 +++++++++++-
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h |  3 +++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 565d85d..79c5daa 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1126,6 +1126,7 @@ static int hns3_nic_set_features(struct net_device *netdev,
 {
 	struct hns3_nic_priv *priv = netdev_priv(netdev);
 	int queue_num = priv->ae_handle->kinfo.num_tqps;
+	struct hnae3_handle *handle = priv->ae_handle;
 	struct hns3_enet_ring *ring;
 	unsigned int start;
 	unsigned int idx;
@@ -1134,6 +1135,8 @@ static int hns3_nic_set_features(struct net_device *netdev,
 	u64 tx_pkts = 0;
 	u64 rx_pkts = 0;
 
+	handle->ae_algo->ops->update_stats(handle, &netdev->stats);
+
 	for (idx = 0; idx < queue_num; idx++) {
 		/* fetch the tx stats */
 		ring = priv->ring_data[idx].ring;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 2cca37c..20ec791 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -698,6 +698,9 @@ static void hclge_update_stats(struct hnae3_handle *handle,
 	struct hclge_hw_stats *hw_stats = &hdev->hw_stats;
 	int status;
 
+	if (test_and_set_bit(HCLGE_STATE_STATISTICS_UPDATING, &hdev->state))
+		return;
+
 	status = hclge_mac_update_stats(hdev);
 	if (status)
 		dev_err(&hdev->pdev->dev,
@@ -723,6 +726,8 @@ static void hclge_update_stats(struct hnae3_handle *handle,
 			status);
 
 	hclge_update_netstat(hw_stats, net_stats);
+
+	clear_bit(HCLGE_STATE_STATISTICS_UPDATING, &hdev->state);
 }
 
 static int hclge_get_sset_count(struct hnae3_handle *handle, int stringset)
@@ -2380,6 +2385,7 @@ static void hclge_service_timer(struct timer_list *t)
 	struct hclge_dev *hdev = from_timer(hdev, t, service_timer);
 
 	mod_timer(&hdev->service_timer, jiffies + HZ);
+	hdev->hw_stats.stats_timer++;
 	hclge_task_schedule(hdev);
 }
 
@@ -2779,9 +2785,13 @@ static void hclge_service_task(struct work_struct *work)
 	struct hclge_dev *hdev =
 		container_of(work, struct hclge_dev, service_task);
 
+	if (hdev->hw_stats.stats_timer >= HCLGE_STATS_TIMER_INTERVAL) {
+		hclge_update_stats_for_all(hdev);
+		hdev->hw_stats.stats_timer = 0;
+	}
+
 	hclge_update_speed_duplex(hdev);
 	hclge_update_link_status(hdev);
-	hclge_update_stats_for_all(hdev);
 	hclge_service_complete(hdev);
 }
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 15ca95f..50ae13a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -112,6 +112,7 @@ enum HCLGE_DEV_STATE {
 	HCLGE_STATE_RST_HANDLING,
 	HCLGE_STATE_MBX_SERVICE_SCHED,
 	HCLGE_STATE_MBX_HANDLING,
+	HCLGE_STATE_STATISTICS_UPDATING,
 	HCLGE_STATE_MAX
 };
 
@@ -422,10 +423,12 @@ struct hclge_mac_stats {
 	u64 mac_rx_send_app_bad_pkt_num;
 };
 
+#define HCLGE_STATS_TIMER_INTERVAL	(60 * 5)
 struct hclge_hw_stats {
 	struct hclge_mac_stats      mac_stats;
 	struct hclge_64_bit_stats   all_64_bit_stats;
 	struct hclge_32_bit_stats   all_32_bit_stats;
+	u32 stats_timer;
 };
 
 struct hclge_vlan_type_cfg {
-- 
1.9.1

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

* [PATCH net-next 07/20] net: hns3: Mask the packet statistics query when NIC is down
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (5 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 06/20] net: hns3: Modify the update period of packet statistics Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 08/20] net: hns3: Fix an error of total drop packet statistics Peng Li
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

Update the HNS3_NIC_STATE_DOWN bit when NIC state changes.
When NIC is down, mask the packet statistics for querying
with ifconfig command. It's a common practice.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 79c5daa..a8e4406 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -247,6 +247,8 @@ static int hns3_nic_net_up(struct net_device *netdev)
 	if (ret)
 		goto out_start_err;
 
+	clear_bit(HNS3_NIC_STATE_DOWN, &priv->state);
+
 	return 0;
 
 out_start_err:
@@ -286,6 +288,9 @@ static void hns3_nic_net_down(struct net_device *netdev)
 	const struct hnae3_ae_ops *ops;
 	int i;
 
+	if (test_and_set_bit(HNS3_NIC_STATE_DOWN, &priv->state))
+		return;
+
 	/* stop ae_dev */
 	ops = priv->ae_handle->ae_algo->ops;
 	if (ops->stop)
@@ -1135,6 +1140,9 @@ static int hns3_nic_set_features(struct net_device *netdev,
 	u64 tx_pkts = 0;
 	u64 rx_pkts = 0;
 
+	if (test_bit(HNS3_NIC_STATE_DOWN, &priv->state))
+		return;
+
 	handle->ae_algo->ops->update_stats(handle, &netdev->stats);
 
 	for (idx = 0; idx < queue_num; idx++) {
-- 
1.9.1

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

* [PATCH net-next 08/20] net: hns3: Fix an error of total drop packet statistics
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (6 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 07/20] net: hns3: Mask the packet statistics query when NIC is down Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 09/20] net: hns3: Fix a loop index error of tqp statistics query Peng Li
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

The dropped tx/rx packets number of each tqp should also
be counted into the total drop tx/rx packets numbers.

Fixes: 76ad4f0ee74 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index a8e4406..eb9ac53 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1139,6 +1139,8 @@ static int hns3_nic_set_features(struct net_device *netdev,
 	u64 rx_bytes = 0;
 	u64 tx_pkts = 0;
 	u64 rx_pkts = 0;
+	u64 tx_drop = 0;
+	u64 rx_drop = 0;
 
 	if (test_bit(HNS3_NIC_STATE_DOWN, &priv->state))
 		return;
@@ -1152,6 +1154,8 @@ static int hns3_nic_set_features(struct net_device *netdev,
 			start = u64_stats_fetch_begin_irq(&ring->syncp);
 			tx_bytes += ring->stats.tx_bytes;
 			tx_pkts += ring->stats.tx_pkts;
+			tx_drop += ring->stats.tx_busy;
+			tx_drop += ring->stats.sw_err_cnt;
 		} while (u64_stats_fetch_retry_irq(&ring->syncp, start));
 
 		/* fetch the rx stats */
@@ -1160,6 +1164,9 @@ static int hns3_nic_set_features(struct net_device *netdev,
 			start = u64_stats_fetch_begin_irq(&ring->syncp);
 			rx_bytes += ring->stats.rx_bytes;
 			rx_pkts += ring->stats.rx_pkts;
+			rx_drop += ring->stats.non_vld_descs;
+			rx_drop += ring->stats.err_pkt_len;
+			rx_drop += ring->stats.l2_err;
 		} while (u64_stats_fetch_retry_irq(&ring->syncp, start));
 	}
 
@@ -1175,8 +1182,8 @@ static int hns3_nic_set_features(struct net_device *netdev,
 	stats->rx_missed_errors = netdev->stats.rx_missed_errors;
 
 	stats->tx_errors = netdev->stats.tx_errors;
-	stats->rx_dropped = netdev->stats.rx_dropped;
-	stats->tx_dropped = netdev->stats.tx_dropped;
+	stats->rx_dropped = rx_drop + netdev->stats.rx_dropped;
+	stats->tx_dropped = tx_drop + netdev->stats.tx_dropped;
 	stats->collisions = netdev->stats.collisions;
 	stats->rx_over_errors = netdev->stats.rx_over_errors;
 	stats->rx_frame_errors = netdev->stats.rx_frame_errors;
-- 
1.9.1

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

* [PATCH net-next 09/20] net: hns3: Fix a loop index error of tqp statistics query
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (7 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 08/20] net: hns3: Fix an error of total drop packet statistics Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 10/20] net: hns3: Fix an error macro definition of HNS3_TQP_STAT Peng Li
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

An error loop index was used while querying statistics data
of tqps, which may cause call trace.

Fixes: 496d03e960ae ("net: hns3: Add Ethtool support to HNS3 driver")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index c96ef40..9cca33c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -458,13 +458,13 @@ static u64 *hns3_get_stats_tqps(struct hnae3_handle *handle, u64 *data)
 	struct hnae3_knic_private_info *kinfo = &handle->kinfo;
 	struct hns3_enet_ring *ring;
 	u8 *stat;
-	u32 i;
+	int i, j;
 
 	/* get stats for Tx */
 	for (i = 0; i < kinfo->num_tqps; i++) {
 		ring = nic_priv->ring_data[i].ring;
-		for (i = 0; i < HNS3_TXQ_STATS_COUNT; i++) {
-			stat = (u8 *)ring + hns3_txq_stats[i].stats_offset;
+		for (j = 0; j < HNS3_TXQ_STATS_COUNT; j++) {
+			stat = (u8 *)ring + hns3_txq_stats[j].stats_offset;
 			*data++ = *(u64 *)stat;
 		}
 	}
@@ -472,8 +472,8 @@ static u64 *hns3_get_stats_tqps(struct hnae3_handle *handle, u64 *data)
 	/* get stats for Rx */
 	for (i = 0; i < kinfo->num_tqps; i++) {
 		ring = nic_priv->ring_data[i + kinfo->num_tqps].ring;
-		for (i = 0; i < HNS3_RXQ_STATS_COUNT; i++) {
-			stat = (u8 *)ring + hns3_rxq_stats[i].stats_offset;
+		for (j = 0; j < HNS3_RXQ_STATS_COUNT; j++) {
+			stat = (u8 *)ring + hns3_rxq_stats[j].stats_offset;
 			*data++ = *(u64 *)stat;
 		}
 	}
-- 
1.9.1

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

* [PATCH net-next 10/20] net: hns3: Fix an error macro definition of HNS3_TQP_STAT
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (8 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 09/20] net: hns3: Fix a loop index error of tqp statistics query Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 11/20] net: hns3: Remove a useless member of struct hns3_stats Peng Li
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

The member "stats_offset" was designed to indicate the offset
of each member of struct ring_stats in struct hns3_enet_ring,
but forgot to add the offset of the member in struct ring_stats.

Fixes: 496d03e960a ("net: hns3: Add Ethtool support to HNS3 driver")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 9cca33c..c7ac546 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -23,7 +23,8 @@ struct hns3_stats {
 #define HNS3_TQP_STAT(_string, _member)	{			\
 	.stats_string = _string,				\
 	.stats_size = FIELD_SIZEOF(struct ring_stats, _member),	\
-	.stats_offset = offsetof(struct hns3_enet_ring, stats),	\
+	.stats_offset = offsetof(struct hns3_enet_ring, stats) +\
+			offsetof(struct ring_stats, _member),   \
 }								\
 
 static const struct hns3_stats hns3_txq_stats[] = {
-- 
1.9.1

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

* [PATCH net-next 11/20] net: hns3: Remove a useless member of struct hns3_stats
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (9 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 10/20] net: hns3: Fix an error macro definition of HNS3_TQP_STAT Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev Peng Li
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

The member "stats_size" of struct hns3_stats is useless,
remove it and fix the macro definition which has uses this
struct.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index c7ac546..d3cb3ec 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -15,17 +15,15 @@
 
 struct hns3_stats {
 	char stats_string[ETH_GSTRING_LEN];
-	int stats_size;
 	int stats_offset;
 };
 
 /* tqp related stats */
 #define HNS3_TQP_STAT(_string, _member)	{			\
 	.stats_string = _string,				\
-	.stats_size = FIELD_SIZEOF(struct ring_stats, _member),	\
 	.stats_offset = offsetof(struct hns3_enet_ring, stats) +\
 			offsetof(struct ring_stats, _member),   \
-}								\
+}
 
 static const struct hns3_stats hns3_txq_stats[] = {
 	/* Tx per-queue statistics */
-- 
1.9.1

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

* [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (10 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 11/20] net: hns3: Remove a useless member of struct hns3_stats Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-08 20:04   ` Jakub Kicinski
  2018-01-05 10:18 ` [PATCH net-next 13/20] net: hns3: Fix a response data read error of tqp statistics query Peng Li
                   ` (8 subsequent siblings)
  20 siblings, 1 reply; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

Add packet statistics of netdev for ethtool -S, in
order to show the statistics data for current net
device.

Remove update_stats() calling because it has been
completed in hns3_get_netdev_stats().

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 80 +++++++++++++++++++++-
 1 file changed, 79 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index d3cb3ec..1e8fac3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -59,6 +59,41 @@ struct hns3_stats {
 
 #define HNS3_TQP_STATS_COUNT (HNS3_TXQ_STATS_COUNT + HNS3_RXQ_STATS_COUNT)
 
+/* netdev stats */
+#define HNS3_NETDEV_STAT(_string, _member)	{			\
+	.stats_string = _string,					\
+	.stats_offset = offsetof(struct rtnl_link_stats64, _member)	\
+}
+
+static const struct hns3_stats hns3_netdev_stats[] = {
+	/* Rx per-queue statistics */
+	HNS3_NETDEV_STAT("rx_packets", rx_packets),
+	HNS3_NETDEV_STAT("tx_packets", tx_packets),
+	HNS3_NETDEV_STAT("rx_bytes", rx_bytes),
+	HNS3_NETDEV_STAT("tx_bytes", tx_bytes),
+	HNS3_NETDEV_STAT("rx_errors", rx_errors),
+	HNS3_NETDEV_STAT("tx_errors", tx_errors),
+	HNS3_NETDEV_STAT("rx_dropped", rx_dropped),
+	HNS3_NETDEV_STAT("tx_dropped", tx_dropped),
+	HNS3_NETDEV_STAT("multicast", multicast),
+	HNS3_NETDEV_STAT("collisions", collisions),
+	HNS3_NETDEV_STAT("rx_length_errors", rx_length_errors),
+	HNS3_NETDEV_STAT("rx_over_errors", rx_over_errors),
+	HNS3_NETDEV_STAT("rx_crc_errors", rx_crc_errors),
+	HNS3_NETDEV_STAT("rx_frame_errors", rx_frame_errors),
+	HNS3_NETDEV_STAT("rx_fifo_errors", rx_fifo_errors),
+	HNS3_NETDEV_STAT("rx_missed_errors", rx_missed_errors),
+	HNS3_NETDEV_STAT("tx_aborted_errors", tx_aborted_errors),
+	HNS3_NETDEV_STAT("tx_carrier_errors", tx_carrier_errors),
+	HNS3_NETDEV_STAT("tx_fifo_errors", tx_fifo_errors),
+	HNS3_NETDEV_STAT("tx_heartbeat_errors", tx_heartbeat_errors),
+	HNS3_NETDEV_STAT("tx_window_errors", tx_window_errors),
+	HNS3_NETDEV_STAT("rx_compressed", rx_compressed),
+	HNS3_NETDEV_STAT("tx_compressed", tx_compressed),
+};
+
+#define HNS3_NETDEV_STATS_COUNT ARRAY_SIZE(hns3_netdev_stats)
+
 #define HNS3_SELF_TEST_TPYE_NUM		1
 #define HNS3_NIC_LB_TEST_PKT_NUM	1
 #define HNS3_NIC_LB_TEST_RING_ID	0
@@ -431,6 +466,27 @@ static u8 *hns3_get_strings_tqps(struct hnae3_handle *handle, u8 *data)
 	return data;
 }
 
+static u8 *hns3_netdev_stats_get_strings(u8 *data)
+{
+	int i;
+
+	/* get strings for netdev */
+	for (i = 0; i < HNS3_NETDEV_STATS_COUNT; i++) {
+		snprintf(data, ETH_GSTRING_LEN,
+			 hns3_netdev_stats[i].stats_string);
+		data += ETH_GSTRING_LEN;
+	}
+
+	snprintf(data, ETH_GSTRING_LEN, "netdev_rx_dropped");
+	data += ETH_GSTRING_LEN;
+	snprintf(data, ETH_GSTRING_LEN, "netdev_tx_dropped");
+	data += ETH_GSTRING_LEN;
+	snprintf(data, ETH_GSTRING_LEN, "netdev_tx_timeout");
+	data += ETH_GSTRING_LEN;
+
+	return data;
+}
+
 static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
 {
 	struct hnae3_handle *h = hns3_get_handle(netdev);
@@ -442,6 +498,7 @@ static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
 
 	switch (stringset) {
 	case ETH_SS_STATS:
+		buff = hns3_netdev_stats_get_strings(buff);
 		buff = hns3_get_strings_tqps(h, buff);
 		h->ae_algo->ops->get_strings(h, stringset, (u8 *)buff);
 		break;
@@ -480,6 +537,27 @@ static u64 *hns3_get_stats_tqps(struct hnae3_handle *handle, u64 *data)
 	return data;
 }
 
+static u64 *hns3_get_netdev_stats(struct net_device *netdev, u64 *data)
+{
+	struct hns3_nic_priv *priv = netdev_priv(netdev);
+	const struct rtnl_link_stats64 *net_stats;
+	struct rtnl_link_stats64 temp;
+	u8 *stat;
+	int i;
+
+	net_stats = dev_get_stats(netdev, &temp);
+	for (i = 0; i < HNS3_NETDEV_STATS_COUNT; i++) {
+		stat = (u8 *)net_stats + hns3_netdev_stats[i].stats_offset;
+		*data++ = *(u64 *)stat;
+	}
+
+	*data++ = netdev->rx_dropped.counter;
+	*data++ = netdev->tx_dropped.counter;
+	*data++ = priv->tx_timeout_count;
+
+	return data;
+}
+
 /* hns3_get_stats - get detail statistics.
  * @netdev: net device
  * @stats: statistics info.
@@ -496,7 +574,7 @@ static void hns3_get_stats(struct net_device *netdev,
 		return;
 	}
 
-	h->ae_algo->ops->update_stats(h, &netdev->stats);
+	p = hns3_get_netdev_stats(netdev, p);
 
 	/* get per-queue stats */
 	p = hns3_get_stats_tqps(h, p);
-- 
1.9.1

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

* [PATCH net-next 13/20] net: hns3: Fix a response data read error of tqp statistics query
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (11 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 14/20] net: hns3: fix for updating fc_mode_last_time Peng Li
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

The result of tqp statistics query was read with an
error position, fix it according to the user manual.

Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c   | 4 ++--
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 20ec791..8004922 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -525,7 +525,7 @@ static int hclge_tqps_update_stats(struct hnae3_handle *handle)
 			return ret;
 		}
 		tqp->tqp_stats.rcb_rx_ring_pktnum_rcd +=
-			le32_to_cpu(desc[0].data[4]);
+			le32_to_cpu(desc[0].data[1]);
 	}
 
 	for (i = 0; i < kinfo->num_tqps; i++) {
@@ -545,7 +545,7 @@ static int hclge_tqps_update_stats(struct hnae3_handle *handle)
 			return ret;
 		}
 		tqp->tqp_stats.rcb_tx_ring_pktnum_rcd +=
-			le32_to_cpu(desc[0].data[4]);
+			le32_to_cpu(desc[0].data[1]);
 	}
 
 	return 0;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 46f6c53..f74b66a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -49,7 +49,7 @@ static int hclgevf_tqps_update_stats(struct hnae3_handle *handle)
 			return status;
 		}
 		tqp->tqp_stats.rcb_rx_ring_pktnum_rcd +=
-			le32_to_cpu(desc.data[4]);
+			le32_to_cpu(desc.data[1]);
 
 		hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_QUERY_TX_STATUS,
 					     true);
@@ -63,7 +63,7 @@ static int hclgevf_tqps_update_stats(struct hnae3_handle *handle)
 			return status;
 		}
 		tqp->tqp_stats.rcb_tx_ring_pktnum_rcd +=
-			le32_to_cpu(desc.data[4]);
+			le32_to_cpu(desc.data[1]);
 	}
 
 	return 0;
-- 
1.9.1

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

* [PATCH net-next 14/20] net: hns3: fix for updating fc_mode_last_time
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (12 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 13/20] net: hns3: Fix a response data read error of tqp statistics query Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 15/20] net: hns3: fix for setting MTU Peng Li
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Fuyun Liang <liangfuyun1@huawei.com>

commit a9c782822166 ("net: hns3: add support for set_pauseparam")
adds set_pauseparam support for ethtool cmd, but forgets to update
fc_mode_last_time when PFC mode is disabled in hclge_cfg_pauseparam().
The wrong fc_mode_last_time will be used to update flow control mode
when lldpad has been running. As a result, when using the ethtool
command "-a", user will get a wrong pause parameter.

This patch adds the fc_mode_last_time update when PFC mode is disabled.

Fixes: a9c782822166 ("net: hns3: add support for set_pauseparam")
Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 8004922..fcda9a2 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -4707,22 +4707,19 @@ static void hclge_set_flowctrl_adv(struct hclge_dev *hdev, u32 rx_en, u32 tx_en)
 
 static int hclge_cfg_pauseparam(struct hclge_dev *hdev, u32 rx_en, u32 tx_en)
 {
-	enum hclge_fc_mode fc_mode;
 	int ret;
 
 	if (rx_en && tx_en)
-		fc_mode = HCLGE_FC_FULL;
+		hdev->fc_mode_last_time = HCLGE_FC_FULL;
 	else if (rx_en && !tx_en)
-		fc_mode = HCLGE_FC_RX_PAUSE;
+		hdev->fc_mode_last_time = HCLGE_FC_RX_PAUSE;
 	else if (!rx_en && tx_en)
-		fc_mode = HCLGE_FC_TX_PAUSE;
+		hdev->fc_mode_last_time = HCLGE_FC_TX_PAUSE;
 	else
-		fc_mode = HCLGE_FC_NONE;
+		hdev->fc_mode_last_time = HCLGE_FC_NONE;
 
-	if (hdev->tm_info.fc_mode == HCLGE_FC_PFC) {
-		hdev->fc_mode_last_time = fc_mode;
+	if (hdev->tm_info.fc_mode == HCLGE_FC_PFC)
 		return 0;
-	}
 
 	ret = hclge_mac_pause_en_cfg(hdev, tx_en, rx_en);
 	if (ret) {
@@ -4731,7 +4728,7 @@ static int hclge_cfg_pauseparam(struct hclge_dev *hdev, u32 rx_en, u32 tx_en)
 		return ret;
 	}
 
-	hdev->tm_info.fc_mode = fc_mode;
+	hdev->tm_info.fc_mode = hdev->fc_mode_last_time;
 
 	return 0;
 }
-- 
1.9.1

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

* [PATCH net-next 15/20] net: hns3: fix for setting MTU
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (13 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 14/20] net: hns3: fix for updating fc_mode_last_time Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 16/20] net: hns3: fix for changing MTU Peng Li
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Fuyun Liang <liangfuyun1@huawei.com>

When setting MTU, actually what we do is configuring the max frame size
for the hardware. ETH_HLEN、ETH_FCS_LEN and VLAN_HLEN must need to be
considered. And the frame size which is less than the default value
should not be set to the hardware. Because in the hardware, the the max
frame size not only controls the RX packet size, but also controls the
TX packet size. the RX packets whose size are greater than the setting
value will be dropped.

This patch fixes the bug setting a error max frame size to hardware.

Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h  |  2 --
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 14 +++++++++++---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h |  5 +++++
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
index f5baba21..3c3159b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
@@ -556,8 +556,6 @@ struct hclge_config_auto_neg_cmd {
 	u8      rsv[20];
 };
 
-#define HCLGE_MAC_MIN_MTU		64
-#define HCLGE_MAC_MAX_MTU		9728
 #define HCLGE_MAC_UPLINK_PORT		0x100
 
 struct hclge_config_max_frm_size_cmd {
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index fcda9a2..f1702db 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -17,6 +17,7 @@
 #include <linux/netdevice.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/if_vlan.h>
 #include <net/rtnetlink.h>
 #include "hclge_cmd.h"
 #include "hclge_dcb.h"
@@ -4560,16 +4561,21 @@ static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu)
 	struct hclge_config_max_frm_size_cmd *req;
 	struct hclge_dev *hdev = vport->back;
 	struct hclge_desc desc;
+	int max_frm_size;
 	int ret;
 
-	if ((new_mtu < HCLGE_MAC_MIN_MTU) || (new_mtu > HCLGE_MAC_MAX_MTU))
+	max_frm_size = new_mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN;
+
+	if (max_frm_size < HCLGE_MAC_MIN_FRAME ||
+	    max_frm_size > HCLGE_MAC_MAX_FRAME)
 		return -EINVAL;
 
-	hdev->mps = new_mtu;
+	max_frm_size = max(max_frm_size, HCLGE_MAC_DEFAULT_FRAME);
+
 	hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CONFIG_MAX_FRM_SIZE, false);
 
 	req = (struct hclge_config_max_frm_size_cmd *)desc.data;
-	req->max_frm_size = cpu_to_le16(new_mtu);
+	req->max_frm_size = cpu_to_le16(max_frm_size);
 
 	ret = hclge_cmd_send(&hdev->hw, &desc, 1);
 	if (ret) {
@@ -4577,6 +4583,8 @@ static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu)
 		return ret;
 	}
 
+	hdev->mps = max_frm_size;
+
 	return 0;
 }
 
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 50ae13a..83fb195 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -101,6 +101,11 @@
 /* CMDQ register bits for RX event(=MBX event) */
 #define HCLGE_VECTOR0_RX_CMDQ_INT_B	1
 
+#define HCLGE_MAC_DEFAULT_FRAME \
+	(ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN + ETH_DATA_LEN)
+#define HCLGE_MAC_MIN_FRAME		64
+#define HCLGE_MAC_MAX_FRAME		9728
+
 enum HCLGE_DEV_STATE {
 	HCLGE_STATE_REINITING,
 	HCLGE_STATE_DOWN,
-- 
1.9.1

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

* [PATCH net-next 16/20] net: hns3: fix for changing MTU
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (14 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 15/20] net: hns3: fix for setting MTU Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 17/20] net: hns3: add MTU initialization for hardware Peng Li
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Fuyun Liang <liangfuyun1@huawei.com>

when changing MTU, The new MTU must need to be set to netdevice.

Fixes: a8e8b7ff3517 ("net: hns3: Add support to change MTU in HNS3 hardware")
Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index eb9ac53..b23107d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -1413,6 +1413,8 @@ static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu)
 		return ret;
 	}
 
+	netdev->mtu = new_mtu;
+
 	/* if the netdev was running earlier, bring it up again */
 	if (if_running && hns3_nic_net_open(netdev))
 		ret = -EINVAL;
-- 
1.9.1

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

* [PATCH net-next 17/20] net: hns3: add MTU initialization for hardware
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (15 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 16/20] net: hns3: fix for changing MTU Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 18/20] net: hns3: fix for not setting pause parameters Peng Li
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Fuyun Liang <liangfuyun1@huawei.com>

When initializing the MAC, the MTU vlaue need to be set to the hardware
too. Otherwise, the MTU value of software will be different from the MTU
value of hardware.

Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c    | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index f1702db..f8dbd1e 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -36,6 +36,7 @@
 static int hclge_set_mta_filter_mode(struct hclge_dev *hdev,
 				     enum hclge_mta_dmac_sel_type mta_mac_sel,
 				     bool enable);
+static int hclge_set_mtu(struct hnae3_handle *handle, int new_mtu);
 static int hclge_init_vlan_config(struct hclge_dev *hdev);
 static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev);
 
@@ -2208,8 +2209,11 @@ static int hclge_set_default_mac_vlan_mask(struct hclge_dev *hdev,
 
 static int hclge_mac_init(struct hclge_dev *hdev)
 {
+	struct hnae3_handle *handle = &hdev->vport[0].nic;
+	struct net_device *netdev = handle->kinfo.netdev;
 	struct hclge_mac *mac = &hdev->hw.mac;
 	u8 mac_mask[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+	int mtu;
 	int ret;
 
 	ret = hclge_cfg_mac_speed_dup(hdev, hdev->hw.mac.speed, HCLGE_MAC_FULL);
@@ -2243,11 +2247,25 @@ static int hclge_mac_init(struct hclge_dev *hdev)
 	}
 
 	ret = hclge_set_default_mac_vlan_mask(hdev, true, mac_mask);
-	if (ret)
+	if (ret) {
 		dev_err(&hdev->pdev->dev,
 			"set default mac_vlan_mask fail ret=%d\n", ret);
+		return ret;
+	}
 
-	return ret;
+	if (netdev)
+		mtu = netdev->mtu;
+	else
+		mtu = ETH_DATA_LEN;
+
+	ret = hclge_set_mtu(handle, mtu);
+	if (ret) {
+		dev_err(&hdev->pdev->dev,
+			"set mtu failed ret=%d\n", ret);
+		return ret;
+	}
+
+	return 0;
 }
 
 static void hclge_mbx_task_schedule(struct hclge_dev *hdev)
-- 
1.9.1

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

* [PATCH net-next 18/20] net: hns3: fix for not setting pause parameters
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (16 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 17/20] net: hns3: add MTU initialization for hardware Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 19/20] net: hns3: remove redundant semicolon Peng Li
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Fuyun Liang <liangfuyun1@huawei.com>

Pause parameters include source address, transmit gap and pause time.
The default value of the pause source address is zero in the hardware.
Default pause parameters need to be set to the hardware. Also, when
setting new mac address, the pause source address need to be updated.

Fixes: 9dc2145d910e ("net: hns3: Add support for PFC setting in TM module")
Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c    | 36 ++++++++++++--
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c  | 58 +++++++++++++++++++++-
 .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h  | 11 ++++
 3 files changed, 98 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index f8dbd1e..24d75ca 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -4225,6 +4225,7 @@ static int hclge_set_mac_addr(struct hnae3_handle *handle, void *p)
 	const unsigned char *new_addr = (const unsigned char *)p;
 	struct hclge_vport *vport = hclge_get_vport(handle);
 	struct hclge_dev *hdev = vport->back;
+	int ret;
 
 	/* mac addr check */
 	if (is_zero_ether_addr(new_addr) ||
@@ -4236,14 +4237,39 @@ static int hclge_set_mac_addr(struct hnae3_handle *handle, void *p)
 		return -EINVAL;
 	}
 
-	hclge_rm_uc_addr(handle, hdev->hw.mac.mac_addr);
+	ret = hclge_rm_uc_addr(handle, hdev->hw.mac.mac_addr);
+	if (ret)
+		dev_warn(&hdev->pdev->dev,
+			 "remove old uc mac address fail, ret =%d.\n",
+			 ret);
 
-	if (!hclge_add_uc_addr(handle, new_addr)) {
-		ether_addr_copy(hdev->hw.mac.mac_addr, new_addr);
-		return 0;
+	ret = hclge_add_uc_addr(handle, new_addr);
+	if (ret) {
+		dev_err(&hdev->pdev->dev,
+			"add uc mac address fail, ret =%d.\n",
+			ret);
+
+		ret = hclge_add_uc_addr(handle, hdev->hw.mac.mac_addr);
+		if (ret) {
+			dev_err(&hdev->pdev->dev,
+				"restore uc mac address fail, ret =%d.\n",
+				ret);
+		}
+
+		return -EIO;
 	}
 
-	return -EIO;
+	ret = hclge_mac_pause_addr_cfg(hdev, new_addr);
+	if (ret) {
+		dev_err(&hdev->pdev->dev,
+			"configure mac pause address fail, ret =%d.\n",
+			ret);
+		return -EIO;
+	}
+
+	ether_addr_copy(hdev->hw.mac.mac_addr, new_addr);
+
+	return 0;
 }
 
 static int hclge_set_vlan_filter_ctrl(struct hclge_dev *hdev, u8 vlan_type,
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
index ea9355d..36bd79a 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
@@ -138,6 +138,46 @@ static int hclge_pfc_pause_en_cfg(struct hclge_dev *hdev, u8 tx_rx_bitmap,
 	return hclge_cmd_send(&hdev->hw, &desc, 1);
 }
 
+static int hclge_mac_pause_param_cfg(struct hclge_dev *hdev, const u8 *addr,
+				     u8 pause_trans_gap, u16 pause_trans_time)
+{
+	struct hclge_cfg_pause_param_cmd *pause_param;
+	struct hclge_desc desc;
+
+	pause_param = (struct hclge_cfg_pause_param_cmd *)&desc.data;
+
+	hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CFG_MAC_PARA, false);
+
+	ether_addr_copy(pause_param->mac_addr, addr);
+	pause_param->pause_trans_gap = pause_trans_gap;
+	pause_param->pause_trans_time = cpu_to_le16(pause_trans_time);
+
+	return hclge_cmd_send(&hdev->hw, &desc, 1);
+}
+
+int hclge_mac_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr)
+{
+	struct hclge_cfg_pause_param_cmd *pause_param;
+	struct hclge_desc desc;
+	u16 trans_time;
+	u8 trans_gap;
+	int ret;
+
+	pause_param = (struct hclge_cfg_pause_param_cmd *)&desc.data;
+
+	hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CFG_MAC_PARA, true);
+
+	ret = hclge_cmd_send(&hdev->hw, &desc, 1);
+	if (ret)
+		return ret;
+
+	trans_gap = pause_param->pause_trans_gap;
+	trans_time = le16_to_cpu(pause_param->pause_trans_time);
+
+	return hclge_mac_pause_param_cfg(hdev, mac_addr, trans_gap,
+					 trans_time);
+}
+
 static int hclge_fill_pri_array(struct hclge_dev *hdev, u8 *pri, u8 pri_id)
 {
 	u8 tc;
@@ -1056,6 +1096,15 @@ static int hclge_tm_schd_setup_hw(struct hclge_dev *hdev)
 	return hclge_tm_schd_mode_hw(hdev);
 }
 
+static int hclge_mac_pause_param_setup_hw(struct hclge_dev *hdev)
+{
+	struct hclge_mac *mac = &hdev->hw.mac;
+
+	return hclge_mac_pause_param_cfg(hdev, mac->mac_addr,
+					 HCLGE_DEFAULT_PAUSE_TRANS_GAP,
+					 HCLGE_DEFAULT_PAUSE_TRANS_TIME);
+}
+
 static int hclge_pfc_setup_hw(struct hclge_dev *hdev)
 {
 	u8 enable_bitmap = 0;
@@ -1102,8 +1151,13 @@ int hclge_pause_setup_hw(struct hclge_dev *hdev)
 	int ret;
 	u8 i;
 
-	if (hdev->tm_info.fc_mode != HCLGE_FC_PFC)
-		return hclge_mac_pause_setup_hw(hdev);
+	if (hdev->tm_info.fc_mode != HCLGE_FC_PFC) {
+		ret = hclge_mac_pause_setup_hw(hdev);
+		if (ret)
+			return ret;
+
+		return hclge_mac_pause_param_setup_hw(hdev);
+	}
 
 	/* Only DCB-supported dev supports qset back pressure and pfc cmd */
 	if (!hnae3_dev_dcb_supported(hdev))
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
index 16f4139..5401e75 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
@@ -18,6 +18,9 @@
 
 #define HCLGE_TM_PORT_BASE_MODE_MSK	BIT(0)
 
+#define HCLGE_DEFAULT_PAUSE_TRANS_GAP	0xFF
+#define HCLGE_DEFAULT_PAUSE_TRANS_TIME	0xFFFF
+
 /* SP or DWRR */
 #define HCLGE_TM_TX_SCHD_DWRR_MSK	BIT(0)
 #define HCLGE_TM_TX_SCHD_SP_MSK		(0xFE)
@@ -99,6 +102,13 @@ struct hclge_pfc_en_cmd {
 	u8 pri_en_bitmap;
 };
 
+struct hclge_cfg_pause_param_cmd {
+	u8 mac_addr[ETH_ALEN];
+	u8 pause_trans_gap;
+	u8 rsvd;
+	__le16 pause_trans_time;
+};
+
 struct hclge_port_shapping_cmd {
 	__le32 port_shapping_para;
 };
@@ -119,4 +129,5 @@ struct hclge_port_shapping_cmd {
 int hclge_tm_map_cfg(struct hclge_dev *hdev);
 int hclge_tm_init_hw(struct hclge_dev *hdev);
 int hclge_mac_pause_en_cfg(struct hclge_dev *hdev, bool tx, bool rx);
+int hclge_mac_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr);
 #endif
-- 
1.9.1

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

* [PATCH net-next 19/20] net: hns3: remove redundant semicolon
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (17 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 18/20] net: hns3: fix for not setting pause parameters Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-05 10:18 ` [PATCH net-next 20/20] net: hns3: Add more packet size statisctics Peng Li
  2018-01-08 19:08 ` [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver David Miller
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

There is a redundant semicolon, this patch removes it.

Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index f74b66a..655f522 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -1288,7 +1288,7 @@ static int hclgevf_pci_init(struct hclgevf_dev *hdev)
 	pci_set_master(pdev);
 	hw = &hdev->hw;
 	hw->hdev = hdev;
-	hw->io_base = pci_iomap(pdev, 2, 0);;
+	hw->io_base = pci_iomap(pdev, 2, 0);
 	if (!hw->io_base) {
 		dev_err(&pdev->dev, "can't map configuration register space\n");
 		ret = -ENOMEM;
-- 
1.9.1

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

* [PATCH net-next 20/20] net: hns3: Add more packet size statisctics
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (18 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 19/20] net: hns3: remove redundant semicolon Peng Li
@ 2018-01-05 10:18 ` Peng Li
  2018-01-08 19:08 ` [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver David Miller
  20 siblings, 0 replies; 33+ messages in thread
From: Peng Li @ 2018-01-05 10:18 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, linuxarm, salil.mehta, lipeng321

From: Jian Shen <shenjian15@huawei.com>

The statistics of rx/tx packets size greater than 1518
are not detailed. This patch adds more statistics for
different packet size range.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
---
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c    | 42 +++++++++++++++++++---
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h    | 21 +++++++++--
 2 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 24d75ca..d7352f5 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -295,8 +295,24 @@ static int hclge_set_mta_filter_mode(struct hclge_dev *hdev,
 		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_512_1023_oct_pkt_num)},
 	{"mac_tx_1024_1518_oct_pkt_num",
 		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_1024_1518_oct_pkt_num)},
-	{"mac_tx_1519_max_oct_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_1519_max_oct_pkt_num)},
+	{"mac_tx_1519_2047_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_1519_2047_oct_pkt_num)},
+	{"mac_tx_2048_4095_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_2048_4095_oct_pkt_num)},
+	{"mac_tx_4096_8191_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_4096_8191_oct_pkt_num)},
+	{"mac_tx_8192_12287_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_8192_12287_oct_pkt_num)},
+	{"mac_tx_8192_9216_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_8192_9216_oct_pkt_num)},
+	{"mac_tx_9217_12287_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_9217_12287_oct_pkt_num)},
+	{"mac_tx_12288_16383_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_12288_16383_oct_pkt_num)},
+	{"mac_tx_1519_max_good_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_1519_max_good_oct_pkt_num)},
+	{"mac_tx_1519_max_bad_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_1519_max_bad_oct_pkt_num)},
 	{"mac_rx_total_pkt_num",
 		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_total_pkt_num)},
 	{"mac_rx_total_oct_num",
@@ -331,8 +347,24 @@ static int hclge_set_mta_filter_mode(struct hclge_dev *hdev,
 		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_512_1023_oct_pkt_num)},
 	{"mac_rx_1024_1518_oct_pkt_num",
 		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_1024_1518_oct_pkt_num)},
-	{"mac_rx_1519_max_oct_pkt_num",
-		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_1519_max_oct_pkt_num)},
+	{"mac_rx_1519_2047_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_1519_2047_oct_pkt_num)},
+	{"mac_rx_2048_4095_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_2048_4095_oct_pkt_num)},
+	{"mac_rx_4096_8191_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_4096_8191_oct_pkt_num)},
+	{"mac_rx_8192_12287_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_8192_12287_oct_pkt_num)},
+	{"mac_rx_8192_9216_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_8192_9216_oct_pkt_num)},
+	{"mac_rx_9217_12287_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_9217_12287_oct_pkt_num)},
+	{"mac_rx_12288_16383_oct_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_12288_16383_oct_pkt_num)},
+	{"mac_rx_1519_max_good_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_1519_max_good_oct_pkt_num)},
+	{"mac_rx_1519_max_bad_pkt_num",
+		HCLGE_MAC_STATS_FIELD_OFF(mac_rx_1519_max_bad_oct_pkt_num)},
 
 	{"mac_tx_fragment_pkt_num",
 		HCLGE_MAC_STATS_FIELD_OFF(mac_tx_fragment_pkt_num)},
@@ -465,7 +497,7 @@ static int hclge_32_bit_update_stats(struct hclge_dev *hdev)
 
 static int hclge_mac_update_stats(struct hclge_dev *hdev)
 {
-#define HCLGE_MAC_CMD_NUM 17
+#define HCLGE_MAC_CMD_NUM 21
 #define HCLGE_RTN_DATA_NUM 4
 
 	u64 *data = (u64 *)(&hdev->hw_stats.mac_stats);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
index 83fb195..eeb6c8d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h
@@ -394,7 +394,16 @@ struct hclge_mac_stats {
 	u64 mac_tx_256_511_oct_pkt_num;
 	u64 mac_tx_512_1023_oct_pkt_num;
 	u64 mac_tx_1024_1518_oct_pkt_num;
-	u64 mac_tx_1519_max_oct_pkt_num;
+	u64 mac_tx_1519_2047_oct_pkt_num;
+	u64 mac_tx_2048_4095_oct_pkt_num;
+	u64 mac_tx_4096_8191_oct_pkt_num;
+	u64 mac_tx_8192_12287_oct_pkt_num; /* valid for GE MAC only */
+	u64 mac_tx_8192_9216_oct_pkt_num; /* valid for LGE & CGE MAC only */
+	u64 mac_tx_9217_12287_oct_pkt_num; /* valid for LGE & CGE MAC */
+	u64 mac_tx_12288_16383_oct_pkt_num;
+	u64 mac_tx_1519_max_good_oct_pkt_num;
+	u64 mac_tx_1519_max_bad_oct_pkt_num;
+
 	u64 mac_rx_total_pkt_num;
 	u64 mac_rx_total_oct_num;
 	u64 mac_rx_good_pkt_num;
@@ -412,7 +421,15 @@ struct hclge_mac_stats {
 	u64 mac_rx_256_511_oct_pkt_num;
 	u64 mac_rx_512_1023_oct_pkt_num;
 	u64 mac_rx_1024_1518_oct_pkt_num;
-	u64 mac_rx_1519_max_oct_pkt_num;
+	u64 mac_rx_1519_2047_oct_pkt_num;
+	u64 mac_rx_2048_4095_oct_pkt_num;
+	u64 mac_rx_4096_8191_oct_pkt_num;
+	u64 mac_rx_8192_12287_oct_pkt_num;/* valid for GE MAC only */
+	u64 mac_rx_8192_9216_oct_pkt_num; /* valid for LGE & CGE MAC only */
+	u64 mac_rx_9217_12287_oct_pkt_num; /* valid for LGE & CGE MAC only */
+	u64 mac_rx_12288_16383_oct_pkt_num;
+	u64 mac_rx_1519_max_good_oct_pkt_num;
+	u64 mac_rx_1519_max_bad_oct_pkt_num;
 
 	u64 mac_tx_fragment_pkt_num;
 	u64 mac_tx_undermin_pkt_num;
-- 
1.9.1

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

* Re: [PATCH net-next 06/20] net: hns3: Modify the update period of packet statistics
  2018-01-05 10:18 ` [PATCH net-next 06/20] net: hns3: Modify the update period of packet statistics Peng Li
@ 2018-01-05 14:54   ` Andrew Lunn
  2018-01-06  6:23     ` lipeng (Y)
  0 siblings, 1 reply; 33+ messages in thread
From: Andrew Lunn @ 2018-01-05 14:54 UTC (permalink / raw)
  To: Peng Li; +Cc: davem, netdev, linux-kernel, linuxarm, salil.mehta

> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> @@ -1126,6 +1126,7 @@ static int hns3_nic_set_features(struct net_device *netdev,
>  {
>  	struct hns3_nic_priv *priv = netdev_priv(netdev);
>  	int queue_num = priv->ae_handle->kinfo.num_tqps;
> +	struct hnae3_handle *handle = priv->ae_handle;
>  	struct hns3_enet_ring *ring;
>  	unsigned int start;
>  	unsigned int idx;
> @@ -1134,6 +1135,8 @@ static int hns3_nic_set_features(struct net_device *netdev,
>  	u64 tx_pkts = 0;
>  	u64 rx_pkts = 0;
>  
> +	handle->ae_algo->ops->update_stats(handle, &netdev->stats);
> +
>  	for (idx = 0; idx < queue_num; idx++) {
>  		/* fetch the tx stats */
>  		ring = priv->ring_data[idx].ring;

There is something odd going on with patch here. Notice how it says
hns3_nic_set_features(). This is not the function being patched, it is
actually the next one, hns3_nic_get_stats64(), which makes a lot more
sense.

Is it because the static void is on the previous line?

It would be nice if the function was correctly reported. It makes it
easier to review the patch.

       Andrew

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

* Re: [PATCH net-next 06/20] net: hns3: Modify the update period of packet statistics
  2018-01-05 14:54   ` Andrew Lunn
@ 2018-01-06  6:23     ` lipeng (Y)
  2018-01-06 15:49       ` Andrew Lunn
  0 siblings, 1 reply; 33+ messages in thread
From: lipeng (Y) @ 2018-01-06  6:23 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: davem, netdev, linux-kernel, linuxarm, salil.mehta



On 2018/1/5 22:54, Andrew Lunn wrote:
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
>> @@ -1126,6 +1126,7 @@ static int hns3_nic_set_features(struct net_device *netdev,
>>   {
>>   	struct hns3_nic_priv *priv = netdev_priv(netdev);
>>   	int queue_num = priv->ae_handle->kinfo.num_tqps;
>> +	struct hnae3_handle *handle = priv->ae_handle;
>>   	struct hns3_enet_ring *ring;
>>   	unsigned int start;
>>   	unsigned int idx;
>> @@ -1134,6 +1135,8 @@ static int hns3_nic_set_features(struct net_device *netdev,
>>   	u64 tx_pkts = 0;
>>   	u64 rx_pkts = 0;
>>   
>> +	handle->ae_algo->ops->update_stats(handle, &netdev->stats);
>> +
>>   	for (idx = 0; idx < queue_num; idx++) {
>>   		/* fetch the tx stats */
>>   		ring = priv->ring_data[idx].ring;
> There is something odd going on with patch here. Notice how it says
> hns3_nic_set_features(). This is not the function being patched, it is
> actually the next one, hns3_nic_get_stats64(), which makes a lot more
> sense.
>
> Is it because the static void is on the previous line?
Yes, it is because the static void is on the previous line.

I can add one patch to fix the  previous line ,  and this patch will 
correct  automatically.

do it need V2 patchset? or push a new patch after this patchset?

>
> It would be nice if the function was correctly reported. It makes it
> easier to review the patch.
>
>         Andrew
>
> .
>

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

* Re: [PATCH net-next 06/20] net: hns3: Modify the update period of packet statistics
  2018-01-06  6:23     ` lipeng (Y)
@ 2018-01-06 15:49       ` Andrew Lunn
  0 siblings, 0 replies; 33+ messages in thread
From: Andrew Lunn @ 2018-01-06 15:49 UTC (permalink / raw)
  To: lipeng (Y); +Cc: davem, netdev, linux-kernel, linuxarm, salil.mehta

> >Is it because the static void is on the previous line?
> Yes, it is because the static void is on the previous line.
> 
> I can add one patch to fix the  previous line ,  and this patch will correct
> automatically.
> 
> do it need V2 patchset? or push a new patch after this patchset?

Thanks for looking into this. This actually seems like a patch bug,
but i think the consensus is to have the function type on the same
line as the function name within Linux.

No need for a v2. Just send followup patches.

   Andrew

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

* Re: [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver
  2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
                   ` (19 preceding siblings ...)
  2018-01-05 10:18 ` [PATCH net-next 20/20] net: hns3: Add more packet size statisctics Peng Li
@ 2018-01-08 19:08 ` David Miller
  20 siblings, 0 replies; 33+ messages in thread
From: David Miller @ 2018-01-08 19:08 UTC (permalink / raw)
  To: lipeng321; +Cc: netdev, linux-kernel, linuxarm, salil.mehta

From: Peng Li <lipeng321@huawei.com>
Date: Fri, 5 Jan 2018 18:18:04 +0800

> This patchset adds some new features support and fixes some bugs:
> [Patch 1/20] adds support to enable/disable vlan filter with ethtool
> [Patch 2/20] disables VFs change rxvlan offload status
> [Patch 3/20 - 13/120 fix bugs and refine some codes for packet
> statistics, support query with both ifconfig and ethtool.
> [Patch 14/20 - 20/20] fix some other bugs.

Series applied, thank you.

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

* Re: [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev
  2018-01-05 10:18 ` [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev Peng Li
@ 2018-01-08 20:04   ` Jakub Kicinski
  2018-01-09  1:39     ` David Miller
  0 siblings, 1 reply; 33+ messages in thread
From: Jakub Kicinski @ 2018-01-08 20:04 UTC (permalink / raw)
  To: Peng Li; +Cc: davem, netdev, linux-kernel, linuxarm, salil.mehta

On Fri, 5 Jan 2018 18:18:16 +0800, Peng Li wrote:
> +static const struct hns3_stats hns3_netdev_stats[] = {
> +	/* Rx per-queue statistics */
> +	HNS3_NETDEV_STAT("rx_packets", rx_packets),
> +	HNS3_NETDEV_STAT("tx_packets", tx_packets),
> +	HNS3_NETDEV_STAT("rx_bytes", rx_bytes),
> +	HNS3_NETDEV_STAT("tx_bytes", tx_bytes),
> +	HNS3_NETDEV_STAT("rx_errors", rx_errors),
> +	HNS3_NETDEV_STAT("tx_errors", tx_errors),
> +	HNS3_NETDEV_STAT("rx_dropped", rx_dropped),
> +	HNS3_NETDEV_STAT("tx_dropped", tx_dropped),
> +	HNS3_NETDEV_STAT("multicast", multicast),
> +	HNS3_NETDEV_STAT("collisions", collisions),
> +	HNS3_NETDEV_STAT("rx_length_errors", rx_length_errors),
> +	HNS3_NETDEV_STAT("rx_over_errors", rx_over_errors),
> +	HNS3_NETDEV_STAT("rx_crc_errors", rx_crc_errors),
> +	HNS3_NETDEV_STAT("rx_frame_errors", rx_frame_errors),
> +	HNS3_NETDEV_STAT("rx_fifo_errors", rx_fifo_errors),
> +	HNS3_NETDEV_STAT("rx_missed_errors", rx_missed_errors),
> +	HNS3_NETDEV_STAT("tx_aborted_errors", tx_aborted_errors),
> +	HNS3_NETDEV_STAT("tx_carrier_errors", tx_carrier_errors),
> +	HNS3_NETDEV_STAT("tx_fifo_errors", tx_fifo_errors),
> +	HNS3_NETDEV_STAT("tx_heartbeat_errors", tx_heartbeat_errors),
> +	HNS3_NETDEV_STAT("tx_window_errors", tx_window_errors),
> +	HNS3_NETDEV_STAT("rx_compressed", rx_compressed),
> +	HNS3_NETDEV_STAT("tx_compressed", tx_compressed),
> +};

Ugh, I so didn't review this in time :(  I think there is a consensus
that we should avoid duplicating standard stats in ethtool.  Especially
those old ones.  Like "collisions", I assume this is a modern NIC, are
collisions still a thing?

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

* Re: [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev
  2018-01-08 20:04   ` Jakub Kicinski
@ 2018-01-09  1:39     ` David Miller
  2018-01-09  1:46       ` Jakub Kicinski
  0 siblings, 1 reply; 33+ messages in thread
From: David Miller @ 2018-01-09  1:39 UTC (permalink / raw)
  To: kubakici; +Cc: lipeng321, netdev, linux-kernel, linuxarm, salil.mehta

From: Jakub Kicinski <kubakici@wp.pl>
Date: Mon, 8 Jan 2018 12:04:31 -0800

> Ugh, I so didn't review this in time :(  I think there is a consensus
> that we should avoid duplicating standard stats in ethtool.  Especially
> those old ones.  Like "collisions", I assume this is a modern NIC, are
> collisions still a thing?

There is no standard way to get per-queue values, and ethtool stats are
how pretty much every driver provides it.

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

* Re: [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev
  2018-01-09  1:39     ` David Miller
@ 2018-01-09  1:46       ` Jakub Kicinski
  2018-01-09  1:50         ` Jakub Kicinski
  0 siblings, 1 reply; 33+ messages in thread
From: Jakub Kicinski @ 2018-01-09  1:46 UTC (permalink / raw)
  To: David Miller; +Cc: lipeng321, netdev, linux-kernel, linuxarm, salil.mehta

On Mon, 08 Jan 2018 20:39:13 -0500 (EST), David Miller wrote:
> From: Jakub Kicinski <kubakici@wp.pl>
> Date: Mon, 8 Jan 2018 12:04:31 -0800
> 
> > Ugh, I so didn't review this in time :(  I think there is a consensus
> > that we should avoid duplicating standard stats in ethtool.  Especially
> > those old ones.  Like "collisions", I assume this is a modern NIC, are
> > collisions still a thing?  
> 
> There is no standard way to get per-queue values, and ethtool stats are
> how pretty much every driver provides it.

Right, agreed.  I'm only objecting to this patch (12/20), where we can
see the telltale code like this:

+	const struct rtnl_link_stats64 *net_stats;
+	struct rtnl_link_stats64 temp;
+
+	net_stats = dev_get_stats(netdev, &temp);
+	for (i = 0; i < HNS3_NETDEV_STATS_COUNT; i++) {
+		stat = (u8 *)net_stats + hns3_netdev_stats[i].stats_offset;
+		*data++ = *(u64 *)stat;
+	}

Where:

+#define HNS3_NETDEV_STAT(_string, _member)	{			\
+	.stats_string = _string,					\
+	.stats_offset = offsetof(struct rtnl_link_stats64, _member)	\
+}
+
+static const struct hns3_stats hns3_netdev_stats[] = {
+	/* Rx per-queue statistics */
+	HNS3_NETDEV_STAT("rx_packets", rx_packets),
+	HNS3_NETDEV_STAT("tx_packets", tx_packets),

etc.  IOW dumping struct rtnl_link_stats64 to ethtool -S member by
member.

Let me put the netlink per-queue stats on my soft TODO list :)

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

* Re: [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev
  2018-01-09  1:46       ` Jakub Kicinski
@ 2018-01-09  1:50         ` Jakub Kicinski
  2018-01-09  1:54           ` David Miller
  0 siblings, 1 reply; 33+ messages in thread
From: Jakub Kicinski @ 2018-01-09  1:50 UTC (permalink / raw)
  To: David Miller; +Cc: lipeng321, netdev, linux-kernel, linuxarm, salil.mehta

On Mon, 8 Jan 2018 17:46:02 -0800, Jakub Kicinski wrote:
> On Mon, 08 Jan 2018 20:39:13 -0500 (EST), David Miller wrote:
> > From: Jakub Kicinski <kubakici@wp.pl>
> > Date: Mon, 8 Jan 2018 12:04:31 -0800
> >   
> > > Ugh, I so didn't review this in time :(  I think there is a consensus
> > > that we should avoid duplicating standard stats in ethtool.  Especially
> > > those old ones.  Like "collisions", I assume this is a modern NIC, are
> > > collisions still a thing?    
> > 
> > There is no standard way to get per-queue values, and ethtool stats are
> > how pretty much every driver provides it.  
> 
> Right, agreed.  I'm only objecting to this patch (12/20), where we can
> see the telltale code like this:
> 
> +	const struct rtnl_link_stats64 *net_stats;
> +	struct rtnl_link_stats64 temp;
> +
> +	net_stats = dev_get_stats(netdev, &temp);
> +	for (i = 0; i < HNS3_NETDEV_STATS_COUNT; i++) {
> +		stat = (u8 *)net_stats + hns3_netdev_stats[i].stats_offset;
> +		*data++ = *(u64 *)stat;
> +	}
> 
> Where:
> 
> +#define HNS3_NETDEV_STAT(_string, _member)	{			\
> +	.stats_string = _string,					\
> +	.stats_offset = offsetof(struct rtnl_link_stats64, _member)	\
> +}
> +
> +static const struct hns3_stats hns3_netdev_stats[] = {
> +	/* Rx per-queue statistics */

Oh, I only noticed this extra misleading comment now.  Unless each queue
has a netdev, I don't see how these are per-queue.

> +	HNS3_NETDEV_STAT("rx_packets", rx_packets),
> +	HNS3_NETDEV_STAT("tx_packets", tx_packets),
> 
> etc.  IOW dumping struct rtnl_link_stats64 to ethtool -S member by
> member.
> 
> Let me put the netlink per-queue stats on my soft TODO list :)
> 

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

* Re: [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev
  2018-01-09  1:50         ` Jakub Kicinski
@ 2018-01-09  1:54           ` David Miller
  2018-01-09  2:48             ` lipeng (Y)
  0 siblings, 1 reply; 33+ messages in thread
From: David Miller @ 2018-01-09  1:54 UTC (permalink / raw)
  To: kubakici; +Cc: lipeng321, netdev, linux-kernel, linuxarm, salil.mehta

From: Jakub Kicinski <kubakici@wp.pl>
Date: Mon, 8 Jan 2018 17:50:21 -0800

> Oh, I only noticed this extra misleading comment now.  Unless each queue
> has a netdev, I don't see how these are per-queue.

If it isn't per-queue I want this change reverted.

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

* Re: [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev
  2018-01-09  1:54           ` David Miller
@ 2018-01-09  2:48             ` lipeng (Y)
  2018-01-09  3:06               ` David Miller
  0 siblings, 1 reply; 33+ messages in thread
From: lipeng (Y) @ 2018-01-09  2:48 UTC (permalink / raw)
  To: David Miller, kubakici; +Cc: netdev, linux-kernel, linuxarm, salil.mehta



On 2018/1/9 9:54, David Miller wrote:
> From: Jakub Kicinski <kubakici@wp.pl>
> Date: Mon, 8 Jan 2018 17:50:21 -0800
>
>> Oh, I only noticed this extra misleading comment now.  Unless each queue
>> has a netdev, I don't see how these are per-queue.
> If it isn't per-queue I want this change reverted.

[patch 12/20 ] add statistics of netdev for ethtool -S, netdev may have 
multi queue.

As discussion here,  it is duplicate to add this patch.


I revert  [patch 12/20 ] , and then test on my board, HNS3 basic function and ethtool -S work well.

So I think it is OK if you can revert  [patch 12/20 ]("net: hns3: Add packet statistics of netdev").


Thanks
Peng Li

> .
>

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

* Re: [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev
  2018-01-09  2:48             ` lipeng (Y)
@ 2018-01-09  3:06               ` David Miller
  2018-01-09  3:27                 ` lipeng (Y)
  0 siblings, 1 reply; 33+ messages in thread
From: David Miller @ 2018-01-09  3:06 UTC (permalink / raw)
  To: lipeng321; +Cc: kubakici, netdev, linux-kernel, linuxarm, salil.mehta

From: "lipeng (Y)" <lipeng321@huawei.com>
Date: Tue, 9 Jan 2018 10:48:04 +0800

> So I think it is OK if you can revert [patch 12/20 ]("net: hns3: Add
> packet statistics of netdev").

I think it is OK if you send the revert patch, which is what I
am asking for :-)

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

* Re: [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev
  2018-01-09  3:06               ` David Miller
@ 2018-01-09  3:27                 ` lipeng (Y)
  0 siblings, 0 replies; 33+ messages in thread
From: lipeng (Y) @ 2018-01-09  3:27 UTC (permalink / raw)
  To: David Miller; +Cc: kubakici, netdev, linux-kernel, linuxarm, salil.mehta



On 2018/1/9 11:06, David Miller wrote:
> From: "lipeng (Y)" <lipeng321@huawei.com>
> Date: Tue, 9 Jan 2018 10:48:04 +0800
>
>> So I think it is OK if you can revert [patch 12/20 ]("net: hns3: Add
>> packet statistics of netdev").
> I think it is OK if you send the revert patch, which is what I
> am asking for :-)
>
> .
sure,  i will send the revert patch.
I have tested it in my local branch.

Thanks
Peng Li

>

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

end of thread, other threads:[~2018-01-09  3:27 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-05 10:18 [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver Peng Li
2018-01-05 10:18 ` [PATCH net-next 01/20] net: hns3: Add ethtool interface for vlan filter Peng Li
2018-01-05 10:18 ` [PATCH net-next 02/20] net: hns3: Disable VFs change rxvlan offload status Peng Li
2018-01-05 10:18 ` [PATCH net-next 03/20] net: hns3: Unify the strings display of packet statistics Peng Li
2018-01-05 10:18 ` [PATCH net-next 04/20] net: hns3: Fix spelling errors Peng Li
2018-01-05 10:18 ` [PATCH net-next 05/20] net: hns3: Remove repeat statistic of rx_errors Peng Li
2018-01-05 10:18 ` [PATCH net-next 06/20] net: hns3: Modify the update period of packet statistics Peng Li
2018-01-05 14:54   ` Andrew Lunn
2018-01-06  6:23     ` lipeng (Y)
2018-01-06 15:49       ` Andrew Lunn
2018-01-05 10:18 ` [PATCH net-next 07/20] net: hns3: Mask the packet statistics query when NIC is down Peng Li
2018-01-05 10:18 ` [PATCH net-next 08/20] net: hns3: Fix an error of total drop packet statistics Peng Li
2018-01-05 10:18 ` [PATCH net-next 09/20] net: hns3: Fix a loop index error of tqp statistics query Peng Li
2018-01-05 10:18 ` [PATCH net-next 10/20] net: hns3: Fix an error macro definition of HNS3_TQP_STAT Peng Li
2018-01-05 10:18 ` [PATCH net-next 11/20] net: hns3: Remove a useless member of struct hns3_stats Peng Li
2018-01-05 10:18 ` [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev Peng Li
2018-01-08 20:04   ` Jakub Kicinski
2018-01-09  1:39     ` David Miller
2018-01-09  1:46       ` Jakub Kicinski
2018-01-09  1:50         ` Jakub Kicinski
2018-01-09  1:54           ` David Miller
2018-01-09  2:48             ` lipeng (Y)
2018-01-09  3:06               ` David Miller
2018-01-09  3:27                 ` lipeng (Y)
2018-01-05 10:18 ` [PATCH net-next 13/20] net: hns3: Fix a response data read error of tqp statistics query Peng Li
2018-01-05 10:18 ` [PATCH net-next 14/20] net: hns3: fix for updating fc_mode_last_time Peng Li
2018-01-05 10:18 ` [PATCH net-next 15/20] net: hns3: fix for setting MTU Peng Li
2018-01-05 10:18 ` [PATCH net-next 16/20] net: hns3: fix for changing MTU Peng Li
2018-01-05 10:18 ` [PATCH net-next 17/20] net: hns3: add MTU initialization for hardware Peng Li
2018-01-05 10:18 ` [PATCH net-next 18/20] net: hns3: fix for not setting pause parameters Peng Li
2018-01-05 10:18 ` [PATCH net-next 19/20] net: hns3: remove redundant semicolon Peng Li
2018-01-05 10:18 ` [PATCH net-next 20/20] net: hns3: Add more packet size statisctics Peng Li
2018-01-08 19:08 ` [PATCH net-next 00/20] add some new features and fix some bugs for HNS3 driver David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.