未验证 提交 dd7d9ef1 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!1003 roh: Fix ROH multi-BD cmdq issue

Merge Pull Request from: @chenke1978 
 
When the ROH CMDQ processes multiple BDs, the operations are inconsistent
with those in the UM manual. As a result, the CMDQ parses unexpected return
values, interrupts the CMDQ processing process, and the ROH MIB statistics
query may fail.

This patch fix the process method of roh cmdq multiple BDs. 
 
Link:https://gitee.com/openeuler/kernel/pulls/1003 

Reviewed-by: Ling Mingqiang <lingmingqiang@huawei.com> 
Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
......@@ -2,10 +2,10 @@
// Copyright (c) 2022 Hisilicon Limited.
#include <linux/pci.h>
#include <net/rtnetlink.h>
#include <linux/inetdevice.h>
#include "core.h"
#include "core_priv.h"
#include "core.h"
static DEFINE_XARRAY_FLAGS(devices, XA_FLAGS_ALLOC);
static DECLARE_RWSEM(devices_rwsem);
......@@ -193,20 +193,6 @@ static int assign_name(struct roh_device *device)
return ret;
}
static int setup_device(struct roh_device *device)
{
int ret;
/* Query GUID */
ret = device->ops.query_guid(device, &device->node_guid);
if (ret) {
pr_err("failed to query guid, ret = %d\n", ret);
return ret;
}
return 0;
}
static void disable_device(struct roh_device *device)
{
u32 cid;
......@@ -264,10 +250,8 @@ static int roh_ipv4_event(struct notifier_block *this, unsigned long event, void
device = container_of(this, struct roh_device, nb);
ndev = ifa->ifa_dev->dev;
if (device->netdev != ndev) {
pr_warn("netdev mismatch.\n");
if (device->netdev != ndev || event != NETDEV_UP)
return NOTIFY_DONE;
}
in.sin_addr.s_addr = ifa->ifa_address;
......@@ -318,12 +302,6 @@ int roh_register_device(struct roh_device *device)
return ret;
}
ret = setup_device(device);
if (ret) {
pr_err("roh_core: failed to setup device, ret = %d\n", ret);
return ret;
}
dev_set_uevent_suppress(&device->dev, true);
ret = device_add(&device->dev);
if (ret) {
......@@ -559,7 +537,7 @@ static int roh_set_pf_mac_by_eid(struct roh_device *device,
u32 eid = eid_attr->base;
struct net_device *ndev;
struct sockaddr s_addr;
u8 mac[ETH_ALEN];
u8 mac[ETH_ALEN] = {0};
int ret;
ndev = device->netdev;
......@@ -628,11 +606,6 @@ void roh_device_get_eid(struct roh_device *device, struct roh_eid_attr *attr)
mutex_unlock(&device->eid_mutex);
}
void roh_device_query_guid(struct roh_device *device, struct roh_guid_attr *attr)
{
memcpy(attr, &device->node_guid, sizeof(*attr));
}
enum roh_link_status roh_device_query_link_status(struct roh_device *device)
{
return device->link_status;
......
......@@ -7,7 +7,7 @@
#include <linux/types.h>
#include <linux/workqueue.h>
#include <linux/netdevice.h>
#include <net/bonding.h>
#include <linux/etherdevice.h>
#define ROH_DEVICE_NAME_MAX 64
#define MAX_DEVICE_REFCOUNT 2
......@@ -23,14 +23,9 @@ enum roh_link_status { ROH_LINK_DOWN = 0, ROH_LINK_UP };
enum roh_mib_type { ROH_MIB_PUBLIC = 0, ROH_MIB_PRIVATE };
static inline void convert_eid_to_mac(u8 mac[6], u32 eid)
static inline void convert_eid_to_mac(u8 *mac, u32 eid)
{
mac[0] = 0;
mac[1] = 0;
mac[2] = 0;
mac[3] = (eid >> 16) & 0xff;
mac[4] = (eid >> 8) & 0xff;
mac[5] = eid & 0xff;
u64_to_ether_addr((u64)eid, mac);
}
struct roh_eid_attr {
......@@ -38,10 +33,6 @@ struct roh_eid_attr {
u32 num;
};
struct roh_guid_attr {
u8 data[16];
};
struct roh_mib_stats {
struct mutex lock; /* Protect values[] */
const char * const *names;
......@@ -51,13 +42,7 @@ struct roh_mib_stats {
struct roh_device;
struct roh_device_ops {
int (*query_guid)(struct roh_device *device, struct roh_guid_attr *attr);
int (*set_eid)(struct roh_device *device, struct roh_eid_attr *attr);
struct sk_buff *(*pkt_create)(struct net_device *ndev,
u8 *dest_mac, u8 *src_mac, int ptype,
struct roh_guid_attr *guid, u16 eid_nums);
int (*pkt_parse)(struct sk_buff *skb, struct roh_eid_attr *eid_attr, int ptype);
enum roh_dev_tx (*xmit_pkt)(struct roh_device *device, struct sk_buff *skb);
struct roh_mib_stats *(*alloc_hw_stats)(struct roh_device *device, enum roh_mib_type);
int (*get_hw_stats)(struct roh_device *device,
struct roh_mib_stats *stats, enum roh_mib_type);
......@@ -85,7 +70,6 @@ struct roh_device {
struct completion unreg_completion;
struct mutex unregistration_lock; /* lock for unregiste */
struct roh_guid_attr node_guid;
struct roh_eid_attr eid;
struct mutex eid_mutex; /* operate eid needs to be mutexed */
u32 link_status;
......
......@@ -4,6 +4,8 @@
#ifndef __CORE_PRIV_H__
#define __CORE_PRIV_H__
#include "core.h"
struct roh_client {
char *name;
int (*add)(struct roh_device *device);
......@@ -24,7 +26,6 @@ void roh_device_unregister_sysfs(struct roh_device *device);
int roh_device_set_eid(struct roh_device *device, struct roh_eid_attr *attr);
void roh_device_get_eid(struct roh_device *device, struct roh_eid_attr *attr);
void roh_device_query_guid(struct roh_device *device, struct roh_guid_attr *attr);
enum roh_link_status roh_device_query_link_status(struct roh_device *device);
#endif /* __CORE_PRIV_H__ */
// SPDX-License-Identifier: GPL-2.0+
// Copyright (c) 2020-2022 Hisilicon Limited.
#include <net/sock.h>
#include <linux/sysfs.h>
#include <linux/stat.h>
#include <net/sock.h>
#include "core.h"
#include "core_priv.h"
......@@ -21,18 +21,6 @@ static ssize_t node_eid_show(struct device *device,
return sprintf(buf, "base:%u num:%u\n", eid.base, eid.num);
}
static ssize_t node_guid_show(struct device *device,
struct device_attribute *attr, char *buf)
{
struct roh_device *dev = container_of(device, struct roh_device, dev);
struct roh_guid_attr guid;
u32 *val = (u32 *)guid.data;
roh_device_query_guid(dev, &guid);
return sprintf(buf, "%08x:%08x:%08x:%08x\n", val[0], val[1], val[2], val[3]);
}
static ssize_t node_link_status_show(struct device *device,
struct device_attribute *attr, char *buf)
{
......@@ -44,12 +32,10 @@ static ssize_t node_link_status_show(struct device *device,
}
static DEVICE_ATTR_RO(node_eid);
static DEVICE_ATTR_RO(node_guid);
static DEVICE_ATTR_RO(node_link_status);
static struct device_attribute *roh_class_attr[] = {
&dev_attr_node_eid,
&dev_attr_node_guid,
&dev_attr_node_link_status,
};
......@@ -71,7 +57,7 @@ static void remove_device_sysfs(struct roh_device *device)
device_remove_file(&device->dev, roh_class_attr[i]);
}
static const char * const roh_hw_stats_name[ROH_MIB_STATS_TYPE_NUM] = {
static const char * const g_roh_hw_stats_name[ROH_MIB_STATS_TYPE_NUM] = {
"mib_public",
"mib_private",
};
......@@ -91,18 +77,19 @@ static ssize_t print_hw_stat(struct roh_device *dev,
static ssize_t node_public_mib_stats_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
struct roh_hw_stats_attribute *hsa;
struct roh_mib_stats *public_stats;
struct roh_device *dev;
int ret;
hsa = container_of(attr, struct roh_hw_stats_attribute, attr);
dev = container_of(kobj, struct roh_device, dev.kobj);
public_stats = dev->hw_public_stats;
mutex_lock(&public_stats->lock);
ret = dev->ops.get_hw_stats(dev, public_stats, ROH_MIB_PUBLIC);
if (ret)
if (ret) {
dev_err(&dev->dev,
"failed to get roh public hw stats, ret = %d.\n", ret);
goto unlock;
}
ret = print_hw_stat(dev, public_stats, buf);
......@@ -115,17 +102,18 @@ static ssize_t node_private_mib_stats_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
struct roh_mib_stats *private_stats;
struct roh_hw_stats_attribute *hsa;
struct roh_device *dev;
int ret;
hsa = container_of(attr, struct roh_hw_stats_attribute, attr);
dev = container_of(kobj, struct roh_device, dev.kobj);
private_stats = dev->hw_private_stats;
mutex_lock(&private_stats->lock);
ret = dev->ops.get_hw_stats(dev, private_stats, ROH_MIB_PRIVATE);
if (ret)
if (ret) {
dev_err(&dev->dev,
"failed to get roh private hw stats, ret = %d.\n", ret);
goto unlock;
}
ret = print_hw_stat(dev, private_stats, buf);
......@@ -134,7 +122,7 @@ static ssize_t node_private_mib_stats_show(struct kobject *kobj,
return ret;
}
static ssize_t (*show_roh_mib_hw_stats[ROH_MIB_STATS_TYPE_NUM])
static ssize_t (*g_show_roh_mib_hw_stats[ROH_MIB_STATS_TYPE_NUM])
(struct kobject *, struct attribute *, char *) = {
node_public_mib_stats_show,
node_private_mib_stats_show
......@@ -168,70 +156,131 @@ static struct attribute *alloc_hsa(const char *name,
return &hsa->attr;
}
static void setup_mib_stats(struct roh_device *device)
static void free_hw_stats(struct roh_device *device)
{
kfree(device->hw_private_stats);
kfree(device->hw_public_stats);
}
static int alloc_and_get_hw_stats(struct roh_device *device)
{
struct roh_mib_stats *privite_stats, *public_stats;
struct attribute_group *hsag;
struct kobject *kobj;
int i, j;
int ret;
public_stats = device->ops.alloc_hw_stats(device, ROH_MIB_PUBLIC);
if (!public_stats)
return;
if (!public_stats) {
dev_err(&device->dev, "failed to alloc roh public hw stats.\n");
return -ENOMEM;
}
privite_stats = device->ops.alloc_hw_stats(device, ROH_MIB_PRIVATE);
if (!privite_stats) {
dev_err(&device->dev, "failed to alloc roh privite hw stats.\n");
kfree(public_stats);
return;
return -ENOMEM;
}
hsag = kzalloc(sizeof(*hsag) +
sizeof(void *) * (ARRAY_SIZE(roh_hw_stats_name)),
GFP_KERNEL);
if (!hsag)
goto err_free_stats;
ret = device->ops.get_hw_stats(device, public_stats, ROH_MIB_PUBLIC);
if (ret)
goto err_free_hsag;
if (ret) {
dev_err(&device->dev,
"failed to get roh public mib stats, ret = %d\n", ret);
goto err;
}
ret = device->ops.get_hw_stats(device, privite_stats, ROH_MIB_PRIVATE);
if (ret)
goto err_free_hsag;
if (ret) {
dev_err(&device->dev,
"failed to get roh privite mib stats, ret = %d\n", ret);
goto err;
}
mutex_init(&privite_stats->lock);
mutex_init(&public_stats->lock);
device->hw_public_stats = public_stats;
device->hw_private_stats = privite_stats;
return 0;
err:
free_hw_stats(device);
return ret;
}
static int alloc_hsag(struct roh_device *device)
{
struct attribute_group *hsag;
struct kobject *kobj;
int i, j;
int ret;
/*
* one extra attribue elements here, terminate the
* list for the sysfs core code
*/
hsag = kzalloc(sizeof(*hsag) +
sizeof(void *) * (ARRAY_SIZE(g_roh_hw_stats_name) + 1),
GFP_KERNEL);
if (!hsag) {
dev_err(&device->dev, "failed to kzalloc hsag.\n");
return -ENOMEM;
}
hsag->name = "node_mib_stats";
hsag->attrs = (void *)hsag + sizeof(*hsag);
for (i = 0; i < ARRAY_SIZE(roh_hw_stats_name); i++) {
hsag->attrs[i] = alloc_hsa(roh_hw_stats_name[i],
show_roh_mib_hw_stats[i]);
if (!hsag->attrs[i])
for (i = 0; i < ARRAY_SIZE(g_roh_hw_stats_name); i++) {
hsag->attrs[i] = alloc_hsa(g_roh_hw_stats_name[i],
g_show_roh_mib_hw_stats[i]);
if (!hsag->attrs[i]) {
ret = -ENOMEM;
dev_err(&device->dev,
"failed to alloc hsa for hsag attrs[%d].\n", i);
goto err;
}
sysfs_attr_init(hsag->attrs[i]);
}
mutex_init(&privite_stats->lock);
mutex_init(&public_stats->lock);
kobj = &device->dev.kobj;
ret = sysfs_create_group(kobj, hsag);
if (ret)
if (ret) {
dev_err(&device->dev,
"failed to create roh sysfs group, ret = %d\n", ret);
goto err;
device->hw_stats_ag = hsag;
device->hw_public_stats = public_stats;
device->hw_private_stats = privite_stats;
}
return;
device->hw_stats_ag = hsag;
return 0;
err:
for (j = i - 1; j >= 0; j--)
kfree(hsag->attrs[j]);
err_free_hsag:
kfree(hsag);
err_free_stats:
kfree(public_stats);
kfree(privite_stats);
return ret;
}
static int setup_mib_stats(struct roh_device *device)
{
int ret;
ret = alloc_and_get_hw_stats(device);
if (ret) {
dev_err(&device->dev,
"failed to alloc and get roh hw stats, ret = %d.\n", ret);
return ret;
}
ret = alloc_hsag(device);
if (ret) {
dev_err(&device->dev,
"failed to alloc hsag, ret = %d.\n", ret);
free_hw_stats(device);
return ret;
}
return 0;
}
int roh_device_register_sysfs(struct roh_device *device)
......@@ -242,17 +291,23 @@ int roh_device_register_sysfs(struct roh_device *device)
for (i = 0; i < ARRAY_SIZE(roh_class_attr); i++) {
ret = device_create_file(&device->dev, roh_class_attr[i]);
if (ret) {
pr_err("failed to create node %s, ret = %d.\n",
dev_err(&device->dev,
"failed to create node %s, ret = %d.\n",
roh_class_attr[i]->attr.name, ret);
goto err;
}
}
if (device->ops.alloc_hw_stats)
setup_mib_stats(device);
if (device->ops.alloc_hw_stats) {
ret = setup_mib_stats(device);
if (ret) {
dev_err(&device->dev,
"failed to setup roh mib stats, ret = %d.\n", ret);
goto err;
}
}
return 0;
err:
remove_device_sysfs(device);
return ret;
......@@ -263,8 +318,7 @@ void roh_device_unregister_sysfs(struct roh_device *device)
if (device->hw_stats_ag)
free_hsag(&device->dev.kobj, device->hw_stats_ag);
kfree(device->hw_private_stats);
kfree(device->hw_public_stats);
free_hw_stats(device);
remove_device_sysfs(device);
}
......@@ -10,8 +10,8 @@
#include "core.h"
#include "hns3_device.h"
#include "hns3_common.h"
#include "hns3_cmdq.h"
#include "hns3_reg.h"
#include "hns3_cmdq.h"
static int hns3_roh_alloc_cmdq_desc(struct hns3_roh_device *hroh_dev,
struct hns3_roh_cmdq_ring *ring)
......@@ -224,6 +224,11 @@ static int hns3_roh_cmdq_build(struct hns3_roh_device *hroh_dev,
int handle = 0;
if (num > hns3_roh_cmdq_space(csq)) {
/* If CMDQ ring is full, SW HEAD and HW HEAD may be different,
* need update the SW HEAD pointer csq->next_to_clean
*/
csq->next_to_clean =
hns3_roh_read(hroh_dev, HNS3_ROH_TX_CMDQ_HEAD_REG);
dev_err(hroh_dev->dev, "cmdq is full, opcode %x\n", desc->opcode);
return -EBUSY;
}
......@@ -241,49 +246,96 @@ static int hns3_roh_cmdq_build(struct hns3_roh_device *hroh_dev,
return 0;
}
static int hns3_roh_cmdq_done_parse(struct hns3_roh_device *hroh_dev,
struct hns3_roh_desc *desc,
int num, int ntc)
static void hns3_roh_cmd_wait_for_resp(struct hns3_roh_device *hroh_dev,
bool *is_completed)
{
struct hns3_roh_priv *priv = (struct hns3_roh_priv *)hroh_dev->priv;
struct hns3_roh_cmdq_ring *csq = &priv->cmdq.csq;
struct hns3_roh_desc *desc_to_use = NULL;
int handle = 0;
u16 desc_ret;
int ret;
u32 timeout = 0;
do {
if (hns3_roh_cmdq_csq_done(hroh_dev)) {
while (handle < num) {
desc_to_use = &csq->desc[ntc];
desc[handle] = *desc_to_use;
desc_ret = le16_to_cpu(desc[handle].retval);
if (desc_ret == HNS3_ROH_CMD_EXEC_SUCCESS) {
ret = 0;
} else if (desc_ret == HNS3_ROH_CMD_EXEC_TIMEOUT) {
priv->cmdq.last_status = desc_ret;
ret = -ETIME;
} else {
pr_err("desc_ret = %d\n", desc_ret);
ret = -EIO;
*is_completed = true;
break;
}
udelay(1);
timeout++;
} while (timeout < priv->cmdq.tx_timeout);
}
static const u16 spec_opcode[] = { HNS3_ROH_OPC_QUERY_MIB_PUBLIC,
HNS3_ROH_OPC_QUERY_MIB_PRIVATE };
static bool hns_roh_is_special_opcode(u16 opcode)
{
/* these commands have several descriptors,
* and use the first one to save opcode and return value
*/
u32 i;
for (i = 0; i < ARRAY_SIZE(spec_opcode); i++)
if (spec_opcode[i] == opcode)
return true;
return false;
}
static int hns3_roh_cmd_convert_err_code(u16 desc_ret)
{
struct hns3_roh_errcode hns3_roh_cmd_errcode[] = {
{ HNS3_ROH_CMD_EXEC_SUCCESS, 0 },
{ HNS3_ROH_CMD_NO_AUTH, -EPERM },
{ HNS3_ROH_CMD_NOT_SUPPORTED, -EOPNOTSUPP },
{ HNS3_ROH_CMD_QUEUE_FULL, -EXFULL },
{ HNS3_ROH_CMD_NEXT_ERR, -ENOSR },
{ HNS3_ROH_CMD_UNEXE_ERR, -ENOTBLK },
{ HNS3_ROH_CMD_PARA_ERR, -EINVAL },
{ HNS3_ROH_CMD_RESULT_ERR, -ERANGE },
{ HNS3_ROH_CMD_TIMEOUT, -ETIME },
{ HNS3_ROH_CMD_HILINK_ERR, -ENOLINK },
{ HNS3_ROH_CMD_QUEUE_ILLEGAL, -ENXIO },
{ HNS3_ROH_CMD_INVALID, -EBADR },
};
u32 errcode_count = ARRAY_SIZE(hns3_roh_cmd_errcode);
u32 i;
for (i = 0; i < errcode_count; i++)
if (hns3_roh_cmd_errcode[i].imp_errcode == desc_ret)
return hns3_roh_cmd_errcode[i].common_errno;
return -EIO;
}
static int hns3_roh_cmd_check_retval(struct hns3_roh_device *hroh_dev,
struct hns3_roh_desc *desc, int num,
int next_to_clean)
{
struct hns3_roh_priv *priv = (struct hns3_roh_priv *)hroh_dev->priv;
int ntc = next_to_clean;
u16 opcode, desc_ret;
int handle;
opcode = le16_to_cpu(desc[0].opcode);
for (handle = 0; handle < num; handle++) {
desc[handle] = priv->cmdq.csq.desc[ntc];
ntc++;
handle++;
if (ntc == csq->desc_num)
if (ntc >= priv->cmdq.csq.desc_num)
ntc = 0;
}
} else {
ret = -EAGAIN;
}
if (likely(!hns_roh_is_special_opcode(opcode)))
desc_ret = le16_to_cpu(desc[num - 1].retval);
else
desc_ret = le16_to_cpu(desc[0].retval);
return ret;
priv->cmdq.last_status = desc_ret;
return hns3_roh_cmd_convert_err_code(desc_ret);
}
int hns3_roh_cmdq_send(struct hns3_roh_device *hroh_dev, struct hns3_roh_desc *desc, int num)
{
struct hns3_roh_priv *priv = (struct hns3_roh_priv *)hroh_dev->priv;
struct hns3_roh_cmdq_ring *csq = &priv->cmdq.csq;
u32 timeout = 0;
bool is_completed = false;
int handle = 0;
int ntc = 0;
int ret = 0;
......@@ -298,16 +350,13 @@ int hns3_roh_cmdq_send(struct hns3_roh_device *hroh_dev, struct hns3_roh_desc *d
/* Write to hardware */
hns3_roh_write(hroh_dev, HNS3_ROH_TX_CMDQ_TAIL_REG, csq->next_to_use);
if (desc->flag & cpu_to_le16(HNS3_ROH_CMD_FLAG_NO_INTR)) {
do {
if (hns3_roh_cmdq_csq_done(hroh_dev))
break;
udelay(1);
timeout++;
} while (timeout < priv->cmdq.tx_timeout);
}
if (le16_to_cpu(desc->flag) & HNS3_ROH_CMD_FLAG_NO_INTR)
hns3_roh_cmd_wait_for_resp(hroh_dev, &is_completed);
ret = hns3_roh_cmdq_done_parse(hroh_dev, desc, num, ntc);
if (!is_completed)
ret = -EBADE;
else
ret = hns3_roh_cmd_check_retval(hroh_dev, desc, num, ntc);
handle = hns3_roh_cmdq_csq_clean(hroh_dev);
if (handle != num)
......
......@@ -28,21 +28,28 @@ enum hns3_roh_opcode_type {
HNS3_ROH_OPC_GET_INTR_INFO = 0x0023,
HNS3_ROH_OPC_QUERY_PORT_LINK_STATUS = 0x038a,
HNS3_ROH_OPC_SET_EID = 0x9001,
HNS3_ROH_OPC_GET_GUID = 0x9002,
HNS3_ROH_OPC_QUERY_MIB_PUBLIC = 0x9005,
HNS3_ROH_OPC_QUERY_MIB_PRIVATE = 0x9006,
};
struct hns3_roh_errcode {
u32 imp_errcode;
int common_errno;
};
enum hns3_roh_cmd_return_status {
HNS3_ROH_CMD_EXEC_SUCCESS = 0,
HNS3_ROH_CMD_NO_AUTH,
HNS3_ROH_CMD_NOT_EXIST,
HNS3_ROH_CMD_QUEUE_FULL,
HNS3_ROH_CMD_NEXT_ERR,
HNS3_ROH_CMD_NOT_EXEC,
HNS3_ROH_CMD_PARA_ERR,
HNS3_ROH_CMD_RESULT_ERR,
HNS3_ROH_CMD_EXEC_TIMEOUT
HNS3_ROH_CMD_NO_AUTH = 1,
HNS3_ROH_CMD_NOT_SUPPORTED = 2,
HNS3_ROH_CMD_QUEUE_FULL = 3,
HNS3_ROH_CMD_NEXT_ERR = 4,
HNS3_ROH_CMD_UNEXE_ERR = 5,
HNS3_ROH_CMD_PARA_ERR = 6,
HNS3_ROH_CMD_RESULT_ERR = 7,
HNS3_ROH_CMD_TIMEOUT = 8,
HNS3_ROH_CMD_HILINK_ERR = 9,
HNS3_ROH_CMD_QUEUE_ILLEGAL = 10,
HNS3_ROH_CMD_INVALID = 11,
};
enum hns3_roh_mbx_opcode {
......@@ -69,11 +76,6 @@ struct hns3_roh_set_eid_info {
u8 rsv[16];
};
struct hns3_roh_get_guid_info {
u8 guid[16];
u8 rsv[8];
};
struct hns3_roh_query_link_status_info {
__le32 query_link_status;
u8 rsv[20];
......
......@@ -77,7 +77,6 @@ static int hns3_roh_register_device(struct hns3_roh_device *hroh_dev)
rohdev->netdev = hroh_dev->netdev;
rohdev->ops.set_eid = hns3_roh_set_eid;
rohdev->ops.query_guid = hns3_roh_query_guid;
rohdev->ops.alloc_hw_stats = hns3_roh_alloc_hw_stats;
rohdev->ops.get_hw_stats = hns3_roh_get_hw_stats;
......@@ -332,10 +331,8 @@ static int hns3_roh_init_instance(struct hnae3_handle *handle)
int ret;
id = pci_match_id(hns3_roh_pci_tbl, handle->pdev);
if (!id) {
dev_err(dev, "failed to match pci id.\n");
if (!id)
return 0;
}
if (id->driver_data) {
dev_err(dev, "not support vf.\n");
......@@ -562,8 +559,9 @@ static void hns3_roh_dfx_init(struct hns3_roh_device *hroh_dev)
if (IS_ERR_OR_NULL(hroh_dev->dfx_debugfs))
return;
entry = debugfs_create_file("hns3_roh_dfx", 0600, hroh_dev->dfx_debugfs,
hroh_dev, &hns3_roh_dfx_cmd_fops);
entry = debugfs_create_file("hns3_roh_dfx", 0600,
hroh_dev->dfx_debugfs, hroh_dev,
&hns3_roh_dfx_cmd_fops);
if (IS_ERR_OR_NULL(entry)) {
debugfs_remove_recursive(hroh_dev->dfx_debugfs);
hroh_dev->dfx_debugfs = NULL;
......
......@@ -3,8 +3,8 @@
#include "core.h"
#include "hns3_verbs.h"
#include "hns3_cmdq.h"
#include "hns3_verbs.h"
int hns3_roh_set_eid(struct roh_device *rohdev, struct roh_eid_attr *eid_attr)
{
......@@ -28,26 +28,6 @@ int hns3_roh_set_eid(struct roh_device *rohdev, struct roh_eid_attr *eid_attr)
return 0;
}
int hns3_roh_query_guid(struct roh_device *rohdev, struct roh_guid_attr *guid_attr)
{
struct hns3_roh_device *hroh_dev = to_hroh_dev(rohdev);
struct hns3_roh_get_guid_info *req;
struct hns3_roh_desc desc;
int ret;
hns3_roh_cmdq_setup_basic_desc(&desc, HNS3_ROH_OPC_GET_GUID, true);
ret = hns3_roh_cmdq_send(hroh_dev, &desc, 1);
if (ret) {
dev_err(hroh_dev->dev, "failed to query guid, ret = %d\n", ret);
return ret;
}
req = (struct hns3_roh_get_guid_info *)desc.data;
memcpy(guid_attr->data, req->guid, sizeof(req->guid));
return 0;
}
static const char * const hns3_roh_hw_stats_name_public[] = {
"mac_tx_packet_num",
"mac_rx_packet_num",
......
......@@ -7,7 +7,6 @@
#include "hns3_common.h"
int hns3_roh_set_eid(struct roh_device *rohdev, struct roh_eid_attr *eid_attr);
int hns3_roh_query_guid(struct roh_device *rohdev, struct roh_guid_attr *guid_attr);
struct roh_mib_stats *hns3_roh_alloc_hw_stats(struct roh_device *rohdev,
enum roh_mib_type mib_type);
int hns3_roh_get_hw_stats(struct roh_device *rohdev, struct roh_mib_stats *stats,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册