Lines Matching full:bp

23 static int bnxt_ptp_cfg_settime(struct bnxt *bp, u64 time)  in bnxt_ptp_cfg_settime()  argument
28 rc = hwrm_req_init(bp, req, HWRM_FUNC_PTP_CFG); in bnxt_ptp_cfg_settime()
34 return hwrm_req_send(bp, req); in bnxt_ptp_cfg_settime()
67 if (BNXT_PTP_USE_RTC(ptp->bp)) in bnxt_ptp_settime()
68 return bnxt_ptp_cfg_settime(ptp->bp, ns); in bnxt_ptp_settime()
77 static int __bnxt_refclk_read(struct bnxt *bp, struct ptp_system_timestamp *sts, in __bnxt_refclk_read() argument
80 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in __bnxt_refclk_read()
83 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) in __bnxt_refclk_read()
86 high_before = readl(bp->bar0 + ptp->refclk_mapped_regs[1]); in __bnxt_refclk_read()
88 low = readl(bp->bar0 + ptp->refclk_mapped_regs[0]); in __bnxt_refclk_read()
90 high_now = readl(bp->bar0 + ptp->refclk_mapped_regs[1]); in __bnxt_refclk_read()
93 low = readl(bp->bar0 + ptp->refclk_mapped_regs[0]); in __bnxt_refclk_read()
101 static int bnxt_refclk_read(struct bnxt *bp, struct ptp_system_timestamp *sts, in bnxt_refclk_read() argument
104 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_refclk_read()
110 rc = __bnxt_refclk_read(bp, sts, ns); in bnxt_refclk_read()
115 static int bnxt_refclk_read_low(struct bnxt *bp, struct ptp_system_timestamp *sts, in bnxt_refclk_read_low() argument
118 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_refclk_read_low()
124 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_refclk_read_low()
130 *low = readl(bp->bar0 + ptp->refclk_mapped_regs[0]); in bnxt_refclk_read_low()
137 static void bnxt_ptp_get_current_time(struct bnxt *bp) in bnxt_ptp_get_current_time() argument
139 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_get_current_time()
144 bnxt_refclk_read(bp, NULL, &ptp->current_time); in bnxt_ptp_get_current_time()
147 static int bnxt_hwrm_port_ts_query(struct bnxt *bp, u32 flags, u64 *ts, in bnxt_hwrm_port_ts_query() argument
154 rc = hwrm_req_init(bp, req, HWRM_PORT_TS_QUERY); in bnxt_hwrm_port_ts_query()
161 struct bnxt_ptp_tx_req *txts_req = &bp->ptp_cfg->txts_req[slot]; in bnxt_hwrm_port_ts_query()
172 resp = hwrm_req_hold(bp, req); in bnxt_hwrm_port_ts_query()
174 rc = hwrm_req_send_silent(bp, req); in bnxt_hwrm_port_ts_query()
177 hwrm_req_drop(bp, req); in bnxt_hwrm_port_ts_query()
191 rc = bnxt_refclk_read_low(ptp->bp, sts, &low); in bnxt_ptp_gettimex()
202 void bnxt_ptp_update_current_time(struct bnxt *bp) in bnxt_ptp_update_current_time() argument
204 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_update_current_time()
206 bnxt_refclk_read(ptp->bp, NULL, &ptp->current_time); in bnxt_ptp_update_current_time()
215 rc = hwrm_req_init(ptp->bp, req, HWRM_PORT_MAC_CFG); in bnxt_ptp_adjphc()
222 rc = hwrm_req_send(ptp->bp, req); in bnxt_ptp_adjphc()
224 netdev_err(ptp->bp->dev, "ptp adjphc failed. rc = %x\n", rc); in bnxt_ptp_adjphc()
226 bnxt_ptp_update_current_time(ptp->bp); in bnxt_ptp_adjphc()
238 if (BNXT_PTP_USE_RTC(ptp->bp)) in bnxt_ptp_adjtime()
247 static int bnxt_ptp_adjfine_rtc(struct bnxt *bp, long scaled_ppm) in bnxt_ptp_adjfine_rtc() argument
253 rc = hwrm_req_init(bp, req, HWRM_PORT_MAC_CFG); in bnxt_ptp_adjfine_rtc()
259 rc = hwrm_req_send(bp, req); in bnxt_ptp_adjfine_rtc()
261 netdev_err(bp->dev, in bnxt_ptp_adjfine_rtc()
270 struct bnxt *bp = ptp->bp; in bnxt_ptp_adjfine() local
273 if (!BNXT_MH(bp)) in bnxt_ptp_adjfine()
274 return bnxt_ptp_adjfine_rtc(bp, scaled_ppm); in bnxt_ptp_adjfine()
283 void bnxt_ptp_pps_event(struct bnxt *bp, u32 data1, u32 data2) in bnxt_ptp_pps_event() argument
285 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_pps_event()
305 ptp_clock_event(bp->ptp_cfg->ptp_clock, &event); in bnxt_ptp_pps_event()
308 static int bnxt_ptp_cfg_pin(struct bnxt *bp, u8 pin, u8 usage) in bnxt_ptp_cfg_pin() argument
311 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_cfg_pin()
318 netdev_err(ptp->bp->dev, "1PPS: Invalid pin. Check pin-function configuration\n"); in bnxt_ptp_cfg_pin()
322 rc = hwrm_req_init(ptp->bp, req, HWRM_FUNC_PTP_PIN_CFG); in bnxt_ptp_cfg_pin()
336 rc = hwrm_req_send(ptp->bp, req); in bnxt_ptp_cfg_pin()
346 static int bnxt_ptp_cfg_event(struct bnxt *bp, u8 event) in bnxt_ptp_cfg_event() argument
351 rc = hwrm_req_init(bp, req, HWRM_FUNC_PTP_CFG); in bnxt_ptp_cfg_event()
357 return hwrm_req_send(bp, req); in bnxt_ptp_cfg_event()
360 int bnxt_ptp_cfg_tstamp_filters(struct bnxt *bp) in bnxt_ptp_cfg_tstamp_filters() argument
362 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_cfg_tstamp_filters()
369 rc = hwrm_req_init(bp, req, HWRM_PORT_MAC_CFG); in bnxt_ptp_cfg_tstamp_filters()
373 if (!(bp->fw_cap & BNXT_FW_CAP_RX_ALL_PKT_TS) && (ptp->tstamp_filters & in bnxt_ptp_cfg_tstamp_filters()
378 netdev_warn(bp->dev, "Unsupported FW for all RX pkts timestamp filter\n"); in bnxt_ptp_cfg_tstamp_filters()
385 rc = hwrm_req_send(bp, req); in bnxt_ptp_cfg_tstamp_filters()
387 bp->ptp_all_rx_tstamp = !!(ptp->tstamp_filters & in bnxt_ptp_cfg_tstamp_filters()
393 bp->ptp_all_rx_tstamp = 0; in bnxt_ptp_cfg_tstamp_filters()
394 netdev_warn(bp->dev, "Failed to configure HW packet timestamp filters\n"); in bnxt_ptp_cfg_tstamp_filters()
398 void bnxt_ptp_reapply_pps(struct bnxt *bp) in bnxt_ptp_reapply_pps() argument
400 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_reapply_pps()
405 if (!ptp || !(bp->fw_cap & BNXT_FW_CAP_PTP_PPS) || in bnxt_ptp_reapply_pps()
411 rc = bnxt_ptp_cfg_pin(bp, pin, pps->pins[pin].usage); in bnxt_ptp_reapply_pps()
413 rc = bnxt_ptp_cfg_event(bp, in bnxt_ptp_reapply_pps()
416 netdev_err(bp->dev, "1PPS: Failed to configure pin%d\n", in bnxt_ptp_reapply_pps()
429 rc = bnxt_refclk_read(ptp->bp, NULL, &cycles_now); in bnxt_get_target_cycles()
444 struct bnxt *bp = ptp->bp; in bnxt_ptp_perout_cfg() local
458 rc = hwrm_req_init(bp, req, HWRM_FUNC_PTP_CFG); in bnxt_ptp_perout_cfg()
473 return hwrm_req_send(bp, req); in bnxt_ptp_perout_cfg()
481 struct bnxt *bp = ptp->bp; in bnxt_ptp_enable() local
494 rc = bnxt_ptp_cfg_pin(bp, pin_id, BNXT_PPS_PIN_PPS_IN); in bnxt_ptp_enable()
497 rc = bnxt_ptp_cfg_event(bp, BNXT_PPS_EVENT_EXTERNAL); in bnxt_ptp_enable()
510 rc = bnxt_ptp_cfg_pin(bp, pin_id, BNXT_PPS_PIN_PPS_OUT); in bnxt_ptp_enable()
517 rc = bnxt_ptp_cfg_pin(bp, 0, BNXT_PPS_PIN_PPS_IN); in bnxt_ptp_enable()
520 rc = bnxt_ptp_cfg_event(bp, BNXT_PPS_EVENT_INTERNAL); in bnxt_ptp_enable()
525 netdev_err(ptp->bp->dev, "Unrecognized PIN function\n"); in bnxt_ptp_enable()
529 return bnxt_ptp_cfg_pin(bp, pin_id, BNXT_PPS_PIN_NONE); in bnxt_ptp_enable()
532 static int bnxt_hwrm_ptp_cfg(struct bnxt *bp) in bnxt_hwrm_ptp_cfg() argument
534 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_hwrm_ptp_cfg()
543 if (bp->fw_cap & BNXT_FW_CAP_RX_ALL_PKT_TS) in bnxt_hwrm_ptp_cfg()
560 return bnxt_ptp_cfg_tstamp_filters(bp); in bnxt_hwrm_ptp_cfg()
567 struct bnxt *bp = netdev_priv(dev); in bnxt_hwtstamp_set() local
573 ptp = bp->ptp_cfg; in bnxt_hwtstamp_set()
590 if (bp->fw_cap & BNXT_FW_CAP_RX_ALL_PKT_TS) { in bnxt_hwtstamp_set()
622 rc = bnxt_hwrm_ptp_cfg(bp); in bnxt_hwtstamp_set()
639 struct bnxt *bp = netdev_priv(dev); in bnxt_hwtstamp_get() local
642 ptp = bp->ptp_cfg; in bnxt_hwtstamp_get()
654 static int bnxt_map_regs(struct bnxt *bp, u32 *reg_arr, int count, int reg_win) in bnxt_map_regs() argument
665 writel(reg_base, bp->bar0 + win_off); in bnxt_map_regs()
669 static int bnxt_map_ptp_regs(struct bnxt *bp) in bnxt_map_ptp_regs() argument
671 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_map_ptp_regs()
676 if (BNXT_CHIP_P5(bp)) { in bnxt_map_ptp_regs()
677 rc = bnxt_map_regs(bp, reg_arr, 2, BNXT_PTP_GRC_WIN); in bnxt_map_ptp_regs()
685 if (bp->flags & BNXT_FLAG_CHIP_P7) { in bnxt_map_ptp_regs()
696 static void bnxt_unmap_ptp_regs(struct bnxt *bp) in bnxt_unmap_ptp_regs() argument
698 writel(0, bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + in bnxt_unmap_ptp_regs()
707 __bnxt_refclk_read(ptp->bp, NULL, &ns); in bnxt_cc_read()
711 static int bnxt_stamp_tx_skb(struct bnxt *bp, int slot) in bnxt_stamp_tx_skb() argument
713 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_stamp_tx_skb()
726 rc = bnxt_hwrm_port_ts_query(bp, PORT_TS_QUERY_REQ_FLAGS_PATH_TX, &ts, in bnxt_stamp_tx_skb()
739 netdev_warn_once(bp->dev, in bnxt_stamp_tx_skb()
754 struct bnxt *bp = ptp->bp; in bnxt_ptp_ts_aux_work() local
766 rc = bnxt_stamp_tx_skb(bp, cons); in bnxt_ptp_ts_aux_work()
781 bnxt_ptp_get_current_time(bp); in bnxt_ptp_ts_aux_work()
830 void bnxt_get_tx_ts_p5(struct bnxt *bp, struct sk_buff *skb, u16 prod) in bnxt_get_tx_ts_p5() argument
832 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_get_tx_ts_p5()
843 int bnxt_get_rx_ts_p5(struct bnxt *bp, u64 *ts, u32 pkt_ts) in bnxt_get_rx_ts_p5() argument
845 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_get_rx_ts_p5()
855 void bnxt_tx_ts_cmp(struct bnxt *bp, struct bnxt_napi *bnapi, in bnxt_tx_ts_cmp() argument
859 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_tx_ts_cmp()
869 tx_buf = &txr->tx_buf_ring[RING_TX(bp, cons)]; in bnxt_tx_ts_cmp()
872 netdev_err(bp->dev, in bnxt_tx_ts_cmp()
915 static int bnxt_ptp_pps_init(struct bnxt *bp) in bnxt_ptp_pps_init() argument
919 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_pps_init()
926 rc = hwrm_req_init(bp, req, HWRM_FUNC_PTP_PIN_QCFG); in bnxt_ptp_pps_init()
930 resp = hwrm_req_hold(bp, req); in bnxt_ptp_pps_init()
931 rc = hwrm_req_send(bp, req); in bnxt_ptp_pps_init()
933 hwrm_req_drop(bp, req); in bnxt_ptp_pps_init()
945 hwrm_req_drop(bp, req); in bnxt_ptp_pps_init()
965 hwrm_req_drop(bp, req); in bnxt_ptp_pps_init()
976 static bool bnxt_pps_config_ok(struct bnxt *bp) in bnxt_pps_config_ok() argument
978 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_pps_config_ok()
980 return !(bp->fw_cap & BNXT_FW_CAP_PTP_PPS) == !ptp->ptp_info.pin_config; in bnxt_pps_config_ok()
983 static void bnxt_ptp_timecounter_init(struct bnxt *bp, bool init_tc) in bnxt_ptp_timecounter_init() argument
985 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_timecounter_init()
992 if (BNXT_MH(bp)) { in bnxt_ptp_timecounter_init()
1018 int bnxt_ptp_init_rtc(struct bnxt *bp, bool phc_cfg) in bnxt_ptp_init_rtc() argument
1025 if (!bp->ptp_cfg || !BNXT_PTP_USE_RTC(bp)) in bnxt_ptp_init_rtc()
1031 rc = bnxt_ptp_cfg_settime(bp, ns); in bnxt_ptp_init_rtc()
1035 rc = bnxt_hwrm_port_ts_query(bp, PORT_TS_QUERY_REQ_FLAGS_CURRENT_TIME, in bnxt_ptp_init_rtc()
1040 write_seqlock_irqsave(&bp->ptp_cfg->ptp_lock, flags); in bnxt_ptp_init_rtc()
1041 bnxt_ptp_rtc_timecounter_init(bp->ptp_cfg, ns); in bnxt_ptp_init_rtc()
1042 write_sequnlock_irqrestore(&bp->ptp_cfg->ptp_lock, flags); in bnxt_ptp_init_rtc()
1047 static void bnxt_ptp_free(struct bnxt *bp) in bnxt_ptp_free() argument
1049 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_free()
1059 int bnxt_ptp_init(struct bnxt *bp) in bnxt_ptp_init() argument
1061 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_init()
1067 rc = bnxt_map_ptp_regs(bp); in bnxt_ptp_init()
1071 if (ptp->ptp_clock && bnxt_pps_config_ok(bp)) in bnxt_ptp_init()
1074 bnxt_ptp_free(bp); in bnxt_ptp_init()
1080 if (BNXT_PTP_USE_RTC(bp)) { in bnxt_ptp_init()
1081 bnxt_ptp_timecounter_init(bp, false); in bnxt_ptp_init()
1082 rc = bnxt_ptp_init_rtc(bp, ptp->rtc_configured); in bnxt_ptp_init()
1086 bnxt_ptp_timecounter_init(bp, true); in bnxt_ptp_init()
1087 bnxt_ptp_adjfine_rtc(bp, 0); in bnxt_ptp_init()
1089 bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, true); in bnxt_ptp_init()
1092 if ((bp->fw_cap & BNXT_FW_CAP_PTP_PPS)) { in bnxt_ptp_init()
1093 if (bnxt_ptp_pps_init(bp)) in bnxt_ptp_init()
1094 netdev_err(bp->dev, "1pps not initialized, continuing without 1pps support\n"); in bnxt_ptp_init()
1096 ptp->ptp_clock = ptp_clock_register(&ptp->ptp_info, &bp->pdev->dev); in bnxt_ptp_init()
1109 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) { in bnxt_ptp_init()
1110 bnxt_refclk_read(bp, NULL, &ptp->current_time); in bnxt_ptp_init()
1118 bnxt_ptp_free(bp); in bnxt_ptp_init()
1119 bnxt_unmap_ptp_regs(bp); in bnxt_ptp_init()
1123 void bnxt_ptp_clear(struct bnxt *bp) in bnxt_ptp_clear() argument
1125 struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; in bnxt_ptp_clear()
1137 bnxt_unmap_ptp_regs(bp); in bnxt_ptp_clear()