Skip to content

Commit 36747c9

Browse files
committed
Merge branch 'hns3-fixes'
Guangbin Huang says: ==================== net: hns3: add some fixes for -net This series adds some fixes for the HNS3 ethernet driver. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 42a99a0 + 5126b9d commit 36747c9

File tree

5 files changed

+103
-49
lines changed

5 files changed

+103
-49
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,12 +2445,12 @@ static void hclge_handle_over_8bd_err(struct hclge_dev *hdev,
24452445
return;
24462446
}
24472447

2448-
dev_err(dev, "PPU_PF_ABNORMAL_INT_ST over_8bd_no_fe found, vf_id(%u), queue_id(%u)\n",
2448+
dev_err(dev, "PPU_PF_ABNORMAL_INT_ST over_8bd_no_fe found, vport(%u), queue_id(%u)\n",
24492449
vf_id, q_id);
24502450

24512451
if (vf_id) {
24522452
if (vf_id >= hdev->num_alloc_vport) {
2453-
dev_err(dev, "invalid vf id(%u)\n", vf_id);
2453+
dev_err(dev, "invalid vport(%u)\n", vf_id);
24542454
return;
24552455
}
24562456

@@ -2463,8 +2463,8 @@ static void hclge_handle_over_8bd_err(struct hclge_dev *hdev,
24632463

24642464
ret = hclge_inform_reset_assert_to_vf(&hdev->vport[vf_id]);
24652465
if (ret)
2466-
dev_err(dev, "inform reset to vf(%u) failed %d!\n",
2467-
hdev->vport->vport_id, ret);
2466+
dev_err(dev, "inform reset to vport(%u) failed %d!\n",
2467+
vf_id, ret);
24682468
} else {
24692469
set_bit(HNAE3_FUNC_RESET, reset_requests);
24702470
}

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3661,7 +3661,8 @@ static int hclge_set_all_vf_rst(struct hclge_dev *hdev, bool reset)
36613661
if (ret) {
36623662
dev_err(&hdev->pdev->dev,
36633663
"set vf(%u) rst failed %d!\n",
3664-
vport->vport_id, ret);
3664+
vport->vport_id - HCLGE_VF_VPORT_START_NUM,
3665+
ret);
36653666
return ret;
36663667
}
36673668

@@ -3676,7 +3677,8 @@ static int hclge_set_all_vf_rst(struct hclge_dev *hdev, bool reset)
36763677
if (ret)
36773678
dev_warn(&hdev->pdev->dev,
36783679
"inform reset to vf(%u) failed %d!\n",
3679-
vport->vport_id, ret);
3680+
vport->vport_id - HCLGE_VF_VPORT_START_NUM,
3681+
ret);
36803682
}
36813683

36823684
return 0;
@@ -4741,6 +4743,24 @@ static int hclge_get_rss(struct hnae3_handle *handle, u32 *indir,
47414743
return 0;
47424744
}
47434745

