Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3145855pxb; Tue, 20 Apr 2021 01:22:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxss0td3wUeynUC2pwANayAgR2laO0lR77Gwt61soQkpd+YlBBY0nGiQrHOiRGpbq9n8RLT X-Received: by 2002:a63:6d6:: with SMTP id 205mr15976919pgg.320.1618906924840; Tue, 20 Apr 2021 01:22:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618906924; cv=none; d=google.com; s=arc-20160816; b=LQ2mjb79xrK302Y19Ns1kt3U9E6MTVCeC8n/F2QPFlxAGY6dSp+EFxUrVXiRPlpRGB oJu2rwZeXVLSe4n81jNgwng0WZpHUNBvUSKrY6jcJjJy5tlkUD1tvwwherauzGZGqqN1 ZnF4/0IQmqLH7ThE3J6NfFn80NWFR5etKd2qpokiC/8Enk6cLHyEPRyJflWUeGAFVsOw ZDO05lAlpD4uZWIhcF5oxMjLZCHPM9Tpw+ODVeT771jkmSLZ37WAOyXphAwL7q1ToaYy xfphdweA5/ta1k3HSy/VeeRSvV88+1OuhBA2gTxIkD7oEtqmOhI3upieWwq0TwCuNeqn sCEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bpUVM6DLGPNfVadjMrY94cpXZGTdruG63Wzesfn55es=; b=kUpp0aS2xZTinG2d7TMkv0VNmExmO3ZRbBmX2oObBvyEnWtQhf9D3crNFQlEXnNr3H C3x+4EwGEsVae7ClJKuZrdHsMtGQqSory3pZLprAnItCDY/MWHFAI4T7PDeU7sWNL9zX GqcbT7xdNcz9EtlXtfJIG9iX/p12OpS0i842vBiTpZLhNOaTFBNJ/eCuIweINxjangLm wAdImZAp+/AEgZHQtL7zolo8PYo4lCLMhHLAH0vqjOB9rOxHyqRuyGCMNxlcc1U1Z7jc noCpokmkaf7pu23Vl0WDAqqVEiMQGPEgRLbVMDWMkGOco8ERkfY62JcQyJewIARudNbs L6Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RaNBkPja; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q23si16252631pgt.495.2021.04.20.01.21.53; Tue, 20 Apr 2021 01:22:04 -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=@gmail.com header.s=20161025 header.b=RaNBkPja; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230495AbhDTIVa (ORCPT + 99 others); Tue, 20 Apr 2021 04:21:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230379AbhDTIVR (ORCPT ); Tue, 20 Apr 2021 04:21:17 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E175C06174A; Tue, 20 Apr 2021 01:20:44 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id y3so7680756eds.5; Tue, 20 Apr 2021 01:20:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=bpUVM6DLGPNfVadjMrY94cpXZGTdruG63Wzesfn55es=; b=RaNBkPjah7sMGOsN5eQAC5h9N0FeHARo/mtafE743B/oBuKn06NLSSj5EbjlvuPtJp uUbB4/JI2BrPIiE7r5NqMD0jGB3/7ZlJPw4z5zGhKrhd+85zmMe+V+t69nXxFJSXMqiY q3kPySV08rcS5iPJwGVwkb0Dd2cASsmER/od4eMSzJH1canAHTwtRtJM1vPIZ1Z9zcCV 0jXYkLI8r0p0n48gNQ3M0XPlos+jxozwZ9bQQ7prHjO04eakSB+SFW8KdjdxWCjb4jQ/ kfZXCzM+vTC8shl65zN4IbZZEOc1aHl/x3WWNVEdrElzDdoGHcHHdWZpUZ8v7iKzEts6 EiJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=bpUVM6DLGPNfVadjMrY94cpXZGTdruG63Wzesfn55es=; b=AhkzacmCHDWUczeDL855FNTOMASEpTZwc3y3fmzIjRX4yE5uOMGD86AW7KQXSNhO0W zMNl5Y6FHNmR65/Xi/oHuV6DkA/Cfv2/7/mLEFRYlgabH5HEhe7GOrH3qjON1Ysg2Gre FnNPanQh12LYpAYt3mc3x/4gwRtAUVAJWdiLMxRWc4M8/qXxR8r1VidB5h5sP08C1ReR XYuNdGhnETaYJAQj1bC6IuWkOObmiV6zX3vNwJNSC/qmGz7rJ5LmApvVQzf1z1jtw3hU ahNlOl5KvW3mDDLiu//YdCv3Mb+0Q8Yopk74PvmaEunQl8mfWNoywK1ZYJpmvNRB5hvs CODA== X-Gm-Message-State: AOAM5316OyVTQ9o6AqgGPFfReKc0Z4JA+jDipZSpi0/PzX3gryKmr7OF I/1d3cDLsUumCecbtiNH87k= X-Received: by 2002:a05:6402:350e:: with SMTP id b14mr1115170edd.307.1618906843215; Tue, 20 Apr 2021 01:20:43 -0700 (PDT) Received: from skbuf (5-12-16-165.residential.rdsnet.ro. [5.12.16.165]) by smtp.gmail.com with ESMTPSA id gn19sm11673126ejc.68.2021.04.20.01.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 01:20:42 -0700 (PDT) Date: Tue, 20 Apr 2021 11:20:41 +0300 From: Vladimir Oltean To: "Y.b. Lu" Cc: "netdev@vger.kernel.org" , Richard Cochran , Vladimir Oltean , "David S . Miller" , Jakub Kicinski , Jonathan Corbet , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Claudiu Manoil , Alexandre Belloni , "UNGLinuxDriver@microchip.com" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [net-next 3/3] net: mscc: ocelot: support PTP Sync one-step timestamping Message-ID: <20210420082041.tcthzr6ubtdk6ztf@skbuf> References: <20210416123655.42783-1-yangbo.lu@nxp.com> <20210416123655.42783-4-yangbo.lu@nxp.com> <20210418094609.xijzcg6g6zfcxucp@skbuf> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 20, 2021 at 07:33:39AM +0000, Y.b. Lu wrote: > > > + /* For two-step timestamp, retrieve ptp_cmd in DSA_SKB_CB_PRIV > > > + * and timestamp ID in clone->cb[0]. > > > + * For one-step timestamp, retrieve ptp_cmd in DSA_SKB_CB_PRIV. > > > + */ > > > + u8 *ptp_cmd = DSA_SKB_CB_PRIV(skb); > > > > This is fine in the sense that it works, but please consider creating something > > similar to sja1105: > > > > struct ocelot_skb_cb { > > u8 ptp_cmd; /* For both one-step and two-step timestamping */ > > u8 ts_id; /* Only for two-step timestamping */ }; > > > > #define OCELOT_SKB_CB(skb) \ > > ((struct ocelot_skb_cb *)DSA_SKB_CB_PRIV(skb)) > > > > And then access as OCELOT_SKB_CB(skb)->ptp_cmd, > > OCELOT_SKB_CB(clone)->ts_id. > > > > and put a comment to explain that this is done in order to have common code > > between Felix DSA and Ocelot switchdev. Basically Ocelot will not use the first > > 8 bytes of skb->cb, but there's enough space for this to not make any > > difference. The original skb will hold only ptp_cmd, the clone will only hold > > ts_id, but it helps to have the same structure in place. > > > > If you create this ocelot_skb_cb structure, I expect the comment above to be > > fairly redundant, you can consider removing it. > > > > You're right to define the structure. > Considering patch #1, move skb cloning to drivers, and populate DSA_SKB_CB(skb)->clone if needs to do so (per suggestion). > Can we totally drop dsa_skb_cb in dsa core? The only usage of it is holding a skb clone pointer, for only felix and sja1105. > Actually we can move such pointer in _skb_cb, instead of reserving the space of skb for any drivers. > > Do you think so? The trouble with skb->cb is that it isn't zero-initialized. But somebody needs to initialize the clone pointer to NULL, otherwise you don't know if this is a valid pointer or not. Because dsa_skb_tx_timestamp() is called before p->xmit(), the driver has no way to initialize the clone pointer by itself. So this was done directly from dsa_slave_xmit(), and not from any driver-specific hook. So this is why there is a DSA_SKB_CB(skb)->clone and not SJA1105_SKB_CB(skb)->clone. The alternative would be to memset(skb->cb, 0, 48) which is a bit sub-optimal because it initializes more than it needs. Alternatively, it might be possible to introduce a new property in struct dsa_device_ops which holds sizeof(struct sja1105_skb_cb), and the generic code will only zero-initialize this number of bytes. I don't know, if you can get it to work in a way that does not incur a noticeable performance penalty, I'm okay with whatever you come up with.