Support some enhances features for the HIBMCGE driver
Subsystems (4)
Jijie Shao
maintainerv4 cover Support some enhances features for the HIBMCGE driver
In this patch set, we mainly implement some enhanced features. It mainly includes the statistics, diagnosis, and ioctl to improve fault locating efficiency,
abnormal irq and MAC link exception handling feature to enhance driver robustness,
and rx checksum offload feature to improve performance (tx checksum feature has been implemented).
---
ChangeLog:
v3 -> v4:
- Don't drop packets on csum validation failure, suggested by Jakub Kicinski.
- Fix "__umoddi3" undefined error, reported by Jakub Kicinski.
v3: https://lore.kernel.org/all/[email protected]/
v2 -> v3:
- Remove "in this module" from all patch titles,
suggested by Kalesh Anakkur Purayil, Simon Horman and Jakub Kicinski.
- Remove .ndo_fix_features() suggested by Jakub Kicinski.
v2: https://lore.kernel.org/all/[email protected]/
v1 -> v2:
- Remove self_test patch from this series, suggested by Andrew.
- Use phy_do_ioctl() to simplify ioctl code, suggested by Andrew.
- Replace phy_reset() with phy_stop() and phy_start(), suggested by Andrew.
- Recalculate the interval for the scheduled task to update statistics, suggested by Andrew.
- Use !! to convert integer to boolean, suggested by Simon Horman.
v1: https://lore.kernel.org/all/[email protected]/
---
Jijie Shao (6):
net: hibmcge: Add support for dump statistics
net: hibmcge: Add support for checksum offload
net: hibmcge: Add support for abnormal irq handling feature
net: hibmcge: Add support for mac link exception handling feature
net: hibmcge: Add support for BMC diagnose feature
net: hibmcge: Add support for ioctl
.../net/ethernet/hisilicon/hibmcge/Makefile | 2 +- .../ethernet/hisilicon/hibmcge/hbg_common.h | 122 ++++++ .../ethernet/hisilicon/hibmcge/hbg_debugfs.c | 7 +- .../ethernet/hisilicon/hibmcge/hbg_diagnose.c | 348 ++++++++++++++++++ .../ethernet/hisilicon/hibmcge/hbg_diagnose.h | 11 + .../net/ethernet/hisilicon/hibmcge/hbg_err.c | 58 +++ .../net/ethernet/hisilicon/hibmcge/hbg_err.h | 1 + .../ethernet/hisilicon/hibmcge/hbg_ethtool.c | 298 +++++++++++++++ .../ethernet/hisilicon/hibmcge/hbg_ethtool.h | 5 + .../net/ethernet/hisilicon/hibmcge/hbg_hw.c | 10 + .../net/ethernet/hisilicon/hibmcge/hbg_irq.c | 55 +-- .../net/ethernet/hisilicon/hibmcge/hbg_main.c | 103 ++++++ .../net/ethernet/hisilicon/hibmcge/hbg_mdio.c | 22 ++ .../net/ethernet/hisilicon/hibmcge/hbg_mdio.h | 2 + .../net/ethernet/hisilicon/hibmcge/hbg_reg.h | 105 ++++++ .../net/ethernet/hisilicon/hibmcge/hbg_txrx.c | 181 ++++++++- 16 files changed, 1304 insertions(+), 26 deletions(-) create mode 100644 drivers/net/ethernet/hisilicon/hibmcge/hbg_diagnose.c create mode 100644 drivers/net/ethernet/hisilicon/hibmcge/hbg_diagnose.h
Signature · 1 line
2.33.0
Jijie Shao
maintainerPATCH v4 1/6 net: hibmcge: Add support for dump statistics
The driver supports many hw statistics. This patch supports dump statistics through ethtool_ops and ndo.get_stats64().
The type of hw statistics register is u32, To prevent the statistics register from overflowing, the driver dump the statistics every 30 seconds. in a scheduled task.
---
ChangeLog:
v1 -> v2:
- Recalculate the interval for the scheduled task to update statistics, suggested by Andrew.
v1: https://lore.kernel.org/all/[email protected]/
--- .../ethernet/hisilicon/hibmcge/hbg_common.h | 111 +++++++ .../ethernet/hisilicon/hibmcge/hbg_ethtool.c | 297 ++++++++++++++++++ .../ethernet/hisilicon/hibmcge/hbg_ethtool.h | 5 + .../net/ethernet/hisilicon/hibmcge/hbg_main.c | 70 +++++ .../net/ethernet/hisilicon/hibmcge/hbg_reg.h | 96 ++++++ .../net/ethernet/hisilicon/hibmcge/hbg_txrx.c | 164 +++++++++- 6 files changed, 741 insertions(+), 2 deletions(-)
drivers/net/ethernet/hisilicon/hibmcge/hbg_common.h +111 -0
@@ -142,6 +142,115 @@ struct hbg_user_def {struct ethtool_pauseparam pause_param; }; +struct hbg_stats { +u64 rx_desc_drop; +u64 rx_desc_l2_err_cnt; +u64 rx_desc_pkt_len_err_cnt; +u64 rx_desc_l3l4_err_cnt; +u64 rx_desc_l3_wrong_head_cnt; +u64 rx_desc_l3_csum_err_cnt; +u64 rx_desc_l3_len_err_cnt; +u64 rx_desc_l3_zero_ttl_cnt; +u64 rx_desc_l3_other_cnt; +u64 rx_desc_l4_err_cnt; +u64 rx_desc_l4_wrong_head_cnt; +u64 rx_desc_l4_len_err_cnt; +u64 rx_desc_l4_csum_err_cnt; +u64 rx_desc_l4_zero_port_num_cnt; +u64 rx_desc_l4_other_cnt; +u64 rx_desc_frag_cnt; +u64 rx_desc_ip_ver_err_cnt; +u64 rx_desc_ipv4_pkt_cnt; +u64 rx_desc_ipv6_pkt_cnt; +u64 rx_desc_no_ip_pkt_cnt; +u64 rx_desc_ip_pkt_cnt; +u64 rx_desc_tcp_pkt_cnt; +u64 rx_desc_udp_pkt_cnt; +u64 rx_desc_vlan_pkt_cnt; +u64 rx_desc_icmp_pkt_cnt; +u64 rx_desc_arp_pkt_cnt; +u64 rx_desc_rarp_pkt_cnt; +u64 rx_desc_multicast_pkt_cnt; +u64 rx_desc_broadcast_pkt_cnt; +u64 rx_desc_ipsec_pkt_cnt; +u64 rx_desc_ip_opt_pkt_cnt; +u64 rx_desc_key_not_match_cnt; + +u64 rx_octets_total_ok_cnt; +u64 rx_uc_pkt_cnt; +u64 rx_mc_pkt_cnt; +u64 rx_bc_pkt_cnt; +u64 rx_vlan_pkt_cnt; +u64 rx_octets_bad_cnt; +u64 rx_octets_total_filt_cnt; +u64 rx_filt_pkt_cnt; +u64 rx_trans_pkt_cnt; +u64 rx_framesize_64; +u64 rx_framesize_65_127; +u64 rx_framesize_128_255; +u64 rx_framesize_256_511; +u64 rx_framesize_512_1023; +u64 rx_framesize_1024_1518; +u64 rx_framesize_bt_1518; +u64 rx_fcs_error_cnt; +u64 rx_data_error_cnt; +u64 rx_align_error_cnt; +u64 rx_pause_macctl_frame_cnt; +u64 rx_unknown_macctl_frame_cnt; +/* crc ok, > max_frm_size, < 2max_frm_size */ +u64 rx_frame_long_err_cnt; +/* crc fail, > max_frm_size, < 2max_frm_size */ +u64 rx_jabber_err_cnt; +/* > 2max_frm_size */ +u64 rx_frame_very_long_err_cnt; +/* < 64byte, >= short_runts_thr */ +u64 rx_frame_runt_err_cnt; +/* < short_runts_thr */ +u64 rx_frame_short_err_cnt; +/* PCU: dropped when the RX FIFO is full.*/ +u64 rx_overflow_cnt; +/* GMAC: the count of overflows of the RX FIFO */ +u64 rx_overrun_cnt; +/* PCU: the count of buffer alloc errors in RX */ +u64 rx_bufrq_err_cnt; +/* PCU: the count of write descriptor errors in RX */ +u64 rx_we_err_cnt; +/* GMAC: the count of pkts that contain PAD but length is not 64 */ +u64 rx_lengthfield_err_cnt; +u64 rx_fail_comma_cnt; + +u64 rx_dma_err_cnt; + +u64 tx_octets_total_ok_cnt; +u64 tx_uc_pkt_cnt; +u64 tx_mc_pkt_cnt; +u64 tx_bc_pkt_cnt; +u64 tx_vlan_pkt_cnt; +u64 tx_octets_bad_cnt; +u64 tx_trans_pkt_cnt; +u64 tx_pause_frame_cnt; +u64 tx_framesize_64; +u64 tx_framesize_65_127; +u64 tx_framesize_128_255; +u64 tx_framesize_256_511; +u64 tx_framesize_512_1023; +u64 tx_framesize_1024_1518; +u64 tx_framesize_bt_1518; +/* GMAC: the count of times that frames fail to be transmitted +* due to internal errors. +*/ +u64 tx_underrun_err_cnt; +u64 tx_add_cs_fail_cnt; +/* PCU: the count of buffer free errors in TX */ +u64 tx_bufrl_err_cnt; +u64 tx_crc_err_cnt; +u64 tx_drop_cnt; +u64 tx_excessive_length_drop_cnt; + +u64 tx_timeout_cnt; +u64 tx_dma_err_cnt; +}; +struct hbg_priv {struct net_device *netdev;struct pci_dev *pdev;
@@ -155,6 +264,8 @@ struct hbg_priv {struct hbg_mac_filter filter;enum hbg_reset_type reset_type;struct hbg_user_def user_def; +struct hbg_stats stats; + struct delayed_work service_task; };#endif
drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.c +297 -0
315 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.h +5 -0
@@ -6,6 +6,11 @@#include <linux/netdevice.h> +#define HBG_STATS_FIELD_OFF (f) (offsetof(struct hbg_stats, f)) +#define HBG_STATS_R (p, offset) (*(u64 *)((u8 *)(p) + (offset))) +#define HBG_STATS_U (p, offset, val) (HBG_STATS_R(p, offset) += (val)) +void hbg_ethtool_set_ops (struct net_device *netdev); +void hbg_update_stats (struct hbg_priv *priv);#endif
drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c +70 -0
96 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hibmcge/hbg_reg.h +96 -0
131 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c +162 -2
184 lines not on this page · raw message
Signature · 1 line
2.33.0
Jijie Shao
maintainerPATCH v4 2/6 net: hibmcge: Add support for checksum offload
In reply to Jijie ShaoThis patch implements the rx checksum offload feature.
The tx checksum offload processing in .ndo_start_xmit() has been accepted. This patch also adds the tx checksum feature, including NETIF_F_IP_CSUM and NETIF_F_IPV6_CSUM
---
ChangeLog:
v3 -> v4:
- Don't drop packets on csum validation failure, suggested by Jakub Kicinski.
v3: https://lore.kernel.org/all/[email protected]/
v2 -> v3:
- Remove .ndo_fix_features() suggested by Jakub Kicinski.
v2: https://lore.kernel.org/all/[email protected]/
v1 -> v2:
- Use !! to convert integer to boolean, suggested by Simon Horman.
v1: https://lore.kernel.org/all/[email protected]/
--- .../net/ethernet/hisilicon/hibmcge/hbg_main.c | 6 ++++ .../net/ethernet/hisilicon/hibmcge/hbg_txrx.c | 29 +++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-)
drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c +6 -0
@@ -14,6 +14,9 @@#include "hbg_txrx.h" #include "hbg_debugfs.h" +#define HBG_SUPPORT_FEATURES (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \ + NETIF_F_RXCSUM) +static void hbg_all_irq_enable (struct hbg_priv *priv,bool enabled) {struct hbg_irq_info *info;
@@ -419,6 +422,9 @@ static int hbg_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (ret)return ret; +/* set default features */ + netdev->features |=HBG_SUPPORT_FEATURES ; + netdev->hw_features |=HBG_SUPPORT_FEATURES ; netdev->priv_flags |=IFF_UNICAST_FLT ; netdev->pcpu_stat_type =NETDEV_PCPU_STAT_TSTATS ;
drivers/net/ethernet/hisilicon/hibmcge/hbg_txrx.c +23 -6
@@ -202,8 +202,14 @@ static int hbg_napi_tx_recycle(struct napi_struct *napi, int budget) }static bool hbg_rx_check_l3l4_error (struct hbg_priv *priv, -struct hbg_rx_desc *desc) +struct hbg_rx_desc *desc, +struct sk_buff *skb) { +bool rx_checksum_offload = !!(priv->netdev->features &NETIF_F_RXCSUM ); + + skb->ip_summed = rx_checksum_offload ? +CHECKSUM_UNNECESSARY :CHECKSUM_NONE ; +if (likely (!FIELD_GET (HBG_RX_DESC_W4_L3_ERR_CODE_M , desc->word4) && !FIELD_GET (HBG_RX_DESC_W4_L4_ERR_CODE_M , desc->word4)))return true;
@@ -215,8 +221,13 @@ static bool hbg_rx_check_l3l4_error(struct hbg_priv *priv, priv->stats.rx_desc_l3_wrong_head_cnt++;return false;case HBG_L3_CSUM_ERR : + skb->ip_summed =CHECKSUM_NONE ; priv->stats.rx_desc_l3_csum_err_cnt++; -return false; + +/* Don't drop packets on csum validation failure, +* suggest by Jakub +*/ +break ;case HBG_L3_LEN_ERR : priv->stats.rx_desc_l3_len_err_cnt++;return false;
@@ -238,8 +249,13 @@ static bool hbg_rx_check_l3l4_error(struct hbg_priv *priv, priv->stats.rx_desc_l4_len_err_cnt++;return false;case HBG_L4_CSUM_ERR : + skb->ip_summed =CHECKSUM_NONE ; priv->stats.rx_desc_l4_csum_err_cnt++; -return false; + +/* Don't drop packets on csum validation failure, +* suggest by Jakub +*/ +break ;case HBG_L4_ZERO_PORT_NUM : priv->stats.rx_desc_l4_zero_port_num_cnt++;return false;
@@ -322,7 +338,8 @@ static void hbg_update_rx_protocol_stats(struct hbg_priv *priv,hbg_update_rx_ip_protocol_stats (priv, desc); } -static bool hbg_rx_pkt_check (struct hbg_priv *priv,struct hbg_rx_desc *desc) +static bool hbg_rx_pkt_check (struct hbg_priv *priv,struct hbg_rx_desc *desc, +struct sk_buff *skb) {if (unlikely (FIELD_GET (HBG_RX_DESC_W2_PKT_LEN_M , desc->word2) > priv->dev_specs.max_frame_len)) {
@@ -342,7 +359,7 @@ static bool hbg_rx_pkt_check(struct hbg_priv *priv, struct hbg_rx_desc *desc)return false; } -if (unlikely (!hbg_rx_check_l3l4_error (priv, desc))) { +if (unlikely (!hbg_rx_check_l3l4_error (priv, desc, skb))) { priv->stats.rx_desc_l3l4_err_cnt++;return false; }
@@ -413,7 +430,7 @@ static int hbg_napi_rx_poll(struct napi_struct *napi, int budget) rx_desc = (struct hbg_rx_desc *)buffer->skb->data; pkt_len =FIELD_GET (HBG_RX_DESC_W2_PKT_LEN_M , rx_desc->word2); -if (unlikely (!hbg_rx_pkt_check (priv, rx_desc))) { +if (unlikely (!hbg_rx_pkt_check (priv, rx_desc, buffer->skb))) {hbg_buffer_free (buffer); goto next_buffer; }
Signature · 1 line
2.33.0
Jijie Shao
maintainerPATCH v4 3/6 net: hibmcge: Add support for abnormal irq handling feature
In reply to Jijie Shaothe hardware error was reported by interrupt, and need be fixed by doing function reset, but the whole reset flow takes a long time, should not do it in irq handler,
so do it in scheduled task.
--- .../ethernet/hisilicon/hibmcge/hbg_common.h | 5 ++ .../ethernet/hisilicon/hibmcge/hbg_debugfs.c | 5 +- .../net/ethernet/hisilicon/hibmcge/hbg_err.c | 58 +++++++++++++++++++ .../net/ethernet/hisilicon/hibmcge/hbg_err.h | 1 + .../ethernet/hisilicon/hibmcge/hbg_ethtool.c | 1 + .../net/ethernet/hisilicon/hibmcge/hbg_irq.c | 55 +++++++++++------- .../net/ethernet/hisilicon/hibmcge/hbg_main.c | 9 +++ .../net/ethernet/hisilicon/hibmcge/hbg_reg.h | 1 + 8 files changed, 112 insertions(+), 23 deletions(-)
drivers/net/ethernet/hisilicon/hibmcge/hbg_common.h +5 -0
@@ -36,6 +36,7 @@ enum hbg_nic_state {HBG_NIC_STATE_EVENT_HANDLING =0 ,HBG_NIC_STATE_RESETTING ,HBG_NIC_STATE_RESET_FAIL , + HBG_NIC_STATE_NEED_RESET, /* trigger a reset in scheduled task */ }; enum hbg_reset_type {
@@ -104,6 +105,7 @@ struct hbg_irq_info {u32 mask;bool re_enable;bool need_print; +bool need_reset;u64 count;void (*irq_handle)(struct hbg_priv *priv,struct hbg_irq_info *info);
@@ -220,6 +222,7 @@ struct hbg_stats {u64 rx_fail_comma_cnt;u64 rx_dma_err_cnt; +u64 rx_fifo_less_empty_thrsld_cnt;u64 tx_octets_total_ok_cnt;u64 tx_uc_pkt_cnt;
@@ -268,4 +271,6 @@ struct hbg_priv { struct delayed_work service_task; }; +void hbg_err_reset_task_schedule (struct hbg_priv *priv); +#endif
drivers/net/ethernet/hisilicon/hibmcge/hbg_debugfs.c +4 -1
@@ -67,10 +67,11 @@ static int hbg_dbg_irq_info(struct seq_file *s, void *unused)for (i =0 ; i < priv->vectors.info_array_len; i++) { info = &priv->vectors.info_array[i];seq_printf (s, -"%-20s: enabled: %-5s, logged: %-5s, count: %llu\n" , +"%-20s: enabled: %-5s, reset: %-5s, logged: %-5s, count: %llu\n" , info->name,str_true_false (hbg_hw_irq_is_enabled (priv, info->mask)), +str_true_false (info->need_reset),str_true_false (info->need_print), info->count); }
@@ -114,6 +115,8 @@ static int hbg_dbg_nic_state(struct seq_file *s, void *unused) state_str_true_false(priv, HBG_NIC_STATE_RESET_FAIL));seq_printf (s,"last reset type: %s\n" , reset_type_str[priv->reset_type]); +seq_printf (s,"need reset state: %s\n" , +state_str_true_false (priv,HBG_NIC_STATE_NEED_RESET ));return 0 ; }
drivers/net/ethernet/hisilicon/hibmcge/hbg_err.c +58 -0
70 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hibmcge/hbg_err.h +1 -0
@@ -9,5 +9,6 @@void hbg_set_pci_err_handler (struct pci_driver *pdrv);int hbg_reset (struct hbg_priv *priv);int hbg_rebuild (struct hbg_priv *priv); +void hbg_err_reset (struct hbg_priv *priv);#endif
drivers/net/ethernet/hisilicon/hibmcge/hbg_ethtool.c +1 -0
@@ -69,6 +69,7 @@ static const struct hbg_ethtool_stats hbg_ethtool_stats_info[] = { HBG_REG_RX_LENGTHFIELD_ERR_CNT_ADDR),HBG_STATS_REG_I (rx_fail_comma_cnt,HBG_REG_RX_FAIL_COMMA_CNT_ADDR ),HBG_STATS_I (rx_dma_err_cnt), +HBG_STATS_I (rx_fifo_less_empty_thrsld_cnt),HBG_STATS_REG_I (tx_uc_pkt_cnt,HBG_REG_TX_UC_PKTS_ADDR ), HBG_STATS_REG_I(tx_vlan_pkt_cnt, HBG_REG_TX_TAGGED_ADDR),
drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c +33 -22
69 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c +9 -0
@@ -283,6 +283,9 @@ static void hbg_service_task(struct work_struct *work) struct hbg_priv *priv = container_of(work, struct hbg_priv, service_task.work); +if (test_and_clear_bit (HBG_NIC_STATE_NEED_RESET , &priv->state)) +hbg_err_reset (priv); +/* The type of statistics register is u32, * To prevent the statistics register from overflowing, * the driver dumps the statistics every 30 seconds.
@@ -292,6 +295,12 @@ static void hbg_service_task(struct work_struct *work) msecs_to_jiffies(30 * MSEC_PER_SEC)); } +void hbg_err_reset_task_schedule (struct hbg_priv *priv) +{ +set_bit (HBG_NIC_STATE_NEED_RESET , &priv->state); +schedule_delayed_work (&priv->service_task,0 ); +} +static void hbg_cancel_delayed_work_sync (void *data) {cancel_delayed_work_sync (data);
drivers/net/ethernet/hisilicon/hibmcge/hbg_reg.h +1 -0
@@ -148,6 +148,7 @@#define HBG_INT_MSK_MAC_PCS_TX_FIFO_ERR_B BIT(17)#define HBG_INT_MSK_MAC_PCS_RX_FIFO_ERR_B BIT(16)#define HBG_INT_MSK_MAC_MII_FIFO_ERR_B BIT(15) +#define HBG_INT_MSK_TX_PKT_CPL_B BIT(14)#define HBG_INT_MSK_TX_B BIT(1)/* just used in driver */ #define HBG_INT_MSK_RX_B BIT(0)/* just used in driver */ #define HBG_REG_CF_INTRPT_STAT_ADDR (HBG_REG_SGMII_BASE + 0x0434)
Signature · 1 line
2.33.0
Jijie Shao
maintainerPATCH v4 4/6 net: hibmcge: Add support for mac link exception handling feature
In reply to Jijie ShaoIf the rate changed frequently, the PHY link ok, but the MAC link maybe fails.
As a result, the network port is unavailable.
According to the documents of the chip,core_reset needs to do to fix the fault.
In hw_adjus_link(), the core_reset is added to try to ensure that MAC link status is normal.
In addition, MAC link failure detection is added. If the MAC link fails after core_reset, driver invokes the phy_stop() and phy_start() to re-link.
Due to phydev->lock, re-link cannot be triggered in adjust_link(). Therefore, this operation is invoked in a scheduled task.
---
ChangeLog:
v3 -> v4:
- Fix "__umoddi3" undefined error, reported by Jakub Kicinski.
v3: https://lore.kernel.org/all/[email protected]/
v1 -> v2:
- Replace phy_reset() with phy_stop() and phy_start(), suggested by Andrew.
v1: https://lore.kernel.org/all/[email protected]/
--- .../ethernet/hisilicon/hibmcge/hbg_common.h | 5 +++++ .../ethernet/hisilicon/hibmcge/hbg_debugfs.c | 2 ++ .../net/ethernet/hisilicon/hibmcge/hbg_hw.c | 10 +++++++++ .../net/ethernet/hisilicon/hibmcge/hbg_main.c | 9 ++++++++ .../net/ethernet/hisilicon/hibmcge/hbg_mdio.c | 22 +++++++++++++++++++ .../net/ethernet/hisilicon/hibmcge/hbg_mdio.h | 2 ++ .../net/ethernet/hisilicon/hibmcge/hbg_reg.h | 1 + 7 files changed, 51 insertions(+)
drivers/net/ethernet/hisilicon/hibmcge/hbg_common.h +5 -0
@@ -37,6 +37,7 @@ enum hbg_nic_state {HBG_NIC_STATE_RESETTING ,HBG_NIC_STATE_RESET_FAIL ,HBG_NIC_STATE_NEED_RESET ,/* trigger a reset in scheduled task */ + HBG_NIC_STATE_NP_LINK_FAIL, }; enum hbg_reset_type {
@@ -82,6 +83,7 @@ enum hbg_hw_event_type {HBG_HW_EVENT_NONE =0 ,HBG_HW_EVENT_INIT ,/* driver is loading */ HBG_HW_EVENT_RESET , + HBG_HW_EVENT_CORE_RESET, }; struct hbg_dev_specs {
@@ -252,6 +254,8 @@ struct hbg_stats {u64 tx_timeout_cnt;u64 tx_dma_err_cnt; + +u64 np_link_fail_cnt; };struct hbg_priv {
@@ -272,5 +276,6 @@ struct hbg_priv { };void hbg_err_reset_task_schedule (struct hbg_priv *priv); +void hbg_np_link_fail_task_schedule (struct hbg_priv *priv);#endif
drivers/net/ethernet/hisilicon/hibmcge/hbg_debugfs.c +2 -0
@@ -117,6 +117,8 @@ static int hbg_dbg_nic_state(struct seq_file *s, void *unused) reset_type_str[priv->reset_type]);seq_printf (s,"need reset state: %s\n" ,state_str_true_false (priv,HBG_NIC_STATE_NEED_RESET )); +seq_printf (s,"np_link fail state: %s\n" , +state_str_true_false (priv,HBG_NIC_STATE_NP_LINK_FAIL ));return 0 ; }
drivers/net/ethernet/hisilicon/hibmcge/hbg_hw.c +10 -0
@@ -213,10 +213,20 @@ void hbg_hw_fill_buffer(struct hbg_priv *priv, u32 buffer_dma_addr)void hbg_hw_adjust_link (struct hbg_priv *priv,u32 speed,u32 duplex) { +hbg_hw_mac_enable (priv,HBG_STATUS_DISABLE ); +hbg_reg_write_field (priv,HBG_REG_PORT_MODE_ADDR ,HBG_REG_PORT_MODE_M , speed);hbg_reg_write_field (priv,HBG_REG_DUPLEX_TYPE_ADDR ,HBG_REG_DUPLEX_B , duplex); + +hbg_hw_event_notify (priv,HBG_HW_EVENT_CORE_RESET ); + +hbg_hw_mac_enable (priv,HBG_STATUS_ENABLE ); + +if (!hbg_reg_read_field (priv,HBG_REG_AN_NEG_STATE_ADDR , +HBG_REG_AN_NEG_STATE_NP_LINK_OK_B )) +hbg_np_link_fail_task_schedule (priv); }/* only support uc filter */
drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c +9 -0
@@ -286,6 +286,9 @@ static void hbg_service_task(struct work_struct *work)if (test_and_clear_bit (HBG_NIC_STATE_NEED_RESET , &priv->state))hbg_err_reset (priv); +if (test_and_clear_bit (HBG_NIC_STATE_NP_LINK_FAIL , &priv->state)) +hbg_fix_np_link_fail (priv); +/* The type of statistics register is u32, * To prevent the statistics register from overflowing, * the driver dumps the statistics every 30 seconds.
@@ -301,6 +304,12 @@ void hbg_err_reset_task_schedule(struct hbg_priv *priv)schedule_delayed_work (&priv->service_task,0 ); } +void hbg_np_link_fail_task_schedule (struct hbg_priv *priv) +{ +set_bit (HBG_NIC_STATE_NP_LINK_FAIL , &priv->state); +schedule_delayed_work (&priv->service_task,0 ); +} +static void hbg_cancel_delayed_work_sync (void *data) {cancel_delayed_work_sync (data);
drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.c +22 -0
@@ -17,6 +17,8 @@#define HBG_MDIO_OP_TIMEOUT_US (1 * 1000 * 1000)#define HBG_MDIO_OP_INTERVAL_US (5 * 1000) +#define HBG_NP_LINK_FAIL_RETRY_TIMES 5 +static void hbg_mdio_set_command (struct hbg_mac *mac,u32 cmd) {hbg_reg_write (HBG_MAC_GET_PRIV (mac),HBG_REG_MDIO_COMMAND_ADDR , cmd);
@@ -127,6 +129,26 @@ static void hbg_flowctrl_cfg(struct hbg_priv *priv)hbg_hw_set_pause_enable (priv, tx_pause, rx_pause); } +void hbg_fix_np_link_fail (struct hbg_priv *priv) +{ +struct device *dev = &priv->pdev->dev; + +if (priv->stats.np_link_fail_cnt >=HBG_NP_LINK_FAIL_RETRY_TIMES ) { +dev_err (dev,"failed to fix the MAC link status\n" ); + priv->stats.np_link_fail_cnt =0 ; +return ; + } + + priv->stats.np_link_fail_cnt++; +dev_err (dev,"failed to link between MAC and PHY, try to fix...\n" ); + +/* Replace phy_reset() with phy_stop() and phy_start(), +* as suggested by Andrew. +*/ +hbg_phy_stop (priv); +hbg_phy_start (priv); +} +static void hbg_phy_adjust_link (struct net_device *netdev) {struct hbg_priv *priv =netdev_priv (netdev);
drivers/net/ethernet/hisilicon/hibmcge/hbg_mdio.h +2 -0
@@ -9,4 +9,6 @@int hbg_mdio_init (struct hbg_priv *priv);void hbg_phy_start (struct hbg_priv *priv);void hbg_phy_stop (struct hbg_priv *priv); +void hbg_fix_np_link_fail (struct hbg_priv *priv); +#endif
drivers/net/ethernet/hisilicon/hibmcge/hbg_reg.h +1 -0
@@ -54,6 +54,7 @@#define HBG_REG_PAUSE_ENABLE_RX_B BIT(0)#define HBG_REG_PAUSE_ENABLE_TX_B BIT(1)#define HBG_REG_AN_NEG_STATE_ADDR (HBG_REG_SGMII_BASE + 0x0058) +#define HBG_REG_AN_NEG_STATE_NP_LINK_OK_B BIT(15)#define HBG_REG_TRANSMIT_CTRL_ADDR (HBG_REG_SGMII_BASE + 0x0060)#define HBG_REG_TRANSMIT_CTRL_PAD_EN_B BIT(7)#define HBG_REG_TRANSMIT_CTRL_CRC_ADD_B BIT(6)
Signature · 1 line
2.33.0
Jijie Shao
maintainerPATCH v4 5/6 net: hibmcge: Add support for BMC diagnose feature
In reply to Jijie ShaoThe MAC hardware is on the BMC side, and the driver is on the host side. When the driver is abnormal, the BMC cannot directly detect the exception cause.
Therefore, this patch implements the BMC diagnosis feature.
When users query driver diagnosis information on the BMC, the driver detects the query request in the scheduled task and reports driver statistics and link status to the BMC through the bar space. The BMC collects logs to analyze exception causes.
Currently, the scheduled task is executed every 30 seconds To quickly respond to user query requests,
this patch changes the scheduled task to once every second.
--- .../net/ethernet/hisilicon/hibmcge/Makefile | 2 +- .../ethernet/hisilicon/hibmcge/hbg_common.h | 1 + .../ethernet/hisilicon/hibmcge/hbg_diagnose.c | 348 ++++++++++++++++++ .../ethernet/hisilicon/hibmcge/hbg_diagnose.h | 11 + .../net/ethernet/hisilicon/hibmcge/hbg_main.c | 11 +- .../net/ethernet/hisilicon/hibmcge/hbg_reg.h | 7 + 6 files changed, 377 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ethernet/hisilicon/hibmcge/hbg_diagnose.c create mode 100644 drivers/net/ethernet/hisilicon/hibmcge/hbg_diagnose.h
drivers/net/ethernet/hisilicon/hibmcge/Makefile +1 -1
@@ -6,4 +6,4 @@ obj-$(CONFIG_HIBMCGE) += hibmcge.o hibmcge-objs = hbg_main.o hbg_hw.o hbg_mdio.o hbg_irq.o hbg_txrx.o hbg_ethtool.o \ - hbg_debugfs.o hbg_err.o + hbg_debugfs.o hbg_err.o hbg_diagnose.o
drivers/net/ethernet/hisilicon/hibmcge/hbg_common.h +1 -0
@@ -272,6 +272,7 @@ struct hbg_priv {enum hbg_reset_type reset_type;struct hbg_user_def user_def;struct hbg_stats stats; +unsigned long last_update_stats_time;struct delayed_work service_task; };
drivers/net/ethernet/hisilicon/hibmcge/hbg_diagnose.c new file +348 -0
348 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hibmcge/hbg_diagnose.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* Copyright (c) 2025 Hisilicon Limited. */ + +#ifndef __HBG_DIAGNOSE_H +#define __HBG_DIAGNOSE_H + +#include "hbg_common.h" + +void hbg_diagnose_message_push (struct hbg_priv *priv); + +#endif
drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c +9 -2
@@ -6,6 +6,7 @@#include <linux/netdevice.h> #include <linux/pci.h> #include "hbg_common.h" +#include "hbg_diagnose.h" #include "hbg_err.h" #include "hbg_ethtool.h" #include "hbg_hw.h"
@@ -289,13 +290,19 @@ static void hbg_service_task(struct work_struct *work)if (test_and_clear_bit (HBG_NIC_STATE_NP_LINK_FAIL , &priv->state))hbg_fix_np_link_fail (priv); +hbg_diagnose_message_push (priv); +/* The type of statistics register is u32, * To prevent the statistics register from overflowing, * the driver dumps the statistics every 30 seconds. */ -hbg_update_stats (priv); +if (time_after (jiffies, priv->last_update_stats_time +30 *HZ )) { +hbg_update_stats (priv); + priv->last_update_stats_time = jiffies; + } +schedule_delayed_work (&priv->service_task, -msecs_to_jiffies (30 *MSEC_PER_SEC )); +msecs_to_jiffies (MSEC_PER_SEC )); }void hbg_err_reset_task_schedule (struct hbg_priv *priv)
drivers/net/ethernet/hisilicon/hibmcge/hbg_reg.h +7 -0
@@ -18,6 +18,13 @@#define HBG_REG_TX_FIFO_NUM_ADDR 0x0030#define HBG_REG_RX_FIFO_NUM_ADDR 0x0034#define HBG_REG_VLAN_LAYERS_ADDR 0x0038 +#define HBG_REG_PUSH_REQ_ADDR 0x00F0 +#define HBG_REG_MSG_HEADER_ADDR 0x00F4 +#define HBG_REG_MSG_HEADER_OPCODE_M GENMASK(7, 0) +#define HBG_REG_MSG_HEADER_STATUS_M GENMASK(11, 8) +#define HBG_REG_MSG_HEADER_DATA_NUM_M GENMASK(19, 12) +#define HBG_REG_MSG_HEADER_RESP_CODE_M GENMASK(27, 20) +#define HBG_REG_MSG_DATA_BASE_ADDR 0x0100/* MDIO */ #define HBG_REG_MDIO_BASE 0x8000
Signature · 1 line
2.33.0
Jijie Shao
maintainerPATCH v4 6/6 net: hibmcge: Add support for ioctl
In reply to Jijie ShaoThis patch implements the .ndo_eth_ioctl() to
read and write the PHY register.
---
ChangeLog:
v1 -> v2:
- Use phy_do_ioctl() to simplify ioctl code, suggested by Andrew.
v1: https://lore.kernel.org/all/[email protected]/
--- drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/hisilicon/hibmcge/hbg_main.c +2 -0
@@ -5,6 +5,7 @@#include <linux/if_vlan.h> #include <linux/netdevice.h> #include <linux/pci.h> +#include <linux/phy.h> #include "hbg_common.h" #include "hbg_diagnose.h" #include "hbg_err.h"
@@ -277,6 +278,7 @@ static const struct net_device_ops hbg_netdev_ops = { .ndo_tx_timeout = hbg_net_tx_timeout, .ndo_set_rx_mode = hbg_net_set_rx_mode, .ndo_get_stats64 = hbg_net_get_stats, + .ndo_eth_ioctl = phy_do_ioctl_running, };static void hbg_service_task (struct work_struct *work)
Signature · 1 line
2.33.0
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 9 lines · On Fri, 28 Feb 2025 19:54:05 +0800 you wrote:
In this patch set, we mainly implement some enhanced features. It mainly includes the statistics, diagnosis, and ioctl to improve fault locating efficiency,
abnormal irq and MAC link exception handling feature to enhance driver robustness,
and rx checksum offload feature to improve performance (tx checksum feature has been implemented).[...]
Here is the summary with links:
- [v4,net-next,1/6] net: hibmcge: Add support for dump statistics
https://git.kernel.org/netdev/net-next/c/c0bf9bf31e79 - [v4,net-next,2/6] net: hibmcge: Add support for checksum offload https://git.kernel.org/netdev/net-next/c/833b65a3b54d - [v4,net-next,3/6] net: hibmcge: Add support for abnormal irq handling feature https://git.kernel.org/netdev/net-next/c/fd394a334b1c - [v4,net-next,4/6] net: hibmcge: Add support for mac link exception handling feature https://git.kernel.org/netdev/net-next/c/e0306637e85d - [v4,net-next,5/6] net: hibmcge: Add support for BMC diagnose feature https://git.kernel.org/netdev/net-next/c/7a5d60dcf998 - [v4,net-next,6/6] net: hibmcge: Add support for ioctl https://git.kernel.org/netdev/net-next/c/615552c601ed
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html