From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (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 CBD7D21CFF7 for ; Mon, 9 Jun 2025 18:40:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749494437; cv=none; b=Lls+5DSDu1DFXBzPufFcz7UPiTKo6lvcwygd08doPztMVz2adXrHxAYRJ8lRVhP4yPVe7L4t39rvV8vti6azWrea3BPA+Gz7hG1iYy2BS/8M/rl59322ns12DElz+gm3oofIumW7kFpVCVGHQb4vqTa/a3oIQa+WbFXKpBrg1tg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749494437; c=relaxed/simple; bh=Ueh8vB/WqWHbGwdM72Pg49M1EPCrJ+7qrjfiE0mj0/4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=CTP40d0M90U3n9cE15SbrU0PE9fgLUXklJI/SlRBgBH9/gijIo1L65UPiXXUk4K35lM4psyZp3rxTL7iaaL1RDs3svyitvYFcPV7Xb6XeAOpGH/bBTjzt5R4iaS7CXh8caAhsnBC73W2mwzIxqBXNt8F5N4+JSInSc1WPvY1PbA= 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=umi4Fb2N; arc=none smtp.client-ip=209.85.210.201 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="umi4Fb2N" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-7395d07a3dcso3382830b3a.3 for ; Mon, 09 Jun 2025 11:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1749494435; x=1750099235; 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=Yit01hZIFe70C+KveOVG6in64vKXs39Zm3W3QCkhZYg=; b=umi4Fb2NocF0+xPKLGFRa1L3/hNVKauBCbU8V3LNHVhggbM1sBhNQwTtk4BgW4BelD hVqXwac3lNWFuvV8hmcAdF3HLKL4fn34bdiymRrx2DAJaInKn2g0rgbAbKAsxwK0tNmr or2NHV2pK2+ptcgBdcM27tzMoHF+Wg3W7gTlvgAGO6sNX7BgPG0ikpDfgQWftHsOekBw A7nyoAdSLq7E0Sk+LDOyeVyl/P+vVxB7mqKNPot9f2CSXUs7RIiE8tiQhAdIEriWxRcu MMRV9EiN0ei/UysqW3I7RD52b7JyCbL+WtqZBiBVdwmxpnBGbcVbu98KLyZ/hIUawyn8 /Bpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749494435; x=1750099235; 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=Yit01hZIFe70C+KveOVG6in64vKXs39Zm3W3QCkhZYg=; b=eIqVOBH/qin3dDL/R0HxvH9OV5F3ClHlKJM/NzHc6ANa2Icipk2IkhCKhrT2XXrtL1 SsH/2EWPoDomTAI0C90m2mnO5hyvUSYPX1QFcKxKilpiBBbRhhQPAM6fb3efjrOSu5v/ nJN1xYqpKSR/9aw3Ly0sTsM7q+UTFxmdAh3H+EUSvi9Il9f6Q2fTinHX9wqUZXR+3j2I 6xbwj34zxLM1FbCZNMZstIZXnynZgQlz4cZPXRrC6c2RIJEeTBR4eDN2OOmpPum04+wP wUiG9fGMciZ1nNVIRqik7PiaEbKkEql33wYD03wJgJIX2DCn7v3qpho2EnqGgHpLKJBW NyaQ== X-Gm-Message-State: AOJu0Yy+QD6WWQ8qGUIvzk74IrFrJm6skKskvMgnu+MfglxTJHwCdjEf 7BI/J0g7o1MHs0R4JoZWfUca57SCkUrNvWgSfn3yEfsEWzm6n9tyjZME340Qg9NpUQ2ciyXgyDs T925/ViG7dJ1o/LzBh6nlihW+bdZs5q6a1uKQC8atDCbX3k/rZG0xeU/CDccXEnvxyS2j4A+lcO GdigmlR49zCsJIhbUsmHRS3tgDQWM+vFoZ40FAIo4DSP6a3gH53ooCGrVFIJDRDZI= X-Google-Smtp-Source: AGHT+IEOA9JlNuOSn41C3QU8UV6Vy7wjT3OlV3oug9/iq56BEMAkoOF8PupMPb34+Q90lAjshWn16IlbrhP1853hVg== X-Received: from pfbhb7.prod.google.com ([2002:a05:6a00:8587:b0:746:1a7b:a39a]) (user=hramamurthy job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:734e:b0:21d:375a:ee33 with SMTP id adf61e73a8af0-21ee24cc09amr20565286637.9.1749494434965; Mon, 09 Jun 2025 11:40:34 -0700 (PDT) Date: Mon, 9 Jun 2025 18:40:22 +0000 In-Reply-To: <20250609184029.2634345-1-hramamurthy@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250609184029.2634345-1-hramamurthy@google.com> X-Mailer: git-send-email 2.50.0.rc0.604.gd4ff7b7c86-goog Message-ID: <20250609184029.2634345-2-hramamurthy@google.com> Subject: [PATCH net-next v4 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-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/google/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; }; enum gve_service_task_flags_bit { diff --git a/drivers/net/ethernet/google/gve/gve_adminq.c b/drivers/net/ethernet/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 = 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 = (void *)(option + 1); break; + case GVE_DEV_OPT_ID_NIC_TIMESTAMP: + if (option_length < sizeof(**dev_op_nic_timestamp) || + req_feat_mask != 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 = (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 = 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 = next_opt; } @@ -904,6 +924,8 @@ static void gve_enable_supported_features(struct gve_priv *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 = true; } int gve_adminq_describe_device(struct gve_priv *priv) { + struct gve_device_option_nic_timestamp *dev_op_nic_timestamp = NULL; struct gve_device_option_flow_steering *dev_op_flow_steering = NULL; struct gve_device_option_buffer_sizes *dev_op_buffer_sizes = NULL; struct gve_device_option_jumbo_frames *dev_op_jumbo_frames = 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); 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/ethernet/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 { static_assert(sizeof(struct gve_device_option_rss_config) == 8); +struct gve_device_option_nic_timestamp { + __be32 supported_features_mask; +}; + +static_assert(sizeof(struct gve_device_option_nic_timestamp) == 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 = 0x8, GVE_DEV_OPT_ID_BUFFER_SIZES = 0xa, GVE_DEV_OPT_ID_FLOW_STEERING = 0xb, + GVE_DEV_OPT_ID_NIC_TIMESTAMP = 0xd, GVE_DEV_OPT_ID_RSS_CONFIG = 0xe, }; @@ -206,6 +213,7 @@ enum gve_dev_opt_req_feat_mask { GVE_DEV_OPT_REQ_FEAT_MASK_MODIFY_RING = 0x0, GVE_DEV_OPT_REQ_FEAT_MASK_FLOW_STEERING = 0x0, GVE_DEV_OPT_REQ_FEAT_MASK_RSS_CONFIG = 0x0, + GVE_DEV_OPT_REQ_FEAT_MASK_NIC_TIMESTAMP = 0x0, }; enum gve_sup_feature_mask { @@ -214,6 +222,7 @@ enum gve_sup_feature_mask { GVE_SUP_BUFFER_SIZES_MASK = 1 << 4, GVE_SUP_FLOW_STEERING_MASK = 1 << 5, GVE_SUP_RSS_CONFIG_MASK = 1 << 7, + GVE_SUP_NIC_TIMESTAMP_MASK = 1 << 8, }; #define GVE_DEV_OPT_LEN_GQI_RAW_ADDRESSING 0x0 -- 2.50.0.rc0.604.gd4ff7b7c86-goog