From nobody Fri Dec 19 20:16:07 2025 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B94D288C21 for ; Thu, 22 May 2025 23:57:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747958264; cv=none; b=rAaYDOOMB9RfKIHafgOay72gijnnXZPNZwpZbCMyOVmEfsLu3sSiqVThF6lByvnXPLab9SUAn+uioR6qmwqAZ35WpjoUMrixIcoOKuRh8Vj+9wJszo1mHS7Ll1Dmv49YwPO47Wp+wtohNRypFWBuZCScMh4/I+z8cTNFFUYtJnw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747958264; c=relaxed/simple; bh=VvSe3oZkCTrXqGgrSEWCskBQ1CutMi4Wwcy6Jwf3/VM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Rp6uC4WV+T8bVKjjr6yRc4wi702aMMyQraEX3zjvTx3D2crU4dhZbQBhbW7+TJQjpzXQ6kYN8IY+fi//wPJu1SPrcnCo8ZrYL83XLFDdlj6aO8Pk62pNZ81vUaiN34FABvJu0LpYdbYDtverKzRUsrXxcIkw0gvOkcRXsa1IbGI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--hramamurthy.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=xUpGgWhd; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--hramamurthy.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="xUpGgWhd" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-740adfc7babso7145339b3a.0 for ; Thu, 22 May 2025 16:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1747958262; x=1748563062; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Rdc0Nn59D98Yn70bYr/mCjhLlbBJUI2N5zWeAoQlNPQ=; b=xUpGgWhdygp7P+4tjl/nSmoSudbl9AbAODE/kEiLx5dwx2VGKRSf+m1k6IccFSCHmO kexvs/s9mq+ceLQ71/CQea2a8vkiXeED+zHy/AmRO95Cl9QEyUOgxvhlxoXOA5INga8c OTXMYgVfzVMTgFXkQiJjmtCOFTYAcqdX1KZpvTsTvpvce77G2Pn+bclgrIHQ4pTWtNHI ASMFK4p02Vq5qeiQmNHIZJcQvDlw5JSRQ8nchICFhNsgBhVC8V2n1oY1Vr18eSzQ9ESt HHaL7lPgQfDPq/ZKULFOv/edw9gwzCJrwCimYBmHR0ggWv1YCpTcvWAUvzpetZG+PYEG D8bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747958262; x=1748563062; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Rdc0Nn59D98Yn70bYr/mCjhLlbBJUI2N5zWeAoQlNPQ=; b=S2rb57YwWio9Vvf6SsKxVMqdmRSkFDebB4Kjnsp6SNTG5kVc+1hCUwdSiHe0Dc8pEj n9jNBvUbZeFO5MsdTO/WkyZ8VxhOGL29Z1U2rjEQjvOkpFtQ4NTot9oQUUjuLruzxxJl psZm9wNjvUx3laJJ7K+FWW03po3bDItqPLz46pPc/JawoACes68sirJpqlJpIYrfOBzI cindqSanZQ9u6mQ3Oqm1GfgHRUUOaP8i9N4skVXbQuGK6pNiSHkMgccnBaCDvfx+8F8b OcgzbEdz2i+dZqEt/pNHygiRDz6V49VHBIWmmNYCnsX2F03utu1J6NHKNBAougTE6f5l tDOg== X-Forwarded-Encrypted: i=1; AJvYcCWDLKCFUvJYwlvTdSZBXHBz3ZW4PgeOVI4m5VCtDCEsOU6bJbniDpPfCvQijsuBheCGGYvcAN+tbzzO8wc=@vger.kernel.org X-Gm-Message-State: AOJu0YwyV7mdtdV8cSG4f+kMpWyUbGZk02011IKVTShRzdsQeAbQEyRs NF8MKYIXFrzdHXZqEAAFZPzqXuZvt9Pxi+IcXwdxiE2ECM9+AjlMsz1pYu8HsMrBaV01E5s9xdL X7MfJ03mvqIz10rQpQoLudTr0Ow== X-Google-Smtp-Source: AGHT+IFRvRHBk28FNYd3BVonDgdhCutfDUgwsyOjl468lqbL79VcfPJAYg7cOTBywBt6Ptm+cEY3flasmjnaEV9ieg== X-Received: from pfbic8.prod.google.com ([2002:a05:6a00:8a08:b0:736:86e0:8dee]) (user=hramamurthy job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:130e:b0:742:a77b:8c4 with SMTP id d2e1a72fcca58-745ed847e76mr1367290b3a.3.1747958262219; Thu, 22 May 2025 16:57:42 -0700 (PDT) Date: Thu, 22 May 2025 23:57:30 +0000 In-Reply-To: <20250522235737.1925605-1-hramamurthy@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250522235737.1925605-1-hramamurthy@google.com> X-Mailer: git-send-email 2.49.0.1151.ga128411c76-goog Message-ID: <20250522235737.1925605-2-hramamurthy@google.com> Subject: [PATCH net-next v3 1/8] gve: Add device option for nic clock synchronization From: Harshitha Ramamurthy To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jeroendb@google.com, hramamurthy@google.com, andrew+netdev@lunn.ch, willemb@google.com, ziweixiao@google.com, pkaligineedi@google.com, yyd@google.com, joshwash@google.com, shailend@google.com, linux@treblig.org, thostet@google.com, jfraker@google.com, richardcochran@gmail.com, jdamato@fastly.com, vadim.fedorenko@linux.dev, horms@kernel.org, linux-kernel@vger.kernel.org, Jeff Rogers Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: John Fraker Add the device option and negotiation with the device for clock synchronization with the nic. This option is necessary before the driver will advertise support for hardware timestamping or other related features. Signed-off-by: Jeff Rogers Signed-off-by: John Fraker Signed-off-by: Ziwei Xiao Reviewed-by: Willem de Bruijn Signed-off-by: Harshitha Ramamurthy --- drivers/net/ethernet/google/gve/gve.h | 3 ++ drivers/net/ethernet/google/gve/gve_adminq.c | 31 +++++++++++++++++++- drivers/net/ethernet/google/gve/gve_adminq.h | 9 ++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/google/gve/gve.h b/drivers/net/ethernet/g= oogle/gve/gve.h index 2fab38c8ee78..e9b2c1394b1f 100644 --- a/drivers/net/ethernet/google/gve/gve.h +++ b/drivers/net/ethernet/google/gve/gve.h @@ -870,6 +870,9 @@ struct gve_priv { u16 rss_lut_size; bool cache_rss_config; struct gve_rss_config rss_config; + + /* True if the device supports reading the nic clock */ + bool nic_timestamp_supported; }; =20 enum gve_service_task_flags_bit { diff --git a/drivers/net/ethernet/google/gve/gve_adminq.c b/drivers/net/eth= ernet/google/gve/gve_adminq.c index 3e8fc33cc11f..ae20d2f7e6e1 100644 --- a/drivers/net/ethernet/google/gve/gve_adminq.c +++ b/drivers/net/ethernet/google/gve/gve_adminq.c @@ -46,6 +46,7 @@ void gve_parse_device_option(struct gve_priv *priv, struct gve_device_option_buffer_sizes **dev_op_buffer_sizes, struct gve_device_option_flow_steering **dev_op_flow_steering, struct gve_device_option_rss_config **dev_op_rss_config, + struct gve_device_option_nic_timestamp **dev_op_nic_timestamp, struct gve_device_option_modify_ring **dev_op_modify_ring) { u32 req_feat_mask =3D be32_to_cpu(option->required_features_mask); @@ -225,6 +226,23 @@ void gve_parse_device_option(struct gve_priv *priv, "RSS config"); *dev_op_rss_config =3D (void *)(option + 1); break; + case GVE_DEV_OPT_ID_NIC_TIMESTAMP: + if (option_length < sizeof(**dev_op_nic_timestamp) || + req_feat_mask !=3D GVE_DEV_OPT_REQ_FEAT_MASK_NIC_TIMESTAMP) { + dev_warn(&priv->pdev->dev, GVE_DEVICE_OPTION_ERROR_FMT, + "Nic Timestamp", + (int)sizeof(**dev_op_nic_timestamp), + GVE_DEV_OPT_REQ_FEAT_MASK_NIC_TIMESTAMP, + option_length, req_feat_mask); + break; + } + + if (option_length > sizeof(**dev_op_nic_timestamp)) + dev_warn(&priv->pdev->dev, + GVE_DEVICE_OPTION_TOO_BIG_FMT, + "Nic Timestamp"); + *dev_op_nic_timestamp =3D (void *)(option + 1); + break; default: /* If we don't recognize the option just continue * without doing anything. @@ -246,6 +264,7 @@ gve_process_device_options(struct gve_priv *priv, struct gve_device_option_buffer_sizes **dev_op_buffer_sizes, struct gve_device_option_flow_steering **dev_op_flow_steering, struct gve_device_option_rss_config **dev_op_rss_config, + struct gve_device_option_nic_timestamp **dev_op_nic_timestamp, struct gve_device_option_modify_ring **dev_op_modify_ring) { const int num_options =3D be16_to_cpu(descriptor->num_device_options); @@ -269,6 +288,7 @@ gve_process_device_options(struct gve_priv *priv, dev_op_dqo_rda, dev_op_jumbo_frames, dev_op_dqo_qpl, dev_op_buffer_sizes, dev_op_flow_steering, dev_op_rss_config, + dev_op_nic_timestamp, dev_op_modify_ring); dev_opt =3D next_opt; } @@ -904,6 +924,8 @@ static void gve_enable_supported_features(struct gve_pr= iv *priv, *dev_op_flow_steering, const struct gve_device_option_rss_config *dev_op_rss_config, + const struct gve_device_option_nic_timestamp + *dev_op_nic_timestamp, const struct gve_device_option_modify_ring *dev_op_modify_ring) { @@ -980,10 +1002,15 @@ static void gve_enable_supported_features(struct gve= _priv *priv, "RSS device option enabled with key size of %u, lut size of %u.\n", priv->rss_key_size, priv->rss_lut_size); } + + if (dev_op_nic_timestamp && + (supported_features_mask & GVE_SUP_NIC_TIMESTAMP_MASK)) + priv->nic_timestamp_supported =3D true; } =20 int gve_adminq_describe_device(struct gve_priv *priv) { + struct gve_device_option_nic_timestamp *dev_op_nic_timestamp =3D NULL; struct gve_device_option_flow_steering *dev_op_flow_steering =3D NULL; struct gve_device_option_buffer_sizes *dev_op_buffer_sizes =3D NULL; struct gve_device_option_jumbo_frames *dev_op_jumbo_frames =3D NULL; @@ -1024,6 +1051,7 @@ int gve_adminq_describe_device(struct gve_priv *priv) &dev_op_buffer_sizes, &dev_op_flow_steering, &dev_op_rss_config, + &dev_op_nic_timestamp, &dev_op_modify_ring); if (err) goto free_device_descriptor; @@ -1088,7 +1116,8 @@ int gve_adminq_describe_device(struct gve_priv *priv) gve_enable_supported_features(priv, supported_features_mask, dev_op_jumbo_frames, dev_op_dqo_qpl, dev_op_buffer_sizes, dev_op_flow_steering, - dev_op_rss_config, dev_op_modify_ring); + dev_op_rss_config, dev_op_nic_timestamp, + dev_op_modify_ring); =20 free_device_descriptor: dma_pool_free(priv->adminq_pool, descriptor, descriptor_bus); diff --git a/drivers/net/ethernet/google/gve/gve_adminq.h b/drivers/net/eth= ernet/google/gve/gve_adminq.h index 228217458275..42466ee640f1 100644 --- a/drivers/net/ethernet/google/gve/gve_adminq.h +++ b/drivers/net/ethernet/google/gve/gve_adminq.h @@ -174,6 +174,12 @@ struct gve_device_option_rss_config { =20 static_assert(sizeof(struct gve_device_option_rss_config) =3D=3D 8); =20 +struct gve_device_option_nic_timestamp { + __be32 supported_features_mask; +}; + +static_assert(sizeof(struct gve_device_option_nic_timestamp) =3D=3D 4); + /* Terminology: * * RDA - Raw DMA Addressing - Buffers associated with SKBs are directly DMA @@ -192,6 +198,7 @@ enum gve_dev_opt_id { GVE_DEV_OPT_ID_JUMBO_FRAMES =3D 0x8, GVE_DEV_OPT_ID_BUFFER_SIZES =3D 0xa, GVE_DEV_OPT_ID_FLOW_STEERING =3D 0xb, + GVE_DEV_OPT_ID_NIC_TIMESTAMP =3D 0xd, GVE_DEV_OPT_ID_RSS_CONFIG =3D 0xe, }; =20 @@ -206,6 +213,7 @@ enum gve_dev_opt_req_feat_mask { GVE_DEV_OPT_REQ_FEAT_MASK_MODIFY_RING =3D 0x0, GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING =3D 0x0, GVE_DEV_OPT_REQ_FEAT_MASK_RSS_CONFIG =3D 0x0, + GVE_DEV_OPT_REQ_FEAT_MASK_NIC_TIMESTAMP =3D 0x0, }; =20 enum gve_sup_feature_mask { @@ -214,6 +222,7 @@ enum gve_sup_feature_mask { GVE_SUP_BUFFER_SIZES_MASK =3D 1 << 4, GVE_SUP_FLOW_STEERING_MASK =3D 1 << 5, GVE_SUP_RSS_CONFIG_MASK =3D 1 << 7, + GVE_SUP_NIC_TIMESTAMP_MASK =3D 1 << 8, }; =20 #define GVE_DEV_OPT_LEN_GQI_RAW_ADDRESSING 0x0 --=20 2.49.0.1143.g0be31eac6b-goog