diff options
author | 2020-06-28 20:36:22 +0800 | |
---|---|---|
committer | 2020-06-28 20:40:58 -0700 | |
commit | 4aa218a4fe77d57edd068210da4c90dd19523954 (patch) | |
tree | 07a392224d135e2cf8bf4806a2a1f78c6eb48c8f /drivers/net/ethernet/huawei/hinic/hinic_port.c | |
parent | hinic: add support to set and get irq coalesce (diff) | |
download | linux-4aa218a4fe77d57edd068210da4c90dd19523954.tar.gz linux-4aa218a4fe77d57edd068210da4c90dd19523954.tar.bz2 linux-4aa218a4fe77d57edd068210da4c90dd19523954.zip |
hinic: add self test support
add support to excute internal and external loopback test with
ethtool -t cmd.
Signed-off-by: Luo bin <luobin9@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/huawei/hinic/hinic_port.c')
-rw-r--r-- | drivers/net/ethernet/huawei/hinic/hinic_port.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_port.c b/drivers/net/ethernet/huawei/hinic/hinic_port.c index 8b007a268675..98ea3f781611 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_port.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_port.c @@ -1241,3 +1241,30 @@ int hinic_dcb_set_pfc(struct hinic_hwdev *hwdev, u8 pfc_en, u8 pfc_bitmap) return 0; } + +int hinic_set_loopback_mode(struct hinic_hwdev *hwdev, u32 mode, u32 enable) +{ + struct hinic_port_loopback lb = {0}; + u16 out_size = sizeof(lb); + int err; + + lb.mode = mode; + lb.en = enable; + + if (mode < LOOP_MODE_MIN || mode > LOOP_MODE_MAX) { + dev_err(&hwdev->hwif->pdev->dev, + "Invalid loopback mode %d to set\n", mode); + return -EINVAL; + } + + err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_LOOPBACK_MODE, + &lb, sizeof(lb), &lb, &out_size); + if (err || !out_size || lb.status) { + dev_err(&hwdev->hwif->pdev->dev, + "Failed to set loopback mode %d en %d, err: %d, status: 0x%x, out size: 0x%x\n", + mode, enable, err, lb.status, out_size); + return -EIO; + } + + return 0; +} |