4746+
static int hclge_parse_rss_hfunc(struct hclge_vport *vport, const u8 hfunc,
4747+
u8 *hash_algo)
4748+
{
4749+
switch (hfunc) {
4750+
case ETH_RSS_HASH_TOP:
4751+
*hash_algo = HCLGE_RSS_HASH_ALGO_TOEPLITZ;
4752+
return 0;
4753+
case ETH_RSS_HASH_XOR:
4754+
*hash_algo = HCLGE_RSS_HASH_ALGO_SIMPLE;
4755+
return 0;
4756+
case ETH_RSS_HASH_NO_CHANGE:
4757+
*hash_algo = vport->rss_algo;
4758+
return 0;
4759+
default:
4760+
return -EINVAL;
4761+
}
4762+
}
4763+
47444764
static int hclge_set_rss(struct hnae3_handle *handle, const u32 *indir,
47454765
const u8 *key, const u8 hfunc)
47464766
{
@@ -4750,30 +4770,27 @@ static int hclge_set_rss(struct hnae3_handle *handle, const u32 *indir,
47504770
u8 hash_algo;
47514771
int ret, i;
47524772

4773+
ret = hclge_parse_rss_hfunc(vport, hfunc, &hash_algo);
4774+
if (ret) {
4775+
dev_err(&hdev->pdev->dev, "invalid hfunc type %u\n", hfunc);
4776+
return ret;
4777+
}
4778+
47534779
/* Set the RSS Hash Key if specififed by the user */
47544780
if (key) {
4755-
switch (hfunc) {
4756-
case ETH_RSS_HASH_TOP:
4757-
hash_algo = HCLGE_RSS_HASH_ALGO_TOEPLITZ;
4758-
break;
4759-
case ETH_RSS_HASH_XOR:
4760-
hash_algo = HCLGE_RSS_HASH_ALGO_SIMPLE;
4761-
break;
4762-
case ETH_RSS_HASH_NO_CHANGE:
4763-
hash_algo = vport->rss_algo;
4764-
break;
4765-
default:
4766-
return -EINVAL;
4767-
}
4768-
47694781
ret = hclge_set_rss_algo_key(hdev, hash_algo, key);
47704782
if (ret)
47714783
return ret;
47724784

47734785
/* Update the shadow RSS key with user specified qids */
47744786
memcpy(vport->rss_hash_key, key, HCLGE_RSS_KEY_SIZE);
4775-
vport->rss_algo = hash_algo;
4787+
} else {
4788+
ret = hclge_set_rss_algo_key(hdev, hash_algo,
4789+
vport->rss_hash_key);
4790+
if (ret)
4791+
return ret;
47764792
}
4793+
vport->rss_algo = hash_algo;
47774794

47784795
/* Update the shadow RSS table with user specified qids */
47794796
for (i = 0; i < ae_dev->dev_specs.rss_ind_tbl_size; i++)
@@ -6627,10 +6644,13 @@ static int hclge_fd_parse_ring_cookie(struct hclge_dev *hdev, u64 ring_cookie,
66276644
u8 vf = ethtool_get_flow_spec_ring_vf(ring_cookie);
66286645
u16 tqps;
66296646

6647+
/* To keep consistent with user's configuration, minus 1 when
6648+
* printing 'vf', because vf id from ethtool is added 1 for vf.
6649+
*/
66306650
if (vf > hdev->num_req_vfs) {
66316651
dev_err(&hdev->pdev->dev,
6632-
"Error: vf id (%u) > max vf num (%u)\n",
6633-
vf, hdev->num_req_vfs);
6652+
"Error: vf id (%u) should be less than %u\n",
6653+
vf - 1, hdev->num_req_vfs);
66346654
return -EINVAL;
66356655
}
66366656

@@ -9797,6 +9817,9 @@ static int hclge_set_vlan_filter_hw(struct hclge_dev *hdev, __be16 proto,
97979817
if (is_kill && !vlan_id)
97989818
return 0;
97999819

9820+
if (vlan_id >= VLAN_N_VID)
9821+
return -EINVAL;
9822+
98009823
ret = hclge_set_vf_vlan_common(hdev, vport_id, is_kill, vlan_id);
98019824
if (ret) {
98029825
dev_err(&hdev->pdev->dev,
@@ -10703,7 +10726,8 @@ static int hclge_reset_tqp_cmd_send(struct hclge_dev *hdev, u16 queue_id,
1070310726
return 0;
1070410727
}
1070510728

10706-
static int hclge_get_reset_status(struct hclge_dev *hdev, u16 queue_id)
10729+
static int hclge_get_reset_status(struct hclge_dev *hdev, u16 queue_id,
10730+
u8 *reset_status)
1070710731
{
1070810732
struct hclge_reset_tqp_queue_cmd *req;
1070910733
struct hclge_desc desc;
@@ -10721,7 +10745,9 @@ static int hclge_get_reset_status(struct hclge_dev *hdev, u16 queue_id)
1072110745
return ret;
1072210746
}
1072310747

10724-
return hnae3_get_bit(req->ready_to_reset, HCLGE_TQP_RESET_B);
10748+
*reset_status = hnae3_get_bit(req->ready_to_reset, HCLGE_TQP_RESET_B);
10749+
10750+
return 0;
1072510751
}
1072610752

1072710753
u16 hclge_covert_handle_qid_global(struct hnae3_handle *handle, u16 queue_id)
@@ -10740,7 +10766,7 @@ static int hclge_reset_tqp_cmd(struct hnae3_handle *handle)
1074010766
struct hclge_vport *vport = hclge_get_vport(handle);
1074110767
struct hclge_dev *hdev = vport->back;
1074210768
u16 reset_try_times = 0;
10743-
int reset_status;
10769+
u8 reset_status;
1074410770
u16 queue_gid;
1074510771
int ret;
1074610772
u16 i;
@@ -10756,7 +10782,11 @@ static int hclge_reset_tqp_cmd(struct hnae3_handle *handle)
1075610782
}
1075710783

1075810784
while (reset_try_times++ < HCLGE_TQP_RESET_TRY_TIMES) {
10759-
reset_status = hclge_get_reset_status(hdev, queue_gid);
10785+
ret = hclge_get_reset_status(hdev, queue_gid,
10786+
&reset_status);
10787+
if (ret)
10788+
return ret;
10789+
1076010790
if (reset_status)
1076110791
break;
1076210792

@@ -11449,11 +11479,11 @@ static void hclge_clear_resetting_state(struct hclge_dev *hdev)
1144911479
struct hclge_vport *vport = &hdev->vport[i];
1145011480
int ret;
1145111481

11452-
/* Send cmd to clear VF's FUNC_RST_ING */
11482+
/* Send cmd to clear vport's FUNC_RST_ING */
1145311483
ret = hclge_set_vf_rst(hdev, vport->vport_id, false);
1145411484
if (ret)
1145511485
dev_warn(&hdev->pdev->dev,
11456-
"clear vf(%u) rst failed %d!\n",
11486+
"clear vport(%u) rst failed %d!\n",
1145711487
vport->vport_id, ret);
1145811488
}
1145911489
}

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ static int hclge_reset_vf(struct hclge_vport *vport)
566566
struct hclge_dev *hdev = vport->back;
567567

568568
dev_warn(&hdev->pdev->dev, "PF received VF reset request from VF %u!",
569-
vport->vport_id);
569+
vport->vport_id - HCLGE_VF_VPORT_START_NUM);
570570

571571
return hclge_func_reset_cmd(hdev, vport->vport_id);
572572
}
@@ -590,9 +590,17 @@ static void hclge_get_queue_id_in_pf(struct hclge_vport *vport,
590590
struct hclge_mbx_vf_to_pf_cmd *mbx_req,
591591
struct hclge_respond_to_vf_msg *resp_msg)
592592
{
593+
struct hnae3_handle *handle = &vport->nic;
594+
struct hclge_dev *hdev = vport->back;
593595
u16 queue_id, qid_in_pf;
594596

595597
memcpy(&queue_id, mbx_req->msg.data, sizeof(queue_id));
598+
if (queue_id >= handle->kinfo.num_tqps) {
599+
dev_err(&hdev->pdev->dev, "Invalid queue id(%u) from VF %u\n",
600+
queue_id, mbx_req->mbx_src_vfid);
601+
return;
602+
}
603+
596604
qid_in_pf = hclge_covert_handle_qid_global(&vport->nic, queue_id);
597605
memcpy(resp_msg->data, &qid_in_pf, sizeof(qid_in_pf));
598606
resp_msg->len = sizeof(qid_in_pf);

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ int hclge_tm_qs_shaper_cfg(struct hclge_vport *vport, int max_tx_rate)
581581
ret = hclge_cmd_send(&hdev->hw, &desc, 1);
582582
if (ret) {
583583
dev_err(&hdev->pdev->dev,
584-
"vf%u, qs%u failed to set tx_rate:%d, ret=%d\n",
584+
"vport%u, qs%u failed to set tx_rate:%d, ret=%d\n",
585585
vport->vport_id, shap_cfg_cmd->qs_id,
586586
max_tx_rate, ret);
587587
return ret;

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -816,40 +816,56 @@ static int hclgevf_get_rss(struct hnae3_handle *handle, u32 *indir, u8 *key,
816816
return 0;
817817
}
818818

819+
static int hclgevf_parse_rss_hfunc(struct hclgevf_dev *hdev, const u8 hfunc,
820+
u8 *hash_algo)
821+
{
822+
switch (hfunc) {
823+
case ETH_RSS_HASH_TOP:
824+
*hash_algo = HCLGEVF_RSS_HASH_ALGO_TOEPLITZ;
825+
return 0;
826+
case ETH_RSS_HASH_XOR:
827+
*hash_algo = HCLGEVF_RSS_HASH_ALGO_SIMPLE;
828+
return 0;
829+
case ETH_RSS_HASH_NO_CHANGE:
830+
*hash_algo = hdev->rss_cfg.hash_algo;
831+
return 0;
832+
default:
833+
return -EINVAL;
834+
}
835+
}
836+
819837
static int hclgevf_set_rss(struct hnae3_handle *handle, const u32 *indir,
820838
const u8 *key, const u8 hfunc)
821839
{
822840
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
823841
struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg;
842+
u8 hash_algo;
824843
int ret, i;
825844

826845
if (hdev->ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) {
846+
ret = hclgevf_parse_rss_hfunc(hdev, hfunc, &hash_algo);
847+
if (ret)
848+
return ret;
849+
827850
/* Set the RSS Hash Key if specififed by the user */
828851
if (key) {
829-
switch (hfunc) {
830-
case ETH_RSS_HASH_TOP:
831-
rss_cfg->hash_algo =
832-
HCLGEVF_RSS_HASH_ALGO_TOEPLITZ;
833-
break;
834-
case ETH_RSS_HASH_XOR:
835-
rss_cfg->hash_algo =
836-
HCLGEVF_RSS_HASH_ALGO_SIMPLE;
837-
break;
838-
case ETH_RSS_HASH_NO_CHANGE:
839-
break;
840-
default:
841-
return -EINVAL;
842-
}
843-
844-
ret = hclgevf_set_rss_algo_key(hdev, rss_cfg->hash_algo,
845-
key);
846-
if (ret)
852+
ret = hclgevf_set_rss_algo_key(hdev, hash_algo, key);
853+
if (ret) {
854+
dev_err(&hdev->pdev->dev,
855+
"invalid hfunc type %u\n", hfunc);
847856
return ret;
857+
}
848858

849859
/* Update the shadow RSS key with user specified qids */
850860
memcpy(rss_cfg->rss_hash_key, key,
851861
HCLGEVF_RSS_KEY_SIZE);
862+
} else {
863+
ret = hclgevf_set_rss_algo_key(hdev, hash_algo,
864+
rss_cfg->rss_hash_key);
865+
if (ret)
866+
return ret;
852867
}
868+
rss_cfg->hash_algo = hash_algo;
853869
}
854870

855871
/* update the shadow RSS table with user specified qids */

0 commit comments

Comments
 (0)