Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3042043pxb; Mon, 18 Oct 2021 07:09:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2tSKoNGCvU7GBz90n3uBmpG8aK2AWURdLdA6E3PvEi9Yt/JATSnt1x6fEaiOzw9Q2tJmz X-Received: by 2002:a05:6402:1d49:: with SMTP id dz9mr45960523edb.17.1634566169077; Mon, 18 Oct 2021 07:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634566169; cv=none; d=google.com; s=arc-20160816; b=a1t45yuZO2QTtFCAeH0NGPiWJxoAY5iNrhrkl0LBmtU4ED1Jy3FK0aIHHBgVTnzZ51 9CbFfqCk6GuhkLKw0z2TmxYE6xG5g2S8GBmfoiyowMbVSoaNMAajSrNVJAqfXDNgpbnp IPbhnAg69/AQ/6PN8MobOxUgB+Qp5H9w4t8HEWZHeZ4T27jhxy/+vjFnx+FO1pDYM9wd 7zQp63zdflHsFNRxhBXD2TGAUlrQtcR8ra+fleXRwAE0DtUSLXQSXJtx3eTmmHdNS8mh /gmVkPSydJQcj0nb7Kn6xAwyz2oPJNEhgOFtdkR260ydeCuS1HnsCQuvN1V6z0cWDzOp bYcA== 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=rbudKCVDjeGS8SQYil8s69h1s7clcx9S/U9MBmjTmbA=; b=nd+3/vHs1dwfW1TRVflLlMvi0W4Zd8MnJuFw8GdveO3MoFthHukB2QZOEB7SPEWKh1 LAPDIUWxXWHbsZLGxteQ4O/u/bjCunE43oBJszP1+I0AKKtqQEoV8gzcjs2qkPXlcj4d lNXYOEzj6UpIEXAsZh71VObSIckxygMO4hUVk+R8J49EeG0Q7CnS9fv/QstYhSwSlZ7Z dweb2jvB61aF6831u9v5IZPbeU9m0Y95C75OzzTQANvs6HEQBg/oQIxWZl2MDux1SJ8j rqCXkR/fwn7QnXeuHEGduGwhAaIk3Ec1Ky5UZJ5Z301vHzjqVF70fInhPn6uCu7cNy05 6FTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F6XJEfAA; 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 s18si23164037ejx.160.2021.10.18.07.09.04; Mon, 18 Oct 2021 07:09:29 -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=F6XJEfAA; 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 S233665AbhJROGB (ORCPT + 99 others); Mon, 18 Oct 2021 10:06:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:38300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234521AbhJROCd (ORCPT ); Mon, 18 Oct 2021 10:02:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E434C61A55; Mon, 18 Oct 2021 13:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564592; bh=c4Cyn4nHvIBz3K7rCFGkyeXzPmsRkLRYh6D5zPt1C0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F6XJEfAAOdch15JRm6gOmvMW166HwVfOv4uaDNco9szj6nzhX56k164zptQogRhd6 sQpUga1GARbLL2Xo4bKjL8QMRenI4oj5/nyNY0GujlGJ8W5Hf8RHIweQLQU1SqQn1m S3Af14u1yGyE44hf6tNLdcK2TTQe1p/SoCEZ8xis= 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 148/151] net: mscc: ocelot: deny TX timestamping of non-PTP packets Date: Mon, 18 Oct 2021 15:25:27 +0200 Message-Id: <20211018132345.470814695@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 fba01283d85a09e0e2ef552c6e764b903111d90a upstream. It appears that Ocelot switches cannot timestamp non-PTP frames, I tested this using the isochron program at: https://github.com/vladimiroltean/tsn-scripts with the result that the driver increments the ocelot_port->ts_id counter as expected, puts it in the REW_OP, but the hardware seems to not timestamp these packets at all, since no IRQ is emitted. Therefore check whether we are sending PTP frames, and refuse to populate REW_OP otherwise. 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 | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -585,16 +585,12 @@ u32 ocelot_ptp_rew_op(struct sk_buff *sk } EXPORT_SYMBOL(ocelot_ptp_rew_op); -static bool ocelot_ptp_is_onestep_sync(struct sk_buff *skb) +static bool ocelot_ptp_is_onestep_sync(struct sk_buff *skb, + unsigned int ptp_class) { struct ptp_header *hdr; - unsigned int ptp_class; u8 msgtype, twostep; - ptp_class = ptp_classify_raw(skb); - if (ptp_class == PTP_CLASS_NONE) - return false; - hdr = ptp_parse_header(skb, ptp_class); if (!hdr) return false; @@ -614,11 +610,20 @@ int ocelot_port_txtstamp_request(struct { struct ocelot_port *ocelot_port = ocelot->ports[port]; u8 ptp_cmd = ocelot_port->ptp_cmd; + unsigned int ptp_class; int err; + /* Don't do anything if PTP timestamping not enabled */ + if (!ptp_cmd) + return 0; + + ptp_class = ptp_classify_raw(skb); + if (ptp_class == PTP_CLASS_NONE) + return -EINVAL; + /* Store ptp_cmd in OCELOT_SKB_CB(skb)->ptp_cmd */ if (ptp_cmd == IFH_REW_OP_ORIGIN_PTP) { - if (ocelot_ptp_is_onestep_sync(skb)) { + if (ocelot_ptp_is_onestep_sync(skb, ptp_class)) { OCELOT_SKB_CB(skb)->ptp_cmd = ptp_cmd; return 0; }