bnge: Add ethtool register dump support
cover bnge: Add ethtool register dump support
Hi,
This patch series adds ethtool register dump support (ethtool -d) for the Broadcom BNGE Ethernet driver by implementing the .get_regs and .get_regs_len ethtool callbacks.
The dump support covers:
- PXP registers
- PCIe signal integrity and PCIe Latency Histogram statistics
- Adaptive QoS TX and RX MBUF registers
Ramakrishna Koduri (2):
bnge: Add HSI definitions for register dump
bnge: Add support for ethtool -d register dump
drivers/net/ethernet/broadcom/bnge/bnge.h | 9 + .../net/ethernet/broadcom/bnge/bnge_core.c | 3 + .../net/ethernet/broadcom/bnge/bnge_ethtool.c | 168 +++++++++++++++++ .../net/ethernet/broadcom/bnge/bnge_ethtool.h | 19 ++ .../ethernet/broadcom/bnge/bnge_hwrm_lib.c | 178 +++++++++++++++++- .../ethernet/broadcom/bnge/bnge_hwrm_lib.h | 5 + include/linux/bnge/hsi.h | 149 +++++++++++++++ 7 files changed, 530 insertions(+), 1 deletion(-)
Signature · 1 line
2.52.0
PATCH 1/2 bnge: Add HSI definitions for register dump
Add HSI support for get_regs and get_regs_len ethtool callbacks to provide register dump support for the BNGE driver. This includes support for PXP registers, PCIe signal integrity, PCIe Latency Histogram and Adaptive QoS TX/RX MBUF registers.
--- include/linux/bnge/hsi.h | 149 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+)
include/linux/bnge/hsi.h +149 -0
@@ -12900,4 +12900,153 @@ struct mpc_cmpl_hdr {__le32 opaque; }; +/* queue_adptv_qos_rx_info (size:960b/120B) */ +struct queue_adptv_qos_rx_info { +__le16 rx_shared_pool_cells; +__le16 rx_total_cells; +u8 rx_cell_size; +u8 rx_enabled_cos; +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ENABLED_COS0 0x1UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ENABLED_COS1 0x2UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ENABLED_COS2 0x4UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ENABLED_COS3 0x8UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ENABLED_COS4 0x10UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ENABLED_COS5 0x20UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ENABLED_COS6 0x40UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ENABLED_COS7 0x80UL +u8 rx_llfc_enabled; +u8 rx_pfc_enabled_cos; +#define QUEUE_ADPTV_QOS_RX_INFO_RX_PFC_ENABLED_COS0 0x1UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_PFC_ENABLED_COS1 0x2UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_PFC_ENABLED_COS2 0x4UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_PFC_ENABLED_COS3 0x8UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_PFC_ENABLED_COS4 0x10UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_PFC_ENABLED_COS5 0x20UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_PFC_ENABLED_COS6 0x40UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_PFC_ENABLED_COS7 0x80UL +__le16 rx_reserved_cells_cos[8 ]; +__le16 rx_shared_cells_cos[8 ]; +__le16 rx_shared_combined_cells_cos[8 ]; +__le16 rx_headroom_cells_cos[8 ]; +__le16 rx_headroom_combined_cells_cos[8 ]; +u8 rx_shared_pool_index_cos[8 ]; +u8 rx_roce_enabled_cos; +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ROCE_ENABLED_COS0 0x1UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ROCE_ENABLED_COS1 0x2UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ROCE_ENABLED_COS2 0x4UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ROCE_ENABLED_COS3 0x8UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ROCE_ENABLED_COS4 0x10UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ROCE_ENABLED_COS5 0x20UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ROCE_ENABLED_COS6 0x40UL +#define QUEUE_ADPTV_QOS_RX_INFO_RX_ROCE_ENABLED_COS7 0x80UL +u8 unused_0[7 ]; +__le16 rx_cos_allocate[8 ]; +}; + +/* queue_adptv_qos_tx_info (size:640b/80B) */ +struct queue_adptv_qos_tx_info { +__le16 tx_shared_pool_cells; +__le16 tx_total_cells; +u8 tx_cell_size; +u8 tx_enabled_cos; +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ENABLED_COS0 0x1UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ENABLED_COS1 0x2UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ENABLED_COS2 0x4UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ENABLED_COS3 0x8UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ENABLED_COS4 0x10UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ENABLED_COS5 0x20UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ENABLED_COS6 0x40UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ENABLED_COS7 0x80UL +u8 tx_roce_enabled_cos; +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ROCE_ENABLED_COS0 0x1UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ROCE_ENABLED_COS1 0x2UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ROCE_ENABLED_COS2 0x4UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ROCE_ENABLED_COS3 0x8UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ROCE_ENABLED_COS4 0x10UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ROCE_ENABLED_COS5 0x20UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ROCE_ENABLED_COS6 0x40UL +#define QUEUE_ADPTV_QOS_TX_INFO_TX_ROCE_ENABLED_COS7 0x80UL +u8 unused_0; +__le16 tx_reserved_cells_cos[8 ]; +__le16 tx_shared_cells_cos[8 ]; +__le16 tx_shared_combined_cells_cos[8 ]; +u8 tx_shared_pool_index_cos[8 ]; +__le16 tx_cos_allocate[8 ]; +}; + +/* hwrm_queue_adptv_qos_rx_qcfg_input (size:256b/32B) */ +struct hwrm_queue_adptv_qos_rx_qcfg_input { +__le16 req_type; +__le16 cmpl_ring; +__le16 seq_id; +__le16 target_id; +__le64 resp_addr; +__le64 rx_qcfg_host_addr; +__le16 rx_qcfg_size; +u8 port_id; +u8 flags; +#define QUEUE_ADPTV_QOS_RX_QCFG_REQ_FLAGS_COUNTER_MASK 0x1UL +u8 unused_0[4 ]; +}; + +/* hwrm_queue_adptv_qos_rx_qcfg_output (size:128b/16B) */ +struct hwrm_queue_adptv_qos_rx_qcfg_output { +__le16 error_code; +__le16 req_type; +__le16 seq_id; +__le16 resp_len; +__le16 rx_qcfg_size; +u8 unused_0[5 ]; +u8 valid; +}; + +/* hwrm_queue_adptv_qos_tx_qcfg_input (size:256b/32B) */ +struct hwrm_queue_adptv_qos_tx_qcfg_input { +__le16 req_type; +__le16 cmpl_ring; +__le16 seq_id; +__le16 target_id; +__le64 resp_addr; +__le64 tx_qcfg_host_addr; +__le16 tx_qcfg_size; +u8 port_id; +u8 flags; +#define QUEUE_ADPTV_QOS_TX_QCFG_REQ_FLAGS_COUNTER_MASK 0x1UL +u8 unused_0[4 ]; +}; + +/* hwrm_queue_adptv_qos_tx_qcfg_output (size:128b/16B) */ +struct hwrm_queue_adptv_qos_tx_qcfg_output { +__le16 error_code; +__le16 req_type; +__le16 seq_id; +__le16 resp_len; +__le16 tx_qcfg_size; +u8 unused_0[5 ]; +u8 valid; +}; + +/* hwrm_dbg_read_direct_input (size:256b/32B) */ +struct hwrm_dbg_read_direct_input { +__le16 req_type; +__le16 cmpl_ring; +__le16 seq_id; +__le16 target_id; +__le64 resp_addr; +__le64 host_dest_addr; +__le32 read_addr; +__le32 read_len32; +}; + +/* hwrm_dbg_read_direct_output (size:128b/16B) */ +struct hwrm_dbg_read_direct_output { +__le16 error_code; +__le16 req_type; +__le16 seq_id; +__le16 resp_len; +__le32 crc32; +u8 unused_0[3 ]; +u8 valid; +}; +#endif /* _BNGE_HSI_H_ */
Signature · 1 line
2.52.0
PATCH 2/2 bnge: Add support for ethtool -d register dump
In reply to Ramakrishna KoduriImplement get_regs and get_regs_len ethtool callbacks to provide register dump support for the BNGE driver. This includes support for PXP registers, PCIe signal integrity, PCIe Latency Histogram and Adaptive QoS TX/RX MBUF registers.
--- drivers/net/ethernet/broadcom/bnge/bnge.h | 9 + .../net/ethernet/broadcom/bnge/bnge_core.c | 3 + .../net/ethernet/broadcom/bnge/bnge_ethtool.c | 168 +++++++++++++++++ .../net/ethernet/broadcom/bnge/bnge_ethtool.h | 19 ++ .../ethernet/broadcom/bnge/bnge_hwrm_lib.c | 178 +++++++++++++++++- .../ethernet/broadcom/bnge/bnge_hwrm_lib.h | 5 + 6 files changed, 381 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnge/bnge.h +9 -0
@@ -66,6 +66,7 @@ enum {BNGE_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO =BIT_ULL (24 ),BNGE_FW_CAP_CFA_RFS_RING_TBL_IDX_V3 =BIT_ULL (25 ),BNGE_FW_CAP_VNIC_RE_FLUSH =BIT_ULL (26 ), + BNGE_FW_CAP_MBUF_DATA = BIT_ULL(27), }; enum {
@@ -89,6 +90,10 @@ enum { BNGE_RSS_CAP_ESP_V6_RSS_CAP = BIT(7), }; +enum { +BNGE_STATS_CAP_PCIE =BIT (0 ), +}; +#define BNGE_MAX_QUEUE 8struct bnge_queue_info {u8 queue_id;
@@ -149,6 +154,8 @@ struct bnge_dev {#define BNGE_STATE_OPEN 1u64 fw_cap; +u32 stats_cap; +u32 fw_dbg_cap;/* Backing stores */ struct bnge_ctx_mem_info *ctx;
@@ -250,6 +257,8 @@ struct bnge_dev {#define bnge_for_each_open_nq (i, bd) \ for ((i) = BNGE_FIRST_OPEN_NQ; (i) < (bd)->nq_nr_rings; (i)++) +#define CHIMP_REG_VIEW_ADDR 0x80000000 +static inline bool bnge_is_roce_en (struct bnge_dev *bd) {return bd->flags &BNGE_EN_ROCE ;
drivers/net/ethernet/broadcom/bnge/bnge_core.c +3 -0
@@ -8,6 +8,7 @@#include "bnge.h" #include "bnge_devlink.h" +#include "bnge_ethtool.h" #include "bnge_hwrm.h" #include "bnge_hwrm_lib.h" #include "bnge_link.h"
@@ -74,6 +75,8 @@ static int bnge_func_qcaps(struct bnge_dev *bd)return rc; } +bnge_hwrm_dbg_qcaps (bd); +return 0 ; }
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +168 -0
187 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.h +19 -0
@@ -4,6 +4,25 @@#ifndef _BNGE_ETHTOOL_H_#define _BNGE_ETHTOOL_H_ +struct bnge_dev ; + +struct bnge_reg_desc { +u8 size; +u16 count; +}; + +void bnge_copy_regs (u8 *src,u8 *dst,const struct bnge_reg_desc *desc, +int num_desc,int max_len); + +#define BNGE_PXP_REG_LEN 0x3110 + +#define BNGE_MBUF_REG_START 0x3800 +#define BNGE_MBUF_REG_LEN 0x12c + +#define BNGE_RX_MBUF_REG_OFFSET BNGE_MBUF_REG_START +#define BNGE_TX_MBUF_REG_OFFSET (BNGE_RX_MBUF_REG_OFFSET + 0x64 + \ + sizeof(struct queue_adptv_qos_rx_info)) +void bnge_set_ethtool_ops (struct net_device *dev);#endif /* _BNGE_ETHTOOL_H_ */
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +177 -1
209 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.h +5 -0
@@ -65,4 +65,9 @@ int bnge_hwrm_shutdown_link(struct bnge_dev *bd);int bnge_hwrm_port_qstats (struct bnge_dev *bd,u8 flags);int bnge_hwrm_port_qstats_ext (struct bnge_dev *bd,u8 flags);int bnge_hwrm_func_qstat_ext (struct bnge_dev *bd,struct bnge_stats_mem *stats); +int bnge_hwrm_rx_mbuf_data (struct bnge_dev *bd,u8 *reg_buf); +int bnge_hwrm_tx_mbuf_data (struct bnge_dev *bd,u8 *reg_buf); +void bnge_hwrm_dbg_qcaps (struct bnge_dev *bd); +int bnge_dbg_hwrm_rd_reg (struct bnge_dev *bd,u32 reg_off, +u16 num_words,u32 *reg_buf);#endif /* _BNGE_HWRM_LIB_H_ */
Signature · 1 line
2.52.0
[email protected]
AI reviewRe: [PATCH net-next 2/2] bnge: Add support for ethtool -d register dump
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 3
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] bnge_get_pcie_regs() sets regs->version to 1, 2 or 3 from the PCIe stats size firmware actually returned (`min(resp->pcie_stat_size,…
- [Low] In bnge_hwrm_dbg_qcaps() (drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c), the comment says…
- [Low] The commit message lists only the categories of data that are dumped.
- [Low] In bnge_pcie_reg[] (drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c, line 786),…
--
bnge: Add support for ethtool -d register dump
This commit adds get_regs and get_regs_len ethtool callbacks to the bnge driver. The dump has three parts: PXP registers read through HWRM_DBG_READ_DIRECT, PCIe statistics from HWRM_PCIE_QSTATS, and adaptive QoS RX/TX MBUF data. It also adds HWRM_DBG_QCAPS discovery at probe time and reads new capability flags from FUNC_QCAPS.
Quoted 4 lines
Implement
get_regsandget_regs_lenethtool callbacks to provide register dump support for the BNGE driver. This includes support for PXP registers, PCIe signal integrity, PCIe Latency Histogram and Adaptive QoS TX/RX MBUF registers.
[Severity: Low]
Could the commit message describe the dump layout and the version numbers? Both become visible to userspace once this is merged.
The layout is:
- PXP registers at offset 0
- PCIe stats at BNGE_PXP_REG_LEN (0x3110)
- RX MBUF data at 0x3800
- TX MBUF data at:
#define BNGE_TX_MBUF_REG_OFFSET (BNGE_RX_MBUF_REG_OFFSET + 0x64 + \
sizeof(struct queue_adptv_qos_rx_info))
What is the 0x64 byte gap between the RX and TX blocks? BNGE_MBUF_REG_LEN (0x12c) seems to include it.
regs->version can be anything from 0 to 4, and version 4 does not exist in bnxt. The comment in bnge_get_regs() says "Version 4 is required for the userspace ethtool decoder". DRV_NAME is "bng_en", though, so ethtool will not use its existing bnxt decoder. Is a bng_en decoder available or planned?
The patch also adds a new HWRM_DBG_QCAPS query at probe time, through bnge_func_qcaps()->bnge_hwrm_dbg_qcaps(). The commit message doesn't mention this either.
Quoted 4 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +0
-0
[ ... ]
Quoted 1 line
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +0
-0@@ -740,6 +742,170 @@ static int bnge_set_pauseparam(struct net_device *dev,
[ ... ]
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c static int bnge_set_pauseparam(struct net_device *dev, · line 786
Quoted 6 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +6
-0+#define BNGE_PCIE_REG_SIZE (reg) \ + sizeof_field(struct pcie_ctx_hw_stats_v2, pcie_##reg) + +static const struct bnge_reg_desc bnge_pcie_reg[] = { + {BNGE_PCIE_REG_SIZE (pl_signal_integrity),8 }, + {sizeof (__le16),4 },/* pcie_equalization_time: 4x __le16 */
[Severity: Low]
Does this entry match the HSI definition? include/linux/bnge/hsi.h declares the field as a single 64-bit value, in both pcie_ctx_hw_stats and pcie_ctx_hw_stats_v2:
__le64 pcie_equalization_time;
Every other entry in this table takes its size from the struct through BNGE_PCIE_REG_SIZE(). This one hardcodes 2 bytes instead.
The difference shows up on big-endian hosts. Converting four __le16 values swaps the bytes inside each 16-bit part but leaves the parts in their original order. A single le64_to_cpu() also reverses the order of the parts. bnxt_get_regs() converts this field as one u64.
Should the HSI describe the field as __le16[4]? Or should this entry use BNGE_PCIE_REG_SIZE(equalization_time) with a count of 1?
Quoted 6 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +6
-0+ { BNGE_PCIE_REG_SIZE(ltssm_histogram[0]), 4 }, + { BNGE_PCIE_REG_SIZE(recovery_histogram), 1 }, + { BNGE_PCIE_REG_SIZE(tl_credit_nph_histogram[0]), 94 }, + { BNGE_PCIE_REG_SIZE(posted_packet_count), 5 }, + { BNGE_PCIE_REG_SIZE(rd_latency_histogram[0]), 14 }, +};
[ ... ]
Quoted 3 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +3
-0+static void bnge_get_pcie_regs (struct bnge_dev *bd,struct ethtool_regs *regs, +u8 *dst) +{
[ ... ]
Quoted 11 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +11
-0+ len =min_t (int,le16_to_cpu (resp->pcie_stat_size), +sizeof (struct pcie_ctx_hw_stats_v2 )); +if (len <=0 ) + goto drop_req; + +if (len <=sizeof (struct pcie_ctx_hw_stats )) + regs->version =1 ; +else if (len <sizeof (struct pcie_ctx_hw_stats_v2 )) + regs->version =2 ; +else + regs->version =3 ;
[ ... ]
Quoted 25 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +25
-0+static void bnge_get_regs (struct net_device *dev,struct ethtool_regs *regs, +void *_p) +{ +struct bnge_net *bn =netdev_priv (dev); +struct bnge_dev *bd = bn->bd; +u8 *p = _p; + + regs->version =0 ; + +if (BNGE_NO_FW_ACCESS (bd)) +return ; + +if (!(bd->fw_dbg_cap &DBG_QCAPS_RESP_FLAGS_REG_ACCESS_RESTRICTED )) { +int rc; + + rc =bnge_dbg_hwrm_rd_reg (bd,0 ,BNGE_PXP_REG_LEN /4 , _p); +if (rc) +netdev_warn (dev,"Failed to read PXP regs: %d\n" , rc); + } + +if (bd->stats_cap &BNGE_STATS_CAP_PCIE ) +bnge_get_pcie_regs (bd, regs, p +BNGE_PXP_REG_LEN ); + +if (bd->fw_cap &BNGE_FW_CAP_MBUF_DATA ) { +int rc_rx, rc_tx;
[ ... ]
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c static int bnge_set_pauseparam(struct net_device *dev, · line 905
Quoted 6 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +6
-0+ rc_rx =bnge_hwrm_rx_mbuf_data (bd, + p +BNGE_RX_MBUF_REG_OFFSET ); + rc_tx =bnge_hwrm_tx_mbuf_data (bd, + p +BNGE_TX_MBUF_REG_OFFSET ); +if (!rc_rx || !rc_tx) + regs->version =4 ;
[Severity: Medium]
Doesn't this assignment throw away the PCIe layout version that bnge_get_pcie_regs() just set?
bnge_get_pcie_regs() picks version 1, 2 or 3 from the size firmware returned in resp->pcie_stat_size. That version is the only thing that tells userspace how much of the PCIe region holds real data.
If BNGE_FW_CAP_MBUF_DATA is set and either MBUF query succeeds, the version becomes 4. That happens in all of these cases:
- the PCIe stats were v1 sized
- the PCIe stats were v2 sized or full v2
- HWRM_PCIE_QSTATS failed
- PCIe stats were never queried because BNGE_STATS_CAP_PCIE isn't set
The ethtool core zero-fills the buffer. A decoder that sees version 4 would treat the unwritten tail as real TL credit and latency histogram values. bnxt_get_regs() uses the same 1/2/3 scheme but never overwrites it.
A related point: when bnge_dbg_hwrm_rd_reg() fails, the only sign is the netdev_warn() above. The zeroed 0x3110 byte PXP region is still reported as register contents, and neither version nor len tells userspace about the failure. bnxt behaves the same way today.
Quoted 2 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +2
-0+ } +}
[ ... ]
Quoted 4 lines
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +0
-0
[ ... ]
Quoted 7 lines
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +3
-0@@ -597,12 +598,45 @@ int bnge_hwrm_func_resc_qcaps(struct bnge_dev *bd)return rc; } +void bnge_hwrm_dbg_qcaps (struct bnge_dev *bd) +{ +struct hwrm_dbg_qcaps_output *resp;
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c int bnge_hwrm_func_resc_qcaps(struct bnge_dev *bd) · line 613
Quoted 10 lines
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +10
-0+struct hwrm_dbg_qcaps_input *req; +int rc; + + bd->fw_dbg_cap =0 ; +if (!(bd->fw_cap &BNGE_FW_CAP_DBG_QCAPS )) +return ; + +/* Discovery failure is treated as restricted so we never attempt +* direct register reads without confirmation from firmware. +*/
[Severity: Low]
Does the early return above match this comment? If firmware doesn't advertise FUNC_QCAPS_RESP_FLAGS_DBG_QCAPS_CMD_SUPPORTED, fw_dbg_cap stays 0. bnge_get_regs() only checks the restricted bit:
if (!(bd->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_REG_ACCESS_RESTRICTED)) {
...
rc = bnge_dbg_hwrm_rd_reg(bd, 0, BNGE_PXP_REG_LEN / 4, _p);So HWRM_DBG_READ_DIRECT is sent for 0xc44 words in exactly the case where firmware has confirmed the least. If firmware rejects the request, every ethtool -d logs "Failed to read PXP regs".
bnxt_hwrm_dbg_qcaps() also treats missing DBG_QCAPS as unrestricted. Should the comment be changed to match? Or should this branch also set DBG_QCAPS_RESP_FLAGS_REG_ACCESS_RESTRICTED?
Quoted 5 lines
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +5
-0+ rc =bnge_hwrm_req_init (bd, req,HWRM_DBG_QCAPS ); +if (rc) { + bd->fw_dbg_cap =DBG_QCAPS_RESP_FLAGS_REG_ACCESS_RESTRICTED ; +return ; + }
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124100751.179270-1-ramakrishna.koduri%40broadcom.com
Re: [PATCH net-next 2/2] bnge: Add support for ethtool -d register dump
I see a valid comment by sashiko in this patch and will send out v2.
Thanks,
Ramakrishna Koduri.
Quoted 240 lines · On Wed, Nov 25, 2026 at 3:41 PM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 3
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium]
bnge_get_pcie_regs()setsregs->versionto 1, 2 or 3 from the PCIe stats size firmware actually returned (`min(resp->pcie_stat_size,…
- [Low] Inbnge_hwrm_dbg_qcaps()(drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c), the comment says…
- [Low] The commit message lists only the categories of data that are dumped.
- [Low] In bnge_pcie_reg[] (drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c, line 786),…--
bnge: Add support for ethtool -d register dump
This commit adds
get_regsandget_regs_lenethtool callbacks to the bnge driver. The dump has three parts: PXP registers read throughHWRM_DBG_READ_DIRECT, PCIe statistics fromHWRM_PCIE_QSTATS, and adaptive QoS RX/TX MBUF data. It also addsHWRM_DBG_QCAPSdiscovery at probe time and reads new capability flags fromFUNC_QCAPS.Quoted 4 lines
Implement
get_regsandget_regs_lenethtool callbacks to provide register dump support for the BNGE driver. This includes support for PXP registers, PCIe signal integrity, PCIe Latency Histogram and Adaptive QoS TX/RX MBUF registers.[Severity: Low]
Could the commit message describe the dump layout and the version numbers? Both become visible to userspace once this is merged.The layout is:
- PXP registers at offset 0
- PCIe stats atBNGE_PXP_REG_LEN(0x3110)
- RX MBUF data at0x3800
- TX MBUF data at:#define
BNGE_TX_MBUF_REG_OFFSET(BNGE_RX_MBUF_REG_OFFSET+0x64+ \
sizeof(struct queue_adptv_qos_rx_info))What is the
0x64byte gap between the RX and TX blocks?BNGE_MBUF_REG_LEN(0x12c) seems to include it.
regs->versioncan be anything from 0 to 4, and version 4 does not exist in bnxt. The comment inbnge_get_regs()says "Version 4 is required for the userspace ethtool decoder".DRV_NAMEis "bng_en", though, so ethtool will not use its existing bnxt decoder. Is abng_endecoder available or planned?The patch also adds a new
HWRM_DBG_QCAPSquery at probe time, through bnge_func_qcaps()->bnge_hwrm_dbg_qcaps(). The commit message doesn't mention this either.Quoted 4 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +0
-0[ ... ]
Quoted 1 line
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +0
-0@@ -740,6 +742,170 @@ static int bnge_set_pauseparam(struct net_device *dev,[ ... ]
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c static int bnge_set_pauseparam(struct net_device *dev, · line 786
Quoted 6 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +6
-0+#define BNGE_PCIE_REG_SIZE (reg) \ + sizeof_field(struct pcie_ctx_hw_stats_v2, pcie_##reg) + +static const struct bnge_reg_desc bnge_pcie_reg[] = { + {BNGE_PCIE_REG_SIZE (pl_signal_integrity),8 }, + {sizeof (__le16),4 },/* pcie_equalization_time: 4x __le16 */ [Severity: Low]
Does this entry match the HSI definition?include/linux/bnge/hsi.hdeclares the field as a single 64-bit value, in bothpcie_ctx_hw_statsandpcie_ctx_hw_stats_v2:__le64 pcie_equalization_time;Every other entry in this table takes its size from the struct through
BNGE_PCIE_REG_SIZE(). This one hardcodes 2 bytes instead.The difference shows up on big-endian hosts. Converting four
__le16values swaps the bytes inside each 16-bit part but leaves the parts in their original order. A singlele64_to_cpu()also reverses the order of the parts.bnxt_get_regs()converts this field as one u64.Should the HSI describe the field as __le16[4]? Or should this entry use
BNGE_PCIE_REG_SIZE(equalization_time)with a count of 1?Quoted 6 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +6
-0+ { BNGE_PCIE_REG_SIZE(ltssm_histogram[0]), 4 }, + { BNGE_PCIE_REG_SIZE(recovery_histogram), 1 }, + { BNGE_PCIE_REG_SIZE(tl_credit_nph_histogram[0]), 94 }, + { BNGE_PCIE_REG_SIZE(posted_packet_count), 5 }, + { BNGE_PCIE_REG_SIZE(rd_latency_histogram[0]), 14 }, +};[ ... ]
Quoted 3 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +3
-0+static void bnge_get_pcie_regs (struct bnge_dev *bd,struct ethtool_regs *regs, +u8 *dst) +{[ ... ]
Quoted 11 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +11
-0+ len =min_t (int,le16_to_cpu (resp->pcie_stat_size), +sizeof (struct pcie_ctx_hw_stats_v2 )); +if (len <=0 ) + goto drop_req; + +if (len <=sizeof (struct pcie_ctx_hw_stats )) + regs->version =1 ; +else if (len <sizeof (struct pcie_ctx_hw_stats_v2 )) + regs->version =2 ; +else + regs->version =3 ;[ ... ]
Quoted 25 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +25
-0+static void bnge_get_regs (struct net_device *dev,struct ethtool_regs *regs, +void *_p) +{ +struct bnge_net *bn =netdev_priv (dev); +struct bnge_dev *bd = bn->bd; +u8 *p = _p; + + regs->version =0 ; + +if (BNGE_NO_FW_ACCESS (bd)) +return ; + +if (!(bd->fw_dbg_cap &DBG_QCAPS_RESP_FLAGS_REG_ACCESS_RESTRICTED )) { +int rc; + + rc =bnge_dbg_hwrm_rd_reg (bd,0 ,BNGE_PXP_REG_LEN /4 , _p); +if (rc) +netdev_warn (dev,"Failed to read PXP regs: %d\n" , rc); + } + +if (bd->stats_cap &BNGE_STATS_CAP_PCIE ) +bnge_get_pcie_regs (bd, regs, p +BNGE_PXP_REG_LEN ); + +if (bd->fw_cap &BNGE_FW_CAP_MBUF_DATA ) { +int rc_rx, rc_tx;[ ... ]
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c static int bnge_set_pauseparam(struct net_device *dev, · line 905
Quoted 6 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +6
-0+ rc_rx =bnge_hwrm_rx_mbuf_data (bd, + p +BNGE_RX_MBUF_REG_OFFSET ); + rc_tx =bnge_hwrm_tx_mbuf_data (bd, + p +BNGE_TX_MBUF_REG_OFFSET ); +if (!rc_rx || !rc_tx) + regs->version =4 ;[Severity: Medium]
Doesn't this assignment throw away the PCIe layout version thatbnge_get_pcie_regs()just set?
bnge_get_pcie_regs()picks version 1, 2 or 3 from the size firmware returned inresp->pcie_stat_size. That version is the only thing that tells userspace how much of the PCIe region holds real data.If
BNGE_FW_CAP_MBUF_DATAis set and either MBUF query succeeds, the version becomes 4. That happens in all of these cases:- the PCIe stats were v1 sized
- the PCIe stats were v2 sized or full v2
-HWRM_PCIE_QSTATSfailed
- PCIe stats were never queried becauseBNGE_STATS_CAP_PCIEisn't setThe ethtool core zero-fills the buffer. A decoder that sees version 4 would treat the unwritten tail as real TL credit and latency histogram values.
bnxt_get_regs()uses the same 1/2/3 scheme but never overwrites it.A related point: when
bnge_dbg_hwrm_rd_reg()fails, the only sign is thenetdev_warn()above. The zeroed0x3110byte PXP region is still reported as register contents, and neither version nor len tells userspace about the failure. bnxt behaves the same way today.Quoted 2 lines
drivers/net/ethernet/broadcom/bnge/bnge_ethtool.c +2
-0+ } +}[ ... ]
Quoted 4 lines
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +0
-0[ ... ]
Quoted 7 lines
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +3
-0@@ -597,12 +598,45 @@ int bnge_hwrm_func_resc_qcaps(struct bnge_dev *bd)return rc; } +void bnge_hwrm_dbg_qcaps (struct bnge_dev *bd) +{ +struct hwrm_dbg_qcaps_output *resp;drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c int bnge_hwrm_func_resc_qcaps(struct bnge_dev *bd) · line 613
Quoted 10 lines
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +10
-0+struct hwrm_dbg_qcaps_input *req; +int rc; + + bd->fw_dbg_cap =0 ; +if (!(bd->fw_cap &BNGE_FW_CAP_DBG_QCAPS )) +return ; + +/* Discovery failure is treated as restricted so we never attempt +* direct register reads without confirmation from firmware. +*/ [Severity: Low]
Does the early return above match this comment? If firmware doesn't advertiseFUNC_QCAPS_RESP_FLAGS_DBG_QCAPS_CMD_SUPPORTED,fw_dbg_capstays 0.bnge_get_regs()only checks the restricted bit:if (!(bd->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_REG_ACCESS_RESTRICTED)) { ... rc = bnge_dbg_hwrm_rd_reg(bd, 0, BNGE_PXP_REG_LEN / 4, _p);So
HWRM_DBG_READ_DIRECTis sent for0xc44words in exactly the case where firmware has confirmed the least. If firmware rejects the request, every ethtool -d logs "Failed to read PXP regs".
bnxt_hwrm_dbg_qcaps()also treats missingDBG_QCAPSas unrestricted. Should the comment be changed to match? Or should this branch also setDBG_QCAPS_RESP_FLAGS_REG_ACCESS_RESTRICTED?drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c int bnge_hwrm_func_resc_qcaps(struct bnge_dev *bd) · line 618
Quoted 5 lines
drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c +5
-0+ rc =bnge_hwrm_req_init (bd, req,HWRM_DBG_QCAPS ); +if (rc) { + bd->fw_dbg_cap =DBG_QCAPS_RESP_FLAGS_REG_ACCESS_RESTRICTED ; +return ; + }
Quoted 4 lines
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124100751.179270-1-ramakrishna.koduri%40broadcom.com
pw-bot: cr