From patchwork Tue Feb 5 12:15:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 157472 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp5085761jaa; Tue, 5 Feb 2019 04:15:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IaJyeKM17/cxZS4xPs+wmSyKdSEpi9AmP1jt32XFzR2LmbKoXEHiRq6Lrb6CK4goXHYADx5 X-Received: by 2002:a62:442:: with SMTP id 63mr4622863pfe.156.1549368936525; Tue, 05 Feb 2019 04:15:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549368936; cv=none; d=google.com; s=arc-20160816; b=bxBCJdkM5jitfRzN4WitrrA5al2qmLOyfdjD1O7AeNP1c4HpznZ6pbBieCQbEGUzg3 oUCt0zRHnDMoyhG4MTIBV4jjhxhIQhyXSooc8YqQi4jvSmk9cwCvWxDy45qT+DRE+hhA 9mhEu8IC8IT72WhlcNPqYkRQWolvcyKpr83Rn7i0Ol2U9beUV90w6XwtxKggoBtAYbjo 7L0SaPxz1ILAPWNqZfiQf8mJrHk7IwD/R3lQzc5uWosH8JDweDDMZxKS4RZF9BbmoUkj pI/6Jxp/diXqcuPwGI7/H0m2NuLAQKNr82uTxOCyMvp9qvsGSUqLZ0ToudI8UaAH4W21 qs4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=sBppXxcw0COicNq3kIcrMsTKIyYv5Uu2rZNumt8Ntnw=; b=rwJX4wpfRaNuazZOp5Uykd22rNHZ8LlxvN8y/jf/Er+L91JjghGm6vWGfZKOym9Or8 erotXSkWO0fZj+OHil5N4fJdpHHsBD5k4eUjQqp2AmWbJ0lcH/DEhK7OdS13CpxhwvGv jLXn+5j0trqlu7vm8IGfB9gTj06D3bL8sUppOwlpUo66vrduScs18jmn9c1oZ8CKuuAy US1LYm4OKqgUj958Q5H6mzY06mwEgZf12lswQnioKJqa1NdmWhblz6UEriyX7Aq1nSo7 nDOUsm2LvS45dcEC8xoh5opehOFG/h0sUg7xLsQoTceOIqS9fihxG9CShywuIe86k+4S yF0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BViObQnJ; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 v3si2820615pga.556.2019.02.05.04.15.36; Tue, 05 Feb 2019 04:15:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-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.s=google header.b=BViObQnJ; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 S1728782AbfBEMPe (ORCPT + 10 others); Tue, 5 Feb 2019 07:15:34 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33582 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726456AbfBEMPe (ORCPT ); Tue, 5 Feb 2019 07:15:34 -0500 Received: by mail-wr1-f66.google.com with SMTP id a16so3401505wrv.0 for ; Tue, 05 Feb 2019 04:15:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=sBppXxcw0COicNq3kIcrMsTKIyYv5Uu2rZNumt8Ntnw=; b=BViObQnJQ0LFP9eHhR4GMg5rhoGOh91R/k6OUqlji4hBcAtp0fzbUi0HYulLtRKyJ5 6IQhoC2V7NTH2l7+6vbtjqUjQVnT0uXQTM6ZHSeF8hHAze0RrtWPoBQsKiBVN9pOAOzi 8s6JzEYPaqk6oRhQ48uWfLPFBni7IrT5lJcmOUwxG6kpzII21uTNkuSUkpOT827xJZmV JrZ5/IXMVlLz328mRetXKJaEixIohy85gKmZs7GMub+sN/ZthnHbiV+h712Yya+q2bzd 7ltuCZ6fFCv0KcNfzTz5TxAlHqM1EJJLDZbuLmO/W22OujkGyHakWX1zJ06MKitJmdXx dHtA== 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; bh=sBppXxcw0COicNq3kIcrMsTKIyYv5Uu2rZNumt8Ntnw=; b=BcNqDBGMHHbumwTXTZ92y9Je2Cg37sn/JFxQAinaRvAQxEOJCVpCxEgjXdFkHjDPiv Zi2UZnzK52zyUD4ZcLVuEkpvnFuJ0OwXb1nr0z1/Td/avAPVZEWGmb23LPMQTxi+6R0T aEjnZpBchzyzH1X9iGACF2hh9fSkOllNQO5pFmFxGufcFYnNdwQqNg/HP9JB9QA4OKbr jro6HRLCSMG0uQJcO2eXBmKjFK5/UpZyCnJGP3YKQji71wG5U9BcStZinpUU5mlgOa9s +90A4qj4ZmGEpume3tiQNcvOwMYS8WUX/7562UJipdMljlvaFwRDiGzJm1bjXnnJ2OCI LXfg== X-Gm-Message-State: AHQUAuYY0uCkJ925NvsqUm4jMbE37V1f9BYsYheA7WiNfsoG0RQepQ3H OWpA4qVh220DvD5UuM+H3pRUNw== X-Received: by 2002:a05:6000:8f:: with SMTP id m15mr1432394wrx.87.1549368932180; Tue, 05 Feb 2019 04:15:32 -0800 (PST) Received: from apalos.lan (athedsl-4478959.home.otenet.gr. [94.71.35.247]) by smtp.gmail.com with ESMTPSA id e2sm856664wrw.35.2019.02.05.04.15.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Feb 2019 04:15:31 -0800 (PST) From: Ilias Apalodimas To: alexandre.torgue@st.com Cc: peppe.cavallaro@st.com, davem@davemloft.net, mcoquelin.stm32@gmail.com, netdev@vger.kernel.org, joabreu@synopsys.com, Ilias Apalodimas Subject: [net-next, PATCH] net: stmmac: fix ptp timestamping on Rx on gmac4 Date: Tue, 5 Feb 2019 14:15:20 +0200 Message-Id: <1549368920-1989-1-git-send-email-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The current driver only enables Pdelay_Req and Pdelay_Resp when HWTSTAMP_FILTER_PTP_V2_EVENT, HWTSTAMP_FILTER_PTP_V1_L4_EVENT or HWTSTAMP_FILTER_PTP_V2_L4_EVENT is requested. This results in ptp sync on slave mode to report 'received SYNC without timestamp' when using ptp4l. Although the hardware can support Sync, Pdelay_Req and Pdelay_resp by setting bit14 annd bits 17/16 to 01 this leaves Delay_Req timestamps out. Fix this by enabling all event and general messages timestamps. This includes SYNC, Follow_Up, Delay_Req, Delay_Resp, Pdelay_Req, Pdelay_Resp and Pdelay_Resp_Follow_Up messages. Signed-off-by: Ilias Apalodimas --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 25 ++++++++--------------- drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h | 9 ++++++-- 2 files changed, 16 insertions(+), 18 deletions(-) -- 2.7.4 Acked-by: Jose Abreu Tested-by: Alexandre TORGUE diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 517555b..effff17 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -597,12 +597,13 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) case HWTSTAMP_FILTER_PTP_V1_L4_EVENT: /* PTP v1, UDP, any kind of event packet */ config.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT; - /* take time stamp for all event messages */ - if (xmac) - snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1; - else - snap_type_sel = PTP_TCR_SNAPTYPSEL_1; - + /* 'xmac' hardware can support Sync, Pdelay_Req and + * Pdelay_resp by setting bit14 and bits17/16 to 01 + * This leaves Delay_Req timestamps out. + * Enable all events *and* general purpose message + * timestamping + */ + snap_type_sel = PTP_TCR_SNAPTYPSEL_1; ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA; ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA; break; @@ -633,10 +634,7 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT; ptp_v2 = PTP_TCR_TSVER2ENA; /* take time stamp for all event messages */ - if (xmac) - snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1; - else - snap_type_sel = PTP_TCR_SNAPTYPSEL_1; + snap_type_sel = PTP_TCR_SNAPTYPSEL_1; ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA; ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA; @@ -669,12 +667,7 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) /* PTP v2/802.AS1 any layer, any kind of event packet */ config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; ptp_v2 = PTP_TCR_TSVER2ENA; - /* take time stamp for all event messages */ - if (xmac) - snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1; - else - snap_type_sel = PTP_TCR_SNAPTYPSEL_1; - + snap_type_sel = PTP_TCR_SNAPTYPSEL_1; ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA; ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA; ptp_over_ethernet = PTP_TCR_TSIPENA; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h index ecccf89..e852821 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h @@ -59,9 +59,14 @@ #define PTP_TCR_TSEVNTENA BIT(14) /* Enable Snapshot for Messages Relevant to Master */ #define PTP_TCR_TSMSTRENA BIT(15) -/* Select PTP packets for Taking Snapshots */ +/* Select PTP packets for Taking Snapshots + * On gmac4 specifically: + * Enable SYNC, Pdelay_Req, Pdelay_Resp when TSEVNTENA is enabled. + * or + * Enable SYNC, Follow_Up, Delay_Req, Delay_Resp, Pdelay_Req, Pdelay_Resp, + * Pdelay_Resp_Follow_Up if TSEVNTENA is disabled + */ #define PTP_TCR_SNAPTYPSEL_1 BIT(16) -#define PTP_GMAC4_TCR_SNAPTYPSEL_1 GENMASK(17, 16) /* Enable MAC address for PTP Frame Filtering */ #define PTP_TCR_TSENMACADDR BIT(18)