gve: Implement XDP HW RX Timestamping support for DQ
Subsystems (4)
[email protected]
maintainercover gve: Implement XDP HW RX Timestamping support for DQ
From: Tim Hostetler <[email protected]>
This patch series adds support for bpf_xdp_metadata_rx_timestamp from an XDP program loaded into the driver on its own or bound to an XSK. This is only supported for DQ.
Tim Hostetler (4):
gve: Move ptp_schedule_worker to gve_init_clock
gve: Wrap struct xdp_buff
gve: Prepare bpf_xdp_metadata_rx_timestamp support
gve: Add Rx HWTS metadata to AF_XDP ZC mode
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
[email protected]
maintainerPATCH 1/4 gve: Move ptp_schedule_worker to gve_init_clock
From: Tim Hostetler <[email protected]>
Previously, gve had been only initializing ptp aux work when hardware timestamping was initialized through ndo_hwtsatmp_set. As this patch series introduces XDP hardware timestamp metadata which will require the ptp aux work, the work can't be gated on the kernel_hwtstamp_config being set and must be initialized elsewhere.
For simplicity, ptp_schedule_worker is invoked right after the ptp_clock is registered with the kernel (which happens during gve_probe or following reset). The worker is scheduled in GVE_NIC_TS_SYNC_INTERVAL_MS as the synchronous call to gve_clock_nic_ts_read makes the worker redundant if scheduled immediately.
If gve cannot read the device clock immediately, it errors out of gve_init_clock.
--- drivers/net/ethernet/google/gve/gve_main.c | 4 ---- drivers/net/ethernet/google/gve/gve_ptp.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-)
drivers/net/ethernet/google/gve/gve_main.c +0 -4
@@ -2188,10 +2188,6 @@ static int gve_set_ts_config(struct net_device *dev, } kernel_config->rx_filter =HWTSTAMP_FILTER_ALL ; -gve_clock_nic_ts_read (priv); -ptp_schedule_worker (priv->ptp->clock,0 ); - }else { -ptp_cancel_worker_sync (priv->ptp->clock); } priv->ts_config.rx_filter = kernel_config->rx_filter;
drivers/net/ethernet/google/gve/gve_ptp.c +12 -0
@@ -133,9 +133,21 @@ int gve_init_clock(struct gve_priv *priv) err = -ENOMEM ; goto release_ptp; } + err =gve_clock_nic_ts_read (priv); +if (err) { +dev_err (&priv->pdev->dev,"failed to read NIC clock %d\n" , err); + goto release_nic_ts_report; + } +ptp_schedule_worker (priv->ptp->clock, +msecs_to_jiffies (GVE_NIC_TS_SYNC_INTERVAL_MS ));return 0 ; +release_nic_ts_report: +dma_free_coherent (&priv->pdev->dev, +sizeof (struct gve_nic_ts_report ), + priv->nic_ts_report, priv->nic_ts_report_bus); + priv->nic_ts_report =NULL ; release_ptp:gve_ptp_release (priv);return err;
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
[email protected]
maintainerPATCH 2/4 gve: Wrap struct xdp_buff
In reply to [email protected]From: Tim Hostetler <[email protected]>
RX timestamping will need to keep track of extra temporary information per-packet. In preparation for this, introduce gve_xdp_buff to wrap the xdp_buff. This is similar in function to stmmac_xdp_buff and ice_xdp_buff.
--- drivers/net/ethernet/google/gve/gve.h | 5 +++++ drivers/net/ethernet/google/gve/gve_rx_dqo.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-)
drivers/net/ethernet/google/gve/gve.h +5 -0
@@ -205,6 +205,11 @@ struct gve_rx_buf_state_dqo {s16 next; }; +/* Wrapper for XDP Rx metadata */ +struct gve_xdp_buff { +struct xdp_buff xdp; +}; +/* `head` and `tail` are indices into an array, or -1 if empty. */ struct gve_index_list {s16 head;
drivers/net/ethernet/google/gve/gve_rx_dqo.c +8 -8
@@ -840,23 +840,23 @@ static int gve_rx_dqo(struct napi_struct *napi, struct gve_rx_ring *rx, }if (xprog) { -struct xdp_buff xdp; +struct gve_xdp_buff gve_xdp;void *old_data;int xdp_act; -xdp_init_buff (&xdp, buf_state->page_info.buf_size, +xdp_init_buff (&gve_xdp.xdp, buf_state->page_info.buf_size, &rx->xdp_rxq); -xdp_prepare_buff (&xdp, +xdp_prepare_buff (&gve_xdp.xdp, buf_state->page_info.page_address + buf_state->page_info.page_offset, buf_state->page_info.pad, buf_len, false); - old_data = xdp.data; - xdp_act =bpf_prog_run_xdp (xprog, &xdp); - buf_state->page_info.pad += xdp.data - old_data; - buf_len = xdp.data_end - xdp.data; + old_data = gve_xdp.xdp.data; + xdp_act =bpf_prog_run_xdp (xprog, &gve_xdp.xdp); + buf_state->page_info.pad += gve_xdp.xdp.data - old_data; + buf_len = gve_xdp.xdp.data_end - gve_xdp.xdp.data;if (xdp_act !=XDP_PASS ) { -gve_xdp_done_dqo (priv, rx, &xdp, xprog, xdp_act, +gve_xdp_done_dqo (priv, rx, &gve_xdp.xdp, xprog, xdp_act, buf_state);return 0 ; }
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
[email protected]
maintainerPATCH 3/4 gve: Prepare bpf_xdp_metadata_rx_timestamp support
In reply to [email protected]From: Tim Hostetler <[email protected]>
Support populating XDP RX metadata with hardware RX timestamps. This patch utilizes the same underlying logic to calculate hardware timestamps as the regular RX path.
xdp_metadata_ops is registered with the net_device in a future patch.
gve_rx_calculate_hwtstamp was pulled out so as to not duplicate logic between gve_xdp_rx_timestamp and gve_rx_hwtstamp.
--- drivers/net/ethernet/google/gve/gve.h | 2 + drivers/net/ethernet/google/gve/gve_dqo.h | 1 + drivers/net/ethernet/google/gve/gve_rx_dqo.c | 41 +++++++++++++++----- 3 files changed, 34 insertions(+), 10 deletions(-)
drivers/net/ethernet/google/gve/gve.h +2 -0
@@ -208,6 +208,8 @@ struct gve_rx_buf_state_dqo {/* Wrapper for XDP Rx metadata */ struct gve_xdp_buff {struct xdp_buff xdp; +struct gve_priv *gve; +const struct gve_rx_compl_desc_dqo *compl_desc; };/* `head` and `tail` are indices into an array, or -1 if empty. */
drivers/net/ethernet/google/gve/gve_dqo.h +1 -0
@@ -36,6 +36,7 @@ netdev_tx_t gve_tx_dqo(struct sk_buff *skb, struct net_device *dev);netdev_features_t gve_features_check_dqo (struct sk_buff *skb,struct net_device *dev,netdev_features_t features); +int gve_xdp_rx_timestamp (const struct xdp_md *_ctx,u64 *timestamp);bool gve_tx_poll_dqo (struct gve_notify_block *block,bool do_clean);bool gve_xdp_poll_dqo (struct gve_notify_block *block);bool gve_xsk_tx_poll_dqo (struct gve_notify_block *block,int budget);
drivers/net/ethernet/google/gve/gve_rx_dqo.c +31 -10
57 lines not on this page · raw message
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
[email protected]
maintainerPATCH 4/4 gve: Add Rx HWTS metadata to AF_XDP ZC mode
In reply to [email protected]From: Tim Hostetler <[email protected]>
By overlaying the struct gve_xdp_buff on top of the struct xdp_buff_xsk that AF_XDP utilizes, the driver records the 32 bit timestamp via the completion descriptor and the cached 64 bit NIC timestamp via gve_priv.
The driver's implementation of xmo_rx_timestamp extends the timestamp to the full and up to date 64 bit timestamp and returns it to the user.
gve_rx_xsk_dqo is modified to accept a pointer to the completion descriptor and no longer takes a buf_len explicitly as it can be pulled out of the descriptor.
With this patch gve now supports bpf_xdp_metadata_rx_timestamp.
--- drivers/net/ethernet/google/gve/gve_main.c | 7 +++++++ drivers/net/ethernet/google/gve/gve_rx_dqo.c | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-)
drivers/net/ethernet/google/gve/gve_main.c +7 -0
@@ -2348,6 +2348,10 @@ static void gve_set_netdev_xdp_features(struct gve_priv *priv)xdp_set_features_flag_locked (priv->dev, xdp_features); } +static const struct xdp_metadata_ops gve_xdp_metadata_ops = { + .xmo_rx_timestamp = gve_xdp_rx_timestamp, +}; +static int gve_init_priv (struct gve_priv *priv,bool skip_describe_device) {int num_ntfy;
@@ -2443,6 +2447,9 @@ static int gve_init_priv(struct gve_priv *priv, bool skip_describe_device) }gve_set_netdev_xdp_features (priv); +if (!gve_is_gqi (priv)) + priv->dev->xdp_metadata_ops = &gve_xdp_metadata_ops; + err =gve_setup_device_resources (priv);if (err) goto err_free_xsk_bitmap;
drivers/net/ethernet/google/gve/gve_rx_dqo.c +14 -2
@@ -240,6 +240,11 @@ int gve_rx_alloc_ring_dqo(struct gve_priv *priv, rx->rx_headroom =0 ; } +/* struct gve_xdp_buff is overlaid on struct xdp_buff_xsk and utilizes +* the 24 byte field cb to store gve specific data. +*/ +XSK_CHECK_PRIV_TYPE (struct gve_xdp_buff ); + rx->dqo.num_buf_states = cfg->raw_addressing ? buffer_queue_slots :gve_get_rx_pages_per_qpl_dqo (cfg->ring_size); rx->dqo.buf_states = kvcalloc_node(rx->dqo.num_buf_states,
@@ -701,16 +706,23 @@ static void gve_xdp_done_dqo(struct gve_priv *priv, struct gve_rx_ring *rx, }static int gve_rx_xsk_dqo (struct napi_struct *napi,struct gve_rx_ring *rx, -struct gve_rx_buf_state_dqo *buf_state,int buf_len, +const struct gve_rx_compl_desc_dqo *compl_desc, +struct gve_rx_buf_state_dqo *buf_state,struct bpf_prog *xprog) {struct xdp_buff *xdp = buf_state->xsk_buff; +int buf_len = compl_desc->packet_len;struct gve_priv *priv = rx->gve; +struct gve_xdp_buff *gve_xdp;int xdp_act; xdp->data_end = xdp->data + buf_len;xsk_buff_dma_sync_for_cpu (xdp); + gve_xdp = (void *)xdp; + gve_xdp->gve = priv; + gve_xdp->compl_desc = compl_desc; +if (xprog) { xdp_act =bpf_prog_run_xdp (xprog, xdp); buf_len = xdp->data_end - xdp->data;
@@ -800,7 +812,7 @@ static int gve_rx_dqo(struct napi_struct *napi, struct gve_rx_ring *rx, xprog =READ_ONCE (priv->xdp_prog);if (buf_state->xsk_buff) -return gve_rx_xsk_dqo (napi, rx, buf_state, buf_len, xprog); +return gve_rx_xsk_dqo (napi, rx, compl_desc, buf_state, xprog);/* Page might have not been used for awhile and was likely last written * by a different thread.
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 11 lines · On Fri, 14 Nov 2025 13:11:42 -0800 you wrote:
From: Tim Hostetler <[email protected]>
This patch series adds support for
bpf_xdp_metadata_rx_timestampfrom an XDP program loaded into the driver on its own or bound to an XSK. This is only supported for DQ.Tim Hostetler (4):
gve: Moveptp_schedule_workertogve_init_clock
gve: Wrap structxdp_buff
gve: Preparebpf_xdp_metadata_rx_timestampsupport
gve: Add Rx HWTS metadata toAF_XDPZC mode
Here is the summary with links:
- [net-next,1/4] gve: Move ptp_schedule_worker to gve_init_clock
https://git.kernel.org/netdev/net-next/c/46e7860ef941 - [net-next,2/4] gve: Wrap struct xdp_buff https://git.kernel.org/netdev/net-next/c/f356a66b87bb - [net-next,3/4] gve: Prepare bpf_xdp_metadata_rx_timestamp support https://git.kernel.org/netdev/net-next/c/66adaf102128 - [net-next,4/4] gve: Add Rx HWTS metadata to AF_XDP ZC mode https://git.kernel.org/netdev/net-next/c/1b42e07af1ee
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html