Skip to content

Commit 5fd0e7b

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

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

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

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -873,25 +873,13 @@ static u8 hclgevf_get_rss_hash_bits(struct ethtool_rxnfc *nfc)
873873
return hash_sets;
874874
}
875875

876-
static int hclgevf_set_rss_tuple(struct hnae3_handle *handle,
877-
struct ethtool_rxnfc *nfc)
876+
static int hclgevf_init_rss_tuple_cmd(struct hnae3_handle *handle,
877+
struct ethtool_rxnfc *nfc,
878+
struct hclgevf_rss_input_tuple_cmd *req)
878879
{
879880
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
880881
struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg;
881-
struct hclgevf_rss_input_tuple_cmd *req;
882-
struct hclgevf_desc desc;
883882
u8 tuple_sets;
884-
int ret;
885-
886-
if (hdev->ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2)
887-
return -EOPNOTSUPP;
888-
889-
if (nfc->data &
890-
~(RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3))
891-
return -EINVAL;
892-
893-
req = (struct hclgevf_rss_input_tuple_cmd *)desc.data;
894-
hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_RSS_INPUT_TUPLE, false);
895883

896884
req->ipv4_tcp_en = rss_cfg->rss_tuple_sets.ipv4_tcp_en;
897885
req->ipv4_udp_en = rss_cfg->rss_tuple_sets.ipv4_udp_en;
@@ -936,6 +924,35 @@ static int hclgevf_set_rss_tuple(struct hnae3_handle *handle,
936924
return -EINVAL;
937925
}
938926

927+
return 0;
928+
}
929+
930+
static int hclgevf_set_rss_tuple(struct hnae3_handle *handle,
931+
struct ethtool_rxnfc *nfc)
932+
{
933+
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
934+
struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg;
935+
struct hclgevf_rss_input_tuple_cmd *req;
936+
struct hclgevf_desc desc;
937+
int ret;
938+
939+
if (hdev->ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2)
940+
return -EOPNOTSUPP;
941+
942+
if (nfc->data &
943+
~(RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3))
944+
return -EINVAL;
945+
946+
req = (struct hclgevf_rss_input_tuple_cmd *)desc.data;
947+
hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_RSS_INPUT_TUPLE, false);
948+
949+
ret = hclgevf_init_rss_tuple_cmd(handle, nfc, req);
950+
if (ret) {
951+
dev_err(&hdev->pdev->dev,
952+
"failed to init rss tuple cmd, ret = %d\n", ret);
953+
return ret;
954+
}
955+
939956
ret = hclgevf_cmd_send(&hdev->hw, &desc, 1);
940957
if (ret) {
941958
dev_err(&hdev->pdev->dev,

0 commit comments

Comments
 (0)