Commit 720bd583 authored by Huazhong Tan's avatar Huazhong Tan Committed by David S. Miller

net: hns3: add set_default_reset_request in the hnae3_ae_ops

Currently, when reset_event is called because of tx timeout, it will
upgrade the reset level (For PF, HNAE3_FUNC_RESET -> HNAE3_CORE_RESET
-> HNAE3_GLOBAL_RESET) if the time between the new reset and last reset
is within 20 secs, or restore the reset level to HNAE3_FUNC_RESET if
the time between the new reset and last reset is over 20 secs.

There is requirement that the caller needs to decide the reset level
when triggering a reset, for example, RAS recovery. So this patch
adds the set_default_reset_request to meet this requirement.
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 814da63c
...@@ -403,6 +403,8 @@ struct hnae3_ae_ops { ...@@ -403,6 +403,8 @@ struct hnae3_ae_ops {
u16 vlan, u8 qos, __be16 proto); u16 vlan, u8 qos, __be16 proto);
int (*enable_hw_strip_rxvtag)(struct hnae3_handle *handle, bool enable); int (*enable_hw_strip_rxvtag)(struct hnae3_handle *handle, bool enable);
void (*reset_event)(struct pci_dev *pdev, struct hnae3_handle *handle); void (*reset_event)(struct pci_dev *pdev, struct hnae3_handle *handle);
void (*set_default_reset_request)(struct hnae3_ae_dev *ae_dev,
enum hnae3_reset_type rst_type);
void (*get_channels)(struct hnae3_handle *handle, void (*get_channels)(struct hnae3_handle *handle,
struct ethtool_channels *ch); struct ethtool_channels *ch);
void (*get_tqps_and_rss_info)(struct hnae3_handle *h, void (*get_tqps_and_rss_info)(struct hnae3_handle *h,
......
...@@ -2517,6 +2517,10 @@ static void hclge_reset_event(struct pci_dev *pdev, struct hnae3_handle *handle) ...@@ -2517,6 +2517,10 @@ static void hclge_reset_event(struct pci_dev *pdev, struct hnae3_handle *handle)
if (time_before(jiffies, (handle->last_reset_time + 3 * HZ))) if (time_before(jiffies, (handle->last_reset_time + 3 * HZ)))
return; return;
else if (hdev->default_reset_request)
handle->reset_level =
hclge_get_reset_level(hdev,
&hdev->default_reset_request);
else if (time_after(jiffies, (handle->last_reset_time + 4 * 5 * HZ))) else if (time_after(jiffies, (handle->last_reset_time + 4 * 5 * HZ)))
handle->reset_level = HNAE3_FUNC_RESET; handle->reset_level = HNAE3_FUNC_RESET;
...@@ -2531,6 +2535,14 @@ static void hclge_reset_event(struct pci_dev *pdev, struct hnae3_handle *handle) ...@@ -2531,6 +2535,14 @@ static void hclge_reset_event(struct pci_dev *pdev, struct hnae3_handle *handle)
handle->reset_level++; handle->reset_level++;
} }
static void hclge_set_def_reset_request(struct hnae3_ae_dev *ae_dev,
enum hnae3_reset_type rst_type)
{
struct hclge_dev *hdev = ae_dev->priv;
set_bit(rst_type, &hdev->default_reset_request);
}
static void hclge_reset_subtask(struct hclge_dev *hdev) static void hclge_reset_subtask(struct hclge_dev *hdev)
{ {
/* check if there is any ongoing reset in the hardware. This status can /* check if there is any ongoing reset in the hardware. This status can
...@@ -7321,6 +7333,7 @@ static const struct hnae3_ae_ops hclge_ops = { ...@@ -7321,6 +7333,7 @@ static const struct hnae3_ae_ops hclge_ops = {
.set_vf_vlan_filter = hclge_set_vf_vlan_filter, .set_vf_vlan_filter = hclge_set_vf_vlan_filter,
.enable_hw_strip_rxvtag = hclge_en_hw_strip_rxvtag, .enable_hw_strip_rxvtag = hclge_en_hw_strip_rxvtag,
.reset_event = hclge_reset_event, .reset_event = hclge_reset_event,
.set_default_reset_request = hclge_set_def_reset_request,
.get_tqps_and_rss_info = hclge_get_tqps_and_rss_info, .get_tqps_and_rss_info = hclge_get_tqps_and_rss_info,
.set_channels = hclge_set_channels, .set_channels = hclge_set_channels,
.get_channels = hclge_get_channels, .get_channels = hclge_get_channels,
......
...@@ -595,6 +595,7 @@ struct hclge_dev { ...@@ -595,6 +595,7 @@ struct hclge_dev {
unsigned long state; unsigned long state;
enum hnae3_reset_type reset_type; enum hnae3_reset_type reset_type;
unsigned long default_reset_request;
unsigned long reset_request; /* reset has been requested */ unsigned long reset_request; /* reset has been requested */
unsigned long reset_pending; /* client rst is pending to be served */ unsigned long reset_pending; /* client rst is pending to be served */
u32 fw_version; u32 fw_version;
......
...@@ -1219,6 +1219,19 @@ static int hclgevf_do_reset(struct hclgevf_dev *hdev) ...@@ -1219,6 +1219,19 @@ static int hclgevf_do_reset(struct hclgevf_dev *hdev)
return status; return status;
} }
static enum hnae3_reset_type hclgevf_get_reset_level(struct hclgevf_dev *hdev,
unsigned long *addr)
{
enum hnae3_reset_type rst_level = HNAE3_NONE_RESET;
if (test_bit(HNAE3_VF_RESET, addr)) {
rst_level = HNAE3_VF_RESET;
clear_bit(HNAE3_VF_RESET, addr);
}
return rst_level;
}
static void hclgevf_reset_event(struct pci_dev *pdev, static void hclgevf_reset_event(struct pci_dev *pdev,
struct hnae3_handle *handle) struct hnae3_handle *handle)
{ {
...@@ -1226,6 +1239,11 @@ static void hclgevf_reset_event(struct pci_dev *pdev, ...@@ -1226,6 +1239,11 @@ static void hclgevf_reset_event(struct pci_dev *pdev,
dev_info(&hdev->pdev->dev, "received reset request from VF enet\n"); dev_info(&hdev->pdev->dev, "received reset request from VF enet\n");
if (!hdev->default_reset_request)
handle->reset_level =
hclgevf_get_reset_level(hdev,
&hdev->default_reset_request);
else
handle->reset_level = HNAE3_VF_RESET; handle->reset_level = HNAE3_VF_RESET;
/* reset of this VF requested */ /* reset of this VF requested */
...@@ -1235,6 +1253,14 @@ static void hclgevf_reset_event(struct pci_dev *pdev, ...@@ -1235,6 +1253,14 @@ static void hclgevf_reset_event(struct pci_dev *pdev,
handle->last_reset_time = jiffies; handle->last_reset_time = jiffies;
} }
static void hclgevf_set_def_reset_request(struct hnae3_ae_dev *ae_dev,
enum hnae3_reset_type rst_type)
{
struct hclgevf_dev *hdev = ae_dev->priv;
set_bit(rst_type, &hdev->default_reset_request);
}
static u32 hclgevf_get_fw_version(struct hnae3_handle *handle) static u32 hclgevf_get_fw_version(struct hnae3_handle *handle)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
...@@ -2193,6 +2219,7 @@ static const struct hnae3_ae_ops hclgevf_ops = { ...@@ -2193,6 +2219,7 @@ static const struct hnae3_ae_ops hclgevf_ops = {
.set_vlan_filter = hclgevf_set_vlan_filter, .set_vlan_filter = hclgevf_set_vlan_filter,
.enable_hw_strip_rxvtag = hclgevf_en_hw_strip_rxvtag, .enable_hw_strip_rxvtag = hclgevf_en_hw_strip_rxvtag,
.reset_event = hclgevf_reset_event, .reset_event = hclgevf_reset_event,
.set_default_reset_request = hclgevf_set_def_reset_request,
.get_channels = hclgevf_get_channels, .get_channels = hclgevf_get_channels,
.get_tqps_and_rss_info = hclgevf_get_tqps_and_rss_info, .get_tqps_and_rss_info = hclgevf_get_tqps_and_rss_info,
.get_status = hclgevf_get_status, .get_status = hclgevf_get_status,
......
...@@ -145,6 +145,7 @@ struct hclgevf_dev { ...@@ -145,6 +145,7 @@ struct hclgevf_dev {
struct hclgevf_misc_vector misc_vector; struct hclgevf_misc_vector misc_vector;
struct hclgevf_rss_cfg rss_cfg; struct hclgevf_rss_cfg rss_cfg;
unsigned long state; unsigned long state;
unsigned long default_reset_request;
#define HCLGEVF_RESET_REQUESTED 0 #define HCLGEVF_RESET_REQUESTED 0
#define HCLGEVF_RESET_PENDING 1 #define HCLGEVF_RESET_PENDING 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment