Add PHC register mapping, RTC initialization, refclk read with
FW-reset serialization, and sbinuptime-based calibration to convert
the raw hardware timestamp carried in RX completions into an mbuf
timestamp. Advertise IFCAP_HWRXTSTMP, configure the RX timestamp
filter in bnxt_init(), and drain the calibration callout on stop.
Check HWRM_FUNC_QCAPS_OUTPUT_FLAGS_PTP_SUPPORTED in
bnxt_hwrm_func_qcaps() so the capability bit PTP is gated on actually
gets set, without which PTP never armed on real hardware.
Details
Diff Detail
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
- In addition to the inline comments, please make the code conform to style(9)
- There do not seem to be licenses on the new files
Don't we need to re-calibrate after down/up? Eg, bnxt_stop() drains the callout and clears rx_ts_enabled, but never resets clbr_done or the clbr_points[]. On the next bnxt_init(), bnxt_reset_calibration_callout() sees clbr_done != 0 and takes the callout_reset_sbt_curcpu() branch instead of calibrating so there's a full second during which packets are interpolated against very old ref. points.
| sys/dev/bnxt/bnxt_en/bnxt.h | ||
|---|---|---|
| 1487 | Can you clean this up? There are multiple definitions of this (and readl) in bnxt_re/main/c and bnxt_en/if_bnxt.c | |
| sys/dev/bnxt/bnxt_en/bnxt_ptp.c | ||
| 38 | Does this need a htole64? | |
| 52 | Are you sure you want getnanotime() and not just nanotime? Note that getnanotime uses a cached less precise, but faster to obtain, time. While nanotime always queries the timecounter for a very accurate time. | |
| 86 | Why a spin mutex? That's only needed in a hw interrupt context that cannot sleep. Network drivers typically do not run in that context on freebsd and can use a normal mutx. | |
| 93 | Seems to be a bit of a misnomer, since it doesn't deal with mbufs. That would be done at the iflib level. Can you please also include me on the review that adds rx timestamp support to iflib? Unless I'm missing something, I don't think iflib supports this now | |
| 121 | Do we need to worry about wrapping here? | |
| 128 | If i've got my units correct, we can overflow after 4.3s, which could be triggered by a few missed callouts. Maybe bound hw_clocks against hw_clk_div | |
| 129 | Is there any way to differentiate an uncalibrated (which is what i think hw_clk_div == 0 means) clock from a valid timestamp of 0? | |
| 310 | Don't you need to initialize this? bnxt_hwrm_cmd_hdr_init only fills in req_type, cmpl_ring, target_id, resp_addr. Every other field is stack garbage. I'm worried you could misconfigure the mac by accident. | |
| sys/dev/bnxt/bnxt_en/if_bnxt.c | ||
| 2904 | This is kind of weird. If we fail, we're going to return rc, and the attach will fail. But since rc is not checked, all the INIT* stuff below runs. All other failure cases jump to failed. Please either do that, or re-set rc to 0 if failure here is not fatal. | |
| sys/dev/bnxt/bnxt_en/bnxt.h | ||
|---|---|---|
| 1487 | Sure, will clean up. | |
| sys/dev/bnxt/bnxt_en/bnxt_ptp.c | ||
| 38 | Yes, it needs htole64(), will fix up this. | |
| 52 | I think we can use nanotime(). | |
| 86 | bnxt_calibration_callout (which calls bnxt_refclk_read) can get scheduled from the LAPIC timer interrupt while the CPU is in the idle thread. panic: mtx_lock() by idle thread 0xff01000235a96bd0 on mutex 0xffff00fff01000235a96bd0 @ bnxt_ptp.c:119
acpi_cpu_idle() at acpi_cpu_idle+0x299/frame 0xfffffe006152adb0
KDB: enter: panic Stopped at kdb_enter+0x33: movq $0,0x117e392(%rip) | |
| 93 | Ok, will fix up this. | |
| 128 | Ack | |
| 310 | Ack, will fix up this. | |
| sys/dev/bnxt/bnxt_en/if_bnxt.c | ||
| 2904 | Ack, will fix up this. | |
| sys/dev/bnxt/bnxt_en/bnxt_ptp.c | ||
|---|---|---|
| 93 | Here is the iflib changes to support rx timestamp: https://reviews.freebsd.org/D58638 | |
| sys/dev/bnxt/bnxt_en/bnxt_ptp.c | ||
|---|---|---|
| 206 | There is only one caller for this. Maybe just call bnxt_ptp_get_current_time() directly | |
| 239 | This is redundant.. you are checking that above to get into this block | |
| 317 | is this re-registering the driver? is that intended? | |
| 342 | FreeBSD error returns should not be negative | |
| sys/dev/bnxt/bnxt_en/bnxt_ptp.h | ||
| 37–42 | Aren't these already in bnxt.h? | |
| 79 | i think this is unused | |