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: 9811721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B0B9D603D7 for ; Tue, 27 Jun 2017 13:59:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A38C228593 for ; Tue, 27 Jun 2017 13:59:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97FF1285D9; Tue, 27 Jun 2017 13:59:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 441A928593 for ; Tue, 27 Jun 2017 13:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751976AbdF0N7R (ORCPT ); Tue, 27 Jun 2017 09:59:17 -0400 Received: from mail-lf0-f45.google.com ([209.85.215.45]:32943 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751552AbdF0N7C (ORCPT ); Tue, 27 Jun 2017 09:59:02 -0400 Received: by mail-lf0-f45.google.com with SMTP id m77so17710633lfe.0 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=hTXIEFXBog8+bpic96KvBpY/qSM45qUEaXC7xo0hyhBdjOk4WcLM6ZD2rnQgkTLEij jLhFkMFxnWxTmGCW0SG6ZOZ48FCaIbsekW1VPuPoC9AylRkDNUCbOBx8VMYfSz13i83+ +3hfDWv8r/lnbj8T94DOOy35fySicwG+1aC4/YsfsQuu7XY3dQrS95a4IbXvNAmTfBoq CXs6d+V+VRumFCg3bM/Pj0BxXV2+PsaoLJVxlrEqDymsolaqksKq955yfgk28+181EU0 x/xKK0A0svZgqcLIjA66Wsqthc9KsxsqMulKD71wFtZVlsfFlkOB3k584jDFF2PkCaTy 1pLA== X-Gm-Message-State: AKS2vOxqm1Bb0AH8pJ33aJebt0z313C7dJl1xklk00zlrssOpDqG1H8S HSd66sLiH0Bc+8UEYcOc/g== 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-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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