From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B96CA45843; Fri, 23 Aug 2024 09:34:24 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CDF1A43283; Fri, 23 Aug 2024 09:33:19 +0200 (CEST) Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011023.outbound.protection.outlook.com [52.101.65.23]) by mails.dpdk.org (Postfix) with ESMTP id D8E1143270 for ; Fri, 23 Aug 2024 09:33:12 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=N1Kfrbb1bmilE9Zq232P7nvkTn3kbUY63I5ALQX+K51m2YbR9L8TIilkm6rE4GCSPInAnIObzU+6F0xs+am+61Jd2O3oxdk/d0kdHBK34hH8qg5ayofK33cIDIhR9KeXfgyjI5heGJXRUy3nXyuA/c4XXA3MjhDhnwue6MXFdr+2sq4SoIC2J8XVlOcMRCmuzdaoXAzlirluEThXZjhmdCX8Ludn4xys6bzCGbU3aioM2TGArUZDl9QgxJndWeJYUequmV2RZrwymJ0UPAiJ5CEs0vB62H79g2613ZZuAZ/PH9mp5aJYFv03Vpv7RAiSpawvZB8j3Dq1XrYhZQEX1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7llJcOSSJLXyyqcJyGgj62kHCHv+pWsETUhHZWT3/CQ=; b=u/T9NvgJkJvoesM3qcSm0NMdPs6GKNMHNF56Mr+GwAInZqTYAIbx/mgiC8VLLlq4WFK3czjH92VwL3FP5bGeQVP9BmFJREeyP/ps7XIP0etn/QLouYNB/CZjc1Ht20G9gQ4GQKk6hpdWuP0bdL9THf1Lf9vW9atFxX1EJD4KzGHfnZbmKbCn9oaYPQl1myANNSSzWc0VDUK0s1UYaPoPnM8iHG+pRf2mxlOxyGkzNwsQ5ep12RtgJkExkoQXt9Y3HwwgQ1r6VZCRofHZTB+HH+YUe7bm4JsOA6bIIGQ1zU7AhMYkzERcK2ocZs3QWR+/uGtz541aUxdMSzgulr2zNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7llJcOSSJLXyyqcJyGgj62kHCHv+pWsETUhHZWT3/CQ=; b=Zc7rMbj9ydLqcHQ/GBdALo7850I5R/RKMY5aYzZAE7FS2bW2xhOfDgrQzhosGChz1FQSTeJeBNFM/rVSmivNgHkzZsTUHEQEYocKHJV+ok9mkOeh5OV4M4RpaQoJESVegvQPGqop65YWqC+fIoiIWKAmwcWLjpTdrn247+hW9LHwde1yiF8gN3wEtDZT/yyH7C2QFLOVl+B7gZvTZo+/uh0zPKKDxUTit2Gq7spfvo4eIFqMpUNLaTjFvmRlbjLKoTmg7nao7ZzvzJM+msQyP3isk6t/Rn+bT+tq/tyU/O9eaVceM0ejzH6MK9iQ3z5VE88DRZOk5xK6qcOJVc19lA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) by DU2PR04MB8789.eurprd04.prod.outlook.com (2603:10a6:10:2e0::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Fri, 23 Aug 2024 07:33:11 +0000 Received: from PAXPR04MB9328.eurprd04.prod.outlook.com ([fe80::367:d59:375:fb87]) by PAXPR04MB9328.eurprd04.prod.outlook.com ([fe80::367:d59:375:fb87%3]) with mapi id 15.20.7875.019; Fri, 23 Aug 2024 07:33:11 +0000 From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Vanshika Shukla Subject: [PATCH v2 09/18] net/dpaa: support Rx/Tx timestamp read Date: Fri, 23 Aug 2024 13:02:31 +0530 Message-Id: <20240823073240.3708320-10-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240823073240.3708320-1-hemant.agrawal@nxp.com> References: <20240801105313.630280-1-hemant.agrawal@nxp.com> <20240823073240.3708320-1-hemant.agrawal@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR02CA0028.apcprd02.prod.outlook.com (2603:1096:3:18::16) To PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9328:EE_|DU2PR04MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: fac93367-7d35-4f9c-f460-08dcc345d746 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?xmCtj9k+c1wwSPgXafx5HQvOW7bVJ/R4zYsRQpZqNBozKAGB+h+xLhGDuRp1?= =?us-ascii?Q?XiintonIrZYa3uFWqzK/SX3j/15neWl7YySVNC9ym636bXmj6Nb1g9AFuQNJ?= =?us-ascii?Q?RYIMFYnNpTPq9yTwqyGfF7bV/t2OMpiK1gj19UZnPMXlFQw128N/f68kMCFR?= =?us-ascii?Q?djnGdZg90+KepZCZhklsdfCCa34QQSlHwKg57dLMZqy1pKya2pQr3eWmOa7p?= =?us-ascii?Q?y/M11Mta2kBD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ascii?Q?84xDc4hzR7zoiml1nmSgRkAvQ0fReXJa6dpZAWHrFJDJz/ShkkXI51GMeJaj?= =?us-ascii?Q?lK1TH3a8AXA3HnvCafsau5A7w6tFVrR2usmibM1WG4/TK+edIbA7Lkxc3H8X?= =?us-ascii?Q?p60aOG9r5xXV9+/8+9/+7n1lxqhpbIDPqc09AyReji5jTCMH7Z8wakUpXHg5?= =?us-ascii?Q?osxbZsgcUABP/RenkMfGVxQSwrqLyBRjpiVAglZvGrivfjcw6gN9wQLCpsKT?= =?us-ascii?Q?2QlXC59ezrT5QxGavp/svPh1lOJggBcuaDdwSZ3/MJ+bTxPDag=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB9328.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?1M2pjK6xt3rWhFKWjP04jxXuGjaF6hB33d8EqIkvUqiAljRoOk4JmOi1OkBP?= =?us-ascii?Q?hZmMQG3tYaMyZJ90Rnlbh0/3yDrMJiv2WQD7CUTEkbr/BjavOUD0ZZU+0WIk?= =?us-ascii?Q?Vqe3cBCMN4taPBEMNk2HdAVe37zCJumR2b7WqAYGnLf0vvHM+UOZP2p7uYGN?= =?us-ascii?Q?QDmyvJJnwaatI+PeyOm6HIw3N6FVvstAyLrylhuPOLERoOvnA/R2+VnjebwH?= =?us-ascii?Q?SSoBtXoSYJENqqdRPEKjsXgJ4aDhfyXpyuUyEbwDlzuUNiuyHpRybcLDKhbc?= =?us-ascii?Q?zzEgnv/pVlE1F6wfgB7ib13DLBWfvQAV4qSlTa2a16P0MOjDgeGXy13ijkkz?= =?us-ascii?Q?f9Z+cbdQJUYdCnRPmHDloFw51UwjNLGDKKfgsU83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yFWDO6I1dkmlIfpLh/g14WQ1mpaAVv8ts+vRp7jzBfOKyYWxYW/?= =?us-ascii?Q?pnvvgnmys9j+3NC8lOwqE2MviVezGjPqzmeQ5gSoCPK+KiyVt9OHdw5ibjVH?= =?us-ascii?Q?a3CtT/l7kzV1YQLjWySBCukO8VRV3AVENgXBlHpdA7YzmNqPr+quy6OunGjX?= =?us-ascii?Q?dYdkrGQuqWOpWJI+OvSrBu0jvuFxcRjicL5pWddlddIoaeMrgYx1ZFdhs01R?= =?us-ascii?Q?oAOuIYvKjGPqbFWXD13/Wvj1ifedr9km/35Y7Qv0SA2eWC8tl1gs1IR0a1+a?= =?us-ascii?Q?k6gLUTEfmSH7MKg4EDnAt2HTHiSlxTbykCbWe/+k7aQKXXOB5J4i8edCU+Pb?= =?us-ascii?Q?mA=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fac93367-7d35-4f9c-f460-08dcc345d746 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9328.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 07:33:11.4613 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7astIdrLnTt306TZ0kE7zUEuwNAhzH6zMQMPXBp94QIbPW/SbRmHmhl+qpRowAlLl6kYoJrdSnab0FYaJ2X61w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8789 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Vanshika Shukla This patch implements Rx/Tx timestamp read operations for DPAA1 platform. Signed-off-by: Vanshika Shukla --- doc/guides/nics/features/dpaa.ini | 1 + drivers/bus/dpaa/base/fman/fman.c | 21 +++++++- drivers/bus/dpaa/base/fman/fman_hw.c | 6 ++- drivers/bus/dpaa/include/fman.h | 18 ++++++- drivers/net/dpaa/dpaa_ethdev.c | 2 + drivers/net/dpaa/dpaa_ethdev.h | 17 +++++++ drivers/net/dpaa/dpaa_ptp.c | 43 +++++++++++++++++ drivers/net/dpaa/dpaa_rxtx.c | 71 ++++++++++++++++++++++++---- drivers/net/dpaa/dpaa_rxtx.h | 4 +- drivers/net/dpaa/meson.build | 1 + 10 files changed, 169 insertions(+), 15 deletions(-) create mode 100644 drivers/net/dpaa/dpaa_ptp.c diff --git a/doc/guides/nics/features/dpaa.ini b/doc/guides/nics/features/dpaa.ini index b136ed191a..4196dd800c 100644 --- a/doc/guides/nics/features/dpaa.ini +++ b/doc/guides/nics/features/dpaa.ini @@ -19,6 +19,7 @@ Flow control = Y L3 checksum offload = Y L4 checksum offload = Y Packet type parsing = Y +Timestamp offload = Y Basic stats = Y Extended stats = Y FW version = Y diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c index bf41a3ed96..89786636d9 100644 --- a/drivers/bus/dpaa/base/fman/fman.c +++ b/drivers/bus/dpaa/base/fman/fman.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) * * Copyright 2010-2016 Freescale Semiconductor Inc. - * Copyright 2017-2020 NXP + * Copyright 2017-2024 NXP * */ @@ -520,6 +520,25 @@ fman_if_init(const struct device_node *dpa_node) goto err; } + regs_addr = of_get_address(tx_node, 0, &__if->regs_size, NULL); + if (!regs_addr) { + FMAN_ERR(-EINVAL, "of_get_address(%s)\n", mname); + goto err; + } + phys_addr = of_translate_address(tx_node, regs_addr); + if (!phys_addr) { + FMAN_ERR(-EINVAL, "of_translate_address(%s, %p)\n", + mname, regs_addr); + goto err; + } + __if->tx_bmi_map = mmap(NULL, __if->regs_size, + PROT_READ | PROT_WRITE, MAP_SHARED, + fman_ccsr_map_fd, phys_addr); + if (__if->tx_bmi_map == MAP_FAILED) { + FMAN_ERR(-errno, "mmap(0x%"PRIx64")\n", phys_addr); + goto err; + } + /* No channel ID for MAC-less */ assert(lenp == sizeof(*tx_channel_id)); na = of_n_addr_cells(mac_node); diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c b/drivers/bus/dpaa/base/fman/fman_hw.c index 124c69edb4..4fc41c1ae9 100644 --- a/drivers/bus/dpaa/base/fman/fman_hw.c +++ b/drivers/bus/dpaa/base/fman/fman_hw.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-3-Clause * - * Copyright 2017,2020 NXP + * Copyright 2017,2020,2022 NXP * */ @@ -565,6 +565,10 @@ fman_if_set_ic_params(struct fman_if *fm_if, &((struct rx_bmi_regs *)__if->bmi_map)->fmbm_ricp; out_be32(fmbm_ricp, val); + unsigned int *fmbm_ticp = + &((struct tx_bmi_regs *)__if->tx_bmi_map)->fmbm_ticp; + out_be32(fmbm_ticp, val); + return 0; } diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h index 3642b43be7..857eef3d2f 100644 --- a/drivers/bus/dpaa/include/fman.h +++ b/drivers/bus/dpaa/include/fman.h @@ -2,7 +2,7 @@ * * Copyright 2010-2012 Freescale Semiconductor, Inc. * All rights reserved. - * Copyright 2019-2021 NXP + * Copyright 2019-2022 NXP * */ @@ -292,6 +292,21 @@ struct rx_bmi_regs { uint32_t fmbm_rdbg; /**< Rx Debug-*/ }; +struct tx_bmi_regs { + uint32_t fmbm_tcfg; /**< Tx Configuration*/ + uint32_t fmbm_tst; /**< Tx Status*/ + uint32_t fmbm_tda; /**< Tx DMA attributes*/ + uint32_t fmbm_tfp; /**< Tx FIFO Parameters*/ + uint32_t fmbm_tfed; /**< Tx Frame End Data*/ + uint32_t fmbm_ticp; /**< Tx Internal Context Parameters*/ + uint32_t fmbm_tfdne; /**< Tx Frame Dequeue Next Engine*/ + uint32_t fmbm_tfca; /**< Tx Frame Attributes*/ + uint32_t fmbm_tcfqid; /**< Tx Confirmation Frame Queue ID*/ + uint32_t fmbm_tefqid; /**< Tx Error Frame Queue ID*/ + uint32_t fmbm_tfene; /**< Tx Frame Enqueue Next Engine*/ + uint32_t fmbm_trlmts; /**< Tx Rate Limiter Scale*/ + uint32_t fmbm_trlmt; /**< Tx Rate Limiter*/ +}; struct fman_port_qmi_regs { uint32_t fmqm_pnc; /**< PortID n Configuration Register */ uint32_t fmqm_pns; /**< PortID n Status Register */ @@ -380,6 +395,7 @@ struct __fman_if { uint64_t regs_size; void *ccsr_map; void *bmi_map; + void *tx_bmi_map; void *qmi_map; struct list_head node; }; diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index bf14d73433..682cb1c77e 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -1673,6 +1673,8 @@ static struct eth_dev_ops dpaa_devops = { .rx_queue_intr_disable = dpaa_dev_queue_intr_disable, .rss_hash_update = dpaa_dev_rss_hash_update, .rss_hash_conf_get = dpaa_dev_rss_hash_conf_get, + .timesync_read_rx_timestamp = dpaa_timesync_read_rx_timestamp, + .timesync_read_tx_timestamp = dpaa_timesync_read_tx_timestamp, }; static bool diff --git a/drivers/net/dpaa/dpaa_ethdev.h b/drivers/net/dpaa/dpaa_ethdev.h index 0a1ceb376a..bbdb0936c0 100644 --- a/drivers/net/dpaa/dpaa_ethdev.h +++ b/drivers/net/dpaa/dpaa_ethdev.h @@ -151,6 +151,14 @@ struct dpaa_if { void *netenv_handle; void *scheme_handle[2]; uint32_t scheme_count; + /*stores timestamp of last received packet on dev*/ + uint64_t rx_timestamp; + /*stores timestamp of last received tx confirmation packet on dev*/ + uint64_t tx_timestamp; + /* stores pointer to next tx_conf queue that should be processed, + * it corresponds to last packet transmitted + */ + struct qman_fq *next_tx_conf_queue; void *vsp_handle[DPAA_VSP_PROFILE_MAX_NUM]; uint32_t vsp_bpid[DPAA_VSP_PROFILE_MAX_NUM]; @@ -233,6 +241,15 @@ struct dpaa_if_rx_bmi_stats { uint32_t fmbm_rbdc; /**< Rx Buffers Deallocate Counter*/ }; +int +dpaa_timesync_read_tx_timestamp(struct rte_eth_dev *dev, + struct timespec *timestamp); + +int +dpaa_timesync_read_rx_timestamp(struct rte_eth_dev *dev, + struct timespec *timestamp, + uint32_t flags __rte_unused); + /* PMD related logs */ extern int dpaa_logtype_pmd; #define RTE_LOGTYPE_DPAA_PMD dpaa_logtype_pmd diff --git a/drivers/net/dpaa/dpaa_ptp.c b/drivers/net/dpaa/dpaa_ptp.c new file mode 100644 index 0000000000..df6df1ddf2 --- /dev/null +++ b/drivers/net/dpaa/dpaa_ptp.c @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2022-2024 NXP + */ + +/* System headers */ +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +int dpaa_timesync_read_tx_timestamp(struct rte_eth_dev *dev, + struct timespec *timestamp) +{ + struct dpaa_if *dpaa_intf = dev->data->dev_private; + + if (dpaa_intf->next_tx_conf_queue) { + while (!dpaa_intf->tx_timestamp) + dpaa_eth_tx_conf(dpaa_intf->next_tx_conf_queue); + } else { + return -1; + } + *timestamp = rte_ns_to_timespec(dpaa_intf->tx_timestamp); + + return 0; +} + +int dpaa_timesync_read_rx_timestamp(struct rte_eth_dev *dev, + struct timespec *timestamp, + uint32_t flags __rte_unused) +{ + struct dpaa_if *dpaa_intf = dev->data->dev_private; + *timestamp = rte_ns_to_timespec(dpaa_intf->rx_timestamp); + return 0; +} + diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c index d1338d1654..e3b4bb14ab 100644 --- a/drivers/net/dpaa/dpaa_rxtx.c +++ b/drivers/net/dpaa/dpaa_rxtx.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright 2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2017,2019-2021 NXP + * Copyright 2017,2019-2024 NXP * */ @@ -49,7 +49,6 @@ #define DPAA_MBUF_TO_CONTIG_FD(_mbuf, _fd, _bpid) \ do { \ - (_fd)->cmd = 0; \ (_fd)->opaque_addr = 0; \ (_fd)->opaque = QM_FD_CONTIG << DPAA_FD_FORMAT_SHIFT; \ (_fd)->opaque |= ((_mbuf)->data_off) << DPAA_FD_OFFSET_SHIFT; \ @@ -122,6 +121,8 @@ static inline void dpaa_eth_packet_info(struct rte_mbuf *m, void *fd_virt_addr) { struct annotations_t *annot = GET_ANNOTATIONS(fd_virt_addr); uint64_t prs = *((uintptr_t *)(&annot->parse)) & DPAA_PARSE_MASK; + struct rte_ether_hdr *eth_hdr = + rte_pktmbuf_mtod(m, struct rte_ether_hdr *); DPAA_DP_LOG(DEBUG, " Parsing mbuf: %p with annotations: %p", m, annot); @@ -241,6 +242,11 @@ static inline void dpaa_eth_packet_info(struct rte_mbuf *m, void *fd_virt_addr) if (prs & DPAA_PARSE_VLAN_MASK) m->ol_flags |= RTE_MBUF_F_RX_VLAN; /* Packet received without stripping the vlan */ + + if (eth_hdr->ether_type == htons(RTE_ETHER_TYPE_1588)) { + m->ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP; + m->ol_flags |= RTE_MBUF_F_RX_IEEE1588_TMST; + } } static inline void dpaa_checksum(struct rte_mbuf *mbuf) @@ -317,7 +323,7 @@ static inline void dpaa_checksum_offload(struct rte_mbuf *mbuf, prs->ip_off[0] = mbuf->l2_len; prs->l4_off = mbuf->l3_len + mbuf->l2_len; /* Enable L3 (and L4, if TCP or UDP) HW checksum*/ - fd->cmd = DPAA_FD_CMD_RPD | DPAA_FD_CMD_DTC; + fd->cmd |= DPAA_FD_CMD_RPD | DPAA_FD_CMD_DTC; } static inline void @@ -513,6 +519,7 @@ dpaa_rx_cb_no_prefetch(struct qman_fq **fq, struct qm_dqrr_entry **dqrr, uint16_t offset, i; uint32_t length; uint8_t format; + struct annotations_t *annot; bp_info = DPAA_BPID_TO_POOL_INFO(dqrr[0]->fd.bpid); ptr = rte_dpaa_mem_ptov(qm_fd_addr(&dqrr[0]->fd)); @@ -554,6 +561,11 @@ dpaa_rx_cb_no_prefetch(struct qman_fq **fq, struct qm_dqrr_entry **dqrr, rte_mbuf_refcnt_set(mbuf, 1); dpaa_eth_packet_info(mbuf, mbuf->buf_addr); dpaa_display_frame_info(fd, fq[0]->fqid, true); + if (dpaa_ieee_1588) { + annot = GET_ANNOTATIONS(mbuf->buf_addr); + dpaa_intf->rx_timestamp = + rte_cpu_to_be_64(annot->timestamp); + } } } @@ -567,6 +579,7 @@ dpaa_rx_cb(struct qman_fq **fq, struct qm_dqrr_entry **dqrr, uint16_t offset, i; uint32_t length; uint8_t format; + struct annotations_t *annot; for (i = 0; i < num_bufs; i++) { fd = &dqrr[i]->fd; @@ -594,6 +607,11 @@ dpaa_rx_cb(struct qman_fq **fq, struct qm_dqrr_entry **dqrr, rte_mbuf_refcnt_set(mbuf, 1); dpaa_eth_packet_info(mbuf, mbuf->buf_addr); dpaa_display_frame_info(fd, fq[0]->fqid, true); + if (dpaa_ieee_1588) { + annot = GET_ANNOTATIONS(mbuf->buf_addr); + dpaa_intf->rx_timestamp = + rte_cpu_to_be_64(annot->timestamp); + } } } @@ -758,6 +776,8 @@ uint16_t dpaa_eth_queue_rx(void *q, uint32_t num_rx = 0, ifid = ((struct dpaa_if *)fq->dpaa_intf)->ifid; int num_rx_bufs, ret; uint32_t vdqcr_flags = 0; + struct annotations_t *annot; + struct dpaa_if *dpaa_intf = fq->dpaa_intf; if (unlikely(rte_dpaa_bpid_info == NULL && rte_eal_process_type() == RTE_PROC_SECONDARY)) @@ -800,6 +820,10 @@ uint16_t dpaa_eth_queue_rx(void *q, continue; bufs[num_rx++] = dpaa_eth_fd_to_mbuf(&dq->fd, ifid); dpaa_display_frame_info(&dq->fd, fq->fqid, true); + if (dpaa_ieee_1588) { + annot = GET_ANNOTATIONS(bufs[num_rx - 1]->buf_addr); + dpaa_intf->rx_timestamp = rte_cpu_to_be_64(annot->timestamp); + } qman_dqrr_consume(fq, dq); } while (fq->flags & QMAN_FQ_STATE_VDQCR); @@ -1095,6 +1119,7 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) struct dpaa_sw_buf_free buf_to_free[DPAA_MAX_SGS * DPAA_MAX_DEQUEUE_NUM_FRAMES]; uint32_t free_count = 0; struct qman_fq *fq = q; + struct dpaa_if *dpaa_intf = fq->dpaa_intf; struct qman_fq *fq_txconf = fq->tx_conf_queue; if (unlikely(!DPAA_PER_LCORE_PORTAL)) { @@ -1107,6 +1132,12 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) DPAA_DP_LOG(DEBUG, "Transmitting %d buffers on queue: %p", nb_bufs, q); + if (dpaa_ieee_1588) { + dpaa_intf->next_tx_conf_queue = fq_txconf; + dpaa_eth_tx_conf(fq_txconf); + dpaa_intf->tx_timestamp = 0; + } + while (nb_bufs) { frames_to_send = (nb_bufs > DPAA_TX_BURST_SIZE) ? DPAA_TX_BURST_SIZE : nb_bufs; @@ -1119,6 +1150,14 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) if (dpaa_svr_family == SVR_LS1043A_FAMILY && (mbuf->data_off & 0x7F) != 0x0) realloc_mbuf = 1; + + fd_arr[loop].cmd = 0; + if (dpaa_ieee_1588) { + fd_arr[loop].cmd |= DPAA_FD_CMD_FCO | + qman_fq_fqid(fq_txconf); + fd_arr[loop].cmd |= DPAA_FD_CMD_RPD | + DPAA_FD_CMD_UPD; + } seqn = *dpaa_seqn(mbuf); if (seqn != DPAA_INVALID_MBUF_SEQN) { index = seqn - 1; @@ -1176,10 +1215,6 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) mbuf = temp_mbuf; realloc_mbuf = 0; } - - if (dpaa_ieee_1588) - fd_arr[loop].cmd |= DPAA_FD_CMD_FCO | qman_fq_fqid(fq_txconf); - indirect_buf: state = tx_on_dpaa_pool(mbuf, bp_info, &fd_arr[loop], @@ -1208,9 +1243,6 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) sent += frames_to_send; } - if (dpaa_ieee_1588) - dpaa_eth_tx_conf(fq_txconf); - DPAA_DP_LOG(DEBUG, "Transmitted %d buffers on queue: %p", sent, q); for (loop = 0; loop < free_count; loop++) { @@ -1228,6 +1260,12 @@ dpaa_eth_tx_conf(void *q) struct qm_dqrr_entry *dq; int num_tx_conf, ret, dq_num; uint32_t vdqcr_flags = 0; + struct dpaa_if *dpaa_intf = fq->dpaa_intf; + struct qm_dqrr_entry *dqrr; + struct dpaa_bp_info *bp_info; + struct rte_mbuf *mbuf; + void *ptr; + struct annotations_t *annot; if (unlikely(rte_dpaa_bpid_info == NULL && rte_eal_process_type() == RTE_PROC_SECONDARY)) @@ -1252,7 +1290,20 @@ dpaa_eth_tx_conf(void *q) dq = qman_dequeue(fq); if (!dq) continue; + dqrr = dq; dq_num++; + bp_info = DPAA_BPID_TO_POOL_INFO(dqrr->fd.bpid); + ptr = rte_dpaa_mem_ptov(qm_fd_addr(&dqrr->fd)); + rte_prefetch0((void *)((uint8_t *)ptr + + DEFAULT_RX_ICEOF)); + mbuf = (struct rte_mbuf *) + ((char *)ptr - bp_info->meta_data_size); + + if (mbuf->ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST) { + annot = GET_ANNOTATIONS(mbuf->buf_addr); + dpaa_intf->tx_timestamp = + rte_cpu_to_be_64(annot->timestamp); + } dpaa_display_frame_info(&dq->fd, fq->fqid, true); qman_dqrr_consume(fq, dq); dpaa_free_mbuf(&dq->fd); diff --git a/drivers/net/dpaa/dpaa_rxtx.h b/drivers/net/dpaa/dpaa_rxtx.h index 042602e087..1048e86d41 100644 --- a/drivers/net/dpaa/dpaa_rxtx.h +++ b/drivers/net/dpaa/dpaa_rxtx.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * * Copyright 2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright 2017,2020-2021 NXP + * Copyright 2017,2020-2022 NXP * */ @@ -260,7 +260,7 @@ struct dpaa_eth_parse_results_t { struct annotations_t { uint8_t reserved[DEFAULT_RX_ICEOF]; struct dpaa_eth_parse_results_t parse; /**< Pointer to Parsed result*/ - uint64_t reserved1; + uint64_t timestamp; uint64_t hash; /**< Hash Result */ }; diff --git a/drivers/net/dpaa/meson.build b/drivers/net/dpaa/meson.build index 42e1f8c2e2..239858adda 100644 --- a/drivers/net/dpaa/meson.build +++ b/drivers/net/dpaa/meson.build @@ -14,6 +14,7 @@ sources = files( 'dpaa_flow.c', 'dpaa_rxtx.c', 'dpaa_fmc.c', + 'dpaa_ptp.c', ) if cc.has_argument('-Wno-pointer-arith') -- 2.25.1