From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mail.toke.dk (Postfix) with ESMTPS id C6B0C9FE13F for ; Fri, 14 Apr 2023 22:05:12 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=huMVy3fD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681502711; 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=huMVy3fD3abj3d2rPfp3JkrMYEH2T8yvqkhMZMyFjb3/EoKGAGKgbtYUFwn7vepji0OFPd lw4+ZpXBbNPjzXY+kk1bZi5yb6aURbnZ/HQqE5RPDnw1vX6TUFlUg0bzw6lhTKZoEnNi2n ePDPcQzEecf4VuVoL6rHv4UatJgPlbg= 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-587-kpeu5prvPK-eIq4agL7qbA-1; Fri, 14 Apr 2023 16:05:08 -0400 X-MC-Unique: kpeu5prvPK-eIq4agL7qbA-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-50491d5f6ceso3084693a12.1 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=iqlA009Mb1u+gP2xWa7uQ5Qov0amOHH3bmzDYXb1SD0+QkfwIw1j3IlIyqkZ8XzULE NJBG09+XAmr6Dtpc2TaiYPcSVRHaRZ+27GmK8qPu13V3GP7heQFC6HRosddHkR2PDUQm 6PQq93g5WhiLmfAuoZYon5FESZD11QR1HzX4rzdFJtddAupW+/DhBWnKCBo+KHlIh34E VvMyRRLDqj9UwXWipFSKOotkVdXdRQWUIAZYWH1diQtgEixIjHzetqrvNAmmjscMqE56 9fH7LcKKEC+sL/P3Lltz4blXskjePip7kiBXRBjzpzk6x/qlVywwUIySKbHTuptrJvMe lyjw== X-Gm-Message-State: AAQBX9fvjl+WaQd+XYF6CwLEuTpZwPmUif6JlOLz+w+tgmw11JAc1syI LEeyKVYZWfh7BJOkDGRa0ooD4cLJ2thZKbB1AoUTotKYTMh2prTyga7Yv5reDmqh6AuaUCX+ha1 51Pc+12yv50UykchP+csy X-Received: by 2002:aa7:d28e:0:b0:4fa:6767:817b with SMTP id w14-20020aa7d28e000000b004fa6767817bmr7724751edq.41.1681502707430; Fri, 14 Apr 2023 13:05:07 -0700 (PDT) X-Google-Smtp-Source: AKy350YxIOswwl7UdXivfvk380SENlMobnVIRpUteIMxXlizKeOqOgvOSiZA+w+CLL4G0spm0zCdMA== 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 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> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: N32E43WOXKDID3KTNVVOFZRE6DED32JU X-Message-ID-Hash: N32E43WOXKDID3KTNVVOFZRE6DED32JU X-MailFrom: jbrouer@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header 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 X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [PATCH net v3 1/1] igc: read before write to SRRCTL register List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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);