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 672D545843; Fri, 23 Aug 2024 09:34:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 021BF4328F; Fri, 23 Aug 2024 09:33:21 +0200 (CEST) Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011029.outbound.protection.outlook.com [52.101.65.29]) by mails.dpdk.org (Postfix) with ESMTP id 010BB43265 for ; Fri, 23 Aug 2024 09:33:13 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LM3Be8coC23RX94HVD2CARSl4AF+KYQ5C8Aop3Gpxyq2bkb1qmTsrY3dVSZn+RJsySPTgjb/ezgr75fE6QUEKWqwBjAaKK7a40FlNODss+IkrElb7ruJRzKsETeLx4LgQp92c/049Ch6t9JZN+AEj3JEWgrmnWwzme+C96ZHfLaf20zE1z+TR5oZiz/QTJGJoRliRSQxUV7Q139c6sOzzPAAbqZAnxu5L10DaF25o87VOpeeGxkm61kIcZ9Q01LaKVGRj85bzDDcpogiqsivFlxafi/qn0pNc0DCG+7t4xEBLbQg3er8U6ZfEo5GrGP5Pi7SvCH3tPRa7/HE9gBJLQ== 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=2AsEJPC1B2N4EDXgAfIZ/P5rI8PrTQ4HXdUcwQj2GbI=; b=jrHpaDY81JHTmD8SVoMJL9STbLzIetHwTHb6VnlpybR6WrrpYpzIvxO9YouTe7b50rHe0323LDlB21FdyOl/cZNIid8ViBmoTSnRd0TNzYT8mSTgVYiQ8iipv2BhVIzIYFcQr0RQ8fTBLtNwE6bfNGOsyuWFV/p4hqsNXXFUts24EgZx0K1JVZKigNjYSsXLc+XNnZzsFd6VqElUnWkLbyQapsBAKXwtQIkUxaT0TyiqcRe9etJ+6am8OxNm/vZK+lwWuhJZETPEqmNOU0B82AyGf0DhyU+kK21gOW2uq3TSqhtNLcEJh6w11o7cY031W6MpqVqvY39DyO08HQnf8w== 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=2AsEJPC1B2N4EDXgAfIZ/P5rI8PrTQ4HXdUcwQj2GbI=; b=mkchza95axe7IA582+pe7ViDazC8GvSpw6y/AUqnE7ctyQ2TBs0KsOSMln2xDejl1sW5jVeyJDYQXOywSYxAZdtBIESeRMZBLkAg0qQxFdSFZdFJtp0L8MZldTj+kZm5rSTjbI3x2dh/iyW2pU493vXwR1H5mgUlrVcKGS1efXf/6LlkIsUKr152xv4yqHn8kaHEK56PIuNosp7SCFWVc7lLVCJa+PFxqHgOwGskfWHAdKuKUHPHBn5BisNDTZzvEesBlVeAeaqwI+G0sEZr+BezFPM35Ax3q6Snj8KOMJhGLQP376NB1NGsebcucXmAtCZ8FRNpzQhYRN/1UM7heg== 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:12 +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:12 +0000 From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Vanshika Shukla Subject: [PATCH v2 10/18] net/dpaa: support IEEE 1588 PTP Date: Fri, 23 Aug 2024 13:02:32 +0530 Message-Id: <20240823073240.3708320-11-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: 9205e187-e6fe-4524-503e-08dcc345d827 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?Wo+8VkhKEYjAdCqhzbyV1/RHPhibr+j9EXz7YWNtwA/7d5U995Dyg7gjvlBv?= =?us-ascii?Q?U4PBMBzvqIVp9eUudEZdcyq8Z5yfjtskhkAw5Py1/WpqPB8bUk6BbjN4vC8M?= =?us-ascii?Q?XrAGWcjseD5J1GC2cMintbotyGb7kPIefhSuuWGz2lnEb7pVLC9R2gIUpmFh?= =?us-ascii?Q?WrJesnhUKlgDVLhL65K9cATCM2fMkjEW38Ty4WSDHnU7oEHNe7zLFExiOtWR?= =?us-ascii?Q?ceo4hPxwzltwZ9xa7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dv7p?= =?us-ascii?Q?F2j6z8RE+hopAVO9U7fIKMleJXHgLFL1JmHYeC9kMMjpn01gCbilyMNq7JQy?= =?us-ascii?Q?OA0GDRGFJyB19Ulh7y0JiSCB8gI83oOFw9TJN/7KT/75sqsXY959ONHjEmeh?= =?us-ascii?Q?etjdoZMlREUbXJyxhrNNMAbGN4sov10F+1TV5K6pYV/uRgzWEfwJmHa6o8x3?= =?us-ascii?Q?PSgdGZjoFUGLsAv9ph0lCq/09UG3rozWn5IxQU7momU9hUkhdPLSj3cSHIC4?= =?us-ascii?Q?MQLHLtNaZPZKFx6bn2jPn6x+Xa0R//Rt0zEQ4PUu/dIZaBBsXA=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?ASkVdfYhsgE2Qsm/r0X9gbzwxD1mVsvS9sWFnDcPwLtdeqCnVO3rNEcrYNVW?= =?us-ascii?Q?7WEAYp8WAW57VYI8jIBE5TwBnSnrZXPpQmjovw6k2uSOWSAzDu+SLwW/wYH1?= =?us-ascii?Q?U5ubt0DbT69/VI+Gn4WP/aqaZvYexBrd5rnMk3nykjDsWqfi0m9lrv+AeVW8?= =?us-ascii?Q?N0HhR3Ygo8WvVgTd90CZQ1/wQrYSg6CKJNqYbDjvDxHP8ImKM6WINKamj5Lm?= =?us-ascii?Q?D+xMHCFYgrBJ9/vBtKxqdHnrQdzqp1PCQBesRXHDQCEywd7V93gSEFMj4fUu?= =?us-ascii?Q?h0BQ4jMKiGPmlPQrbofydWLectfbJm8VA1aSX+HpXwuuwqx+lu6iaYtmtiWJ?= =?us-ascii?Q?Ah/tVRi6VvPvUasm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LRxa?= =?us-ascii?Q?Jmoct0LpjTS1NEvgnar7v97e0cJ+Dcx4dozh2XNsZJtMdukVkB0vGvYcC0H/?= =?us-ascii?Q?LjxvPMTCCmAz+ZWZouR1/Ho8JKjN2R2nqswI2y17u6tIyJ7CV7jP/yP3gwLk?= =?us-ascii?Q?WReEPyXnN2qKij5LvMLq0pHO2DIxX1cEm6BR8KSAJvz5PVxxRNuiT5Mv7AMG?= =?us-ascii?Q?cQ4XGgKeq1YNtsSO7LGBUkITBG2I23kqBLMYccuq756DP/OX+nKEDUGLzfHs?= =?us-ascii?Q?ibeEjZ7O8J8cX8GcZi6EAXHeTg91Ql2VOFzrPaIj6LqbM5Cy9uHDNlbNukH3?= =?us-ascii?Q?KGYj5Q0rwVlmcwrCHEv5ahWmMWv9dkU7ZVgGeSIvsZKPtpKJSKjR+835qyZP?= =?us-ascii?Q?Yg=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9205e187-e6fe-4524-503e-08dcc345d827 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:12.8361 (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: 0Io7KNOhUObasAfU++pfkU8DrLqDw87bzHVOBeGtrH+yTkPrZFe9hhjw4D/kx2Onilz0vOJJL4aAALhbyppVCg== 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 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 | 2 + 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, 162 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..2c2e79dcb5 100644 --- a/doc/guides/nics/features/dpaa.ini +++ b/doc/guides/nics/features/dpaa.ini @@ -19,9 +19,11 @@ 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 FW version = Y ARMv8 = Y Usage doc = Y + diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c index 89786636d9..a79b0b75dd 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 857eef3d2f..109c1a4a22 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 df6df1ddf2..f9337a9468 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