2018-07-19 22:47:06 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
// Copyright (c) 2016-2017 Hisilicon Limited.
|
2017-08-02 23:59:51 +08:00
|
|
|
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/string.h>
|
2017-11-03 12:18:25 +08:00
|
|
|
#include <linux/phy.h>
|
2020-04-29 11:46:24 +08:00
|
|
|
#include <linux/sfp.h>
|
2017-08-02 23:59:51 +08:00
|
|
|
|
|
|
|
#include "hns3_enet.h"
|
|
|
|
|
|
|
|
struct hns3_stats {
|
|
|
|
char stats_string[ETH_GSTRING_LEN];
|
|
|
|
int stats_offset;
|
|
|
|
};
|
|
|
|
|
2020-04-29 11:46:24 +08:00
|
|
|
struct hns3_sfp_type {
|
|
|
|
u8 type;
|
|
|
|
u8 ext_type;
|
|
|
|
};
|
|
|
|
|
2017-08-02 23:59:51 +08:00
|
|
|
/* tqp related stats */
|
|
|
|
#define HNS3_TQP_STAT(_string, _member) { \
|
|
|
|
.stats_string = _string, \
|
2018-01-05 18:18:14 +08:00
|
|
|
.stats_offset = offsetof(struct hns3_enet_ring, stats) +\
|
|
|
|
offsetof(struct ring_stats, _member), \
|
2018-01-05 18:18:15 +08:00
|
|
|
}
|
2017-08-02 23:59:51 +08:00
|
|
|
|
|
|
|
static const struct hns3_stats hns3_txq_stats[] = {
|
|
|
|
/* Tx per-queue statistics */
|
2018-01-05 18:18:07 +08:00
|
|
|
HNS3_TQP_STAT("io_err_cnt", io_err_cnt),
|
2018-09-21 23:41:39 +08:00
|
|
|
HNS3_TQP_STAT("dropped", sw_err_cnt),
|
2018-01-05 18:18:07 +08:00
|
|
|
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),
|
2018-09-21 23:41:39 +08:00
|
|
|
HNS3_TQP_STAT("wake", restart_queue),
|
|
|
|
HNS3_TQP_STAT("busy", tx_busy),
|
2019-05-06 10:48:41 +08:00
|
|
|
HNS3_TQP_STAT("copy", tx_copy),
|
2019-08-09 10:31:13 +08:00
|
|
|
HNS3_TQP_STAT("vlan_err", tx_vlan_err),
|
|
|
|
HNS3_TQP_STAT("l4_proto_err", tx_l4_proto_err),
|
|
|
|
HNS3_TQP_STAT("l2l3l4_err", tx_l2l3l4_err),
|
|
|
|
HNS3_TQP_STAT("tso_err", tx_tso_err),
|
2017-08-02 23:59:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define HNS3_TXQ_STATS_COUNT ARRAY_SIZE(hns3_txq_stats)
|
|
|
|
|
|
|
|
static const struct hns3_stats hns3_rxq_stats[] = {
|
|
|
|
/* Rx per-queue statistics */
|
2018-01-05 18:18:07 +08:00
|
|
|
HNS3_TQP_STAT("io_err_cnt", io_err_cnt),
|
2018-09-21 23:41:39 +08:00
|
|
|
HNS3_TQP_STAT("dropped", sw_err_cnt),
|
2018-01-05 18:18:07 +08:00
|
|
|
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("err_bd_num", err_bd_num),
|
|
|
|
HNS3_TQP_STAT("l2_err", l2_err),
|
|
|
|
HNS3_TQP_STAT("l3l4_csum_err", l3l4_csum_err),
|
2019-01-23 07:39:28 +08:00
|
|
|
HNS3_TQP_STAT("multicast", rx_multicast),
|
2019-05-06 10:48:43 +08:00
|
|
|
HNS3_TQP_STAT("non_reuse_pg", non_reuse_pg),
|
2017-08-02 23:59:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define HNS3_RXQ_STATS_COUNT ARRAY_SIZE(hns3_rxq_stats)
|
|
|
|
|
|
|
|
#define HNS3_TQP_STATS_COUNT (HNS3_TXQ_STATS_COUNT + HNS3_RXQ_STATS_COUNT)
|
|
|
|
|
2019-08-28 22:23:14 +08:00
|
|
|
#define HNS3_SELF_TEST_TYPE_NUM 4
|
2017-10-20 10:19:22 +08:00
|
|
|
#define HNS3_NIC_LB_TEST_PKT_NUM 1
|
|
|
|
#define HNS3_NIC_LB_TEST_RING_ID 0
|
|
|
|
#define HNS3_NIC_LB_TEST_PACKET_SIZE 128
|
2019-06-07 10:03:10 +08:00
|
|
|
#define HNS3_NIC_LB_SETUP_USEC 10000
|
2017-10-20 10:19:22 +08:00
|
|
|
|
|
|
|
/* Nic loopback test err */
|
|
|
|
#define HNS3_NIC_LB_TEST_NO_MEM_ERR 1
|
|
|
|
#define HNS3_NIC_LB_TEST_TX_CNT_ERR 2
|
|
|
|
#define HNS3_NIC_LB_TEST_RX_CNT_ERR 3
|
|
|
|
|
2018-05-10 00:24:41 +08:00
|
|
|
static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop, bool en)
|
2017-10-20 10:19:22 +08:00
|
|
|
{
|
|
|
|
struct hnae3_handle *h = hns3_get_handle(ndev);
|
2018-10-12 22:34:06 +08:00
|
|
|
bool vlan_filter_enable;
|
2017-10-20 10:19:22 +08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!h->ae_algo->ops->set_loopback ||
|
|
|
|
!h->ae_algo->ops->set_promisc_mode)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
switch (loop) {
|
2018-09-27 02:28:35 +08:00
|
|
|
case HNAE3_LOOP_SERIAL_SERDES:
|
|
|
|
case HNAE3_LOOP_PARALLEL_SERDES:
|
2018-09-27 02:28:34 +08:00
|
|
|
case HNAE3_LOOP_APP:
|
2019-08-28 22:23:14 +08:00
|
|
|
case HNAE3_LOOP_PHY:
|
2018-05-10 00:24:41 +08:00
|
|
|
ret = h->ae_algo->ops->set_loopback(h, loop, en);
|
2017-10-20 10:19:22 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -ENOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
net: hns3: not allow SSU loopback while execute ethtool -t dev
The current loopback mode is to add 0x1F to the SMAC address
as the DMAC address and enable the promiscuous mode.
However, if the VF address is the same as the DMAC address,
the loopback test fails.
Loopback can be enabled in three places: SSU, MAC, and serdes.
By default, SSU loopback is enabled, so if the SMAC and the DMAC
are the same, the packets are looped back in the SSU. If SSU loopback
is disabled, packets can reach MAC even if SMAC is the same as DMAC.
Therefore, this patch disables the SSU loopback before the loopback
test. In this way, the SMAC and DMAC can be the same, and the
promiscuous mode does not need to be enabled. And this is not
valid in version 0x20.
This patch also uses a macro to replace 0x1F.
Fixes: c39c4d98dc65 ("net: hns3: Add mac loopback selftest support in hns3 driver")
Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Reviewed-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-28 22:23:16 +08:00
|
|
|
if (ret || h->pdev->revision >= 0x21)
|
2017-10-20 10:19:22 +08:00
|
|
|
return ret;
|
|
|
|
|
2018-10-12 22:34:06 +08:00
|
|
|
if (en) {
|
|
|
|
h->ae_algo->ops->set_promisc_mode(h, true, true);
|
|
|
|
} else {
|
|
|
|
/* recover promisc mode before loopback test */
|
2020-04-24 10:23:11 +08:00
|
|
|
hns3_request_update_promisc_mode(h);
|
2018-10-12 22:34:06 +08:00
|
|
|
vlan_filter_enable = ndev->flags & IFF_PROMISC ? false : true;
|
|
|
|
hns3_enable_vlan_filter(ndev, vlan_filter_enable);
|
|
|
|
}
|
2017-10-20 10:19:22 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hns3_lp_up(struct net_device *ndev, enum hnae3_loop loop_mode)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *h = hns3_get_handle(ndev);
|
|
|
|
int ret;
|
|
|
|
|
2018-05-26 02:43:04 +08:00
|
|
|
ret = hns3_nic_reset_all_ring(h);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2018-05-10 00:24:41 +08:00
|
|
|
ret = hns3_lp_setup(ndev, loop_mode, true);
|
2019-06-07 10:03:10 +08:00
|
|
|
usleep_range(HNS3_NIC_LB_SETUP_USEC, HNS3_NIC_LB_SETUP_USEC * 2);
|
2017-10-20 10:19:22 +08:00
|
|
|
|
2019-01-27 00:49:13 +08:00
|
|
|
return ret;
|
2017-10-20 10:19:22 +08:00
|
|
|
}
|
|
|
|
|
2018-05-10 00:24:41 +08:00
|
|
|
static int hns3_lp_down(struct net_device *ndev, enum hnae3_loop loop_mode)
|
2017-10-20 10:19:22 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2018-05-10 00:24:41 +08:00
|
|
|
ret = hns3_lp_setup(ndev, loop_mode, false);
|
2017-10-20 10:19:22 +08:00
|
|
|
if (ret) {
|
|
|
|
netdev_err(ndev, "lb_setup return error: %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-06-07 10:03:10 +08:00
|
|
|
usleep_range(HNS3_NIC_LB_SETUP_USEC, HNS3_NIC_LB_SETUP_USEC * 2);
|
2017-10-20 10:19:22 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hns3_lp_setup_skb(struct sk_buff *skb)
|
|
|
|
{
|
net: hns3: not allow SSU loopback while execute ethtool -t dev
The current loopback mode is to add 0x1F to the SMAC address
as the DMAC address and enable the promiscuous mode.
However, if the VF address is the same as the DMAC address,
the loopback test fails.
Loopback can be enabled in three places: SSU, MAC, and serdes.
By default, SSU loopback is enabled, so if the SMAC and the DMAC
are the same, the packets are looped back in the SSU. If SSU loopback
is disabled, packets can reach MAC even if SMAC is the same as DMAC.
Therefore, this patch disables the SSU loopback before the loopback
test. In this way, the SMAC and DMAC can be the same, and the
promiscuous mode does not need to be enabled. And this is not
valid in version 0x20.
This patch also uses a macro to replace 0x1F.
Fixes: c39c4d98dc65 ("net: hns3: Add mac loopback selftest support in hns3 driver")
Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Reviewed-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-28 22:23:16 +08:00
|
|
|
#define HNS3_NIC_LB_DST_MAC_ADDR 0x1f
|
|
|
|
|
2017-10-20 10:19:22 +08:00
|
|
|
struct net_device *ndev = skb->dev;
|
net: hns3: not allow SSU loopback while execute ethtool -t dev
The current loopback mode is to add 0x1F to the SMAC address
as the DMAC address and enable the promiscuous mode.
However, if the VF address is the same as the DMAC address,
the loopback test fails.
Loopback can be enabled in three places: SSU, MAC, and serdes.
By default, SSU loopback is enabled, so if the SMAC and the DMAC
are the same, the packets are looped back in the SSU. If SSU loopback
is disabled, packets can reach MAC even if SMAC is the same as DMAC.
Therefore, this patch disables the SSU loopback before the loopback
test. In this way, the SMAC and DMAC can be the same, and the
promiscuous mode does not need to be enabled. And this is not
valid in version 0x20.
This patch also uses a macro to replace 0x1F.
Fixes: c39c4d98dc65 ("net: hns3: Add mac loopback selftest support in hns3 driver")
Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Reviewed-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-28 22:23:16 +08:00
|
|
|
struct hnae3_handle *handle;
|
2017-10-20 10:19:22 +08:00
|
|
|
unsigned char *packet;
|
|
|
|
struct ethhdr *ethh;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
skb_reserve(skb, NET_IP_ALIGN);
|
|
|
|
ethh = skb_put(skb, sizeof(struct ethhdr));
|
|
|
|
packet = skb_put(skb, HNS3_NIC_LB_TEST_PACKET_SIZE);
|
|
|
|
|
|
|
|
memcpy(ethh->h_dest, ndev->dev_addr, ETH_ALEN);
|
2019-06-07 10:03:13 +08:00
|
|
|
|
|
|
|
/* The dst mac addr of loopback packet is the same as the host'
|
|
|
|
* mac addr, the SSU component may loop back the packet to host
|
|
|
|
* before the packet reaches mac or serdes, which will defect
|
|
|
|
* the purpose of mac or serdes selftest.
|
|
|
|
*/
|
net: hns3: not allow SSU loopback while execute ethtool -t dev
The current loopback mode is to add 0x1F to the SMAC address
as the DMAC address and enable the promiscuous mode.
However, if the VF address is the same as the DMAC address,
the loopback test fails.
Loopback can be enabled in three places: SSU, MAC, and serdes.
By default, SSU loopback is enabled, so if the SMAC and the DMAC
are the same, the packets are looped back in the SSU. If SSU loopback
is disabled, packets can reach MAC even if SMAC is the same as DMAC.
Therefore, this patch disables the SSU loopback before the loopback
test. In this way, the SMAC and DMAC can be the same, and the
promiscuous mode does not need to be enabled. And this is not
valid in version 0x20.
This patch also uses a macro to replace 0x1F.
Fixes: c39c4d98dc65 ("net: hns3: Add mac loopback selftest support in hns3 driver")
Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Reviewed-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-28 22:23:16 +08:00
|
|
|
handle = hns3_get_handle(ndev);
|
|
|
|
if (handle->pdev->revision == 0x20)
|
|
|
|
ethh->h_dest[5] += HNS3_NIC_LB_DST_MAC_ADDR;
|
2017-10-20 10:19:22 +08:00
|
|
|
eth_zero_addr(ethh->h_source);
|
|
|
|
ethh->h_proto = htons(ETH_P_ARP);
|
|
|
|
skb_reset_mac_header(skb);
|
|
|
|
|
|
|
|
for (i = 0; i < HNS3_NIC_LB_TEST_PACKET_SIZE; i++)
|
|
|
|
packet[i] = (unsigned char)(i & 0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hns3_lb_check_skb_data(struct hns3_enet_ring *ring,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct hns3_enet_tqp_vector *tqp_vector = ring->tqp_vector;
|
|
|
|
unsigned char *packet = skb->data;
|
|
|
|
u32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < skb->len; i++)
|
|
|
|
if (packet[i] != (unsigned char)(i & 0xff))
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* The packet is correctly received */
|
|
|
|
if (i == skb->len)
|
|
|
|
tqp_vector->rx_group.total_packets++;
|
|
|
|
else
|
|
|
|
print_hex_dump(KERN_ERR, "selftest:", DUMP_PREFIX_OFFSET, 16, 1,
|
|
|
|
skb->data, skb->len, true);
|
|
|
|
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 hns3_lb_check_rx_ring(struct hns3_nic_priv *priv, u32 budget)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *h = priv->ae_handle;
|
|
|
|
struct hnae3_knic_private_info *kinfo;
|
|
|
|
u32 i, rcv_good_pkt_total = 0;
|
|
|
|
|
|
|
|
kinfo = &h->kinfo;
|
|
|
|
for (i = kinfo->num_tqps; i < kinfo->num_tqps * 2; i++) {
|
2019-10-19 16:03:49 +08:00
|
|
|
struct hns3_enet_ring *ring = &priv->ring[i];
|
2017-10-20 10:19:22 +08:00
|
|
|
struct hns3_enet_ring_group *rx_group;
|
|
|
|
u64 pre_rx_pkt;
|
|
|
|
|
|
|
|
rx_group = &ring->tqp_vector->rx_group;
|
|
|
|
pre_rx_pkt = rx_group->total_packets;
|
|
|
|
|
2018-07-06 18:28:01 +08:00
|
|
|
preempt_disable();
|
2017-10-20 10:19:22 +08:00
|
|
|
hns3_clean_rx_ring(ring, budget, hns3_lb_check_skb_data);
|
2018-07-06 18:28:01 +08:00
|
|
|
preempt_enable();
|
2017-10-20 10:19:22 +08:00
|
|
|
|
|
|
|
rcv_good_pkt_total += (rx_group->total_packets - pre_rx_pkt);
|
|
|
|
rx_group->total_packets = pre_rx_pkt;
|
|
|
|
}
|
|
|
|
return rcv_good_pkt_total;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hns3_lb_clear_tx_ring(struct hns3_nic_priv *priv, u32 start_ringid,
|
|
|
|
u32 end_ringid, u32 budget)
|
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
|
|
|
|
for (i = start_ringid; i <= end_ringid; i++) {
|
2019-10-19 16:03:49 +08:00
|
|
|
struct hns3_enet_ring *ring = &priv->ring[i];
|
2017-10-20 10:19:22 +08:00
|
|
|
|
2018-09-20 01:29:49 +08:00
|
|
|
hns3_clean_tx_ring(ring);
|
2017-10-20 10:19:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hns3_lp_run_test - run loopback test
|
|
|
|
* @ndev: net device
|
|
|
|
* @mode: loopback type
|
|
|
|
*/
|
|
|
|
static int hns3_lp_run_test(struct net_device *ndev, enum hnae3_loop mode)
|
|
|
|
{
|
|
|
|
struct hns3_nic_priv *priv = netdev_priv(ndev);
|
|
|
|
struct sk_buff *skb;
|
|
|
|
u32 i, good_cnt;
|
|
|
|
int ret_val = 0;
|
|
|
|
|
|
|
|
skb = alloc_skb(HNS3_NIC_LB_TEST_PACKET_SIZE + ETH_HLEN + NET_IP_ALIGN,
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!skb)
|
|
|
|
return HNS3_NIC_LB_TEST_NO_MEM_ERR;
|
|
|
|
|
|
|
|
skb->dev = ndev;
|
|
|
|
hns3_lp_setup_skb(skb);
|
|
|
|
skb->queue_mapping = HNS3_NIC_LB_TEST_RING_ID;
|
|
|
|
|
|
|
|
good_cnt = 0;
|
|
|
|
for (i = 0; i < HNS3_NIC_LB_TEST_PKT_NUM; i++) {
|
|
|
|
netdev_tx_t tx_ret;
|
|
|
|
|
|
|
|
skb_get(skb);
|
|
|
|
tx_ret = hns3_nic_net_xmit(skb, ndev);
|
2019-06-13 17:12:30 +08:00
|
|
|
if (tx_ret == NETDEV_TX_OK) {
|
2017-10-20 10:19:22 +08:00
|
|
|
good_cnt++;
|
2019-06-13 17:12:30 +08:00
|
|
|
} else {
|
|
|
|
kfree_skb(skb);
|
2017-10-20 10:19:22 +08:00
|
|
|
netdev_err(ndev, "hns3_lb_run_test xmit failed: %d\n",
|
|
|
|
tx_ret);
|
2019-06-13 17:12:30 +08:00
|
|
|
}
|
2017-10-20 10:19:22 +08:00
|
|
|
}
|
|
|
|
if (good_cnt != HNS3_NIC_LB_TEST_PKT_NUM) {
|
|
|
|
ret_val = HNS3_NIC_LB_TEST_TX_CNT_ERR;
|
|
|
|
netdev_err(ndev, "mode %d sent fail, cnt=0x%x, budget=0x%x\n",
|
|
|
|
mode, good_cnt, HNS3_NIC_LB_TEST_PKT_NUM);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allow 200 milliseconds for packets to go from Tx to Rx */
|
|
|
|
msleep(200);
|
|
|
|
|
|
|
|
good_cnt = hns3_lb_check_rx_ring(priv, HNS3_NIC_LB_TEST_PKT_NUM);
|
|
|
|
if (good_cnt != HNS3_NIC_LB_TEST_PKT_NUM) {
|
|
|
|
ret_val = HNS3_NIC_LB_TEST_RX_CNT_ERR;
|
|
|
|
netdev_err(ndev, "mode %d recv fail, cnt=0x%x, budget=0x%x\n",
|
|
|
|
mode, good_cnt, HNS3_NIC_LB_TEST_PKT_NUM);
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
hns3_lb_clear_tx_ring(priv, HNS3_NIC_LB_TEST_RING_ID,
|
|
|
|
HNS3_NIC_LB_TEST_RING_ID,
|
|
|
|
HNS3_NIC_LB_TEST_PKT_NUM);
|
|
|
|
|
|
|
|
kfree_skb(skb);
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hns3_nic_self_test - self test
|
|
|
|
* @ndev: net device
|
|
|
|
* @eth_test: test cmd
|
|
|
|
* @data: test result
|
|
|
|
*/
|
|
|
|
static void hns3_self_test(struct net_device *ndev,
|
|
|
|
struct ethtool_test *eth_test, u64 *data)
|
|
|
|
{
|
|
|
|
struct hns3_nic_priv *priv = netdev_priv(ndev);
|
|
|
|
struct hnae3_handle *h = priv->ae_handle;
|
2018-08-15 00:13:12 +08:00
|
|
|
int st_param[HNS3_SELF_TEST_TYPE_NUM][2];
|
2017-10-20 10:19:22 +08:00
|
|
|
bool if_running = netif_running(ndev);
|
2018-03-10 11:29:28 +08:00
|
|
|
#if IS_ENABLED(CONFIG_VLAN_8021Q)
|
|
|
|
bool dis_vlan_filter;
|
|
|
|
#endif
|
2017-10-20 10:19:22 +08:00
|
|
|
int test_index = 0;
|
|
|
|
u32 i;
|
|
|
|
|
2018-11-07 12:06:12 +08:00
|
|
|
if (hns3_nic_resetting(ndev)) {
|
|
|
|
netdev_err(ndev, "dev resetting!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-20 10:19:22 +08:00
|
|
|
/* Only do offline selftest, or pass by default */
|
|
|
|
if (eth_test->flags != ETH_TEST_FL_OFFLINE)
|
|
|
|
return;
|
|
|
|
|
2019-07-29 10:53:27 +08:00
|
|
|
netif_dbg(h, drv, ndev, "self test start");
|
|
|
|
|
2018-09-27 02:28:34 +08:00
|
|
|
st_param[HNAE3_LOOP_APP][0] = HNAE3_LOOP_APP;
|
|
|
|
st_param[HNAE3_LOOP_APP][1] =
|
|
|
|
h->flags & HNAE3_SUPPORT_APP_LOOPBACK;
|
2017-10-20 10:19:22 +08:00
|
|
|
|
2018-09-27 02:28:35 +08:00
|
|
|
st_param[HNAE3_LOOP_SERIAL_SERDES][0] = HNAE3_LOOP_SERIAL_SERDES;
|
|
|
|
st_param[HNAE3_LOOP_SERIAL_SERDES][1] =
|
|
|
|
h->flags & HNAE3_SUPPORT_SERDES_SERIAL_LOOPBACK;
|
|
|
|
|
|
|
|
st_param[HNAE3_LOOP_PARALLEL_SERDES][0] =
|
|
|
|
HNAE3_LOOP_PARALLEL_SERDES;
|
|
|
|
st_param[HNAE3_LOOP_PARALLEL_SERDES][1] =
|
|
|
|
h->flags & HNAE3_SUPPORT_SERDES_PARALLEL_LOOPBACK;
|
2018-08-15 00:13:12 +08:00
|
|
|
|
2019-08-28 22:23:14 +08:00
|
|
|
st_param[HNAE3_LOOP_PHY][0] = HNAE3_LOOP_PHY;
|
|
|
|
st_param[HNAE3_LOOP_PHY][1] =
|
|
|
|
h->flags & HNAE3_SUPPORT_PHY_LOOPBACK;
|
|
|
|
|
2017-10-20 10:19:22 +08:00
|
|
|
if (if_running)
|
2018-09-03 18:21:51 +08:00
|
|
|
ndev->netdev_ops->ndo_stop(ndev);
|
2017-10-20 10:19:22 +08:00
|
|
|
|
2018-03-10 11:29:28 +08:00
|
|
|
#if IS_ENABLED(CONFIG_VLAN_8021Q)
|
|
|
|
/* Disable the vlan filter for selftest does not support it */
|
|
|
|
dis_vlan_filter = (ndev->features & NETIF_F_HW_VLAN_CTAG_FILTER) &&
|
|
|
|
h->ae_algo->ops->enable_vlan_filter;
|
|
|
|
if (dis_vlan_filter)
|
|
|
|
h->ae_algo->ops->enable_vlan_filter(h, false);
|
|
|
|
#endif
|
|
|
|
|
2019-06-20 16:52:35 +08:00
|
|
|
/* Tell firmware to stop mac autoneg before loopback test start,
|
|
|
|
* otherwise loopback test may be failed when the port is still
|
|
|
|
* negotiating.
|
|
|
|
*/
|
|
|
|
if (h->ae_algo->ops->halt_autoneg)
|
|
|
|
h->ae_algo->ops->halt_autoneg(h, true);
|
|
|
|
|
2017-10-20 10:19:22 +08:00
|
|
|
set_bit(HNS3_NIC_STATE_TESTING, &priv->state);
|
|
|
|
|
2018-08-15 00:13:12 +08:00
|
|
|
for (i = 0; i < HNS3_SELF_TEST_TYPE_NUM; i++) {
|
2017-10-20 10:19:22 +08:00
|
|
|
enum hnae3_loop loop_type = (enum hnae3_loop)st_param[i][0];
|
|
|
|
|
|
|
|
if (!st_param[i][1])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
data[test_index] = hns3_lp_up(ndev, loop_type);
|
2019-01-27 00:49:13 +08:00
|
|
|
if (!data[test_index])
|
2017-10-20 10:19:22 +08:00
|
|
|
data[test_index] = hns3_lp_run_test(ndev, loop_type);
|
2019-01-27 00:49:13 +08:00
|
|
|
|
|
|
|
hns3_lp_down(ndev, loop_type);
|
2017-10-20 10:19:22 +08:00
|
|
|
|
|
|
|
if (data[test_index])
|
|
|
|
eth_test->flags |= ETH_TEST_FL_FAILED;
|
|
|
|
|
|
|
|
test_index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
clear_bit(HNS3_NIC_STATE_TESTING, &priv->state);
|
|
|
|
|
2019-06-20 16:52:35 +08:00
|
|
|
if (h->ae_algo->ops->halt_autoneg)
|
|
|
|
h->ae_algo->ops->halt_autoneg(h, false);
|
|
|
|
|
2018-03-10 11:29:28 +08:00
|
|
|
#if IS_ENABLED(CONFIG_VLAN_8021Q)
|
|
|
|
if (dis_vlan_filter)
|
|
|
|
h->ae_algo->ops->enable_vlan_filter(h, true);
|
|
|
|
#endif
|
|
|
|
|
2017-10-20 10:19:22 +08:00
|
|
|
if (if_running)
|
2018-09-03 18:21:51 +08:00
|
|
|
ndev->netdev_ops->ndo_open(ndev);
|
2019-07-29 10:53:27 +08:00
|
|
|
|
|
|
|
netif_dbg(h, drv, ndev, "self test end\n");
|
2017-10-20 10:19:22 +08:00
|
|
|
}
|
|
|
|
|
2017-08-02 23:59:51 +08:00
|
|
|
static int hns3_get_sset_count(struct net_device *netdev, int stringset)
|
|
|
|
{
|
2017-10-09 15:43:56 +08:00
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
2017-08-02 23:59:51 +08:00
|
|
|
const struct hnae3_ae_ops *ops = h->ae_algo->ops;
|
|
|
|
|
|
|
|
if (!ops->get_sset_count)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
switch (stringset) {
|
|
|
|
case ETH_SS_STATS:
|
|
|
|
return ((HNS3_TQP_STATS_COUNT * h->kinfo.num_tqps) +
|
|
|
|
ops->get_sset_count(h, stringset));
|
|
|
|
|
|
|
|
case ETH_SS_TEST:
|
|
|
|
return ops->get_sset_count(h, stringset);
|
|
|
|
|
2018-09-21 23:41:42 +08:00
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2017-08-02 23:59:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *hns3_update_strings(u8 *data, const struct hns3_stats *stats,
|
2018-01-05 18:18:07 +08:00
|
|
|
u32 stat_count, u32 num_tqps, const char *prefix)
|
2017-08-02 23:59:51 +08:00
|
|
|
{
|
2018-01-05 18:18:07 +08:00
|
|
|
#define MAX_PREFIX_SIZE (6 + 4)
|
2017-08-02 23:59:51 +08:00
|
|
|
u32 size_left;
|
|
|
|
u32 i, j;
|
|
|
|
u32 n1;
|
|
|
|
|
|
|
|
for (i = 0; i < num_tqps; i++) {
|
|
|
|
for (j = 0; j < stat_count; j++) {
|
|
|
|
data[ETH_GSTRING_LEN - 1] = '\0';
|
|
|
|
|
|
|
|
/* first, prepend the prefix string */
|
2020-01-20 20:50:33 +08:00
|
|
|
n1 = scnprintf(data, MAX_PREFIX_SIZE, "%s%d_",
|
|
|
|
prefix, i);
|
2017-08-02 23:59:51 +08:00
|
|
|
size_left = (ETH_GSTRING_LEN - 1) - n1;
|
|
|
|
|
|
|
|
/* now, concatenate the stats string to it */
|
|
|
|
strncat(data, stats[j].stats_string, size_left);
|
|
|
|
data += ETH_GSTRING_LEN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 *hns3_get_strings_tqps(struct hnae3_handle *handle, u8 *data)
|
|
|
|
{
|
|
|
|
struct hnae3_knic_private_info *kinfo = &handle->kinfo;
|
2018-01-05 18:18:07 +08:00
|
|
|
const char tx_prefix[] = "txq";
|
|
|
|
const char rx_prefix[] = "rxq";
|
2017-08-02 23:59:51 +08:00
|
|
|
|
|
|
|
/* get strings for Tx */
|
|
|
|
data = hns3_update_strings(data, hns3_txq_stats, HNS3_TXQ_STATS_COUNT,
|
2018-01-05 18:18:07 +08:00
|
|
|
kinfo->num_tqps, tx_prefix);
|
2017-08-02 23:59:51 +08:00
|
|
|
|
|
|
|
/* get strings for Rx */
|
|
|
|
data = hns3_update_strings(data, hns3_rxq_stats, HNS3_RXQ_STATS_COUNT,
|
2018-01-05 18:18:07 +08:00
|
|
|
kinfo->num_tqps, rx_prefix);
|
2017-08-02 23:59:51 +08:00
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
|
|
|
|
{
|
2017-10-09 15:43:56 +08:00
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
2017-08-02 23:59:51 +08:00
|
|
|
const struct hnae3_ae_ops *ops = h->ae_algo->ops;
|
|
|
|
char *buff = (char *)data;
|
|
|
|
|
|
|
|
if (!ops->get_strings)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (stringset) {
|
|
|
|
case ETH_SS_STATS:
|
|
|
|
buff = hns3_get_strings_tqps(h, buff);
|
2019-06-07 10:03:12 +08:00
|
|
|
ops->get_strings(h, stringset, (u8 *)buff);
|
2017-08-02 23:59:51 +08:00
|
|
|
break;
|
|
|
|
case ETH_SS_TEST:
|
|
|
|
ops->get_strings(h, stringset, data);
|
|
|
|
break;
|
2018-09-21 23:41:42 +08:00
|
|
|
default:
|
|
|
|
break;
|
2017-08-02 23:59:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static u64 *hns3_get_stats_tqps(struct hnae3_handle *handle, u64 *data)
|
|
|
|
{
|
|
|
|
struct hns3_nic_priv *nic_priv = (struct hns3_nic_priv *)handle->priv;
|
|
|
|
struct hnae3_knic_private_info *kinfo = &handle->kinfo;
|
|
|
|
struct hns3_enet_ring *ring;
|
|
|
|
u8 *stat;
|
2018-01-05 18:18:13 +08:00
|
|
|
int i, j;
|
2017-08-02 23:59:51 +08:00
|
|
|
|
|
|
|
/* get stats for Tx */
|
|
|
|
for (i = 0; i < kinfo->num_tqps; i++) {
|
2019-10-19 16:03:49 +08:00
|
|
|
ring = &nic_priv->ring[i];
|
2018-01-05 18:18:13 +08:00
|
|
|
for (j = 0; j < HNS3_TXQ_STATS_COUNT; j++) {
|
|
|
|
stat = (u8 *)ring + hns3_txq_stats[j].stats_offset;
|
2017-08-02 23:59:51 +08:00
|
|
|
*data++ = *(u64 *)stat;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get stats for Rx */
|
|
|
|
for (i = 0; i < kinfo->num_tqps; i++) {
|
2019-10-19 16:03:49 +08:00
|
|
|
ring = &nic_priv->ring[i + kinfo->num_tqps];
|
2018-01-05 18:18:13 +08:00
|
|
|
for (j = 0; j < HNS3_RXQ_STATS_COUNT; j++) {
|
|
|
|
stat = (u8 *)ring + hns3_rxq_stats[j].stats_offset;
|
2017-08-02 23:59:51 +08:00
|
|
|
*data++ = *(u64 *)stat;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* hns3_get_stats - get detail statistics.
|
|
|
|
* @netdev: net device
|
|
|
|
* @stats: statistics info.
|
|
|
|
* @data: statistics data.
|
|
|
|
*/
|
2017-10-09 15:44:01 +08:00
|
|
|
static void hns3_get_stats(struct net_device *netdev,
|
|
|
|
struct ethtool_stats *stats, u64 *data)
|
2017-08-02 23:59:51 +08:00
|
|
|
{
|
2017-10-09 15:43:56 +08:00
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
2017-08-02 23:59:51 +08:00
|
|
|
u64 *p = data;
|
|
|
|
|
2019-04-04 16:17:56 +08:00
|
|
|
if (hns3_nic_resetting(netdev)) {
|
|
|
|
netdev_err(netdev, "dev resetting, could not get stats\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-02 23:59:51 +08:00
|
|
|
if (!h->ae_algo->ops->get_stats || !h->ae_algo->ops->update_stats) {
|
|
|
|
netdev_err(netdev, "could not get any statistics\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-09 14:50:58 +08:00
|
|
|
h->ae_algo->ops->update_stats(h, &netdev->stats);
|
2017-08-02 23:59:51 +08:00
|
|
|
|
|
|
|
/* get per-queue stats */
|
|
|
|
p = hns3_get_stats_tqps(h, p);
|
|
|
|
|
|
|
|
/* get MAC & other misc hardware stats */
|
|
|
|
h->ae_algo->ops->get_stats(h, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hns3_get_drvinfo(struct net_device *netdev,
|
|
|
|
struct ethtool_drvinfo *drvinfo)
|
|
|
|
{
|
|
|
|
struct hns3_nic_priv *priv = netdev_priv(netdev);
|
|
|
|
struct hnae3_handle *h = priv->ae_handle;
|
2019-07-29 10:53:26 +08:00
|
|
|
u32 fw_version;
|
2017-08-02 23:59:51 +08:00
|
|
|
|
2019-06-07 10:03:12 +08:00
|
|
|
if (!h->ae_algo->ops->get_fw_version) {
|
|
|
|
netdev_err(netdev, "could not get fw version!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-02 23:59:51 +08:00
|
|
|
strncpy(drvinfo->driver, h->pdev->driver->name,
|
|
|
|
sizeof(drvinfo->driver));
|
|
|
|
drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0';
|
|
|
|
|
|
|
|
strncpy(drvinfo->bus_info, pci_name(h->pdev),
|
|
|
|
sizeof(drvinfo->bus_info));
|
|
|
|
drvinfo->bus_info[ETHTOOL_BUSINFO_LEN - 1] = '\0';
|
|
|
|
|
2019-07-29 10:53:26 +08:00
|
|
|
fw_version = priv->ae_handle->ae_algo->ops->get_fw_version(h);
|
|
|
|
|
|
|
|
snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
|
|
|
|
"%lu.%lu.%lu.%lu",
|
|
|
|
hnae3_get_field(fw_version, HNAE3_FW_VERSION_BYTE3_MASK,
|
|
|
|
HNAE3_FW_VERSION_BYTE3_SHIFT),
|
|
|
|
hnae3_get_field(fw_version, HNAE3_FW_VERSION_BYTE2_MASK,
|
|
|
|
HNAE3_FW_VERSION_BYTE2_SHIFT),
|
|
|
|
hnae3_get_field(fw_version, HNAE3_FW_VERSION_BYTE1_MASK,
|
|
|
|
HNAE3_FW_VERSION_BYTE1_SHIFT),
|
|
|
|
hnae3_get_field(fw_version, HNAE3_FW_VERSION_BYTE0_MASK,
|
|
|
|
HNAE3_FW_VERSION_BYTE0_SHIFT));
|
2017-08-02 23:59:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static u32 hns3_get_link(struct net_device *netdev)
|
|
|
|
{
|
2017-10-09 15:43:56 +08:00
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
2017-08-02 23:59:51 +08:00
|
|
|
|
2019-06-07 10:03:12 +08:00
|
|
|
if (h->ae_algo->ops->get_status)
|
2017-08-02 23:59:51 +08:00
|
|
|
return h->ae_algo->ops->get_status(h);
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hns3_get_ringparam(struct net_device *netdev,
|
|
|
|
struct ethtool_ringparam *param)
|
|
|
|
{
|
|
|
|
struct hns3_nic_priv *priv = netdev_priv(netdev);
|
2017-10-09 15:43:56 +08:00
|
|
|
struct hnae3_handle *h = priv->ae_handle;
|
|
|
|
int queue_num = h->kinfo.num_tqps;
|
2017-08-02 23:59:51 +08:00
|
|
|
|
2018-11-07 12:06:12 +08:00
|
|
|
if (hns3_nic_resetting(netdev)) {
|
|
|
|
netdev_err(netdev, "dev resetting!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-02 23:59:51 +08:00
|
|
|
param->tx_max_pending = HNS3_RING_MAX_PENDING;
|
|
|
|
param->rx_max_pending = HNS3_RING_MAX_PENDING;
|
|
|
|
|
2019-10-19 16:03:49 +08:00
|
|
|
param->tx_pending = priv->ring[0].desc_num;
|
|
|
|
param->rx_pending = priv->ring[queue_num].desc_num;
|
2017-08-02 23:59:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void hns3_get_pauseparam(struct net_device *netdev,
|
|
|
|
struct ethtool_pauseparam *param)
|
|
|
|
{
|
2017-10-09 15:43:56 +08:00
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
2017-08-02 23:59:51 +08:00
|
|
|
|
2019-06-07 10:03:12 +08:00
|
|
|
if (h->ae_algo->ops->get_pauseparam)
|
2017-08-02 23:59:51 +08:00
|
|
|
h->ae_algo->ops->get_pauseparam(h, ¶m->autoneg,
|
|
|
|
¶m->rx_pause, ¶m->tx_pause);
|
|
|
|
}
|
|
|
|
|
2017-12-22 12:21:51 +08:00
|
|
|
static int hns3_set_pauseparam(struct net_device *netdev,
|
|
|
|
struct ethtool_pauseparam *param)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
|
|
|
|
2019-07-29 10:53:27 +08:00
|
|
|
netif_dbg(h, drv, netdev,
|
|
|
|
"set pauseparam: autoneg=%u, rx:%u, tx:%u\n",
|
|
|
|
param->autoneg, param->rx_pause, param->tx_pause);
|
|
|
|
|
2017-12-22 12:21:51 +08:00
|
|
|
if (h->ae_algo->ops->set_pauseparam)
|
|
|
|
return h->ae_algo->ops->set_pauseparam(h, param->autoneg,
|
|
|
|
param->rx_pause,
|
|
|
|
param->tx_pause);
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2018-09-21 23:41:47 +08:00
|
|
|
static void hns3_get_ksettings(struct hnae3_handle *h,
|
|
|
|
struct ethtool_link_ksettings *cmd)
|
|
|
|
{
|
|
|
|
const struct hnae3_ae_ops *ops = h->ae_algo->ops;
|
|
|
|
|
|
|
|
/* 1.auto_neg & speed & duplex from cmd */
|
|
|
|
if (ops->get_ksettings_an_result)
|
|
|
|
ops->get_ksettings_an_result(h,
|
|
|
|
&cmd->base.autoneg,
|
|
|
|
&cmd->base.speed,
|
|
|
|
&cmd->base.duplex);
|
|
|
|
|
2019-08-16 16:09:37 +08:00
|
|
|
/* 2.get link mode */
|
2018-09-21 23:41:47 +08:00
|
|
|
if (ops->get_link_mode)
|
|
|
|
ops->get_link_mode(h,
|
|
|
|
cmd->link_modes.supported,
|
|
|
|
cmd->link_modes.advertising);
|
|
|
|
|
|
|
|
/* 3.mdix_ctrl&mdix get from phy reg */
|
|
|
|
if (ops->get_mdix_mode)
|
|
|
|
ops->get_mdix_mode(h, &cmd->base.eth_tp_mdix_ctrl,
|
|
|
|
&cmd->base.eth_tp_mdix);
|
|
|
|
}
|
|
|
|
|
2017-08-02 23:59:51 +08:00
|
|
|
static int hns3_get_link_ksettings(struct net_device *netdev,
|
|
|
|
struct ethtool_link_ksettings *cmd)
|
|
|
|
{
|
2017-10-09 15:43:56 +08:00
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
2018-09-03 18:21:56 +08:00
|
|
|
const struct hnae3_ae_ops *ops;
|
2019-05-03 17:50:37 +08:00
|
|
|
u8 module_type;
|
2018-09-21 23:41:47 +08:00
|
|
|
u8 media_type;
|
2017-08-02 23:59:51 +08:00
|
|
|
u8 link_stat;
|
|
|
|
|
2018-09-03 18:21:56 +08:00
|
|
|
ops = h->ae_algo->ops;
|
2018-09-21 23:41:47 +08:00
|
|
|
if (ops->get_media_type)
|
2019-05-03 17:50:37 +08:00
|
|
|
ops->get_media_type(h, &media_type, &module_type);
|
2018-09-03 18:21:56 +08:00
|
|
|
else
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2018-09-21 23:41:47 +08:00
|
|
|
switch (media_type) {
|
|
|
|
case HNAE3_MEDIA_TYPE_NONE:
|
|
|
|
cmd->base.port = PORT_NONE;
|
|
|
|
hns3_get_ksettings(h, cmd);
|
|
|
|
break;
|
|
|
|
case HNAE3_MEDIA_TYPE_FIBER:
|
2019-05-03 17:50:37 +08:00
|
|
|
if (module_type == HNAE3_MODULE_TYPE_CR)
|
|
|
|
cmd->base.port = PORT_DA;
|
|
|
|
else
|
|
|
|
cmd->base.port = PORT_FIBRE;
|
|
|
|
|
|
|
|
hns3_get_ksettings(h, cmd);
|
|
|
|
break;
|
|
|
|
case HNAE3_MEDIA_TYPE_BACKPLANE:
|
|
|
|
cmd->base.port = PORT_NONE;
|
2018-09-21 23:41:47 +08:00
|
|
|
hns3_get_ksettings(h, cmd);
|
2018-09-03 18:21:56 +08:00
|
|
|
break;
|
2018-09-21 23:41:47 +08:00
|
|
|
case HNAE3_MEDIA_TYPE_COPPER:
|
|
|
|
cmd->base.port = PORT_TP;
|
2019-02-20 10:32:43 +08:00
|
|
|
if (!netdev->phydev)
|
|
|
|
hns3_get_ksettings(h, cmd);
|
|
|
|
else
|
|
|
|
phy_ethtool_ksettings_get(netdev->phydev, cmd);
|
2018-09-03 18:21:56 +08:00
|
|
|
break;
|
|
|
|
default:
|
2018-09-21 23:41:47 +08:00
|
|
|
|
|
|
|
netdev_warn(netdev, "Unknown media type");
|
2018-03-21 15:49:30 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-03 18:21:56 +08:00
|
|
|
/* mdio_support */
|
|
|
|
cmd->base.mdio_support = ETH_MDIO_SUPPORTS_C22;
|
2017-11-03 12:18:25 +08:00
|
|
|
|
|
|
|
link_stat = hns3_get_link(netdev);
|
|
|
|
if (!link_stat) {
|
|
|
|
cmd->base.speed = SPEED_UNKNOWN;
|
|
|
|
cmd->base.duplex = DUPLEX_UNKNOWN;
|
2017-08-02 23:59:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-08-16 16:09:39 +08:00
|
|
|
static int hns3_check_ksettings_param(const struct net_device *netdev,
|
2019-05-03 17:50:38 +08:00
|
|
|
const struct ethtool_link_ksettings *cmd)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *handle = hns3_get_handle(netdev);
|
|
|
|
const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
|
|
|
|
u8 module_type = HNAE3_MODULE_TYPE_UNKNOWN;
|
|
|
|
u8 media_type = HNAE3_MEDIA_TYPE_UNKNOWN;
|
|
|
|
u8 autoneg;
|
|
|
|
u32 speed;
|
|
|
|
u8 duplex;
|
|
|
|
int ret;
|
|
|
|
|
2019-09-11 10:40:36 +08:00
|
|
|
/* hw doesn't support use specified speed and duplex to negotiate,
|
|
|
|
* unnecessary to check them when autoneg on.
|
|
|
|
*/
|
|
|
|
if (cmd->base.autoneg)
|
|
|
|
return 0;
|
|
|
|
|
2019-05-03 17:50:38 +08:00
|
|
|
if (ops->get_ksettings_an_result) {
|
|
|
|
ops->get_ksettings_an_result(handle, &autoneg, &speed, &duplex);
|
|
|
|
if (cmd->base.autoneg == autoneg && cmd->base.speed == speed &&
|
|
|
|
cmd->base.duplex == duplex)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ops->get_media_type)
|
|
|
|
ops->get_media_type(handle, &media_type, &module_type);
|
|
|
|
|
2020-02-19 09:23:30 +08:00
|
|
|
if (cmd->base.duplex == DUPLEX_HALF &&
|
2019-05-03 17:50:38 +08:00
|
|
|
media_type != HNAE3_MEDIA_TYPE_COPPER) {
|
|
|
|
netdev_err(netdev,
|
|
|
|
"only copper port supports half duplex!");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ops->check_port_speed) {
|
|
|
|
ret = ops->check_port_speed(handle, cmd->base.speed);
|
|
|
|
if (ret) {
|
|
|
|
netdev_err(netdev, "unsupported speed\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-11-03 12:18:28 +08:00
|
|
|
static int hns3_set_link_ksettings(struct net_device *netdev,
|
|
|
|
const struct ethtool_link_ksettings *cmd)
|
|
|
|
{
|
2019-05-03 17:50:38 +08:00
|
|
|
struct hnae3_handle *handle = hns3_get_handle(netdev);
|
|
|
|
const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
|
2019-08-16 16:09:38 +08:00
|
|
|
int ret;
|
2019-05-03 17:50:38 +08:00
|
|
|
|
|
|
|
/* Chip don't support this mode. */
|
2019-04-04 16:17:48 +08:00
|
|
|
if (cmd->base.speed == SPEED_1000 && cmd->base.duplex == DUPLEX_HALF)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2019-07-29 10:53:27 +08:00
|
|
|
netif_dbg(handle, drv, netdev,
|
|
|
|
"set link(%s): autoneg=%u, speed=%u, duplex=%u\n",
|
|
|
|
netdev->phydev ? "phy" : "mac",
|
|
|
|
cmd->base.autoneg, cmd->base.speed, cmd->base.duplex);
|
|
|
|
|
2017-11-03 12:18:28 +08:00
|
|
|
/* Only support ksettings_set for netdev with phy attached for now */
|
2020-05-09 17:27:41 +08:00
|
|
|
if (netdev->phydev) {
|
|
|
|
if (cmd->base.speed == SPEED_1000 &&
|
|
|
|
cmd->base.autoneg == AUTONEG_DISABLE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2017-11-03 12:18:28 +08:00
|
|
|
return phy_ethtool_ksettings_set(netdev->phydev, cmd);
|
2020-05-09 17:27:41 +08:00
|
|
|
}
|
2017-11-03 12:18:28 +08:00
|
|
|
|
2019-05-03 17:50:38 +08:00
|
|
|
if (handle->pdev->revision == 0x20)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
ret = hns3_check_ksettings_param(netdev, cmd);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (ops->set_autoneg) {
|
|
|
|
ret = ops->set_autoneg(handle, cmd->base.autoneg);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-09-11 10:40:36 +08:00
|
|
|
/* hw doesn't support use specified speed and duplex to negotiate,
|
|
|
|
* ignore them when autoneg on.
|
|
|
|
*/
|
|
|
|
if (cmd->base.autoneg) {
|
|
|
|
netdev_info(netdev,
|
|
|
|
"autoneg is on, ignore the speed and duplex\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-05-03 17:50:38 +08:00
|
|
|
if (ops->cfg_mac_speed_dup_h)
|
|
|
|
ret = ops->cfg_mac_speed_dup_h(handle, cmd->base.speed,
|
|
|
|
cmd->base.duplex);
|
|
|
|
|
|
|
|
return ret;
|
2017-11-03 12:18:28 +08:00
|
|
|
}
|
|
|
|
|
2017-08-02 23:59:51 +08:00
|
|
|
static u32 hns3_get_rss_key_size(struct net_device *netdev)
|
|
|
|
{
|
2017-10-09 15:43:56 +08:00
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
2017-08-02 23:59:51 +08:00
|
|
|
|
2019-06-07 10:03:12 +08:00
|
|
|
if (!h->ae_algo->ops->get_rss_key_size)
|
2018-03-24 11:32:43 +08:00
|
|
|
return 0;
|
2017-08-02 23:59:51 +08:00
|
|
|
|
|
|
|
return h->ae_algo->ops->get_rss_key_size(h);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 hns3_get_rss_indir_size(struct net_device *netdev)
|
|
|
|
{
|
2017-10-09 15:43:56 +08:00
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
2017-08-02 23:59:51 +08:00
|
|
|
|
2019-06-07 10:03:12 +08:00
|
|
|
if (!h->ae_algo->ops->get_rss_indir_size)
|
2018-03-24 11:32:44 +08:00
|
|
|
return 0;
|
2017-08-02 23:59:51 +08:00
|
|
|
|
|
|
|
return h->ae_algo->ops->get_rss_indir_size(h);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hns3_get_rss(struct net_device *netdev, u32 *indir, u8 *key,
|
|
|
|
u8 *hfunc)
|
|
|
|
{
|
2017-10-09 15:43:56 +08:00
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
2017-08-02 23:59:51 +08:00
|
|
|
|
2019-06-07 10:03:12 +08:00
|
|
|
if (!h->ae_algo->ops->get_rss)
|
2017-08-02 23:59:51 +08:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return h->ae_algo->ops->get_rss(h, indir, key, hfunc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hns3_set_rss(struct net_device *netdev, const u32 *indir,
|
|
|
|
const u8 *key, const u8 hfunc)
|
|
|
|
{
|
2017-10-09 15:43:56 +08:00
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
2017-08-02 23:59:51 +08:00
|
|
|
|
2019-06-07 10:03:12 +08:00
|
|
|
if (!h->ae_algo->ops->set_rss)
|
2017-08-02 23:59:51 +08:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2018-10-11 03:05:34 +08:00
|
|
|
if ((h->pdev->revision == 0x20 &&
|
|
|
|
hfunc != ETH_RSS_HASH_TOP) || (hfunc != ETH_RSS_HASH_NO_CHANGE &&
|
|
|
|
hfunc != ETH_RSS_HASH_TOP && hfunc != ETH_RSS_HASH_XOR)) {
|
|
|
|
netdev_err(netdev, "hash func not supported\n");
|
2017-08-02 23:59:51 +08:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
2018-10-11 03:05:34 +08:00
|
|
|
|
2017-08-02 23:59:51 +08:00
|
|
|
if (!indir) {
|
|
|
|
netdev_err(netdev,
|
|
|
|
"set rss failed for indir is empty\n");
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
return h->ae_algo->ops->set_rss(h, indir, key, hfunc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hns3_get_rxnfc(struct net_device *netdev,
|
|
|
|
struct ethtool_rxnfc *cmd,
|
|
|
|
u32 *rule_locs)
|
|
|
|
{
|
2017-10-09 15:43:56 +08:00
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
2017-08-02 23:59:51 +08:00
|
|
|
|
|
|
|
switch (cmd->cmd) {
|
|
|
|
case ETHTOOL_GRXRINGS:
|
2018-10-01 19:46:44 +08:00
|
|
|
cmd->data = h->kinfo.num_tqps;
|
|
|
|
return 0;
|
2017-10-10 16:42:06 +08:00
|
|
|
case ETHTOOL_GRXFH:
|
2018-10-01 19:46:44 +08:00
|
|
|
if (h->ae_algo->ops->get_rss_tuple)
|
|
|
|
return h->ae_algo->ops->get_rss_tuple(h, cmd);
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
case ETHTOOL_GRXCLSRLCNT:
|
|
|
|
if (h->ae_algo->ops->get_fd_rule_cnt)
|
|
|
|
return h->ae_algo->ops->get_fd_rule_cnt(h, cmd);
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
case ETHTOOL_GRXCLSRULE:
|
|
|
|
if (h->ae_algo->ops->get_fd_rule_info)
|
|
|
|
return h->ae_algo->ops->get_fd_rule_info(h, cmd);
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
case ETHTOOL_GRXCLSRLALL:
|
|
|
|
if (h->ae_algo->ops->get_fd_all_rules)
|
|
|
|
return h->ae_algo->ops->get_fd_all_rules(h, cmd,
|
|
|
|
rule_locs);
|
|
|
|
return -EOPNOTSUPP;
|
2017-08-02 23:59:51 +08:00
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-01 11:55:37 +08:00
|
|
|
static void hns3_change_all_ring_bd_num(struct hns3_nic_priv *priv,
|
|
|
|
u32 tx_desc_num, u32 rx_desc_num)
|
2017-10-10 16:42:04 +08:00
|
|
|
{
|
|
|
|
struct hnae3_handle *h = priv->ae_handle;
|
|
|
|
int i;
|
|
|
|
|
2019-02-23 17:22:15 +08:00
|
|
|
h->kinfo.num_tx_desc = tx_desc_num;
|
|
|
|
h->kinfo.num_rx_desc = rx_desc_num;
|
2017-10-10 16:42:04 +08:00
|
|
|
|
2019-02-23 17:22:15 +08:00
|
|
|
for (i = 0; i < h->kinfo.num_tqps; i++) {
|
2019-10-19 16:03:49 +08:00
|
|
|
priv->ring[i].desc_num = tx_desc_num;
|
|
|
|
priv->ring[i + h->kinfo.num_tqps].desc_num = rx_desc_num;
|
2019-02-23 17:22:15 +08:00
|
|
|
}
|
2017-10-10 16:42:04 +08:00
|
|
|
}
|
|
|
|
|
2019-08-01 11:55:37 +08:00
|
|
|
static struct hns3_enet_ring *hns3_backup_ringparam(struct hns3_nic_priv *priv)
|
2017-10-10 16:42:04 +08:00
|
|
|
{
|
2019-08-01 11:55:37 +08:00
|
|
|
struct hnae3_handle *handle = priv->ae_handle;
|
|
|
|
struct hns3_enet_ring *tmp_rings;
|
|
|
|
int i;
|
2017-10-10 16:42:04 +08:00
|
|
|
|
2019-08-01 11:55:37 +08:00
|
|
|
tmp_rings = kcalloc(handle->kinfo.num_tqps * 2,
|
|
|
|
sizeof(struct hns3_enet_ring), GFP_KERNEL);
|
|
|
|
if (!tmp_rings)
|
|
|
|
return NULL;
|
|
|
|
|
2019-09-05 21:31:37 +08:00
|
|
|
for (i = 0; i < handle->kinfo.num_tqps * 2; i++) {
|
2019-10-19 16:03:49 +08:00
|
|
|
memcpy(&tmp_rings[i], &priv->ring[i],
|
2019-08-01 11:55:37 +08:00
|
|
|
sizeof(struct hns3_enet_ring));
|
2019-09-05 21:31:37 +08:00
|
|
|
tmp_rings[i].skb = NULL;
|
|
|
|
}
|
2019-08-01 11:55:37 +08:00
|
|
|
|
|
|
|
return tmp_rings;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hns3_check_ringparam(struct net_device *ndev,
|
|
|
|
struct ethtool_ringparam *param)
|
|
|
|
{
|
2018-11-07 12:06:12 +08:00
|
|
|
if (hns3_nic_resetting(ndev))
|
|
|
|
return -EBUSY;
|
|
|
|
|
2017-10-10 16:42:04 +08:00
|
|
|
if (param->rx_mini_pending || param->rx_jumbo_pending)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (param->tx_pending > HNS3_RING_MAX_PENDING ||
|
2019-02-23 17:22:15 +08:00
|
|
|
param->tx_pending < HNS3_RING_MIN_PENDING ||
|
|
|
|
param->rx_pending > HNS3_RING_MAX_PENDING ||
|
|
|
|
param->rx_pending < HNS3_RING_MIN_PENDING) {
|
|
|
|
netdev_err(ndev, "Queue depth out of range [%d-%d]\n",
|
|
|
|
HNS3_RING_MIN_PENDING, HNS3_RING_MAX_PENDING);
|
2017-10-10 16:42:04 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2019-08-01 11:55:37 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hns3_set_ringparam(struct net_device *ndev,
|
|
|
|
struct ethtool_ringparam *param)
|
|
|
|
{
|
|
|
|
struct hns3_nic_priv *priv = netdev_priv(ndev);
|
|
|
|
struct hnae3_handle *h = priv->ae_handle;
|
|
|
|
struct hns3_enet_ring *tmp_rings;
|
|
|
|
bool if_running = netif_running(ndev);
|
|
|
|
u32 old_tx_desc_num, new_tx_desc_num;
|
|
|
|
u32 old_rx_desc_num, new_rx_desc_num;
|
|
|
|
u16 queue_num = h->kinfo.num_tqps;
|
|
|
|
int ret, i;
|
|
|
|
|
|
|
|
ret = hns3_check_ringparam(ndev, param);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2017-10-10 16:42:04 +08:00
|
|
|
/* Hardware requires that its descriptors must be multiple of eight */
|
2019-02-23 17:22:15 +08:00
|
|
|
new_tx_desc_num = ALIGN(param->tx_pending, HNS3_RING_BD_MULTIPLE);
|
|
|
|
new_rx_desc_num = ALIGN(param->rx_pending, HNS3_RING_BD_MULTIPLE);
|
2019-10-19 16:03:49 +08:00
|
|
|
old_tx_desc_num = priv->ring[0].desc_num;
|
|
|
|
old_rx_desc_num = priv->ring[queue_num].desc_num;
|
2019-02-23 17:22:15 +08:00
|
|
|
if (old_tx_desc_num == new_tx_desc_num &&
|
|
|
|
old_rx_desc_num == new_rx_desc_num)
|
2017-10-10 16:42:04 +08:00
|
|
|
return 0;
|
|
|
|
|
2019-08-01 11:55:37 +08:00
|
|
|
tmp_rings = hns3_backup_ringparam(priv);
|
|
|
|
if (!tmp_rings) {
|
|
|
|
netdev_err(ndev,
|
|
|
|
"backup ring param failed by allocating memory fail\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2017-10-10 16:42:04 +08:00
|
|
|
netdev_info(ndev,
|
2019-10-31 19:23:23 +08:00
|
|
|
"Changing Tx/Rx ring depth from %u/%u to %u/%u\n",
|
2019-02-23 17:22:15 +08:00
|
|
|
old_tx_desc_num, old_rx_desc_num,
|
|
|
|
new_tx_desc_num, new_rx_desc_num);
|
2017-10-10 16:42:04 +08:00
|
|
|
|
|
|
|
if (if_running)
|
2019-01-31 04:55:43 +08:00
|
|
|
ndev->netdev_ops->ndo_stop(ndev);
|
2017-10-10 16:42:04 +08:00
|
|
|
|
2019-08-01 11:55:37 +08:00
|
|
|
hns3_change_all_ring_bd_num(priv, new_tx_desc_num, new_rx_desc_num);
|
|
|
|
ret = hns3_init_all_ring(priv);
|
2017-10-10 16:42:04 +08:00
|
|
|
if (ret) {
|
2019-08-01 11:55:37 +08:00
|
|
|
netdev_err(ndev, "Change bd num fail, revert to old value(%d)\n",
|
|
|
|
ret);
|
|
|
|
|
|
|
|
hns3_change_all_ring_bd_num(priv, old_tx_desc_num,
|
|
|
|
old_rx_desc_num);
|
|
|
|
for (i = 0; i < h->kinfo.num_tqps * 2; i++)
|
2019-10-19 16:03:49 +08:00
|
|
|
memcpy(&priv->ring[i], &tmp_rings[i],
|
2019-08-01 11:55:37 +08:00
|
|
|
sizeof(struct hns3_enet_ring));
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < h->kinfo.num_tqps * 2; i++)
|
|
|
|
hns3_fini_ring(&tmp_rings[i]);
|
2017-10-10 16:42:04 +08:00
|
|
|
}
|
|
|
|
|
2019-08-01 11:55:37 +08:00
|
|
|
kfree(tmp_rings);
|
|
|
|
|
2017-10-10 16:42:04 +08:00
|
|
|
if (if_running)
|
2019-01-31 04:55:43 +08:00
|
|
|
ret = ndev->netdev_ops->ndo_open(ndev);
|
2017-10-10 16:42:04 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-10-10 16:42:05 +08:00
|
|
|
static int hns3_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
|
|
|
|
|
|
|
switch (cmd->cmd) {
|
|
|
|
case ETHTOOL_SRXFH:
|
2018-10-01 19:46:43 +08:00
|
|
|
if (h->ae_algo->ops->set_rss_tuple)
|
|
|
|
return h->ae_algo->ops->set_rss_tuple(h, cmd);
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
case ETHTOOL_SRXCLSRLINS:
|
|
|
|
if (h->ae_algo->ops->add_fd_entry)
|
|
|
|
return h->ae_algo->ops->add_fd_entry(h, cmd);
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
case ETHTOOL_SRXCLSRLDEL:
|
|
|
|
if (h->ae_algo->ops->del_fd_entry)
|
|
|
|
return h->ae_algo->ops->del_fd_entry(h, cmd);
|
|
|
|
return -EOPNOTSUPP;
|
2017-10-10 16:42:05 +08:00
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-03 12:18:29 +08:00
|
|
|
static int hns3_nway_reset(struct net_device *netdev)
|
|
|
|
{
|
2019-05-03 17:50:38 +08:00
|
|
|
struct hnae3_handle *handle = hns3_get_handle(netdev);
|
|
|
|
const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
|
2017-11-03 12:18:29 +08:00
|
|
|
struct phy_device *phy = netdev->phydev;
|
2019-05-03 17:50:38 +08:00
|
|
|
int autoneg;
|
2017-11-03 12:18:29 +08:00
|
|
|
|
|
|
|
if (!netif_running(netdev))
|
|
|
|
return 0;
|
|
|
|
|
2019-05-03 17:50:38 +08:00
|
|
|
if (hns3_nic_resetting(netdev)) {
|
|
|
|
netdev_err(netdev, "dev resetting!");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ops->get_autoneg || !ops->restart_autoneg)
|
2017-11-03 12:18:29 +08:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2019-05-03 17:50:38 +08:00
|
|
|
autoneg = ops->get_autoneg(handle);
|
|
|
|
if (autoneg != AUTONEG_ENABLE) {
|
|
|
|
netdev_err(netdev,
|
|
|
|
"Autoneg is off, don't support to restart it\n");
|
2017-11-03 12:18:29 +08:00
|
|
|
return -EINVAL;
|
2019-05-03 17:50:38 +08:00
|
|
|
}
|
|
|
|
|
2019-07-29 10:53:27 +08:00
|
|
|
netif_dbg(handle, drv, netdev,
|
|
|
|
"nway reset (using %s)\n", phy ? "phy" : "mac");
|
|
|
|
|
2019-05-03 17:50:38 +08:00
|
|
|
if (phy)
|
|
|
|
return genphy_restart_aneg(phy);
|
|
|
|
|
|
|
|
if (handle->pdev->revision == 0x20)
|
|
|
|
return -EOPNOTSUPP;
|
2017-11-03 12:18:29 +08:00
|
|
|
|
2019-05-03 17:50:38 +08:00
|
|
|
return ops->restart_autoneg(handle);
|
2017-11-03 12:18:29 +08:00
|
|
|
}
|
|
|
|
|
2017-12-28 09:09:59 +08:00
|
|
|
static void hns3_get_channels(struct net_device *netdev,
|
|
|
|
struct ethtool_channels *ch)
|
2017-12-22 12:21:40 +08:00
|
|
|
{
|
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
|
|
|
|
|
|
|
if (h->ae_algo->ops->get_channels)
|
|
|
|
h->ae_algo->ops->get_channels(h, ch);
|
|
|
|
}
|
|
|
|
|
2018-01-12 16:23:09 +08:00
|
|
|
static int hns3_get_coalesce_per_queue(struct net_device *netdev, u32 queue,
|
|
|
|
struct ethtool_coalesce *cmd)
|
|
|
|
{
|
|
|
|
struct hns3_enet_tqp_vector *tx_vector, *rx_vector;
|
|
|
|
struct hns3_nic_priv *priv = netdev_priv(netdev);
|
|
|
|
struct hnae3_handle *h = priv->ae_handle;
|
|
|
|
u16 queue_num = h->kinfo.num_tqps;
|
|
|
|
|
2018-11-07 12:06:12 +08:00
|
|
|
if (hns3_nic_resetting(netdev))
|
|
|
|
return -EBUSY;
|
|
|
|
|
2018-01-12 16:23:09 +08:00
|
|
|
if (queue >= queue_num) {
|
|
|
|
netdev_err(netdev,
|
2019-10-31 19:23:23 +08:00
|
|
|
"Invalid queue value %u! Queue max id=%u\n",
|
2018-01-12 16:23:09 +08:00
|
|
|
queue, queue_num - 1);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2019-10-19 16:03:49 +08:00
|
|
|
tx_vector = priv->ring[queue].tqp_vector;
|
|
|
|
rx_vector = priv->ring[queue_num + queue].tqp_vector;
|
2018-01-12 16:23:09 +08:00
|
|
|
|
2018-03-09 10:37:03 +08:00
|
|
|
cmd->use_adaptive_tx_coalesce =
|
|
|
|
tx_vector->tx_group.coal.gl_adapt_enable;
|
|
|
|
cmd->use_adaptive_rx_coalesce =
|
|
|
|
rx_vector->rx_group.coal.gl_adapt_enable;
|
2018-01-12 16:23:09 +08:00
|
|
|
|
2018-03-09 10:37:03 +08:00
|
|
|
cmd->tx_coalesce_usecs = tx_vector->tx_group.coal.int_gl;
|
|
|
|
cmd->rx_coalesce_usecs = rx_vector->rx_group.coal.int_gl;
|
2018-01-12 16:23:09 +08:00
|
|
|
|
|
|
|
cmd->tx_coalesce_usecs_high = h->kinfo.int_rl_setting;
|
|
|
|
cmd->rx_coalesce_usecs_high = h->kinfo.int_rl_setting;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hns3_get_coalesce(struct net_device *netdev,
|
|
|
|
struct ethtool_coalesce *cmd)
|
|
|
|
{
|
|
|
|
return hns3_get_coalesce_per_queue(netdev, 0, cmd);
|
|
|
|
}
|
|
|
|
|
2018-01-12 16:23:10 +08:00
|
|
|
static int hns3_check_gl_coalesce_para(struct net_device *netdev,
|
|
|
|
struct ethtool_coalesce *cmd)
|
|
|
|
{
|
|
|
|
u32 rx_gl, tx_gl;
|
|
|
|
|
|
|
|
if (cmd->rx_coalesce_usecs > HNS3_INT_GL_MAX) {
|
|
|
|
netdev_err(netdev,
|
|
|
|
"Invalid rx-usecs value, rx-usecs range is 0-%d\n",
|
|
|
|
HNS3_INT_GL_MAX);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd->tx_coalesce_usecs > HNS3_INT_GL_MAX) {
|
|
|
|
netdev_err(netdev,
|
|
|
|
"Invalid tx-usecs value, tx-usecs range is 0-%d\n",
|
|
|
|
HNS3_INT_GL_MAX);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rx_gl = hns3_gl_round_down(cmd->rx_coalesce_usecs);
|
|
|
|
if (rx_gl != cmd->rx_coalesce_usecs) {
|
|
|
|
netdev_info(netdev,
|
2019-10-31 19:23:23 +08:00
|
|
|
"rx_usecs(%u) rounded down to %u, because it must be multiple of 2.\n",
|
2018-01-12 16:23:10 +08:00
|
|
|
cmd->rx_coalesce_usecs, rx_gl);
|
|
|
|
}
|
|
|
|
|
|
|
|
tx_gl = hns3_gl_round_down(cmd->tx_coalesce_usecs);
|
|
|
|
if (tx_gl != cmd->tx_coalesce_usecs) {
|
|
|
|
netdev_info(netdev,
|
2019-10-31 19:23:23 +08:00
|
|
|
"tx_usecs(%u) rounded down to %u, because it must be multiple of 2.\n",
|
2018-01-12 16:23:10 +08:00
|
|
|
cmd->tx_coalesce_usecs, tx_gl);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hns3_check_rl_coalesce_para(struct net_device *netdev,
|
|
|
|
struct ethtool_coalesce *cmd)
|
|
|
|
{
|
|
|
|
u32 rl;
|
|
|
|
|
|
|
|
if (cmd->tx_coalesce_usecs_high != cmd->rx_coalesce_usecs_high) {
|
|
|
|
netdev_err(netdev,
|
|
|
|
"tx_usecs_high must be same as rx_usecs_high.\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd->rx_coalesce_usecs_high > HNS3_INT_RL_MAX) {
|
|
|
|
netdev_err(netdev,
|
|
|
|
"Invalid usecs_high value, usecs_high range is 0-%d\n",
|
|
|
|
HNS3_INT_RL_MAX);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rl = hns3_rl_round_down(cmd->rx_coalesce_usecs_high);
|
|
|
|
if (rl != cmd->rx_coalesce_usecs_high) {
|
|
|
|
netdev_info(netdev,
|
2019-10-31 19:23:23 +08:00
|
|
|
"usecs_high(%u) rounded down to %u, because it must be multiple of 4.\n",
|
2018-01-12 16:23:10 +08:00
|
|
|
cmd->rx_coalesce_usecs_high, rl);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hns3_check_coalesce_para(struct net_device *netdev,
|
|
|
|
struct ethtool_coalesce *cmd)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = hns3_check_gl_coalesce_para(netdev, cmd);
|
|
|
|
if (ret) {
|
|
|
|
netdev_err(netdev,
|
|
|
|
"Check gl coalesce param fail. ret = %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = hns3_check_rl_coalesce_para(netdev, cmd);
|
|
|
|
if (ret) {
|
|
|
|
netdev_err(netdev,
|
|
|
|
"Check rl coalesce param fail. ret = %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd->use_adaptive_tx_coalesce == 1 ||
|
|
|
|
cmd->use_adaptive_rx_coalesce == 1) {
|
|
|
|
netdev_info(netdev,
|
2019-10-31 19:23:23 +08:00
|
|
|
"adaptive-tx=%u and adaptive-rx=%u, tx_usecs or rx_usecs will changed dynamically.\n",
|
2018-01-12 16:23:10 +08:00
|
|
|
cmd->use_adaptive_tx_coalesce,
|
|
|
|
cmd->use_adaptive_rx_coalesce);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hns3_set_coalesce_per_queue(struct net_device *netdev,
|
|
|
|
struct ethtool_coalesce *cmd,
|
|
|
|
u32 queue)
|
|
|
|
{
|
|
|
|
struct hns3_enet_tqp_vector *tx_vector, *rx_vector;
|
|
|
|
struct hns3_nic_priv *priv = netdev_priv(netdev);
|
|
|
|
struct hnae3_handle *h = priv->ae_handle;
|
|
|
|
int queue_num = h->kinfo.num_tqps;
|
|
|
|
|
2019-10-19 16:03:49 +08:00
|
|
|
tx_vector = priv->ring[queue].tqp_vector;
|
|
|
|
rx_vector = priv->ring[queue_num + queue].tqp_vector;
|
2018-01-12 16:23:10 +08:00
|
|
|
|
2018-03-09 10:37:03 +08:00
|
|
|
tx_vector->tx_group.coal.gl_adapt_enable =
|
|
|
|
cmd->use_adaptive_tx_coalesce;
|
|
|
|
rx_vector->rx_group.coal.gl_adapt_enable =
|
|
|
|
cmd->use_adaptive_rx_coalesce;
|
2018-01-12 16:23:10 +08:00
|
|
|
|
2018-03-09 10:37:03 +08:00
|
|
|
tx_vector->tx_group.coal.int_gl = cmd->tx_coalesce_usecs;
|
|
|
|
rx_vector->rx_group.coal.int_gl = cmd->rx_coalesce_usecs;
|
2018-01-12 16:23:10 +08:00
|
|
|
|
2018-03-09 10:37:03 +08:00
|
|
|
hns3_set_vector_coalesce_tx_gl(tx_vector,
|
|
|
|
tx_vector->tx_group.coal.int_gl);
|
|
|
|
hns3_set_vector_coalesce_rx_gl(rx_vector,
|
|
|
|
rx_vector->rx_group.coal.int_gl);
|
2018-01-12 16:23:10 +08:00
|
|
|
|
|
|
|
hns3_set_vector_coalesce_rl(tx_vector, h->kinfo.int_rl_setting);
|
|
|
|
hns3_set_vector_coalesce_rl(rx_vector, h->kinfo.int_rl_setting);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hns3_set_coalesce(struct net_device *netdev,
|
|
|
|
struct ethtool_coalesce *cmd)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
|
|
|
u16 queue_num = h->kinfo.num_tqps;
|
|
|
|
int ret;
|
|
|
|
int i;
|
|
|
|
|
2018-11-07 12:06:12 +08:00
|
|
|
if (hns3_nic_resetting(netdev))
|
|
|
|
return -EBUSY;
|
|
|
|
|
2018-01-12 16:23:10 +08:00
|
|
|
ret = hns3_check_coalesce_para(netdev, cmd);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
h->kinfo.int_rl_setting =
|
|
|
|
hns3_rl_round_down(cmd->rx_coalesce_usecs_high);
|
|
|
|
|
|
|
|
for (i = 0; i < queue_num; i++)
|
|
|
|
hns3_set_coalesce_per_queue(netdev, cmd, i);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-19 14:41:09 +08:00
|
|
|
static int hns3_get_regs_len(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
|
|
|
|
|
|
|
if (!h->ae_algo->ops->get_regs_len)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return h->ae_algo->ops->get_regs_len(h);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hns3_get_regs(struct net_device *netdev,
|
|
|
|
struct ethtool_regs *cmd, void *data)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
|
|
|
|
|
|
|
if (!h->ae_algo->ops->get_regs)
|
|
|
|
return;
|
|
|
|
|
|
|
|
h->ae_algo->ops->get_regs(h, &cmd->version, data);
|
|
|
|
}
|
|
|
|
|
2018-01-19 14:41:11 +08:00
|
|
|
static int hns3_set_phys_id(struct net_device *netdev,
|
|
|
|
enum ethtool_phys_id_state state)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
|
|
|
|
2019-06-07 10:03:12 +08:00
|
|
|
if (!h->ae_algo->ops->set_led_id)
|
2018-01-19 14:41:11 +08:00
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return h->ae_algo->ops->set_led_id(h, state);
|
|
|
|
}
|
|
|
|
|
2019-04-19 11:05:43 +08:00
|
|
|
static u32 hns3_get_msglevel(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
|
|
|
|
|
|
|
return h->msg_enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hns3_set_msglevel(struct net_device *netdev, u32 msg_level)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
|
|
|
|
|
|
|
h->msg_enable = msg_level;
|
|
|
|
}
|
|
|
|
|
2019-05-03 17:50:39 +08:00
|
|
|
/* Translate local fec value into ethtool value. */
|
|
|
|
static unsigned int loc_to_eth_fec(u8 loc_fec)
|
|
|
|
{
|
|
|
|
u32 eth_fec = 0;
|
|
|
|
|
|
|
|
if (loc_fec & BIT(HNAE3_FEC_AUTO))
|
|
|
|
eth_fec |= ETHTOOL_FEC_AUTO;
|
|
|
|
if (loc_fec & BIT(HNAE3_FEC_RS))
|
|
|
|
eth_fec |= ETHTOOL_FEC_RS;
|
|
|
|
if (loc_fec & BIT(HNAE3_FEC_BASER))
|
|
|
|
eth_fec |= ETHTOOL_FEC_BASER;
|
|
|
|
|
|
|
|
/* if nothing is set, then FEC is off */
|
|
|
|
if (!eth_fec)
|
|
|
|
eth_fec = ETHTOOL_FEC_OFF;
|
|
|
|
|
|
|
|
return eth_fec;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Translate ethtool fec value into local value. */
|
|
|
|
static unsigned int eth_to_loc_fec(unsigned int eth_fec)
|
|
|
|
{
|
|
|
|
u32 loc_fec = 0;
|
|
|
|
|
|
|
|
if (eth_fec & ETHTOOL_FEC_OFF)
|
|
|
|
return loc_fec;
|
|
|
|
|
|
|
|
if (eth_fec & ETHTOOL_FEC_AUTO)
|
|
|
|
loc_fec |= BIT(HNAE3_FEC_AUTO);
|
|
|
|
if (eth_fec & ETHTOOL_FEC_RS)
|
|
|
|
loc_fec |= BIT(HNAE3_FEC_RS);
|
|
|
|
if (eth_fec & ETHTOOL_FEC_BASER)
|
|
|
|
loc_fec |= BIT(HNAE3_FEC_BASER);
|
|
|
|
|
|
|
|
return loc_fec;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hns3_get_fecparam(struct net_device *netdev,
|
|
|
|
struct ethtool_fecparam *fec)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *handle = hns3_get_handle(netdev);
|
|
|
|
const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
|
|
|
|
u8 fec_ability;
|
|
|
|
u8 fec_mode;
|
|
|
|
|
|
|
|
if (handle->pdev->revision == 0x20)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!ops->get_fec)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
ops->get_fec(handle, &fec_ability, &fec_mode);
|
|
|
|
|
|
|
|
fec->fec = loc_to_eth_fec(fec_ability);
|
|
|
|
fec->active_fec = loc_to_eth_fec(fec_mode);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hns3_set_fecparam(struct net_device *netdev,
|
|
|
|
struct ethtool_fecparam *fec)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *handle = hns3_get_handle(netdev);
|
|
|
|
const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
|
|
|
|
u32 fec_mode;
|
|
|
|
|
|
|
|
if (handle->pdev->revision == 0x20)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!ops->set_fec)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
fec_mode = eth_to_loc_fec(fec->fec);
|
2019-07-29 10:53:27 +08:00
|
|
|
|
|
|
|
netif_dbg(handle, drv, netdev, "set fecparam: mode=%u\n", fec_mode);
|
|
|
|
|
2019-05-03 17:50:39 +08:00
|
|
|
return ops->set_fec(handle, fec_mode);
|
|
|
|
}
|
|
|
|
|
2020-04-29 11:46:24 +08:00
|
|
|
static int hns3_get_module_info(struct net_device *netdev,
|
|
|
|
struct ethtool_modinfo *modinfo)
|
|
|
|
{
|
|
|
|
#define HNS3_SFF_8636_V1_3 0x03
|
|
|
|
|
|
|
|
struct hnae3_handle *handle = hns3_get_handle(netdev);
|
|
|
|
const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
|
|
|
|
struct hns3_sfp_type sfp_type;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (handle->pdev->revision == 0x20 || !ops->get_module_eeprom)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
memset(&sfp_type, 0, sizeof(sfp_type));
|
|
|
|
ret = ops->get_module_eeprom(handle, 0, sizeof(sfp_type) / sizeof(u8),
|
|
|
|
(u8 *)&sfp_type);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
switch (sfp_type.type) {
|
|
|
|
case SFF8024_ID_SFP:
|
|
|
|
modinfo->type = ETH_MODULE_SFF_8472;
|
|
|
|
modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
|
|
|
|
break;
|
|
|
|
case SFF8024_ID_QSFP_8438:
|
|
|
|
modinfo->type = ETH_MODULE_SFF_8436;
|
|
|
|
modinfo->eeprom_len = ETH_MODULE_SFF_8436_MAX_LEN;
|
|
|
|
break;
|
|
|
|
case SFF8024_ID_QSFP_8436_8636:
|
|
|
|
if (sfp_type.ext_type < HNS3_SFF_8636_V1_3) {
|
|
|
|
modinfo->type = ETH_MODULE_SFF_8436;
|
|
|
|
modinfo->eeprom_len = ETH_MODULE_SFF_8436_MAX_LEN;
|
|
|
|
} else {
|
|
|
|
modinfo->type = ETH_MODULE_SFF_8636;
|
|
|
|
modinfo->eeprom_len = ETH_MODULE_SFF_8636_MAX_LEN;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SFF8024_ID_QSFP28_8636:
|
|
|
|
modinfo->type = ETH_MODULE_SFF_8636;
|
|
|
|
modinfo->eeprom_len = ETH_MODULE_SFF_8636_MAX_LEN;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
netdev_err(netdev, "Optical module unknown: %#x\n",
|
|
|
|
sfp_type.type);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int hns3_get_module_eeprom(struct net_device *netdev,
|
|
|
|
struct ethtool_eeprom *ee, u8 *data)
|
|
|
|
{
|
|
|
|
struct hnae3_handle *handle = hns3_get_handle(netdev);
|
|
|
|
const struct hnae3_ae_ops *ops = handle->ae_algo->ops;
|
|
|
|
|
|
|
|
if (handle->pdev->revision == 0x20 || !ops->get_module_eeprom)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
if (!ee->len)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
memset(data, 0, ee->len);
|
|
|
|
|
|
|
|
return ops->get_module_eeprom(handle, ee->offset, ee->len, data);
|
|
|
|
}
|
|
|
|
|
2020-03-12 06:32:53 +08:00
|
|
|
#define HNS3_ETHTOOL_COALESCE (ETHTOOL_COALESCE_USECS | \
|
|
|
|
ETHTOOL_COALESCE_USE_ADAPTIVE | \
|
|
|
|
ETHTOOL_COALESCE_RX_USECS_HIGH | \
|
|
|
|
ETHTOOL_COALESCE_TX_USECS_HIGH)
|
|
|
|
|
2017-12-15 02:03:06 +08:00
|
|
|
static const struct ethtool_ops hns3vf_ethtool_ops = {
|
2020-03-12 06:32:53 +08:00
|
|
|
.supported_coalesce_params = HNS3_ETHTOOL_COALESCE,
|
2017-12-15 02:03:06 +08:00
|
|
|
.get_drvinfo = hns3_get_drvinfo,
|
|
|
|
.get_ringparam = hns3_get_ringparam,
|
|
|
|
.set_ringparam = hns3_set_ringparam,
|
|
|
|
.get_strings = hns3_get_strings,
|
|
|
|
.get_ethtool_stats = hns3_get_stats,
|
|
|
|
.get_sset_count = hns3_get_sset_count,
|
|
|
|
.get_rxnfc = hns3_get_rxnfc,
|
2018-10-11 03:05:36 +08:00
|
|
|
.set_rxnfc = hns3_set_rxnfc,
|
2017-12-15 02:03:06 +08:00
|
|
|
.get_rxfh_key_size = hns3_get_rss_key_size,
|
|
|
|
.get_rxfh_indir_size = hns3_get_rss_indir_size,
|
|
|
|
.get_rxfh = hns3_get_rss,
|
|
|
|
.set_rxfh = hns3_set_rss,
|
|
|
|
.get_link_ksettings = hns3_get_link_ksettings,
|
2018-01-12 16:23:07 +08:00
|
|
|
.get_channels = hns3_get_channels,
|
2019-09-11 10:40:33 +08:00
|
|
|
.set_channels = hns3_set_channels,
|
2018-01-26 19:31:24 +08:00
|
|
|
.get_coalesce = hns3_get_coalesce,
|
|
|
|
.set_coalesce = hns3_set_coalesce,
|
2019-01-31 04:55:42 +08:00
|
|
|
.get_regs_len = hns3_get_regs_len,
|
|
|
|
.get_regs = hns3_get_regs,
|
2018-03-21 15:49:28 +08:00
|
|
|
.get_link = hns3_get_link,
|
2019-04-19 11:05:43 +08:00
|
|
|
.get_msglevel = hns3_get_msglevel,
|
|
|
|
.set_msglevel = hns3_set_msglevel,
|
2017-12-15 02:03:06 +08:00
|
|
|
};
|
|
|
|
|
2017-08-02 23:59:51 +08:00
|
|
|
static const struct ethtool_ops hns3_ethtool_ops = {
|
2020-03-12 06:32:53 +08:00
|
|
|
.supported_coalesce_params = HNS3_ETHTOOL_COALESCE,
|
2017-10-20 10:19:22 +08:00
|
|
|
.self_test = hns3_self_test,
|
2017-08-02 23:59:51 +08:00
|
|
|
.get_drvinfo = hns3_get_drvinfo,
|
|
|
|
.get_link = hns3_get_link,
|
|
|
|
.get_ringparam = hns3_get_ringparam,
|
2017-10-10 16:42:04 +08:00
|
|
|
.set_ringparam = hns3_set_ringparam,
|
2017-08-02 23:59:51 +08:00
|
|
|
.get_pauseparam = hns3_get_pauseparam,
|
2017-12-22 12:21:51 +08:00
|
|
|
.set_pauseparam = hns3_set_pauseparam,
|
2017-08-02 23:59:51 +08:00
|
|
|
.get_strings = hns3_get_strings,
|
|
|
|
.get_ethtool_stats = hns3_get_stats,
|
|
|
|
.get_sset_count = hns3_get_sset_count,
|
|
|
|
.get_rxnfc = hns3_get_rxnfc,
|
2017-10-10 16:42:05 +08:00
|
|
|
.set_rxnfc = hns3_set_rxnfc,
|
2017-08-02 23:59:51 +08:00
|
|
|
.get_rxfh_key_size = hns3_get_rss_key_size,
|
|
|
|
.get_rxfh_indir_size = hns3_get_rss_indir_size,
|
|
|
|
.get_rxfh = hns3_get_rss,
|
|
|
|
.set_rxfh = hns3_set_rss,
|
|
|
|
.get_link_ksettings = hns3_get_link_ksettings,
|
2017-11-03 12:18:28 +08:00
|
|
|
.set_link_ksettings = hns3_set_link_ksettings,
|
2017-11-03 12:18:29 +08:00
|
|
|
.nway_reset = hns3_nway_reset,
|
2017-12-22 12:21:40 +08:00
|
|
|
.get_channels = hns3_get_channels,
|
2017-12-22 12:21:41 +08:00
|
|
|
.set_channels = hns3_set_channels,
|
2018-01-12 16:23:09 +08:00
|
|
|
.get_coalesce = hns3_get_coalesce,
|
2018-01-12 16:23:10 +08:00
|
|
|
.set_coalesce = hns3_set_coalesce,
|
2018-01-19 14:41:09 +08:00
|
|
|
.get_regs_len = hns3_get_regs_len,
|
|
|
|
.get_regs = hns3_get_regs,
|
2018-01-19 14:41:11 +08:00
|
|
|
.set_phys_id = hns3_set_phys_id,
|
2019-04-19 11:05:43 +08:00
|
|
|
.get_msglevel = hns3_get_msglevel,
|
|
|
|
.set_msglevel = hns3_set_msglevel,
|
2019-05-03 17:50:39 +08:00
|
|
|
.get_fecparam = hns3_get_fecparam,
|
|
|
|
.set_fecparam = hns3_set_fecparam,
|
2020-04-29 11:46:24 +08:00
|
|
|
.get_module_info = hns3_get_module_info,
|
|
|
|
.get_module_eeprom = hns3_get_module_eeprom,
|
2017-08-02 23:59:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void hns3_ethtool_set_ops(struct net_device *netdev)
|
|
|
|
{
|
2017-12-15 02:03:06 +08:00
|
|
|
struct hnae3_handle *h = hns3_get_handle(netdev);
|
|
|
|
|
|
|
|
if (h->flags & HNAE3_SUPPORT_VF)
|
|
|
|
netdev->ethtool_ops = &hns3vf_ethtool_ops;
|
|
|
|
else
|
|
|
|
netdev->ethtool_ops = &hns3_ethtool_ops;
|
2017-08-02 23:59:51 +08:00
|
|
|
}
|