Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3040258pxb; Mon, 18 Oct 2021 07:07:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrnYZOwz3cAtWbBin4GsX2m83UrK56NGlTjG+ggxK9x3XemmwpmB4IDOshmQnJHTLlY/G7 X-Received: by 2002:a17:90a:191a:: with SMTP id 26mr48099984pjg.118.1634566051639; Mon, 18 Oct 2021 07:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634566051; cv=none; d=google.com; s=arc-20160816; b=ABSPRK8zvn6rKjKZ1HdxiZQzzTASDGJ9si1Z+cmC92G/0spx0Bg67FIwUIfM/XaN3d tOlsoVg9UK8d/tX1o+2R2aD2PyuXwsEn5LBrADEwrItsDSP7x0UwrcDGID7HvnLV9+JE /zBNsjCkV4utTT4p0vbLQnTyc53r4/awifMIVYuSr9+TTIT73g+vifZLOa5QiHRB3aqu mOwUH77WlYCnB6PfDb3y4cnlXh1cLq+lcaLpNSXlh6I7sBwgezZh6grIyjGTKYPJCZ7M BVB0asJUZ9+p1pfLVZQU7Yh1lxekWthDzL134Y4QDxSvOUKiVrErrpIaPiggnmBQPuQe e3gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oN6+vLeFo6jPgrAdg0V4CBGrwbcAcNRVnyeCiO6ej6E=; b=qMtR/KhVpZecPFEe2+2Cu/hSwfuHXMyy1jm0s302oN3YOqe1Ax+umIspAOiIgKnyUg ANvrt4cuv99vU7rcXSbm1fAOJBjRmMrn4og9z46+K0NSGc8XHqpwBBYsqTCChMsSMpBD I3hD26EjWugKBw6hm++jqQWXwFtt1jS540DxortRD4/fNxyzFvhTSfzbCAfCFoGe1uvA RVFsVkV9Y1WlP+MSU9QKqq5+o4hY1ewiMVHERJ9fQtRQFuWUv0JdccLICIZXMxJv4fWM ngz69HORpZgrwdHZXrMudbGWp3HX+ZYCOK4JXsWA7Nwr8keE/EOWyKplyPZsiZKWIwji UHCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OgJi9wNz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e18si25447536plh.102.2021.10.18.07.07.11; Mon, 18 Oct 2021 07:07:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OgJi9wNz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234807AbhJROGg (ORCPT + 99 others); Mon, 18 Oct 2021 10:06:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:40650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234921AbhJRODe (ORCPT ); Mon, 18 Oct 2021 10:03:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 513F56135E; Mon, 18 Oct 2021 13:43:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564616; bh=fI1uiQxqbOO361F5XdBqN7wyao4gVHverHJa7SFikqc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OgJi9wNzfGjKeLVb2lGiNcuzfxpoGCiCaaQrBkNbrE9IJ59pdEifEotKz9JHXQpwE 7oj6oQC/RvT+4T0HNXD3EI80cmKqummLozTvFFJr87670ljPPjI6qj0MOIR5zKLleh wRETs8Gn7gBfyf8WLrx0krazYiSycnnhbqJvJu88= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Jakub Kicinski Subject: [PATCH 5.14 145/151] net: mscc: ocelot: make use of all 63 PTP timestamp identifiers Date: Mon, 18 Oct 2021 15:25:24 +0200 Message-Id: <20211018132345.379645054@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean commit c57fe0037a4e3863d9b740f8c14df9c51ac31aa1 upstream. At present, there is a problem when user space bombards a port with PTP event frames which have TX timestamping requests (or when a tc-taprio offload is installed on a port, which delays the TX timestamps by a significant amount of time). The driver will happily roll over the 2-bit timestamp ID and this will cause incorrect matches between an skb and the TX timestamp collected from the FIFO. The Ocelot switches have a 6-bit PTP timestamp identifier, and the value 63 is reserved, so that leaves identifiers 0-62 to be used. The timestamp identifiers are selected by the REW_OP packet field, and are actually shared between CPU-injected frames and frames which match a VCAP IS2 rule that modifies the REW_OP. The hardware supports partitioning between the two uses of the REW_OP field through the PTP_ID_LOW and PTP_ID_HIGH registers, and by default reserves the PTP IDs 0-3 for CPU-injected traffic and the rest for VCAP IS2. The driver does not use VCAP IS2 to set REW_OP for 2-step timestamping, and it also writes 0xffffffff to both PTP_ID_HIGH and PTP_ID_LOW in ocelot_init_timestamp() which makes all timestamp identifiers available to CPU injection. Therefore, we can make use of all 63 timestamp identifiers, which should allow more timestampable packets to be in flight on each port. This is only part of the solution, more issues will be addressed in future changes. Fixes: 4e3b0468e6d7 ("net: mscc: PTP Hardware Clock (PHC) support") Signed-off-by: Vladimir Oltean Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mscc/ocelot.c | 4 +++- include/soc/mscc/ocelot_ptp.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -546,7 +546,9 @@ static void ocelot_port_add_txtstamp_skb skb_shinfo(clone)->tx_flags |= SKBTX_IN_PROGRESS; /* Store timestamp ID in OCELOT_SKB_CB(clone)->ts_id */ OCELOT_SKB_CB(clone)->ts_id = ocelot_port->ts_id; - ocelot_port->ts_id = (ocelot_port->ts_id + 1) % 4; + ocelot_port->ts_id++; + if (ocelot_port->ts_id == OCELOT_MAX_PTP_ID) + ocelot_port->ts_id = 0; skb_queue_tail(&ocelot_port->tx_skbs, clone); spin_unlock(&ocelot_port->ts_id_lock); --- a/include/soc/mscc/ocelot_ptp.h +++ b/include/soc/mscc/ocelot_ptp.h @@ -13,6 +13,8 @@ #include #include +#define OCELOT_MAX_PTP_ID 63 + #define PTP_PIN_CFG_RSZ 0x20 #define PTP_PIN_TOD_SEC_MSB_RSZ PTP_PIN_CFG_RSZ #define PTP_PIN_TOD_SEC_LSB_RSZ PTP_PIN_CFG_RSZ