From patchwork Tue Jun 27 13:58:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 106439 Delivered-To: patch@linaro.org Received: by 10.140.101.48 with SMTP id t45csp1234264qge; Tue, 27 Jun 2017 06:59:37 -0700 (PDT) X-Received: by 10.84.231.9 with SMTP id f9mr5971948plk.5.1498571977517; Tue, 27 Jun 2017 06:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498571977; cv=none; d=google.com; s=arc-20160816; b=A0evXGCGhbSE6X6+d4hcNLHl+Waco9UXcviikPnYUF56oQg4C2z/XCKLWHjd/LAi0z +8nDEZO6hdoB5gQHVAwSgyJH6FmgKH58nA/mzCdLhnA77g7VoaO0HVK4+7Fs+P0GFMLb tPHsTpHhaPuLeWjyhFCg5/zOsE9s6f6i7jJeRVdGkzHVsRZ7j0bia+EbC55m7SzMSohy yfVI9hHy0YsvdiIyhWq6fB+pQzBTF9FHUsovse7TPfCjo8BN7l6PZxJx02A7YnpqQhI+ z1RVz5Rdt28kF2Q2nzFEPOrmdqcKW9Mzto7o3dVZ8QxMue9/HACHnb8QsGL6Td3blhFz VlVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=rgcl5oIHOA1Vs/B6c5inT16a4Vb/abjjDVW7bUH/sQQ=; b=h9Ac6+B/MzumxX9Cl5ejH+INMuvADrLm0PIVbZ4JWqo95S3XvsKVuOtW4a2Vvd5snw eaNkORt0LLJ8oa60xOIczn/mFU3uubC8LpqKdLR1zAW7lbnRMlA0/HJfpNPMo+ZpEZcZ 5y240xuiv271QrbgVBsaKRP1RyFxOy4kEdGrp/h6zwcusWdeNHIwyIPLlQq6oU36sEiF 7+lWbx2jNK17Hjwd6UbjqvLbbCI1zW9A66VwwnilJmJDo1DWCYV9/YcUlcQB0BZhZ53k Ik9Ir1ZmvXnHVB3281P6ZZab38PxllrXXnFuyrC7VAkTJJxXC34slF7RZx31iy3Mmi/R 8uGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=Mm8hoTwI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13si1975816pgq.524.2017.06.27.06.59.37; Tue, 27 Jun 2017 06:59:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=Mm8hoTwI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751744AbdF0N7d (ORCPT + 25 others); Tue, 27 Jun 2017 09:59:33 -0400 Received: from mail-lf0-f52.google.com ([209.85.215.52]:35549 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751571AbdF0N7C (ORCPT ); Tue, 27 Jun 2017 09:59:02 -0400 Received: by mail-lf0-f52.google.com with SMTP id b207so17687670lfg.2 for ; Tue, 27 Jun 2017 06:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rgcl5oIHOA1Vs/B6c5inT16a4Vb/abjjDVW7bUH/sQQ=; b=Mm8hoTwIxyXkMUxrlsjR1Yzh+stk6OM9CqnwkPJdcW7FQW/DTO1Lp2oeMPrsChYwvH 41roxLRe9p6mEEseq3QR+mcMnfptEGlqTuM8HVP95C1WHW9aHDXEQlAVU/9LXJfekzan Eq0iDMllGhPs9rxYceYE73mVDp+roGM5C2Zkw= 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; bh=rgcl5oIHOA1Vs/B6c5inT16a4Vb/abjjDVW7bUH/sQQ=; b=qE5kFR8Nn9piN+eDEGZ11/8X5cSnoLUzqf4hTZhS/ijOjj3tbXeLURy3sM+L1weFC1 cb28o7Jd1WK7o5PM2HPdX80fT+xboK7JnbLNnXFQ0cJKC3zpMwb48UHBoVZjxiynM3bB V+KnSgHDaifkZIG2NdKzegbu3knsYFQN7MEedOz8vRnfAzoHeqnavD/F/xSiRY3SWFC1 T03gxKGsH1/frty6zk5sKGHXh+IT1BRhLiCJTyi1t3lb/zzefmnc8dGmRhEHdOEs7MUu eCjwhCumRdIyg6RdTZj3BNOhLKR6RiZTKTuZJn3opSeMD88YEZfJfXZk3Qnq60CX/eb4 7rSw== X-Gm-Message-State: AKS2vOzZ26dUA7+cBLqZBoqaGeR8bPSRMP/FExCRdF3uwZ3dP/2HoVe9 5PWR00dMga3GZQqr X-Received: by 10.46.69.137 with SMTP id s131mr218392lja.31.1498571940554; Tue, 27 Jun 2017 06:59:00 -0700 (PDT) Received: from localhost.localdomain (183-224-132-95.pool.ukrtel.net. [95.132.224.183]) by smtp.gmail.com with ESMTPSA id m29sm670836ljb.26.2017.06.27.06.58.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Jun 2017 06:58:59 -0700 (PDT) From: Ivan Khoronzhuk To: m-karicheri2@ti.com, w-kwok2@ti.com Cc: grygorii.strashko@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Ivan Khoronzhuk Subject: [PATCH net-next 2/3] net: ethernet: ti: cpsw: fix sw timestamping for non PTP packets Date: Tue, 27 Jun 2017 16:58:52 +0300 Message-Id: <1498571933-3663-3-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498571933-3663-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1498571933-3663-1-git-send-email-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cpts can timestmap only ptp packets at this moment, so driver cannot mark every packet as though it's going to be timestamped, only because h/w timestamping for given skb is enabled with SKBTX_HW_TSTAMP. It doesn't allow to use sw timestamping, as result outgoing packet is not timestamped at all if it's not PTP and h/w timestamping is enabled. So, fix it by setting SKBTX_IN_PROGRESS only for PTP packets. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw.c | 3 ++- drivers/net/ethernet/ti/cpts.h | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 422994e..1850e34 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -1598,6 +1598,7 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb, { struct cpsw_priv *priv = netdev_priv(ndev); struct cpsw_common *cpsw = priv->cpsw; + struct cpts *cpts = cpsw->cpts; struct netdev_queue *txq; struct cpdma_chan *txch; int ret, q_idx; @@ -1609,7 +1610,7 @@ static netdev_tx_t cpsw_ndo_start_xmit(struct sk_buff *skb, } if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && - cpts_is_tx_enabled(cpsw->cpts)) + cpts_is_tx_enabled(cpts) && cpts_can_timestamp(cpts, skb)) skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; q_idx = skb_get_queue_mapping(skb); diff --git a/drivers/net/ethernet/ti/cpts.h b/drivers/net/ethernet/ti/cpts.h index c96eca2..01ea82b 100644 --- a/drivers/net/ethernet/ti/cpts.h +++ b/drivers/net/ethernet/ti/cpts.h @@ -30,6 +30,7 @@ #include #include #include +#include #include struct cpsw_cpts { @@ -155,6 +156,16 @@ static inline bool cpts_is_tx_enabled(struct cpts *cpts) return !!cpts->tx_enable; } +static inline bool cpts_can_timestamp(struct cpts *cpts, struct sk_buff *skb) +{ + unsigned int class = ptp_classify_raw(skb); + + if (class == PTP_CLASS_NONE) + return false; + + return true; +} + #else struct cpts; @@ -203,6 +214,11 @@ static inline bool cpts_is_tx_enabled(struct cpts *cpts) { return false; } + +static inline bool cpts_can_timestamp(struct cpts *cpts, struct sk_buff *skb) +{ + return false; +} #endif