From: shaojijie shaojijie@huawei.com
driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I94FVZ CVE: NA
----------------------------------------------------------------------
The patch provides a customized interface to modify the pause trans time and retains the configured parameters.
Signed-off-by: shaojijie shaojijie@huawei.com Signed-off-by: Jiantao Xiao xiaojiantao1@h-partners.com --- .../net/ethernet/hisilicon/hns3/hnae3_ext.h | 1 + .../net/ethernet/hisilicon/hns3/hns3_ext.c | 7 ++++ .../net/ethernet/hisilicon/hns3/hns3_ext.h | 1 + .../hisilicon/hns3/hns3pf/hclge_ext.c | 38 +++++++++++++++++++ .../hisilicon/hns3/hns3pf/hclge_main.h | 1 + .../ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 7 ++-- .../ethernet/hisilicon/hns3/hns3pf/hclge_tm.h | 2 + 7 files changed, 54 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3_ext.h b/drivers/net/ethernet/hisilicon/hns3/hnae3_ext.h index 208b1f67eb70..e1a176d78273 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3_ext.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3_ext.h @@ -44,6 +44,7 @@ enum hnae3_ext_opcode { HNAE3_EXT_OPC_DISABLE_LANE, HNAE3_EXT_OPC_GET_LANE_STATUS, HNAE3_EXT_OPC_DISABLE_CLOCK, + HNAE3_EXT_OPC_SET_PFC_TIME, };
struct hnae3_pfc_storm_para { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c index b4111cbeee70..b0016da1a428 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c @@ -439,3 +439,10 @@ int nic_disable_clock(struct net_device *ndev) NULL, 0); } EXPORT_SYMBOL(nic_disable_clock); + +int nic_set_pfc_time_cfg(struct net_device *ndev, u16 time) +{ + return nic_invoke_pri_ops(ndev, HNAE3_EXT_OPC_SET_PFC_TIME, + &time, sizeof(time)); +} +EXPORT_SYMBOL(nic_set_pfc_time_cfg); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.h b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.h index 6451b862ae39..b0a1e3f7dfec 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.h @@ -42,4 +42,5 @@ int nic_set_sfp_state(struct net_device *ndev, bool en); int nic_disable_net_lane(struct net_device *ndev); int nic_get_net_lane_status(struct net_device *ndev, u32 *status); int nic_disable_clock(struct net_device *ndev); +int nic_set_pfc_time_cfg(struct net_device *ndev, u16 time); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ext.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ext.c index 1f2c351c5cbd..ceaaa257b2b3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ext.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_ext.c @@ -6,6 +6,7 @@ #include "hnae3_ext.h" #include "hclge_cmd.h" #include "hclge_ext.h" +#include "hclge_tm.h"
static nic_event_fn_t nic_event_call;
@@ -550,6 +551,42 @@ static int hclge_disable_nic_clock(struct hclge_dev *hdev, void *data, return ret; }
+static int hclge_set_pause_trans_time(struct hclge_dev *hdev, void *data, + size_t length) +{ + struct hclge_cfg_pause_param_cmd *pause_param; + struct hclge_desc desc; + u16 pause_trans_time; + int ret; + + if (length != sizeof(u16)) + return -EINVAL; + + pause_param = (struct hclge_cfg_pause_param_cmd *)desc.data; + ret = hclge_get_info_from_cmd(hdev, &desc, 1, HCLGE_OPC_CFG_MAC_PARA); + if (ret) { + dev_err(&hdev->pdev->dev, + "failed to get pause cfg info, ret = %d\n", ret); + return ret; + } + + pause_trans_time = *(u16 *)data; + if (pause_trans_time == le16_to_cpu(pause_param->pause_trans_time)) + return 0; + + ret = hclge_pause_param_cfg(hdev, pause_param->mac_addr, + pause_param->pause_trans_gap, + pause_trans_time); + if (ret) { + dev_err(&hdev->pdev->dev, + "failed to set pause trans time, ret = %d\n", ret); + return ret; + } + + hdev->tm_info.pause_time = pause_trans_time; + return 0; +} + static void hclge_ext_resotre_config(struct hclge_dev *hdev) { if (hdev->reset_type != HNAE3_IMP_RESET && @@ -717,6 +754,7 @@ static const hclge_priv_ops_fn hclge_ext_func_arr[] = { [HNAE3_EXT_OPC_DISABLE_LANE] = hclge_disable_net_lane, [HNAE3_EXT_OPC_GET_LANE_STATUS] = hclge_get_net_lane_status, [HNAE3_EXT_OPC_DISABLE_CLOCK] = hclge_disable_nic_clock, + [HNAE3_EXT_OPC_SET_PFC_TIME] = hclge_set_pause_trans_time, };
int hclge_ext_ops_handle(struct hnae3_handle *handle, int opcode, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 6c2962cf5f5c..993a9d682e06 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -378,6 +378,7 @@ struct hclge_tm_info { enum hclge_fc_mode fc_mode; u8 hw_pfc_map; /* Allow for packet drop or not on this TC */ u8 pfc_en; /* PFC enabled or not for user priority */ + u16 pause_time; };
/* max number of mac statistics on each version */ diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c index c58c31221762..a68dcace90aa 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c @@ -185,8 +185,8 @@ int hclge_pfc_pause_en_cfg(struct hclge_dev *hdev, u8 tx_rx_bitmap, return hclge_cmd_send(&hdev->hw, &desc, 1); }
-static int hclge_pause_param_cfg(struct hclge_dev *hdev, const u8 *addr, - u8 pause_trans_gap, u16 pause_trans_time) +int hclge_pause_param_cfg(struct hclge_dev *hdev, const u8 *addr, + u8 pause_trans_gap, u16 pause_trans_time) { struct hclge_cfg_pause_param_cmd *pause_param; struct hclge_desc desc; @@ -1498,7 +1498,7 @@ static int hclge_pause_param_setup_hw(struct hclge_dev *hdev)
return hclge_pause_param_cfg(hdev, mac->mac_addr, HCLGE_DEFAULT_PAUSE_TRANS_GAP, - HCLGE_DEFAULT_PAUSE_TRANS_TIME); + hdev->tm_info.pause_time); }
static int hclge_pfc_setup_hw(struct hclge_dev *hdev) @@ -1692,6 +1692,7 @@ int hclge_tm_schd_init(struct hclge_dev *hdev) /* fc_mode is HCLGE_FC_FULL on reset */ hdev->tm_info.fc_mode = HCLGE_FC_FULL; hdev->fc_mode_last_time = hdev->tm_info.fc_mode; + hdev->tm_info.pause_time = HCLGE_DEFAULT_PAUSE_TRANS_TIME;
if (hdev->tx_sch_mode != HCLGE_FLAG_TC_BASE_SCH_MODE && hdev->tm_info.num_pg != 1) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h index 53eec6df5194..bfbd35d3bec3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h @@ -244,6 +244,8 @@ int hclge_tm_init_hw(struct hclge_dev *hdev, bool init); int hclge_pfc_pause_en_cfg(struct hclge_dev *hdev, u8 tx_rx_bitmap, u8 pfc_bitmap); int hclge_mac_pause_en_cfg(struct hclge_dev *hdev, bool tx, bool rx); +int hclge_pause_param_cfg(struct hclge_dev *hdev, const u8 *addr, + u8 pause_trans_gap, u16 pause_trans_time); int hclge_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr); int hclge_mac_pause_setup_hw(struct hclge_dev *hdev); void hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats);