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 2F8ED45A68; Mon, 30 Sep 2024 14:17:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 62210406B4; Mon, 30 Sep 2024 14:16:28 +0200 (CEST) Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013067.outbound.protection.outlook.com [52.101.67.67]) by mails.dpdk.org (Postfix) with ESMTP id 12F8240663 for ; Mon, 30 Sep 2024 14:16:23 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=S8G3SqcfWQtvzQq9mdwhSYYheuOaFG8nT0G3fOa2IDJ585T61NTOvrxSuYayqDW1fQhNSrIiYNSNooEnEOWzL86x3yU0gNN//EJttGuiMDcf2SKdaEheUk4wLqKjAXbjYmC2YU78+QUrghftCBnihv3Hfo88NeeQ2tE4ndMgoqvvPlwpNaZ8k4F85Zi5j1AF87GamahqDsfek+WgHXxb49zq3zaWEMv0zjuBhYG4iZz9bdP8cSqNBcy/Q26nxO+Nw4Os4g0SY2eTsvR4B8nd566JrNe4QCNJC3uuzQMmu/NGoO7H4zkPr/JrYuueEvHQsvxGIpQbUG/2ij/68usvew== 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=OXzG5G8sRtPuMnErx25Yg7WupGBfkwvoKjMEppumXiM=; b=Mzg+1JVWssZiUWjLM51UQ8j0zkSflyTHk1lfAFl0Ret3iIWiEBx1Pp8hJuY0xrhcWKdp6fXKaMuh/FBk3wr2Gip5rZKMVi8C8zc0pn509fZMACTghc2EIwInYWdm7ujYg0pabP0Swx/yVQsc2yVr3U4aCR7CZwAKaEDflNhLesCPjfXph7B4DetJyugbNhN3lSr3F89sOvsQcwHv+y+n//uMADVW3yZt1gBe0f0R1GVZWbm6NnuIaIQRlyb4ZPag2jB0YGGfXNZO0IDOeSm1j/L7147VzNWU4oPQ9wIkRSXTVoBSjro73aFsxKNA9LqURtA+lZl/m6ttcqPuwdmELg== 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=OXzG5G8sRtPuMnErx25Yg7WupGBfkwvoKjMEppumXiM=; b=FzaBc/8lZmbJ6mJFqrl4taPtiWwKw45SUFjRsWg3u4fxPGru+e8IKJRO+YVclPFQV8sqWbqvaq1YonSy4z7sfWm1z68aapBFLIS80bKrky6d1DH8bvgYyw1Qq5x9C0tt2inBccOSqrxa6DzmKlSxXCRwA5l2rwKk21wqJq0yUZ5uv0fwqDBjJs6iDR6kzwo2IGxljcwjK0+QTuInRQUnU4GXu2VjfmGPlbB3Yey9hLiwGEF42SrLvAeBVWJr2myrKk+AoLSMq+qV6xO6Fi8WVYeblDYMdVa4rGAcB+ROeQ7CbVP8JbRLQruHzjGL9XCncRo6JIVgqYxm/n+bQ7Boug== 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 GV1PR04MB10583.eurprd04.prod.outlook.com (2603:10a6:150:203::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8005.26; Mon, 30 Sep 2024 12:16:21 +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.8005.026; Mon, 30 Sep 2024 12:16:21 +0000 From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@amd.com, Vanshika Shukla Subject: [PATCH v4 10/18] net/dpaa: support IEEE 1588 PTP Date: Mon, 30 Sep 2024 17:45:17 +0530 Message-Id: <20240930121525.3452847-11-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240930121525.3452847-1-hemant.agrawal@nxp.com> References: <20240823073240.3708320-1-hemant.agrawal@nxp.com> <20240930121525.3452847-1-hemant.agrawal@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR01CA0124.apcprd01.prod.exchangelabs.com (2603:1096:4:40::28) To PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9328:EE_|GV1PR04MB10583:EE_ X-MS-Office365-Filtering-Correlation-Id: aceb9996-79bd-4f98-6a8e-08dce149b1c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?qeXcRiYFEkDSOiUzYoqsHv/gdXRDg1quWrjNLIi69FA6TzLIQbBH4fGoBBiz?= =?us-ascii?Q?J7wVq078JAW1K/5ejnWCnJV7pf6nrOaB715v9JuLOkvn6wd0KayVEfTwDRzk?= =?us-ascii?Q?v+X4pE8HKb/O25FujXDBxnCMhh3L0K63/k0CJB1daHE29ciilEG/E1zd3kt1?= =?us-ascii?Q?sEIJObnLkfKdgrr3BU2I5BorGTE8ga6rn3hwd2s+FSpobePFhf2OJy4IYl5H?= =?us-ascii?Q?hw++2nIV6Y/nv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6qE/NemupE?= =?us-ascii?Q?ucxCWY/ANXNLfa4Qwzrzjt3wYHJ7vuQ8Ja38Dbr7bR7IhaW5dtZI9pKgtvZD?= =?us-ascii?Q?Dc4GAieLRuzudc/rM6JFgrcBY67OArAM1Tbo2nITCnNdWtSjv2MHlGKVbL74?= =?us-ascii?Q?RFguUYFOkGkWKJuWEMiWnhuH+NEAg68OksIGkJhqvEDtewjL4OrrhmMR9dPt?= =?us-ascii?Q?ZFTedV1UdiVitbrgs0in/iPA3bYa1ODbB5jfbudKGzQdWA=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)(1800799024)(366016)(52116014)(376014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?V7nXz4RdBRaLtBHpPCRVnJTFQb4UBcecdg6Dcz2Nfh/2VwsbTOdh+e5uR2V8?= =?us-ascii?Q?ALzHTrE67guPWVG2zIon2k7Reh9M0RjGwhtZWaU0WfQpF5Ew+MXn1bOD52XG?= =?us-ascii?Q?xJ4mpYGGflKxQnkvdtOr3bZvAHmZEZx1I/BByn3jkLWvBnytjD+XGVaCT4BH?= =?us-ascii?Q?j4ystLuMLdoGQWQoCDSWSqWlCld8mJeDSOnlw+r7BDgpZme+6P82mvf0OQeY?= =?us-ascii?Q?Hxh+gbVEkBM7390AB0P+3XiYFBcHFxmSyuWVln2Iztp6bHzBiTt56EWr4nKR?= =?us-ascii?Q?08fASYoFOrjvYAx1LxJbpSJJIfvfiX2ZIgGbiIIOim02KZwq1NY7kDbGtvtU?= =?us-ascii?Q?/hO5US4PWgjdtjBl0I1lzLOrZp4zhshaFTdeowJvrja15RIHnoEG1N9kxS8k?= =?us-ascii?Q?HCcTqc11QcmyedRqBT0oafK1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ascii?Q?8WzpWc9k2KhnM0+YREzQdSL8u90UHhLScrCDIC6pMlpDTGmBgClhjHuvK48e?= =?us-ascii?Q?1hL2hbJFBoFt8ZCni11PsjR8Q3q5vrhvNePQ29cCFvTjf4ljgBryilm8Hfwy?= =?us-ascii?Q?Al+CfoxOn8AtrafCzkKTwPat1HnMmoTlIMUExlpcYKDMt6tHfACqN9DSmW7h?= =?us-ascii?Q?3Oedd5ZlBLnhv1Nz/VPnvM6dXzg4asDCcA2fm95npBD8a4I4G6PcEnL/i1uS?= =?us-ascii?Q?2KUEKy5P9Vr5awJyTADJlmWCTGCnDnrIRTMThMtysMDfRzXj8/k7HCUg9Sak?= =?us-ascii?Q?3Q=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: aceb9996-79bd-4f98-6a8e-08dce149b1c9 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9328.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 12:16:21.2590 (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: pwLv+P6n/uENdL5iOYMpdlUhH82kwONd86kAonkcTCwzj0DXXEeqolBnVP5hozvnsjwk8WlAC4ulLhVmcsj8ZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10583 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 adds the support for the ethdev APIs to enable/disable and read/write/adjust IEEE1588 PTP timestamps for DPAA platform. Signed-off-by: Vanshika Shukla --- doc/guides/nics/dpaa.rst | 1 + doc/guides/nics/features/dpaa.ini | 1 + drivers/bus/dpaa/base/fman/fman.c | 15 ++++++ drivers/bus/dpaa/include/fman.h | 45 +++++++++++++++++ drivers/net/dpaa/dpaa_ethdev.c | 5 ++ drivers/net/dpaa/dpaa_ethdev.h | 16 +++++++ drivers/net/dpaa/dpaa_ptp.c | 80 ++++++++++++++++++++++++++++++- 7 files changed, 161 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst index acf4daab02..ea86e6146c 100644 --- a/doc/guides/nics/dpaa.rst +++ b/doc/guides/nics/dpaa.rst @@ -148,6 +148,7 @@ Features - Packet type information - Checksum offload - Promiscuous mode + - IEEE1588 PTP DPAA Mempool Driver ~~~~~~~~~~~~~~~~~~~ diff --git a/doc/guides/nics/features/dpaa.ini b/doc/guides/nics/features/dpaa.ini index 4196dd800c..4f31b61de1 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 +Timesync = Y Timestamp offload = Y Basic stats = Y Extended stats = Y diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c index e39bc8c252..e2b7120237 100644 --- a/drivers/bus/dpaa/base/fman/fman.c +++ b/drivers/bus/dpaa/base/fman/fman.c @@ -28,6 +28,7 @@ u32 fman_dealloc_bufs_mask_lo; int fman_ccsr_map_fd = -1; static COMPAT_LIST_HEAD(__ifs); +void *rtc_map; /* This is the (const) global variable that callers have read-only access to. * Internally, we have read-write access directly to __ifs. @@ -539,6 +540,20 @@ fman_if_init(const struct device_node *dpa_node) goto err; } + if (!rtc_map) { + __if->rtc_map = mmap(NULL, FMAN_IEEE_1588_SIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, + fman_ccsr_map_fd, FMAN_IEEE_1588_OFFSET); + if (__if->rtc_map == MAP_FAILED) { + pr_err("Can not map FMan RTC regs base\n"); + _errno = -EINVAL; + goto err; + } + rtc_map = __if->rtc_map; + } else { + __if->rtc_map = rtc_map; + } + /* 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/include/fman.h b/drivers/bus/dpaa/include/fman.h index 09d1ddb897..e8bc913943 100644 --- a/drivers/bus/dpaa/include/fman.h +++ b/drivers/bus/dpaa/include/fman.h @@ -64,6 +64,12 @@ #define GROUP_ADDRESS 0x0000010000000000LL #define HASH_CTRL_ADDR_MASK 0x0000003F +#define FMAN_RTC_MAX_NUM_OF_ALARMS 3 +#define FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES 4 +#define FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS 3 +#define FMAN_IEEE_1588_OFFSET 0X1AFE000 +#define FMAN_IEEE_1588_SIZE 4096 + /* Pre definitions of FMAN interface and Bpool structures */ struct __fman_if; struct fman_if_bpool; @@ -307,6 +313,44 @@ struct tx_bmi_regs { uint32_t fmbm_trlmts; /**< Tx Rate Limiter Scale*/ uint32_t fmbm_trlmt; /**< Tx Rate Limiter*/ }; + +/* Description FM RTC timer alarm */ +struct t_tmr_alarm { + uint32_t tmr_alarm_h; + uint32_t tmr_alarm_l; +}; + +/* Description FM RTC timer Ex trigger */ +struct t_tmr_ext_trigger { + uint32_t tmr_etts_h; + uint32_t tmr_etts_l; +}; + +struct rtc_regs { + uint32_t tmr_id; /* 0x000 Module ID register */ + uint32_t tmr_id2; /* 0x004 Controller ID register */ + uint32_t reserved0008[30]; + uint32_t tmr_ctrl; /* 0x0080 timer control register */ + uint32_t tmr_tevent; /* 0x0084 timer event register */ + uint32_t tmr_temask; /* 0x0088 timer event mask register */ + uint32_t reserved008c[3]; + uint32_t tmr_cnt_h; /* 0x0098 timer counter high register */ + uint32_t tmr_cnt_l; /* 0x009c timer counter low register */ + uint32_t tmr_add; /* 0x00a0 timer drift compensation addend register */ + uint32_t tmr_acc; /* 0x00a4 timer accumulator register */ + uint32_t tmr_prsc; /* 0x00a8 timer prescale */ + uint32_t reserved00ac; + uint32_t tmr_off_h; /* 0x00b0 timer offset high */ + uint32_t tmr_off_l; /* 0x00b4 timer offset low */ + struct t_tmr_alarm tmr_alarm[FMAN_RTC_MAX_NUM_OF_ALARMS]; + /* 0x00b8 timer alarm */ + uint32_t tmr_fiper[FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES]; + /* 0x00d0 timer fixed period interval */ + struct t_tmr_ext_trigger tmr_etts[FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS]; + /* 0x00e0 time stamp general purpose external */ + uint32_t reserved00f0[4]; +}; + struct fman_port_qmi_regs { uint32_t fmqm_pnc; /**< PortID n Configuration Register */ uint32_t fmqm_pns; /**< PortID n Status Register */ @@ -396,6 +440,7 @@ struct __fman_if { void *ccsr_map; void *bmi_map; void *tx_bmi_map; + void *rtc_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 682cb1c77e..82d1960356 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -1673,6 +1673,11 @@ 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_enable = dpaa_timesync_enable, + .timesync_disable = dpaa_timesync_disable, + .timesync_read_time = dpaa_timesync_read_time, + .timesync_write_time = dpaa_timesync_write_time, + .timesync_adjust_time = dpaa_timesync_adjust_time, .timesync_read_rx_timestamp = dpaa_timesync_read_rx_timestamp, .timesync_read_tx_timestamp = dpaa_timesync_read_tx_timestamp, }; diff --git a/drivers/net/dpaa/dpaa_ethdev.h b/drivers/net/dpaa/dpaa_ethdev.h index bbdb0936c0..7884cc034c 100644 --- a/drivers/net/dpaa/dpaa_ethdev.h +++ b/drivers/net/dpaa/dpaa_ethdev.h @@ -245,6 +245,22 @@ int dpaa_timesync_read_tx_timestamp(struct rte_eth_dev *dev, struct timespec *timestamp); +int +dpaa_timesync_enable(struct rte_eth_dev *dev); + +int +dpaa_timesync_disable(struct rte_eth_dev *dev); + +int +dpaa_timesync_read_time(struct rte_eth_dev *dev, + struct timespec *timestamp); + +int +dpaa_timesync_write_time(struct rte_eth_dev *dev, + const struct timespec *timestamp); +int +dpaa_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta); + int dpaa_timesync_read_rx_timestamp(struct rte_eth_dev *dev, struct timespec *timestamp, diff --git a/drivers/net/dpaa/dpaa_ptp.c b/drivers/net/dpaa/dpaa_ptp.c index 2ecdda6db0..48e29e22eb 100644 --- a/drivers/net/dpaa/dpaa_ptp.c +++ b/drivers/net/dpaa/dpaa_ptp.c @@ -16,7 +16,82 @@ #include #include -int dpaa_timesync_read_tx_timestamp(struct rte_eth_dev *dev, +int +dpaa_timesync_enable(struct rte_eth_dev *dev __rte_unused) +{ + return 0; +} + +int +dpaa_timesync_disable(struct rte_eth_dev *dev __rte_unused) +{ + return 0; +} + +int +dpaa_timesync_read_time(struct rte_eth_dev *dev, + struct timespec *timestamp) +{ + uint32_t *tmr_cnt_h, *tmr_cnt_l; + struct __fman_if *__fif; + struct fman_if *fif; + uint64_t time; + + fif = dev->process_private; + __fif = container_of(fif, struct __fman_if, __if); + + tmr_cnt_h = &((struct rtc_regs *)__fif->rtc_map)->tmr_cnt_h; + tmr_cnt_l = &((struct rtc_regs *)__fif->rtc_map)->tmr_cnt_l; + + time = (uint64_t)in_be32(tmr_cnt_l); + time |= ((uint64_t)in_be32(tmr_cnt_h) << 32); + + *timestamp = rte_ns_to_timespec(time); + return 0; +} + +int +dpaa_timesync_write_time(struct rte_eth_dev *dev, + const struct timespec *ts) +{ + uint32_t *tmr_cnt_h, *tmr_cnt_l; + struct __fman_if *__fif; + struct fman_if *fif; + uint64_t time; + + fif = dev->process_private; + __fif = container_of(fif, struct __fman_if, __if); + + tmr_cnt_h = &((struct rtc_regs *)__fif->rtc_map)->tmr_cnt_h; + tmr_cnt_l = &((struct rtc_regs *)__fif->rtc_map)->tmr_cnt_l; + + time = rte_timespec_to_ns(ts); + + out_be32(tmr_cnt_l, (uint32_t)time); + out_be32(tmr_cnt_h, (uint32_t)(time >> 32)); + + return 0; +} + +int +dpaa_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta) +{ + struct timespec ts = {0, 0}, *timestamp = &ts; + uint64_t ns; + + dpaa_timesync_read_time(dev, timestamp); + + ns = rte_timespec_to_ns(timestamp); + ns += delta; + *timestamp = rte_ns_to_timespec(ns); + + dpaa_timesync_write_time(dev, timestamp); + + return 0; +} + +int +dpaa_timesync_read_tx_timestamp(struct rte_eth_dev *dev, struct timespec *timestamp) { struct dpaa_if *dpaa_intf = dev->data->dev_private; @@ -32,7 +107,8 @@ int dpaa_timesync_read_tx_timestamp(struct rte_eth_dev *dev, return 0; } -int dpaa_timesync_read_rx_timestamp(struct rte_eth_dev *dev, +int +dpaa_timesync_read_rx_timestamp(struct rte_eth_dev *dev, struct timespec *timestamp, uint32_t flags __rte_unused) { -- 2.25.1