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 CB64F9FDB00 for ; Thu, 13 Apr 2023 20:42:22 +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=AX2iIZQX DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681411341; 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=jFCzXhj5hVtVaLfINs11NiVB1lGjSKJOD4vnQMSSjnY=; b=AX2iIZQXSOPAR+x0qrZFWut/mxIyWKFG3OFwozxG1MBT71D29wEDt9X8L5RfoUs3zU/W0Z 71YB2edpUONnyay4jskZ9WcsyT+ac1wprlCmVwvQZw/xQ7aC0yS/LqmHenq1zZR4l/K24V 2lvEoLqDpxF/jPuQJZgWebgzJrahTtk= 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-499-c6Dvg-_IPwK2Ertvt8clGw-1; Thu, 13 Apr 2023 14:42:20 -0400 X-MC-Unique: c6Dvg-_IPwK2Ertvt8clGw-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5050340f541so914732a12.2 for ; Thu, 13 Apr 2023 11:42:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681411338; x=1684003338; 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=jFCzXhj5hVtVaLfINs11NiVB1lGjSKJOD4vnQMSSjnY=; b=bPg0mYa2BerDX++ImEO0KrOW5ZBPSzPmqdcAKqLi/TrHGCidg+yE0jvbcTDZvRHBse o3dyb52LA000VHSDmXx3yR6MlA2a1ibpfcGUaTwG5zXTBjwhHl1bxz7bB5k+ZN4aYnxA 3CS6CC5b5/w6uhpjyQkivJkK0qam61zvTfpDrv0y26DKL6fdACYIcCHWXqUaJOa/5gIb M2RyROPJUGuzcBGMoo4shEfftP76jON3tJaftd/UZvT/Xs8U21SDM+3N7By6V0LvAiu9 TwLiJ+lUS2bKPXCOnrbrz8XNW6TYYiaZycm5dyOgMiXweH4+B4n/kDEAyOqnZJdicM9v zfRw== X-Gm-Message-State: AAQBX9foZXqjf+PmIyTh0rVjDpjCQ18ZI2abLE/8ZeIF9EY4v1grFv9p 50IoYxMyYM/MMbbajIT/ZKBcmigTmT3Gvelc+baVBkcMfVTOFYstONTwTZ2wfJ6AJE3/l759VxA 0i6dcmHF6c8KIDxRmfJo8 X-Received: by 2002:aa7:ce06:0:b0:501:d917:d52 with SMTP id d6-20020aa7ce06000000b00501d9170d52mr3760446edv.8.1681411338589; Thu, 13 Apr 2023 11:42:18 -0700 (PDT) X-Google-Smtp-Source: AKy350YYifWUgndL9IzmM9sB+EmC6luF5yXBi1Z7Pu0T2Ye4b4wgDVquW2ymvsXbk5mm7Z5uz0Se4A== X-Received: by 2002:aa7:ce06:0:b0:501:d917:d52 with SMTP id d6-20020aa7ce06000000b00501d9170d52mr3760426edv.8.1681411338239; Thu, 13 Apr 2023 11:42:18 -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 d12-20020a50fe8c000000b00504c33675cesm1178071edt.35.2023.04.13.11.42.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Apr 2023 11:42:17 -0700 (PDT) From: Jesper Dangaard Brouer X-Google-Original-From: Jesper Dangaard Brouer Message-ID: <07a88087-bee8-e549-c069-63d52268aef1@redhat.com> Date: Thu, 13 Apr 2023 20:42:16 +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 References: <20230413151222.1864307-1-yoong.siang.song@intel.com> In-Reply-To: <20230413151222.1864307-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: 4TXBITKQLZND2SKM4BHNBRXL5ZKSNXBR X-Message-ID-Hash: 4TXBITKQLZND2SKM4BHNBRXL5ZKSNXBR 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 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 13/04/2023 17.12, 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. > Ah, I believe I have hit this bug with my igc patches. Thanks for fixing. > 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 > Why port 9092 ? The ./xdp_hw_metadata prog will redirect port 9091 > Command on Link Partner: > echo -n skb | nc -u -q1 9092 > Again port 9092 ? > Result before this patch: > skb hwtstamp is not found! > > Result after this patch: > found skb hwtstamp = 1677762212.590696226 I usually use this cmd to see if number is sane: $ date -d @1677762212 2023-03-02T14:03:32 CET > > Fixes: fc9df2a0b520 ("igc: Enable RX via AF_XDP zero-copy") > Cc: # 5.14+ > Signed-off-by: Song Yoong Siang > --- > drivers/net/ethernet/intel/igc/igc_base.h | 7 +++++-- > drivers/net/ethernet/intel/igc/igc_main.c | 5 ++++- > 2 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/intel/igc/igc_base.h b/drivers/net/ethernet/intel/igc/igc_base.h > index 7a992befca24..b95007d51d13 100644 > --- a/drivers/net/ethernet/intel/igc/igc_base.h > +++ b/drivers/net/ethernet/intel/igc/igc_base.h > @@ -87,8 +87,11 @@ 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_BSIZEPKT_MASK GENMASK(6, 0) > +#define IGC_SRRCTL_BSIZEPKT_SHIFT 10 /* Shift _right_ */ > +#define IGC_SRRCTL_BSIZEHDRSIZE_MASK GENMASK(13, 8) > +#define IGC_SRRCTL_BSIZEHDRSIZE_SHIFT 2 /* Shift _left_ */ > +#define IGC_SRRCTL_DESCTYPE_MASK GENMASK(27, 25) > #define IGC_SRRCTL_DESCTYPE_ADV_ONEBUF 0x02000000 > > #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..de7b21c2ccd6 100644 > --- a/drivers/net/ethernet/intel/igc/igc_main.c > +++ b/drivers/net/ethernet/intel/igc/igc_main.c > @@ -641,7 +641,10 @@ 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 = rd32(IGC_SRRCTL(reg_idx)); > + srrctl &= ~(IGC_SRRCTL_BSIZEPKT_MASK | IGC_SRRCTL_BSIZEHDRSIZE_MASK | > + IGC_SRRCTL_DESCTYPE_MASK); > + srrctl |= IGC_RX_HDR_LEN << IGC_SRRCTL_BSIZEHDRSIZE_SHIFT; > srrctl |= buf_size >> IGC_SRRCTL_BSIZEPKT_SHIFT; > srrctl |= IGC_SRRCTL_DESCTYPE_ADV_ONEBUF; >