From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 481ACC433E0 for ; Sat, 13 Feb 2021 00:16:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EA5E64E00 for ; Sat, 13 Feb 2021 00:16:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232166AbhBMAQF (ORCPT ); Fri, 12 Feb 2021 19:16:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231991AbhBMAPt (ORCPT ); Fri, 12 Feb 2021 19:15:49 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFD1EC061793 for ; Fri, 12 Feb 2021 16:14:36 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id f14so2021627ejc.8 for ; Fri, 12 Feb 2021 16:14:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hMiktYE48aC3eRB5nm4zrzo0aS5BSOEhrYvQN5XaT+U=; b=qzdqWDQlZnsBTYEZO8RX3L+nq4B2BHpFSA2odsHsmF3fJOar46dLHfdI3FGZnth3g8 KxxqTjcyINi8iIQMKWc/8O6VSNVMSv1bNbjp8iJqUdhLhBvBwylH2UWGGvNCDq3Fl1m4 fFgNXW8J5lHt4CNMIFkvZHmxOkMmKkVMnkIJkTsA9g3MXMjPJXrVBSRXE/QdEG8Qrmd6 atebdJ9dhSbmVkCQfOcbIO0LdjZzib41vOLX5+lucJC0b8XhieNIWj5pyVWs4upE3psY hBakdznytsqQ0TkfhZHeL/U4c1rbB/SvGn+/vg6+nzi66Zl50aiL1ItcI1n8H1+hebs8 LPww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hMiktYE48aC3eRB5nm4zrzo0aS5BSOEhrYvQN5XaT+U=; b=LGuGOOCXLOiKLz+GMM2yLdPDz7RH5xIPmkzNcjNkNSLmDsy/Vyj76VRXks8rLWY0n6 NZcAVLWCuxp9jK+JImjHYfN1GS78EWvoA/yydTdCtkXpiCdyUrcVHrL+LQ1vDSVb6Oi7 //lvJ+tsm9rLkAWIpFgunMgobgI48NUZL+NNDldTIE08DTv4/coNIVZuOkArGlm+xStt u4/Sp9EfemnkoHooRfnJI7RHWRmavNrWjYQIDv2/ephJwdZmAUw9EzMcHS+6M4Ah7ezX bzWRxOspI51XvejFyCz2J/1f7LNj+UIuIguxx0X8ccsTLZqMDdmyruuMhLis8+jp58BS BMeQ== X-Gm-Message-State: AOAM532FrxZMtBqDAVZLGLF6aP92wTGd8Tg/v8aPS9EqN1J38qNyQYzZ 7g61gAUXYfK68kh2tAbhmzjKan1DiXE= X-Google-Smtp-Source: ABdhPJyfktrgOLaZk/0DEcg6LW0UhpE9TxlWTRW1qoEY+C8aNPg38D3W14E/MTPbw/qBwP4SBF5XtQ== X-Received: by 2002:a17:907:210d:: with SMTP id qn13mr5224227ejb.377.1613175275643; Fri, 12 Feb 2021 16:14:35 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id c1sm7015606eja.81.2021.02.12.16.14.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 16:14:35 -0800 (PST) From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Andrew Lunn , Florian Fainelli , Vivien Didelot , Richard Cochran , Claudiu Manoil , Alexandre Belloni , Vladimir Oltean , Maxim Kochetkov , UNGLinuxDriver@microchip.com Subject: [PATCH net-next 08/12] net: dsa: tag_ocelot: single out PTP-related transmit tag processing Date: Sat, 13 Feb 2021 02:14:08 +0200 Message-Id: <20210213001412.4154051-9-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210213001412.4154051-1-olteanv@gmail.com> References: <20210213001412.4154051-1-olteanv@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean There is one place where we cannot avoid accessing driver data, and that is 2-step PTP TX timestamping, since the switch wants us to provide a timestamp request ID through the injection header, which naturally must come from a sequence number kept by the driver (it is generated by the .port_txtstamp method prior to the tagger's xmit). However, since other drivers like dsa_loop do not claim PTP support anyway, the DSA_SKB_CB(skb)->clone will always be NULL anyway, so if we move all PTP-related dereferences of struct ocelot and struct ocelot_port into a separate function, we can effectively ensure that this is dead code when the ocelot tagger is attached to non-ocelot switches, and the stateful portion of the tagger is more self-contained. Signed-off-by: Vladimir Oltean --- net/dsa/tag_ocelot.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/net/dsa/tag_ocelot.c b/net/dsa/tag_ocelot.c index 8ce0b26f3520..fe00519229d7 100644 --- a/net/dsa/tag_ocelot.c +++ b/net/dsa/tag_ocelot.c @@ -5,6 +5,25 @@ #include #include "dsa_priv.h" +static void ocelot_xmit_ptp(struct dsa_port *dp, void *injection, + struct sk_buff *clone) +{ + struct ocelot *ocelot = dp->ds->priv; + struct ocelot_port *ocelot_port; + u64 rew_op; + + ocelot_port = ocelot->ports[dp->index]; + rew_op = ocelot_port->ptp_cmd; + + /* Retrieve timestamp ID populated inside skb->cb[0] of the + * clone by ocelot_port_add_txtstamp_skb + */ + if (ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) + rew_op |= clone->cb[0] << 3; + + ocelot_ifh_set_rew_op(injection, rew_op); +} + static struct sk_buff *ocelot_xmit(struct sk_buff *skb, struct net_device *netdev) { @@ -29,17 +48,8 @@ static struct sk_buff *ocelot_xmit(struct sk_buff *skb, ocelot_ifh_set_qos_class(injection, skb->priority); /* TX timestamping was requested */ - if (clone) { - u64 rew_op = ocelot_port->ptp_cmd; - - /* Retrieve timestamp ID populated inside skb->cb[0] of the - * clone by ocelot_port_add_txtstamp_skb - */ - if (ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) - rew_op |= clone->cb[0] << 3; - - ocelot_ifh_set_rew_op(injection, rew_op); - } + if (clone) + ocelot_xmit_ptp(dp, injection, clone); return skb; } -- 2.25.1