Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'bnxt_en-misc-fixes'

Michael Chan says:

====================
bnxt_en: Misc. fixes

4 miscellaneous driver fixes covering PM resume, SKB recycling,
wrong return value check, and PTP HWTSTAMP_FILTER_ALL.
====================

Link: https://lore.kernel.org/r/20231208001658.14230-1-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+44 -39
+28 -10
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 1748 1748 static void bnxt_deliver_skb(struct bnxt *bp, struct bnxt_napi *bnapi, 1749 1749 struct sk_buff *skb) 1750 1750 { 1751 + skb_mark_for_recycle(skb); 1752 + 1751 1753 if (skb->dev != bp->dev) { 1752 1754 /* this packet belongs to a vf-rep */ 1753 1755 bnxt_vf_rep_rx(bp, skb); 1754 1756 return; 1755 1757 } 1756 1758 skb_record_rx_queue(skb, bnapi->index); 1757 - skb_mark_for_recycle(skb); 1758 1759 napi_gro_receive(&bnapi->napi, skb); 1760 + } 1761 + 1762 + static bool bnxt_rx_ts_valid(struct bnxt *bp, u32 flags, 1763 + struct rx_cmp_ext *rxcmp1, u32 *cmpl_ts) 1764 + { 1765 + u32 ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp); 1766 + 1767 + if (BNXT_PTP_RX_TS_VALID(flags)) 1768 + goto ts_valid; 1769 + if (!bp->ptp_all_rx_tstamp || !ts || !BNXT_ALL_RX_TS_VALID(flags)) 1770 + return false; 1771 + 1772 + ts_valid: 1773 + *cmpl_ts = ts; 1774 + return true; 1759 1775 } 1760 1776 1761 1777 /* returns the following: ··· 1799 1783 struct sk_buff *skb; 1800 1784 struct xdp_buff xdp; 1801 1785 u32 flags, misc; 1786 + u32 cmpl_ts; 1802 1787 void *data; 1803 1788 int rc = 0; 1804 1789 ··· 2022 2005 } 2023 2006 } 2024 2007 2025 - if (unlikely((flags & RX_CMP_FLAGS_ITYPES_MASK) == 2026 - RX_CMP_FLAGS_ITYPE_PTP_W_TS) || bp->ptp_all_rx_tstamp) { 2008 + if (bnxt_rx_ts_valid(bp, flags, rxcmp1, &cmpl_ts)) { 2027 2009 if (bp->flags & BNXT_FLAG_CHIP_P5) { 2028 - u32 cmpl_ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp); 2029 2010 u64 ns, ts; 2030 2011 2031 2012 if (!bnxt_get_rx_ts_p5(bp, &ts, cmpl_ts)) { ··· 10746 10731 bnxt_free_mem(bp, irq_re_init); 10747 10732 } 10748 10733 10749 - int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) 10734 + void bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) 10750 10735 { 10751 - int rc = 0; 10752 - 10753 10736 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { 10754 10737 /* If we get here, it means firmware reset is in progress 10755 10738 * while we are trying to close. We can safely proceed with ··· 10762 10749 10763 10750 #ifdef CONFIG_BNXT_SRIOV 10764 10751 if (bp->sriov_cfg) { 10752 + int rc; 10753 + 10765 10754 rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait, 10766 10755 !bp->sriov_cfg, 10767 10756 BNXT_SRIOV_CFG_WAIT_TMO); 10768 - if (rc) 10769 - netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete!\n"); 10757 + if (!rc) 10758 + netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete, proceeding to close!\n"); 10759 + else if (rc < 0) 10760 + netdev_warn(bp->dev, "SRIOV config operation interrupted, proceeding to close!\n"); 10770 10761 } 10771 10762 #endif 10772 10763 __bnxt_close_nic(bp, irq_re_init, link_re_init); 10773 - return rc; 10774 10764 } 10775 10765 10776 10766 static int bnxt_close(struct net_device *dev) ··· 13955 13939 rc = bnxt_hwrm_func_qcaps(bp); 13956 13940 if (rc) 13957 13941 goto resume_exit; 13942 + 13943 + bnxt_clear_reservations(bp, true); 13958 13944 13959 13945 if (bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, false)) { 13960 13946 rc = -ENODEV;
+8 -2
drivers/net/ethernet/broadcom/bnxt/bnxt.h
··· 161 161 #define RX_CMP_FLAGS_ERROR (1 << 6) 162 162 #define RX_CMP_FLAGS_PLACEMENT (7 << 7) 163 163 #define RX_CMP_FLAGS_RSS_VALID (1 << 10) 164 - #define RX_CMP_FLAGS_UNUSED (1 << 11) 164 + #define RX_CMP_FLAGS_PKT_METADATA_PRESENT (1 << 11) 165 165 #define RX_CMP_FLAGS_ITYPES_SHIFT 12 166 166 #define RX_CMP_FLAGS_ITYPES_MASK 0xf000 167 167 #define RX_CMP_FLAGS_ITYPE_UNKNOWN (0 << 12) ··· 187 187 188 188 __le32 rx_cmp_rss_hash; 189 189 }; 190 + 191 + #define BNXT_PTP_RX_TS_VALID(flags) \ 192 + (((flags) & RX_CMP_FLAGS_ITYPES_MASK) == RX_CMP_FLAGS_ITYPE_PTP_W_TS) 193 + 194 + #define BNXT_ALL_RX_TS_VALID(flags) \ 195 + !((flags) & RX_CMP_FLAGS_PKT_METADATA_PRESENT) 190 196 191 197 #define RX_CMP_HASH_VALID(rxcmp) \ 192 198 ((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID)) ··· 2381 2375 int bnxt_half_open_nic(struct bnxt *bp); 2382 2376 void bnxt_half_close_nic(struct bnxt *bp); 2383 2377 void bnxt_reenable_sriov(struct bnxt *bp); 2384 - int bnxt_close_nic(struct bnxt *, bool, bool); 2378 + void bnxt_close_nic(struct bnxt *, bool, bool); 2385 2379 void bnxt_get_ring_err_stats(struct bnxt *bp, 2386 2380 struct bnxt_total_ring_err_stats *stats); 2387 2381 int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words,
+2 -9
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
··· 449 449 return -ENODEV; 450 450 } 451 451 bnxt_ulp_stop(bp); 452 - if (netif_running(bp->dev)) { 453 - rc = bnxt_close_nic(bp, true, true); 454 - if (rc) { 455 - NL_SET_ERR_MSG_MOD(extack, "Failed to close"); 456 - dev_close(bp->dev); 457 - rtnl_unlock(); 458 - break; 459 - } 460 - } 452 + if (netif_running(bp->dev)) 453 + bnxt_close_nic(bp, true, true); 461 454 bnxt_vf_reps_free(bp); 462 455 rc = bnxt_hwrm_func_drv_unrgtr(bp); 463 456 if (rc) {
+4 -15
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
··· 165 165 reset_coalesce: 166 166 if (test_bit(BNXT_STATE_OPEN, &bp->state)) { 167 167 if (update_stats) { 168 - rc = bnxt_close_nic(bp, true, false); 169 - if (!rc) 170 - rc = bnxt_open_nic(bp, true, false); 168 + bnxt_close_nic(bp, true, false); 169 + rc = bnxt_open_nic(bp, true, false); 171 170 } else { 172 171 rc = bnxt_hwrm_set_coal(bp); 173 172 } ··· 971 972 * before PF unload 972 973 */ 973 974 } 974 - rc = bnxt_close_nic(bp, true, false); 975 - if (rc) { 976 - netdev_err(bp->dev, "Set channel failure rc :%x\n", 977 - rc); 978 - return rc; 979 - } 975 + bnxt_close_nic(bp, true, false); 980 976 } 981 977 982 978 if (sh) { ··· 4036 4042 bnxt_run_fw_tests(bp, test_mask, &test_results); 4037 4043 } else { 4038 4044 bnxt_ulp_stop(bp); 4039 - rc = bnxt_close_nic(bp, true, false); 4040 - if (rc) { 4041 - etest->flags |= ETH_TEST_FL_FAILED; 4042 - bnxt_ulp_start(bp, rc); 4043 - return; 4044 - } 4045 + bnxt_close_nic(bp, true, false); 4045 4046 bnxt_run_fw_tests(bp, test_mask, &test_results); 4046 4047 4047 4048 buf[BNXT_MACLPBK_TEST_IDX] = 1;
+2 -3
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
··· 521 521 522 522 if (netif_running(bp->dev)) { 523 523 if (ptp->rx_filter == HWTSTAMP_FILTER_ALL) { 524 - rc = bnxt_close_nic(bp, false, false); 525 - if (!rc) 526 - rc = bnxt_open_nic(bp, false, false); 524 + bnxt_close_nic(bp, false, false); 525 + rc = bnxt_open_nic(bp, false, false); 527 526 } else { 528 527 bnxt_ptp_cfg_tstamp_filters(bp); 529 528 }