Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e2d92218 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'hns3-next'



Peng Li says:

====================
add some new features and fix some bugs for HNS3 driver

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.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents b60f699e 91f384f6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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,
+34 −4
Original line number Diff line number Diff line
@@ -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)
@@ -1101,6 +1106,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)
@@ -1121,6 +1131,7 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
{
	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;
@@ -1128,6 +1139,13 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
	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;

	handle->ae_algo->ops->update_stats(handle, &netdev->stats);

	for (idx = 0; idx < queue_num; idx++) {
		/* fetch the tx stats */
@@ -1136,6 +1154,8 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
			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 */
@@ -1144,6 +1164,9 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
			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));
	}

@@ -1159,8 +1182,8 @@ hns3_nic_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats)
	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;
@@ -1390,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;
@@ -1549,6 +1574,8 @@ static struct pci_driver hns3_driver = {
/* 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 +1604,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_FILTER |
		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 | NETIF_F_HW_VLAN_CTAG_RX;
}

static int hns3_alloc_buffer(struct hns3_enet_ring *ring,
+114 −34
Original line number Diff line number Diff line
@@ -15,26 +15,25 @@

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),	\
}								\
	.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 */
	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,24 +41,59 @@ static const struct hns3_stats hns3_txq_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)

#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
@@ -389,9 +423,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 +435,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 +452,37 @@ 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;
}

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;
}
@@ -440,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;
@@ -455,13 +514,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;
		}
	}
@@ -469,8 +528,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;
		}
	}
@@ -478,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.
@@ -494,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);
+0 −2
Original line number Diff line number Diff line
@@ -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 {
+166 −66

File changed.

Preview size limit exceeded, changes collapsed.

Loading