提交 0f6833b2 编写于 作者: L liweihang 提交者: Xie XiuQi

net: hns3: push back from kernel v5.1

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

There are some new review comments after previous patch about
hclge_cmd_check_retval() being merged. This patch aims to push back
these changes from kernel v5.1 to kernel-hulk v4.19.

Feature or Bugfix: Bugfix
Signed-off-by: Nliweihang <liweihang@huawei.com>
Reviewed-by: Nlipeng <lipeng321@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 4700cf13
...@@ -183,45 +183,40 @@ static bool hclge_is_special_opcode(u16 opcode) ...@@ -183,45 +183,40 @@ static bool hclge_is_special_opcode(u16 opcode)
return false; return false;
} }
static int hclge_cmd_check_retval(struct hclge_hw *hw, static int hclge_cmd_check_retval(struct hclge_hw *hw, struct hclge_desc *desc,
struct hclge_desc *desc, int num, int ntc)
int num, int *ntc)
{ {
struct hclge_desc *desc_to_use;
u16 opcode, desc_ret; u16 opcode, desc_ret;
int handle = 0; int handle;
int retval = 0; int retval;
opcode = le16_to_cpu(desc[0].opcode); opcode = le16_to_cpu(desc[0].opcode);
while (handle < num) { for (handle = 0; handle < num; handle++) {
desc_to_use = &hw->cmq.csq.desc[*ntc]; desc[handle] = hw->cmq.csq.desc[ntc];
desc[handle] = *desc_to_use; ntc++;
if (ntc >= hw->cmq.csq.desc_num)
if (likely(!hclge_is_special_opcode(opcode))) ntc = 0;
desc_ret = le16_to_cpu(desc[handle].retval);
else
desc_ret = le16_to_cpu(desc[0].retval);
if (desc_ret == HCLGE_CMD_EXEC_SUCCESS)
retval = 0;
else if (desc_ret == HCLGE_CMD_NO_AUTH)
retval = -EPERM;
else if (desc_ret == HCLGE_CMD_NOT_SUPPORTED)
retval = -EOPNOTSUPP;
else if (desc_ret == HCLGE_CMD_QUEUE_ILLEGAL)
retval = -ENXIO;
else
retval = -EIO;
hw->cmq.last_status = desc_ret;
(*ntc)++;
handle++;
if (*ntc >= hw->cmq.csq.desc_num)
*ntc = 0;
} }
if (likely(!hclge_is_special_opcode(opcode)))
desc_ret = le16_to_cpu(desc[num - 1].retval);
else
desc_ret = le16_to_cpu(desc[0].retval);
if (desc_ret == HCLGE_CMD_EXEC_SUCCESS)
retval = 0;
else if (desc_ret == HCLGE_CMD_NO_AUTH)
retval = -EPERM;
else if (desc_ret == HCLGE_CMD_NOT_SUPPORTED)
retval = -EOPNOTSUPP;
else if (desc_ret == HCLGE_CMD_QUEUE_ILLEGAL)
retval = -ENXIO;
else
retval = -EIO;
hw->cmq.last_status = desc_ret;
return retval; return retval;
} }
/** /**
* hclge_cmd_send - send command to command queue * hclge_cmd_send - send command to command queue
* @hw: pointer to the hw struct * @hw: pointer to the hw struct
...@@ -284,7 +279,7 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num) ...@@ -284,7 +279,7 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num)
if (!complete) { if (!complete) {
retval = -EAGAIN; retval = -EAGAIN;
} else { } else {
retval = hclge_cmd_check_retval(hw, desc, num, &ntc); retval = hclge_cmd_check_retval(hw, desc, num, ntc);
} }
/* Clean the command send queue */ /* Clean the command send queue */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册