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 D1D1345A67; Mon, 30 Sep 2024 12:31:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F2F444066C; Mon, 30 Sep 2024 12:30:28 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2089.outbound.protection.outlook.com [40.107.20.89]) by mails.dpdk.org (Postfix) with ESMTP id AE7C6402A3 for ; Mon, 30 Sep 2024 12:30:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=akebR6ugGi0AFnNOV9AjK56mc8Xu6PdOhLMA8knAbz9PmvVB8aaMhkMBQjKYfv6K5LrsFUx53tmystX3qQn21dCoXGWfgVu2NCvaZfGn52XIZRxeIOwuex0jmujbGL23P606t92JxXB7KkGCcJdmPz6Fr7/UZEkQmxlYI4XbQT/e8szxGTHSdOTauvMbvPwB6g5Ziwdghl7uayGDARBx4i3wwLEdt8PQsMu3dxd3NhTHJzN1Wdn19eqi6wFDuXCdYkn8uFfe3zlRJVoJsS5YQXbRCVYntsSEo9O7ObQCU6Inxi4EqIfUvLSyh0RG6SeYkYhgI3Yk5qJNAPgRIerzog== 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=QV88jqnI0Klp5rl/yHd63nZTan8brb2gHZ4p4LKU+w5eJ/43etOak2W+Z5UBTqY5zn/QCvZlbrjQhKQNMmXv0SZqb5wqa0k1LkIqbFPT+ejy1ZB4+brKusnBF5lcodRQ71jwlVUFGrInuP625y5tB6sqLl5PidRokxc2o7ThEYHFRv2t8Kop1ieUODvPskT/d36pep9fiKT1KRXDK1B2oQzbycWBaNdgdxHNlNxwXt9BE69Vh+F+0jwwSHDp1jE3bKdNsGcNkkozTGPzW1nYF2BgOs7tXqktmxwOZnb/P1rCjYLlCLMbiBDrapmpqRlTRkyLKT0Ol+Y9TGLXYsR0aw== 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=i4EYs6TS1PQk7BLKWA2PWxjb0OpkT6WrdkOncQP+5z8vQTddpUQYI8y7Us/nBBrE6keGP4E/XfrXk9WoH8wUsCNaYlhP2DtnzOxYKQ6lgSNuNHODJmG0M5M3vJ7f1UwC4UYqMm8GZKNvcOlh4Mcb8ac9OCZODa72rC5B2roMmsx8QE11apFFQ3nb6sESulGJhK4ExdRKv3OWiNW45lYV1ynuLVtsgnitxjM/GRDDJJ9ubxo9x2D04EkPyA1OlvKVZCsA+49A9kUTz5Zx8Bj52mGYF9yYTKV4yHDwD2Nw7tEG+nYRkGHwUlQpS2+7mlfXaxa5loNkYT5Zw5JzkRCZsw== 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 VI0PR04MB10161.eurprd04.prod.outlook.com (2603:10a6:800:242::6) 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 10:30:17 +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 10:30:17 +0000 From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@amd.com, Vanshika Shukla Subject: [PATCH v3 10/18] net/dpaa: support IEEE 1588 PTP Date: Mon, 30 Sep 2024 15:59:38 +0530 Message-Id: <20240930102946.3236998-11-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240930102946.3236998-1-hemant.agrawal@nxp.com> References: <20240823073240.3708320-1-hemant.agrawal@nxp.com> <20240930102946.3236998-1-hemant.agrawal@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2P153CA0027.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::14) To PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9328:EE_|VI0PR04MB10161:EE_ X-MS-Office365-Filtering-Correlation-Id: 499533fb-f940-4d80-35ec-08dce13ae0a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|376014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?H12U52hTrEbL7PTBoWacenBUqr3vkQIdaobnOgRIzHtjZVQpChFpfiHPC+ll?= =?us-ascii?Q?S3WUvaOhU7mRZfH0XM0M9u7ymiTnhQ2BviBluysupAVQvE8BHduw4inzAd+b?= =?us-ascii?Q?gwJN7lMPYBSHCQLVFeW/swmdxDVSeNkhT5QxbFNNbxb5wsoa2cKlZL7yK69b?= =?us-ascii?Q?5phjYGWraXjyE7kvvaV1KQw+MtAzcMImXU353KJqIYSPsqYipBvova+UNRcR?= =?us-ascii?Q?KwSyVAN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+dzp5?= =?us-ascii?Q?17YDpey6L4kV2GSNJJFO3h2w3yf+yCzHK5+GUpFWGSGULRMW0RZbUYvCa+gB?= =?us-ascii?Q?z2k+MypEfqjCEyDnaHXKo6i+948zWG3ht2zbPdvGOup9PoPs2JURGdWEe1aE?= =?us-ascii?Q?fOlz9ZIF6pgeVtyrOfuwSD0WRGDtHQwse2OyufPQMOCd1jHpleUj+cgD1ouw?= =?us-ascii?Q?nfM0vnRq8P7k3f4DAID7k/ho9k0PV+7q19DwsKcPsrE+oA=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)(366016)(1800799024)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?w+WjljP4s9P/umKj8nJXnallaIEhEFIw347GH5dN7IPw9B5bAX38mjyXflKd?= =?us-ascii?Q?yXdUNh7bSjR0cxE7EdXMiP699g6NNYxtN5Dx9B1WyVjNqpv7HI4Vo45/H0MY?= =?us-ascii?Q?3AAZsqAo2p+tFX7cQWdhtT4ZhxrOlwzcMZPeh5S+21sW2Go26wgfoDOy1fTF?= =?us-ascii?Q?MZ2wfnhaTy0cn/2lchgcnkMUF2W2+ajOJrjpNlsKY0aU1PeIVXMiE3wHnkaw?= =?us-ascii?Q?PEtYpxE4azuWIuWh2JpqFiZqj5hZ4Q22IweWD3lN42wEicQD7VLWDPYd0joF?= =?us-ascii?Q?rx6mFNF/EolAe7T2qizmdMbprD2IWF3L8+kRxYeGRSJF+3E00gAMLrui8fIn?= =?us-ascii?Q?DtM74ikifg+oxeSiRcUPXnRm2hNFnptJdMG445VrfIxjbtaEd9WPyAipOxbo?= =?us-ascii?Q?88qj5SW5HhFwjYH04SZDpVR9zyKgGiJdUXbVU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S1/XjuGtLb56aFzKRwSMHvSp9ULly/jkEaDS+MIizJJ7LYduWJSBc?= =?us-ascii?Q?gw8V8rMq7kYKIiybsI1NboS8ybUChYT2iCezkZSuJgpXQhJz5FmPA5KX6ogZ?= =?us-ascii?Q?TGsrFXwB52uQXs8NBm8+z7LkhpoGW9HY+sZ8OQdpCK92fBW79nzGqT11ZLW3?= =?us-ascii?Q?CWQ6nvNwXCsIVYn65dwnQPz0I+47lqjNcuvpexdbgrLBNNQlFxfMa+U2pVFB?= =?us-ascii?Q?zjhVPFzHcHiv3mRUR7Fhj3WQD5hCRbXGcg6UF/SBKUWnT0n9hVyTNLXKWgFN?= =?us-ascii?Q?3g=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 499533fb-f940-4d80-35ec-08dce13ae0a7 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9328.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2024 10:30:17.4444 (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: a3lEbXiwj7gluDFr5DTcEI7VrJs5ls4hJw6BKNntVIA9QlYs4MKYTLjVwq8HAxmHMZFlxTrNu2Y4m04XaCEm0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10161 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