Skip to content

Commit 1ae4cd3

Browse files
committed
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/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 9c25aae + c13e268 commit 1ae4cd3

File tree

5 files changed

+44
-39
lines changed

5 files changed

+44
-39
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,16 +1748,32 @@ static void bnxt_tpa_agg(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
17481748
static void bnxt_deliver_skb(struct bnxt *bp, struct bnxt_napi *bnapi,
17491749
struct sk_buff *skb)
17501750
{
1751+
skb_mark_for_recycle(skb);
1752+
17511753
if (skb->dev != bp->dev) {
17521754
/* this packet belongs to a vf-rep */
17531755
bnxt_vf_rep_rx(bp, skb);
17541756
return;
17551757
}
17561758
skb_record_rx_queue(skb, bnapi->index);
1757-
skb_mark_for_recycle(skb);
17581759
napi_gro_receive(&bnapi->napi, skb);
17591760
}
17601761

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;
1775+
}
1776+
17611777
/* returns the following:
17621778
* 1 - 1 packet successfully received
17631779
* 0 - successful TPA_START, packet not completed yet
@@ -1783,6 +1799,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
17831799
struct sk_buff *skb;
17841800
struct xdp_buff xdp;
17851801
u32 flags, misc;
1802+
u32 cmpl_ts;
17861803
void *data;
17871804
int rc = 0;
17881805

@@ -2005,10 +2022,8 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
20052022
}
20062023
}
20072024

2008-
if (unlikely((flags & RX_CMP_FLAGS_ITYPES_MASK) ==
2009-
RX_CMP_FLAGS_ITYPE_PTP_W_TS) || bp->ptp_all_rx_tstamp) {
2025+
if (bnxt_rx_ts_valid(bp, flags, rxcmp1, &cmpl_ts)) {
20102026
if (bp->flags & BNXT_FLAG_CHIP_P5) {
2011-
u32 cmpl_ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp);
20122027
u64 ns, ts;
20132028

20142029
if (!bnxt_get_rx_ts_p5(bp, &ts, cmpl_ts)) {
@@ -10731,10 +10746,8 @@ static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init,
1073110746
bnxt_free_mem(bp, irq_re_init);
1073210747
}
1073310748

10734-
int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
10749+
void bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
1073510750
{
10736-
int rc = 0;
10737-
1073810751
if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) {
1073910752
/* If we get here, it means firmware reset is in progress
1074010753
* while we are trying to close. We can safely proceed with
@@ -10749,15 +10762,18 @@ int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
1074910762

1075010763
#ifdef CONFIG_BNXT_SRIOV
1075110764
if (bp->sriov_cfg) {
10765+
int rc;
10766+
1075210767
rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait,
1075310768
!bp->sriov_cfg,
1075410769
BNXT_SRIOV_CFG_WAIT_TMO);
10755-
if (rc)
10756-
netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete!\n");
10770+
if (!rc)
10771+
netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete, proceeding to close!\n");
10772+
else if (rc < 0)
10773+
netdev_warn(bp->dev, "SRIOV config operation interrupted, proceeding to close!\n");
1075710774
}
1075810775
#endif
1075910776
__bnxt_close_nic(bp, irq_re_init, link_re_init);
10760-
return rc;
1076110777
}
1076210778

1076310779
static int bnxt_close(struct net_device *dev)
@@ -13940,6 +13956,8 @@ static int bnxt_resume(struct device *device)
1394013956
if (rc)
1394113957
goto resume_exit;
1394213958

13959+
bnxt_clear_reservations(bp, true);
13960+
1394313961
if (bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, false)) {
1394413962
rc = -ENODEV;
1394513963
goto resume_exit;

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ struct rx_cmp {
161161
#define RX_CMP_FLAGS_ERROR (1 << 6)
162162
#define RX_CMP_FLAGS_PLACEMENT (7 << 7)
163163
#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)
165165
#define RX_CMP_FLAGS_ITYPES_SHIFT 12
166166
#define RX_CMP_FLAGS_ITYPES_MASK 0xf000
167167
#define RX_CMP_FLAGS_ITYPE_UNKNOWN (0 << 12)
@@ -188,6 +188,12 @@ struct rx_cmp {
188188
__le32 rx_cmp_rss_hash;
189189
};
190190

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)
196+
191197
#define RX_CMP_HASH_VALID(rxcmp) \
192198
((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID))
193199

@@ -2375,7 +2381,7 @@ int bnxt_open_nic(struct bnxt *, bool, bool);
23752381
int bnxt_half_open_nic(struct bnxt *bp);
23762382
void bnxt_half_close_nic(struct bnxt *bp);
23772383
void bnxt_reenable_sriov(struct bnxt *bp);
2378-
int bnxt_close_nic(struct bnxt *, bool, bool);
2384+
void bnxt_close_nic(struct bnxt *, bool, bool);
23792385
void bnxt_get_ring_err_stats(struct bnxt *bp,
23802386
struct bnxt_total_ring_err_stats *stats);
23812387
int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words,

drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -449,15 +449,8 @@ static int bnxt_dl_reload_down(struct devlink *dl, bool netns_change,
449449
return -ENODEV;
450450
}
451451
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);
461454
bnxt_vf_reps_free(bp);
462455
rc = bnxt_hwrm_func_drv_unrgtr(bp);
463456
if (rc) {

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,8 @@ static int bnxt_set_coalesce(struct net_device *dev,
165165
reset_coalesce:
166166
if (test_bit(BNXT_STATE_OPEN, &bp->state)) {
167167
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);
171170
} else {
172171
rc = bnxt_hwrm_set_coal(bp);
173172
}
@@ -972,12 +971,7 @@ static int bnxt_set_channels(struct net_device *dev,
972971
* before PF unload
973972
*/
974973
}
975-
rc = bnxt_close_nic(bp, true, false);
976-
if (rc) {
977-
netdev_err(bp->dev, "Set channel failure rc :%x\n",
978-
rc);
979-
return rc;
980-
}
974+
bnxt_close_nic(bp, true, false);
981975
}
982976

983977
if (sh) {
@@ -4042,12 +4036,7 @@ static void bnxt_self_test(struct net_device *dev, struct ethtool_test *etest,
40424036
bnxt_run_fw_tests(bp, test_mask, &test_results);
40434037
} else {
40444038
bnxt_ulp_stop(bp);
4045-
rc = bnxt_close_nic(bp, true, false);
4046-
if (rc) {
4047-
etest->flags |= ETH_TEST_FL_FAILED;
4048-
bnxt_ulp_start(bp, rc);
4049-
return;
4050-
}
4039+
bnxt_close_nic(bp, true, false);
40514040
bnxt_run_fw_tests(bp, test_mask, &test_results);
40524041

40534042
buf[BNXT_MACLPBK_TEST_IDX] = 1;

drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,8 @@ static int bnxt_hwrm_ptp_cfg(struct bnxt *bp)
521521

522522
if (netif_running(bp->dev)) {
523523
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);
527526
} else {
528527
bnxt_ptp_cfg_tstamp_filters(bp);
529528
}

0 commit comments

Comments
 (0)