@@ -10064,6 +10064,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
}
}
+ bnxt_ptp_start(bp);
rc = bnxt_init_nic(bp, irq_re_init);
if (rc) {
netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc);
@@ -11154,6 +11155,11 @@ static void bnxt_timer(struct timer_list *t)
bnxt_queue_sp_work(bp);
}
+ if (bp->ptp_cfg && (bp->flags & BNXT_FLAG_CHIP_P5)) {
+ set_bit(BNXT_PTP_CURRENT_TIME_EVENT, &bp->sp_event);
+ bnxt_queue_sp_work(bp);
+ }
+
#ifdef CONFIG_RFS_ACCEL
if ((bp->flags & BNXT_FLAG_RFS) && bp->ntp_fltr_count) {
set_bit(BNXT_RX_NTP_FLTR_SP_EVENT, &bp->sp_event);
@@ -11558,6 +11564,9 @@ static void bnxt_sp_task(struct work_struct *work)
if (test_and_clear_bit(BNXT_RING_COAL_NOW_SP_EVENT, &bp->sp_event))
bnxt_chk_missed_irq(bp);
+ if (test_and_clear_bit(BNXT_PTP_CURRENT_TIME_EVENT, &bp->sp_event))
+ bnxt_ptp_get_current_time(bp);
+
if (test_and_clear_bit(BNXT_FW_ECHO_REQUEST_SP_EVENT, &bp->sp_event))
bnxt_fw_echo_reply(bp);
@@ -1957,6 +1957,7 @@ struct bnxt {
#define BNXT_FW_RESET_NOTIFY_SP_EVENT 18
#define BNXT_FW_EXCEPTION_SP_EVENT 19
#define BNXT_LINK_CFG_CHANGE_SP_EVENT 21
+#define BNXT_PTP_CURRENT_TIME_EVENT 22
#define BNXT_FW_ECHO_REQUEST_SP_EVENT 23
struct delayed_work fw_reset_task;
@@ -55,6 +55,17 @@ static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts,
return rc;
}
+int bnxt_ptp_get_current_time(struct bnxt *bp)
+{
+ u32 flags = PORT_TS_QUERY_REQ_FLAGS_CURRENT_TIME;
+ struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
+
+ if (!ptp)
+ return 0;
+ ptp->old_time = ptp->current_time;
+ return bnxt_hwrm_port_ts_query(bp, flags, &ptp->current_time, NULL);
+}
+
static int bnxt_ptp_gettimex(struct ptp_clock_info *ptp_info,
struct timespec64 *ts,
struct ptp_system_timestamp *sts)
@@ -236,6 +247,24 @@ static u64 bnxt_cc_read(const struct cyclecounter *cc)
return ns;
}
+int bnxt_ptp_start(struct bnxt *bp)
+{
+ struct bnxt_ptp_cfg *ptp = bp->ptp_cfg;
+ int rc = 0;
+
+ if (!ptp)
+ return 0;
+
+ if (bp->flags & BNXT_FLAG_CHIP_P5) {
+ u32 flags = PORT_TS_QUERY_REQ_FLAGS_CURRENT_TIME;
+
+ rc = bnxt_hwrm_port_ts_query(bp, flags, &ptp->current_time,
+ NULL);
+ ptp->old_time = ptp->current_time;
+ }
+ return rc;
+}
+
static const struct ptp_clock_info bnxt_ptp_caps = {
.owner = THIS_MODULE,
.name = "bnxt clock",
@@ -50,8 +50,10 @@ struct bnxt_ptp_cfg {
int rx_filter;
};
+int bnxt_ptp_get_current_time(struct bnxt *bp);
int bnxt_hwtstamp_set(struct net_device *dev, struct ifreq *ifr);
int bnxt_hwtstamp_get(struct net_device *dev, struct ifreq *ifr);
+int bnxt_ptp_start(struct bnxt *bp);
int bnxt_ptp_init(struct bnxt *bp);
void bnxt_ptp_clear(struct bnxt *bp);
#endif