Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp1031190rwe; Fri, 14 Apr 2023 13:12:00 -0700 (PDT) X-Google-Smtp-Source: AKy350YWq/CaqeqF8jEMGJaIVeoaH6L30nEGcuBKfghoEic9j+OMQP36muy7sR1/auv+9YbhILlt X-Received: by 2002:a05:6a00:2283:b0:62d:e5eb:2d73 with SMTP id f3-20020a056a00228300b0062de5eb2d73mr10286540pfe.34.1681503120323; Fri, 14 Apr 2023 13:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681503120; cv=none; d=google.com; s=arc-20160816; b=i6TEI199ipnZweXLEHLJhR9cjb4L+Q1FRe2OO0U8hJuB+Sb5HxUqxX/ecG999y1Dj6 EaViBt2dH/hCkf5mQvixBUVa7lLJFbC/uHY8eQ6JlXcTvK+sth60bogm66dDrHfC6qIe thabHNwEfyTdxghjJUDU2OzKJyfmj0CkBYL2ipSnJaPFWZ3STxiB4kkiJ24OMq/MRcH/ HV+aYGNVaLCYusMqAOFgQfk1YynA3cCCQJQYlUdFjlt3b4/zCO0M9N2dYLaV9gOiS1ql LbIxHuZYEDNtRfKzhjmkAoYf2CrogbrXR4JDjAaGSK7MqU+ni0mfUum+q8c6wLIma5Cf H1FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :to:content-language:subject:cc:user-agent:mime-version:date :message-id:from:dkim-signature; bh=H8b8ehHOsU++QqrM70j/M9clO0F9dJb97/yhmghDZiY=; b=xVt1oO87yHB/NVIQb7fprhiRdkAcpJUtk3/ONXXmjQ0ACiAXM6UKEpTsT6jCpkPgKj ef8doVE/8lVfLQkzGyfUjDqKK0fa4STyoBS6EvJrECjxfj+Jmgc3b1CFN1HudD7x805g amk4p58k8JDm9Dktf+l+ktRwPijCZCWelWCNABUcJ+LmmLU0J2e/OcWPYKn5Mr/rDhBU jmnB9FKOJpZ2nYi6EPcyri7ndepLHJvgnX6iTxJ2FSGtAZ/uno3EV+6Lv+14Vxut5Vuz 3yrjWxB8ONuDso/s6xRHNVl7dWnQyRUjRdaBEiS6+UwFzZGtjU9R9LQEif1TPis1ZGgT gIHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ObXmdr1G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i15-20020a056a00004f00b0063b6bc79313si1926750pfk.110.2023.04.14.13.11.47; Fri, 14 Apr 2023 13:12:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ObXmdr1G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229804AbjDNUFx (ORCPT + 99 others); Fri, 14 Apr 2023 16:05:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229864AbjDNUFw (ORCPT ); Fri, 14 Apr 2023 16:05:52 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FF616584 for ; Fri, 14 Apr 2023 13:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681502710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H8b8ehHOsU++QqrM70j/M9clO0F9dJb97/yhmghDZiY=; b=ObXmdr1G4nffVM/nJDrM7r3PmPpGHDV8Ua4Lb0sooyhIUNGk+6A8wDNF9C00mLmhNx5Sly dySoy+mThw8QQSEByaMzyn1NIxUNKDSNLMDEyMCaOOG+/gxwenD/NFJZ0zR2JLRo5pvdAV rkc7+Mr1RjAFyCEfIum6GUA4yMDtJ6E= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-86-o-S-AK3jPImREJCqMx8icA-1; Fri, 14 Apr 2023 16:05:08 -0400 X-MC-Unique: o-S-AK3jPImREJCqMx8icA-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5067227e973so1103694a12.0 for ; Fri, 14 Apr 2023 13:05:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681502707; x=1684094707; h=content-transfer-encoding:in-reply-to:references:to :content-language:subject:cc:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=H8b8ehHOsU++QqrM70j/M9clO0F9dJb97/yhmghDZiY=; b=HkFNTcFVbARPL6czugCactq/xIbeYfHXOPjfcZlx+gRLQrcB/adEQO9XbKTcwGAJSO vCMEjJU0jO8xBDzNnsIaictatcda20DgNEpWLApF467EQ0TE1MgO4gHDvFFon7JHFab6 M5EOnRNeRvhQUHkIgziOhlTxyVAdiuqUtf4wmTOK3A/7gY5M9DkTTXjKomuX4/7Tzff5 Ax7W/G7LeD9qePAWGyCaCg3Iq2O1S9nhRC7l2XEDPt529is/Ns/XgC3zzT4fRAFbGJMq 7bQeFhJ7K0y6EJZFtnDWtCMS49oxn4zbYNHErABJNvabanPC0+GjtCRb+xTok2mKfYHP EKLw== X-Gm-Message-State: AAQBX9e1pqp4M9EGUu/FpMI4tlJ/K/n4HiYG7bbSTvhRHmAnDWMFNTgg 5yVAJM2N9NA9q/yxroL8smXogIqkm7G8h42l3QGOVOAGMjOzN7LJHxCOyyqxTK9HJfg9W1EHWFx SndmaeTH/mN0Ud2Yf5PoaT6yi X-Received: by 2002:aa7:d28e:0:b0:4fa:6767:817b with SMTP id w14-20020aa7d28e000000b004fa6767817bmr7724743edq.41.1681502707429; Fri, 14 Apr 2023 13:05:07 -0700 (PDT) X-Received: by 2002:aa7:d28e:0:b0:4fa:6767:817b with SMTP id w14-20020aa7d28e000000b004fa6767817bmr7724719edq.41.1681502707087; Fri, 14 Apr 2023 13:05:07 -0700 (PDT) Received: from [192.168.42.222] (194-45-78-10.static.kviknet.net. [194.45.78.10]) by smtp.gmail.com with ESMTPSA id fy15-20020a1709069f0f00b0094a5b8791cfsm2826970ejc.109.2023.04.14.13.05.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Apr 2023 13:05:06 -0700 (PDT) From: Jesper Dangaard Brouer X-Google-Original-From: Jesper Dangaard Brouer Message-ID: <934a4204-1920-f5e1-bcde-89429554d0d6@redhat.com> Date: Fri, 14 Apr 2023 22:05:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Cc: brouer@redhat.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, xdp-hints@xdp-project.net, stable@vger.kernel.org Subject: Re: [PATCH net v3 1/1] igc: read before write to SRRCTL register Content-Language: en-US To: Song Yoong Siang , Jesse Brandeburg , Tony Nguyen , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Maciej Fijalkowski , Vedang Patel , Jithu Joseph , Andre Guedes , Stanislav Fomichev , Jacob Keller , David Laight References: <20230414154902.2950535-1-yoong.siang.song@intel.com> In-Reply-To: <20230414154902.2950535-1-yoong.siang.song@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/04/2023 17.49, Song Yoong Siang wrote: > igc_configure_rx_ring() function will be called as part of XDP program > setup. If Rx hardware timestamp is enabled prio to XDP program setup, > this timestamp enablement will be overwritten when buffer size is > written into SRRCTL register. > > Thus, this commit read the register value before write to SRRCTL > register. This commit is tested by using xdp_hw_metadata bpf selftest > tool. The tool enables Rx hardware timestamp and then attach XDP program > to igc driver. It will display hardware timestamp of UDP packet with > port number 9092. Below are detail of test steps and results. > > Command on DUT: > sudo ./xdp_hw_metadata > > Command on Link Partner: > echo -n skb | nc -u -q1 9092 > > Result before this patch: > skb hwtstamp is not found! > > Result after this patch: > found skb hwtstamp = 1677800973.642836757 > > Optionally, read PHC to confirm the values obtained are almost the same: > Command: > sudo ./testptp -d /dev/ptp0 -g > Result: > clock time: 1677800973.913598978 or Fri Mar 3 07:49:33 2023 > > Fixes: fc9df2a0b520 ("igc: Enable RX via AF_XDP zero-copy") > Cc: # 5.14+ > Signed-off-by: Song Yoong Siang > Reviewed-by: Jacob Keller > Reviewed-by: Jesper Dangaard Brouer > --- LGTM, thank for the adjustments :-) Acked-by: Jesper Dangaard Brouer > v2 -> v3: Refactor SRRCTL definitions to more human readable definitions > v1 -> v2: Fix indention > --- > drivers/net/ethernet/intel/igc/igc_base.h | 11 ++++++++--- > drivers/net/ethernet/intel/igc/igc_main.c | 7 +++++-- > 2 files changed, 13 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/ethernet/intel/igc/igc_base.h b/drivers/net/ethernet/intel/igc/igc_base.h > index 7a992befca24..9f3827eda157 100644 > --- a/drivers/net/ethernet/intel/igc/igc_base.h > +++ b/drivers/net/ethernet/intel/igc/igc_base.h > @@ -87,8 +87,13 @@ union igc_adv_rx_desc { > #define IGC_RXDCTL_SWFLUSH 0x04000000 /* Receive Software Flush */ > > /* SRRCTL bit definitions */ > -#define IGC_SRRCTL_BSIZEPKT_SHIFT 10 /* Shift _right_ */ > -#define IGC_SRRCTL_BSIZEHDRSIZE_SHIFT 2 /* Shift _left_ */ > -#define IGC_SRRCTL_DESCTYPE_ADV_ONEBUF 0x02000000 > +#define IGC_SRRCTL_BSIZEPKT_MASK GENMASK(6, 0) > +#define IGC_SRRCTL_BSIZEPKT(x) FIELD_PREP(IGC_SRRCTL_BSIZEPKT_MASK, \ > + (x) / 1024) /* in 1 KB resolution */ > +#define IGC_SRRCTL_BSIZEHDR_MASK GENMASK(13, 8) > +#define IGC_SRRCTL_BSIZEHDR(x) FIELD_PREP(IGC_SRRCTL_BSIZEHDR_MASK, \ > + (x) / 64) /* in 64 bytes resolution */ > +#define IGC_SRRCTL_DESCTYPE_MASK GENMASK(27, 25) > +#define IGC_SRRCTL_DESCTYPE_ADV_ONEBUF FIELD_PREP(IGC_SRRCTL_DESCTYPE_MASK, 1) > > #endif /* _IGC_BASE_H */ > diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c > index 25fc6c65209b..a2d823e64609 100644 > --- a/drivers/net/ethernet/intel/igc/igc_main.c > +++ b/drivers/net/ethernet/intel/igc/igc_main.c > @@ -641,8 +641,11 @@ static void igc_configure_rx_ring(struct igc_adapter *adapter, > else > buf_size = IGC_RXBUFFER_2048; > > - srrctl = IGC_RX_HDR_LEN << IGC_SRRCTL_BSIZEHDRSIZE_SHIFT; > - srrctl |= buf_size >> IGC_SRRCTL_BSIZEPKT_SHIFT; > + srrctl = rd32(IGC_SRRCTL(reg_idx)); > + srrctl &= ~(IGC_SRRCTL_BSIZEPKT_MASK | IGC_SRRCTL_BSIZEHDR_MASK | > + IGC_SRRCTL_DESCTYPE_MASK); > + srrctl |= IGC_SRRCTL_BSIZEHDR(IGC_RX_HDR_LEN); > + srrctl |= IGC_SRRCTL_BSIZEPKT(buf_size); > srrctl |= IGC_SRRCTL_DESCTYPE_ADV_ONEBUF; > > wr32(IGC_SRRCTL(reg_idx), srrctl);