net: hns3: add support to query/set TX pfc_prevention_tout for ethtool with RX prevention disabled
Subsystems (4)
Jijie Shao
maintainerPATCH RESEND 1/1 net: hns3: add support to query/set TX pfc_prevention_tout for ethtool with RX prevention disabled
From: Hao Chen <[email protected]>
Add ethtool support to query and configure the PFC (Priority Flow Control) storm prevention timeout. When TX continuously sends PFC frames, the peer end is suppressed from sending packets. If this persists, a PFC frame storm may occur.
This feature allows configuring a timeout to prevent such storms.
--- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 14 ++ .../hns3/hns3_common/hclge_comm_cmd.h | 3 + .../ethernet/hisilicon/hns3/hns3_ethtool.c | 12 ++ .../hisilicon/hns3/hns3pf/hclge_cmd.h | 9 + .../hisilicon/hns3/hns3pf/hclge_main.c | 172 ++++++++++++++++++ .../hisilicon/hns3/hns3pf/hclge_main.h | 7 + 6 files changed, 217 insertions(+)
drivers/net/ethernet/hisilicon/hns3/hnae3.h +14 -0
@@ -602,6 +602,10 @@ typedef int (*read_func)(struct seq_file *s, void *data);* Config wake on lan * dbg_get_read_func * Return the read func for debugfs seq file +* set_pfc_prevention_tout +* Set PFC storm prevention timeout +* get_pfc_prevention_tout +* Get PFC storm prevention timeout */ struct hnae3_ae_ops {int (*init_ae_dev)(struct hnae3_ae_dev *ae_dev);
@@ -810,6 +814,8 @@ struct hnae3_ae_ops {int (*hwtstamp_set)(struct hnae3_handle *handle,struct kernel_hwtstamp_config *config,struct netlink_ext_ack *extack); +int (*set_pfc_prevention_tout)(struct hnae3_handle *handle,u16 times); +int (*get_pfc_prevention_tout)(struct hnae3_handle *handle,u16 *times); };struct hnae3_dcb_ops {
@@ -891,6 +897,14 @@ struct hnae3_roce_private_info {unsigned long state; }; +struct hnae3_pfc_storm_para { +u32 dir; +u32 enable; +u32 period_ms; +u32 times; +u32 recovery_period_ms; +}; +#define HNAE3_SUPPORT_APP_LOOPBACK BIT(0)#define HNAE3_SUPPORT_PHY_LOOPBACK BIT(1)#define HNAE3_SUPPORT_SERDES_SERIAL_LOOPBACK BIT(2)
drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_cmd.h +3 -0
@@ -314,6 +314,9 @@ enum hclge_opcode_type {/* Query link diagnosis info command */ HCLGE_OPC_QUERY_LINK_DIAGNOSIS =0x702A , + +/* Config pause storm param command */ + HCLGE_OPC_CFG_PAUSE_STORM_PARA = 0x7019, }; enum hclge_comm_cmd_return_status {
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +12 -0
@@ -1895,6 +1895,12 @@ static int hns3_get_tunable(struct net_device *netdev,case ETHTOOL_TX_COPYBREAK_BUF_SIZE : *(u32 *)data = h->kinfo.tx_spare_buf_size;break ; +case ETHTOOL_PFC_PREVENTION_TOUT : +if (!h->ae_algo->ops->get_pfc_prevention_tout) +return -EOPNOTSUPP ; + + ret = h->ae_algo->ops->get_pfc_prevention_tout (h, (u16 *)data); +break ;default : ret = -EOPNOTSUPP ;break ;
@@ -2020,6 +2026,12 @@ static int hns3_set_tunable(struct net_device *netdev,netdev_info (netdev,"the active tx spare buf size is %u, due to page order\n" , priv->ring->tx_spare->len); +break ; +case ETHTOOL_PFC_PREVENTION_TOUT : +if (!h->ae_algo->ops->set_pfc_prevention_tout) +return -EOPNOTSUPP ; + + ret = h->ae_algo->ops->set_pfc_prevention_tout (h, *(u16 *)data);break ;default : ret = -EOPNOTSUPP ;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +9 -0
@@ -890,6 +890,15 @@ struct hclge_query_wol_supported_cmd { u8 rsv[20]; }; +struct hclge_pfc_storm_para_cmd { +__le32 dir; +__le32 enable; +__le32 period_ms; +__le32 times; +__le32 recovery_period_ms; +__le32 rsv; +}; +struct hclge_hw ;int hclge_cmd_send (struct hclge_hw *hw,struct hclge_desc *desc,int num);#endif
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +172 -0
214 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +7 -0
@@ -346,6 +346,11 @@ enum hclge_link_fail_code {#define HCLGE_LINK_STATUS_DOWN 0#define HCLGE_LINK_STATUS_UP 1 +#define HCLGE_DIR_RX 0 +#define HCLGE_DIR_TX 1 +#define HCLGE_MAX_PFC_PREVENTION_TOUT 2000 +#define HCLGE_DEFAULT_PFC_PREVENTION_TOUT 1000 +#define HCLGE_PG_NUM 4#define HCLGE_SCH_MODE_SP 0#define HCLGE_SCH_MODE_DWRR 1
@@ -898,6 +903,8 @@ struct hclge_dev {u16 vf_rss_size_max;/* HW defined VF max RSS task queue */ u16 pf_rss_size_max;/* HW defined PF max RSS task queue */ u32 tx_spare_buf_size;/* HW defined TX spare buffer size */ +u16 pfc_prevention_tout;/* User config, restored after reset */ +u16 pfc_prevention_tout_default;/* HW default, to avoid stale state */ u16 fdir_pf_filter_count;/* Num of guaranteed filters for this PF */ u16 num_alloc_vport;/* Num vports this driver supports */
base-commit: cef9d6804030793cf8b8796fd6936197d065dd3e
Signature · 1 line
2.33.0
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 8 lines · On Tue, 30 Jun 2026 21:40:43 +0800 you wrote:
From: Hao Chen <[email protected]>
Add ethtool support to query and configure the PFC (Priority Flow Control) storm prevention timeout. When TX continuously sends PFC frames, the peer end is suppressed from sending packets. If this persists, a PFC frame storm may occur.
[...]
Here is the summary with links:
- [RESEND,net-next] net: hns3: add support to query/set TX pfc_prevention_tout for ethtool with RX prevention disabled
https://git.kernel.org/netdev/net-next/c/d7261cdb9550
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html