Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp288938pxb; Fri, 16 Apr 2021 05:53:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUIM3vcGAUYJ/MDMBWjUCSXe3KVGX2TPtK9QcqFrvFu8CU1pk38jHzvI/pafInPgsmgXLQ X-Received: by 2002:a05:6402:176e:: with SMTP id da14mr9503442edb.191.1618577588511; Fri, 16 Apr 2021 05:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618577588; cv=none; d=google.com; s=arc-20160816; b=yORlJlG5neU8dvQ0FbeXNAW5E8jLRxkDRWEbzfGKNUssCeY6zxIE21ytJU48dYaUMZ 3Z+drrw6+hTS8MVInUpxJWc/hUgk+yYdCXwokkHR8Y3SYDxqlopq8O2ZcAf7BjpEAsa6 tdlV6dbblTFehlo2yJIMHXOmezwAshfDFBbFWXMVcNX7MksJuEpo7d94iGGI7kZ2Hip/ tMbywTRCrHLss3MLmPnMIYHEBb1An1R2d4dKnRoCtTnlMbYhclPjRgSXCBcswv1B6dvH hYTDApm8/XPUhcTtB6KBqkqOU3AhCGJHvAHBcp5WGhLHwu38mz8DVmleK9nakxO4ECLW k2Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=yFk432X6+IIEBXuk1TdYOg9JtEedbpJPxN+QBFucFhg=; b=GkssGBm/HfHilfWMdKBxlrO49bDTEdZek/VYAqHDyKqSFi67L2Yauu8IuiVhuqtqtF bl5igMGmbKkhPDdRnvSKBvw2onvvOS7lAlgMsPlDGM0tfmwpN+XObM2dH+tqa3StuD7m yhifH04KsXjftTN3cGtrZvu2MJTETZWdrGZset5lx7F95ZxQRR9onX0h37MFeBkXF+Op EkqyN5h6bNtBr2aZTWBdJTJ26tcKgRXuw79+auq1G3Sq2Cb2kqSw+P84iWJWz4tA/7ZJ EOvBxR1sIx9DYJVhHfhEGKltTu8i0Km7XtgKAtgzmqRJejhkClUJm/ofnjy5kCOEboaC dcWg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qu7si4711247ejb.282.2021.04.16.05.52.45; Fri, 16 Apr 2021 05:53:08 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243507AbhDPMbR (ORCPT + 99 others); Fri, 16 Apr 2021 08:31:17 -0400 Received: from inva021.nxp.com ([92.121.34.21]:42566 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243424AbhDPMbM (ORCPT ); Fri, 16 Apr 2021 08:31:12 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2B60120092E; Fri, 16 Apr 2021 14:30:47 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id D9C00203A77; Fri, 16 Apr 2021 14:30:40 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id E964B402A6; Fri, 16 Apr 2021 14:30:32 +0200 (CEST) From: Yangbo Lu To: netdev@vger.kernel.org Cc: Yangbo Lu , 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: [net-next 2/3] net: mscc: ocelot: convert to ocelot_port_txtstamp_request() Date: Fri, 16 Apr 2021 20:36:54 +0800 Message-Id: <20210416123655.42783-3-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210416123655.42783-1-yangbo.lu@nxp.com> References: <20210416123655.42783-1-yangbo.lu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Convert to a common ocelot_port_txtstamp_request() for TX timestamp request handling. Signed-off-by: Yangbo Lu --- drivers/net/dsa/ocelot/felix.c | 14 +++++--------- drivers/net/ethernet/mscc/ocelot.c | 24 +++++++++++++++++++++--- drivers/net/ethernet/mscc/ocelot_net.c | 18 +++++++----------- include/soc/mscc/ocelot.h | 5 +++-- 4 files changed, 36 insertions(+), 25 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index cdec2f5e271c..5f2cf0f31253 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -1399,18 +1399,14 @@ static bool felix_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb, struct sk_buff **clone) { struct ocelot *ocelot = ds->priv; - struct ocelot_port *ocelot_port = ocelot->ports[port]; - if (ocelot->ptp && ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) { - *clone = skb_clone_sk(skb); - if (!(*clone)) - return false; + if (!ocelot->ptp) + return false; - ocelot_port_add_txtstamp_skb(ocelot, port, *clone); - return true; - } + if (ocelot_port_txtstamp_request(ocelot, port, skb, clone)) + return false; - return false; + return true; } static int felix_change_mtu(struct dsa_switch *ds, int port, int new_mtu) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 8d06ffaf318a..541d3b4076be 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -530,8 +530,8 @@ void ocelot_port_disable(struct ocelot *ocelot, int port) } EXPORT_SYMBOL(ocelot_port_disable); -void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port, - struct sk_buff *clone) +static void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port, + struct sk_buff *clone) { struct ocelot_port *ocelot_port = ocelot->ports[port]; @@ -545,7 +545,25 @@ void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port, spin_unlock(&ocelot_port->ts_id_lock); } -EXPORT_SYMBOL(ocelot_port_add_txtstamp_skb); + +int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port, + struct sk_buff *skb, + struct sk_buff **clone) +{ + struct ocelot_port *ocelot_port = ocelot->ports[port]; + u8 ptp_cmd = ocelot_port->ptp_cmd; + + if (ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) { + *clone = skb_clone_sk(skb); + if (!(*clone)) + return -ENOMEM; + + ocelot_port_add_txtstamp_skb(ocelot, port, *clone); + } + + return 0; +} +EXPORT_SYMBOL(ocelot_port_txtstamp_request); static void ocelot_get_hwtimestamp(struct ocelot *ocelot, struct timespec64 *ts) diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 36f32a4d9b0f..8293152a6dc1 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -507,19 +507,15 @@ static netdev_tx_t ocelot_port_xmit(struct sk_buff *skb, struct net_device *dev) /* Check if timestamping is needed */ if (ocelot->ptp && (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { - rew_op = ocelot_port->ptp_cmd; + struct sk_buff *clone; - if (ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) { - struct sk_buff *clone; - - clone = skb_clone_sk(skb); - if (!clone) { - kfree_skb(skb); - return NETDEV_TX_OK; - } - - ocelot_port_add_txtstamp_skb(ocelot, port, clone); + if (ocelot_port_txtstamp_request(ocelot, port, skb, &clone)) { + kfree_skb(skb); + return NETDEV_TX_OK; + } + if (ocelot_port->ptp_cmd == IFH_REW_OP_TWO_STEP_PTP) { + rew_op = ocelot_port->ptp_cmd; rew_op |= clone->cb[0] << 3; } } diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 68cdc7ceaf4d..9cdaf1d9199f 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -820,8 +820,9 @@ int ocelot_vlan_add(struct ocelot *ocelot, int port, u16 vid, bool pvid, int ocelot_vlan_del(struct ocelot *ocelot, int port, u16 vid); int ocelot_hwstamp_get(struct ocelot *ocelot, int port, struct ifreq *ifr); int ocelot_hwstamp_set(struct ocelot *ocelot, int port, struct ifreq *ifr); -void ocelot_port_add_txtstamp_skb(struct ocelot *ocelot, int port, - struct sk_buff *clone); +int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port, + struct sk_buff *skb, + struct sk_buff **clone); void ocelot_get_txtstamp(struct ocelot *ocelot); void ocelot_port_set_maxlen(struct ocelot *ocelot, int port, size_t sdu); int ocelot_get_max_mtu(struct ocelot *ocelot, int port); -- 2.25.1