Skip to content

Commit e291eff

Browse files
Huazhong Tandavem330
authored andcommitted
net: hns3: refactor out hclge_set_rss_tuple()
To make it more readable and maintainable, split hclge_set_rss_tuple() into two parts. Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent eb0faf3 commit e291eff

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

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

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4501,22 +4501,12 @@ static u8 hclge_get_rss_hash_bits(struct ethtool_rxnfc *nfc)
45014501
return hash_sets;
45024502
}
45034503

4504-
static int hclge_set_rss_tuple(struct hnae3_handle *handle,
4505-
struct ethtool_rxnfc *nfc)
4504+
static int hclge_init_rss_tuple_cmd(struct hclge_vport *vport,
4505+
struct ethtool_rxnfc *nfc,
4506+
struct hclge_rss_input_tuple_cmd *req)
45064507
{
4507-
struct hclge_vport *vport = hclge_get_vport(handle);
45084508
struct hclge_dev *hdev = vport->back;
4509-
struct hclge_rss_input_tuple_cmd *req;
4510-
struct hclge_desc desc;
45114509
u8 tuple_sets;
4512-
int ret;
4513-
4514-
if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST |
4515-
RXH_L4_B_0_1 | RXH_L4_B_2_3))
4516-
return -EINVAL;
4517-
4518-
req = (struct hclge_rss_input_tuple_cmd *)desc.data;
4519-
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_RSS_INPUT_TUPLE, false);
45204510

45214511
req->ipv4_tcp_en = vport->rss_tuple_sets.ipv4_tcp_en;
45224512
req->ipv4_udp_en = vport->rss_tuple_sets.ipv4_udp_en;
@@ -4561,6 +4551,32 @@ static int hclge_set_rss_tuple(struct hnae3_handle *handle,
45614551
return -EINVAL;
45624552
}
45634553

4554+
return 0;
4555+
}
4556+
4557+
static int hclge_set_rss_tuple(struct hnae3_handle *handle,
4558+
struct ethtool_rxnfc *nfc)
4559+
{
4560+
struct hclge_vport *vport = hclge_get_vport(handle);
4561+
struct hclge_dev *hdev = vport->back;
4562+
struct hclge_rss_input_tuple_cmd *req;
4563+
struct hclge_desc desc;
4564+
int ret;
4565+
4566+
if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST |
4567+
RXH_L4_B_0_1 | RXH_L4_B_2_3))
4568+
return -EINVAL;
4569+
4570+
req = (struct hclge_rss_input_tuple_cmd *)desc.data;
4571+
hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_RSS_INPUT_TUPLE, false);
4572+
4573+
ret = hclge_init_rss_tuple_cmd(vport, nfc, req);
4574+
if (ret) {
4575+
dev_err(&hdev->pdev->dev,
4576+
"failed to init rss tuple cmd, ret = %d\n", ret);
4577+
return ret;
4578+
}
4579+
45644580
ret = hclge_cmd_send(&hdev->hw, &desc, 1);
45654581
if (ret) {
45664582
dev_err(&hdev->pdev->dev,

0 commit comments

Comments
 (0)