From patchwork Thu Aug 1 10:53:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 142829 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9071945710; Thu, 1 Aug 2024 12:54:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 55414433B5; Thu, 1 Aug 2024 12:53:46 +0200 (CEST) Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012045.outbound.protection.outlook.com [52.101.66.45]) by mails.dpdk.org (Postfix) with ESMTP id 22779433BE for ; Thu, 1 Aug 2024 12:53:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wh3tI66M/Ms2QX5lKky40mMtJUdRAvc/ELz3rWZcrK0izqo4APQq9tjuCz02QXJOn/2oIX78kBex3EJKxdx58ENyo5FObsTux6OZ6lMe0vz5d3NG8/qauG85w+Oa8IocdhazYmvjLL3oQx938cWiWVJRrdlDguuScwlGFCo8ndEVed8rrdtep1tWAaScnUEEVjmb5fqHQTYR9TZ/5uyPZ5oWie0aoxTqxKUjM0owh1DEpMvLUZhLe+YYsziULvoBs7cMCiabX48fwBfPrjiFr7QcSmraeh7c3w1+JatT2JYIlgguhhmr1XwYFx8LLrKlvwcE5ZUKo1uVSW3d7JXRQQ== 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=otdhHtYXYXI8rxveH/OmMChJA3xF2P/0K5156ia0rMQ=; b=vErJ6CFIlFPXQ7aKGhdS13pT0uxBxx8CIu7dz7OSrjjAxYp+oAjXivnVY3ny49IiTaOPRxQFHRiG9q+RJgxc2cEZ97Yuh6nK8DixF99NnhRNOuiR05z4+zPVd+GLMMD3PIi2H7PKfZbe73UvJDyDsHKlKON7Du9DRXZP5P3xC6OKZ+y7Qtu6MDtpwR5q2z0fU/Z+hv5XHHm+bnhsA6XI1ii01J8gmbPKFNWgMiktaEZO87EBsMoDmtEA/EL5g67d7jSLEME5vc3DVZdzMG1+wWAaBCmqSG5nChP6aMfPOOUwdeH8JDYKk96TQuZw9TalsyDW8b2q8ogfQV54A5aVlg== 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=otdhHtYXYXI8rxveH/OmMChJA3xF2P/0K5156ia0rMQ=; b=QSSKlA0k7XxYD+5pdaUw6Yd1IhfKCCJa27odlO61rkCHoH/Mm42/3Z7snUSTpxPVEqvU0iclOrvHBEwi1gAeGnM+JahFaFmyutChI1tijadFvvYku66+ebt9gbRFYRTUdcyDmy+46gD5wq/wFMy5kac9FB4AMLQZbur4AIoGXZZrvPl9/gm1ztHpS8ZzMhaY2eKi6Hsb9D+Pj0rs/bP8Tz2PkHqjYjLZIIdDN0rJLA4umP4e4SdFrYN4Z+ecLlxZQRUVMQvIeAg2njB1AAJL7bxM0XfzRoZGGzc41wI43aL2yA3ZvecL/JPOzJcFOxSolGmBB7dnrBhFxdJ6u39eRA== 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 AS8PR04MB8433.eurprd04.prod.outlook.com (2603:10a6:20b:407::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.23; Thu, 1 Aug 2024 10:53:41 +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.7828.021; Thu, 1 Aug 2024 10:53:41 +0000 From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@amd.com, Vanshika Shukla Subject: [PATCH 09/17] net/dpaa: support IEEE 1588 PTP Date: Thu, 1 Aug 2024 16:23:05 +0530 Message-Id: <20240801105313.630280-10-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240801105313.630280-1-hemant.agrawal@nxp.com> References: <20240801105313.630280-1-hemant.agrawal@nxp.com> X-ClientProxiedBy: SG2P153CA0026.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::13) To PAXPR04MB9328.eurprd04.prod.outlook.com (2603:10a6:102:2b6::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9328:EE_|AS8PR04MB8433:EE_ X-MS-Office365-Filtering-Correlation-Id: f4781a87-5c87-4a59-6f89-08dcb218343f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|366016|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: /w4dXKtmHSY13yPOaApxSdq6ccrowQx5K7+TEw5cZlLoOQ1H2fV9qnyc8bBmMUrs3J3884VOFqv68M4sLAPRQqmMuTHUu+BVX7l2STPtwwkxR/BLyX3y9Yy405k/tj5+mYz3U+CB+8Me7PH7Rl71IEbs05hI/nSau/tBTPjl01+C0ckmLlKrutQwkMoOgIh1JsGD/BGMsW62mo9yb7OaU1XvnXiHvPacdzJ/YkwSpSvds7fi9iZicby5syIUBMKeRHeuqY3CckjQZH3gQHd+QIRFEe6hg4jK5hcSrF45OGMnjJyNrBSd46I0SuJA5LG0MkEJhh8OqDC9p13L47yB8gdVAcXOTmiGOUpzCaHAC0Jgx2CGaj7gpynHp0myYNW0VmPw4rpxHK8swJpP2k40N4xXA83i8YAqJ6DGq0T4V+ocS7TWxVQL4Mocu6FOmzmgQ0WPYvW/U+KDICWluhdKMDDxvXCdrNs69Mz4Hk5EVqw+9SbHnkN6T/t+TPoQgJxaXKMq27QPmCGX+5ThSFS9vcy1uqilPvBjc3M2XDmxdLh5bYFpW5/p/jqpgsjXUt97bq1uLtqN5rdhLQJ+jCN6jYFOA6i5tqFl4VA/SXClPj/KJIViceo8FReLvqZuF2S0RnyEPBvw2FXorMjujxpAPie32E9pWbGx8e8Zm7V5KiLi2oYCOF4ldDYPoJWQK8FkplKPgSo0D6FL8aGK0jMVm5UL66vkVez9dU1TkLVPci30Q3jAlWYmDrvd4kBHDKWJ8tD2PTSEQ2Y8OkOOGlLRrwMeI51P31Kc/P7S/NHYa4b5JDIBE+9Vi1LTWi6wVNMfYCKGV0WC43v2l0Ic6izIOHKUUojCqZ+JrhD+UDmQi4dXFRS49OuLi/PHVC3ELTeKQoj+Bcf0yQlau7DcSIjrO1auePGYNuIxtFhTC8Nd29BtXv17D1vJAKtezUk8vL5+10hSuSVFDyXC8D7bKkxUEmcoUf1bsV0N0nYGqDofcDx9o2HcPhT+motbSy1qx8VDNQPLryOguji5LOkioT+PWoRphfyunUJ212RUaCSgL6ycSSm8dviRf9vyFSkTmDQ84qN5Vc51/in4qzDi2y05lLiLslAcfAHGi4v4741I82pZnH4660Xsvyhtqi56yUVY0SldigqyimGgs5jXYg8TbKFmHmv0tb4mFq1IqiaEU0ClZSsTOM5LKuSYqbCLi9rybecSd/3eP7Bt9TUMQ+QKlzDSCeL+ok6UI+n1ZT8y62K2Xd8+K5lyslX1TRnWNlk5lmdTJ6NKw4C0a2EuO1uhjhtbzLk4pdj6/vYdnInzitQQovTxlSxK37KF9aLs4YF/kHqHethNtQSnGZ9QDwt91a/G8NWcRbFMpMv4vQ76BKw3YR7L7aXqCfN56JxZj+dFVTDRG7n20rhfciuC2Qu13w== 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)(376014)(366016)(52116014)(1800799024)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GiPHUKIWOhVP26haJwC/HtxsnfuZZLTH06lboTfGNS+6vRVD0M3PzmSEkwWuaCIiDRRKN4TSz2d5KDKA04JmynIekGP9eqh0wLbMWaDAC3urlx6xbYL6gqI5NqjUCMOa92+PbnHVpAFtFL30tVbK2efcuovUfqZiR8E+0YqRIVC6O0Ys4vNZhwijb7evz8rgefDb/lKF/bkpM2P8kPzQxkD5zYQz6+sgWGQdEaqIVcRFOI1TmCL4LqBhr7GWRpZVgFigGZeEcKmha1NWn2KKWTRBA3G5wJX98AGqWWaTkju7n3lxvocroKApN4FuGu87Hs4dhmIh2o2tIJLNvKQrWmDF/LiNhB8WucSSfdDpYF7OvMl0ha3UkX8JPph9NaRIS4k85at5rIywe/Ekm5Y8G+U0pkJ/SB92HuNFv1iNkbH7FGoBed2A89G6p38ElCVuBGrx4PNXKN/gKXB5m2y+lPt6gMzdt23O29miO4q7VKU76N125D8zODWfoxA7KKs1QVwgZEzvN0RRZm97Y0GBpHIuilPt9B2eYi/JfGiAXXtn/AEHkfirznA1L5bc986UM62RwX9IZDwNgIzoj9585EbrvHycg0JBJubN+7tqqI2BobetRkrlCnOb1/UQPCHevjjJ01/VfgFi4okhIGLwfb27c2xVUD86D+DJ0OeLRPaZGh8TC7nJsUzBCnj7BffqU4oIZekqtzTCCM+wwPiu+4rYY1ziowCAPT6fxfEFeYaqRklnRzy6gIcqldVZm+T5I3RkIYjyEERRUtXxQ9267rB4HJXjDTUHHC8ODECHw8pbH4t7bGBsrTh4qGtv8b5T0IsCRPuTYclYyBfICG62jH0vg0JBBwH1BYjKTK0D3YAslWtpuWK+vSZypHapICSHEHa9ftaqCB6FKlYO9l8KPDtiHrs4Ufa3KXh7SegqGFobRjUi4y6fcRtz9CMd3I5upwCmGEJwoIVOyMPyfu1Ul1n8258zkbTUG5vQbYrxQNl1Ilw/O9A7euSXl8ARU0d5QSoBL8MBj5AmgwhnIx9L684DmEkgbySZiOS7xA1VBHmoV/qCxnCt6DHe02mvas7/wqOc8gwN2kuXYgwEHYt/m8RedcZ9IBpBZ3K0AYu03y4fCuzxY+6oJ/S0t6DVEU8Mg2rgHzggourhatNlb61TR1eUosDL003455k3qWaOmRZ3eL3fmcytGGTM9ACUKYrDQvctTiPLndrdIdUa02clvzXDvbkEJ9jJgyqEEPRWTco8c9McXkhDxaDGHaZPx8qY7wkPf+LPkGH6vkuux5kcgcX3tjsjaNL49zWr/jzrOn++DnkoZLpRdPBKeIoqsAHZDMdMOIZKXdzTGBLTZ7y5W0GUIHHUtTZ46iW4EGcDYcHX97BAKuODHDXo5v0B43/FHca8KiZ7FjUX5UIGhThZUkf4Qc+vl8iAfgVcoWOVZTEFyACa2fbH7jYUND1ccNqeu10IGce/0lYFqDBKCcNHVqiY66copMvWhfAgpJIueOvDAWsHKlJSrbvdl+wCHAKG2uzk2FrOcPInI1kQFjx4ntOpwD1Z2wjmShzy6nh6iJe6t1HOXlq7n9/cFyvAzn/nrq/S+j/hiEXrIUag+xERZA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4781a87-5c87-4a59-6f89-08dcb218343f X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9328.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2024 10:53:40.6683 (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: vBPggzUczfTKZvPssV1lgbQYbeKFwhhBTCUZrM6S3q80ZwxdAzza6HS23F/KLVdZgSvKD0zRrS4i5QuYpGzi+w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8433 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 + 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 ++++++++++++++++++++++++++++++- 6 files changed, 160 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst index e8402dff52..580edd9327 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/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 f7cd7c0d33..e92f1c25b2 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -1671,6 +1671,11 @@ static struct eth_dev_ops dpaa_devops = { .rss_hash_update = dpaa_dev_rss_hash_update, .rss_hash_conf_get = dpaa_dev_rss_hash_conf_get, #if defined(RTE_LIBRTE_IEEE1588) + .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, #endif diff --git a/drivers/net/dpaa/dpaa_ethdev.h b/drivers/net/dpaa/dpaa_ethdev.h index 389157fa10..068c153dc7 100644 --- a/drivers/net/dpaa/dpaa_ethdev.h +++ b/drivers/net/dpaa/dpaa_ethdev.h @@ -244,6 +244,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) {