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 <tanhuazhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e291eff3bc
commit
5fd0e7b4f7
@ -873,25 +873,13 @@ static u8 hclgevf_get_rss_hash_bits(struct ethtool_rxnfc *nfc)
|
|||||||
return hash_sets;
|
return hash_sets;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hclgevf_set_rss_tuple(struct hnae3_handle *handle,
|
static int hclgevf_init_rss_tuple_cmd(struct hnae3_handle *handle,
|
||||||
struct ethtool_rxnfc *nfc)
|
struct ethtool_rxnfc *nfc,
|
||||||
|
struct hclgevf_rss_input_tuple_cmd *req)
|
||||||
{
|
{
|
||||||
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
|
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
|
||||||
struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg;
|
struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg;
|
||||||
struct hclgevf_rss_input_tuple_cmd *req;
|
|
||||||
struct hclgevf_desc desc;
|
|
||||||
u8 tuple_sets;
|
u8 tuple_sets;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (hdev->ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2)
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
|
|
||||||
if (nfc->data &
|
|
||||||
~(RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
req = (struct hclgevf_rss_input_tuple_cmd *)desc.data;
|
|
||||||
hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_RSS_INPUT_TUPLE, false);
|
|
||||||
|
|
||||||
req->ipv4_tcp_en = rss_cfg->rss_tuple_sets.ipv4_tcp_en;
|
req->ipv4_tcp_en = rss_cfg->rss_tuple_sets.ipv4_tcp_en;
|
||||||
req->ipv4_udp_en = rss_cfg->rss_tuple_sets.ipv4_udp_en;
|
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,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int hclgevf_set_rss_tuple(struct hnae3_handle *handle,
|
||||||
|
struct ethtool_rxnfc *nfc)
|
||||||
|
{
|
||||||
|
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
|
||||||
|
struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg;
|
||||||
|
struct hclgevf_rss_input_tuple_cmd *req;
|
||||||
|
struct hclgevf_desc desc;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (hdev->ae_dev->dev_version < HNAE3_DEVICE_VERSION_V2)
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
|
if (nfc->data &
|
||||||
|
~(RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
req = (struct hclgevf_rss_input_tuple_cmd *)desc.data;
|
||||||
|
hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_RSS_INPUT_TUPLE, false);
|
||||||
|
|
||||||
|
ret = hclgevf_init_rss_tuple_cmd(handle, nfc, req);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(&hdev->pdev->dev,
|
||||||
|
"failed to init rss tuple cmd, ret = %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ret = hclgevf_cmd_send(&hdev->hw, &desc, 1);
|
ret = hclgevf_cmd_send(&hdev->hw, &desc, 1);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&hdev->pdev->dev,
|
dev_err(&hdev->pdev->dev,
|
||||||
|
Loading…
Reference in New Issue
Block a user