esp-idf icon indicating copy to clipboard operation
esp-idf copied to clipboard

Enable Timestamping for Non-PTP Ethernet frames (IDFGH-15359)

Open mauzigoe opened this issue 6 months ago • 15 comments

Description

Feature: Add the functionality to enable PTP-based timestamping for non-PTP Ethernet frames via esp_eth_ioctl

Testing

Tested on ESP32-P4-based Olimex Dev-Kit.

mauzigoe avatar May 23 '25 09:05 mauzigoe

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 23 '25 09:05 CLAassistant

Messages
:book: 🎉 Good Job! All checks are passing!

👋 Hello mauzigoe, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests via this public GitHub repository.

This GitHub project is public mirror of our internal git repository

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved, we synchronize it into our internal git repository.
4. In the internal git repository we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
5. If the change is approved and passes the tests it is merged into the default branch.
5. On next sync from the internal git repository merged change will appear in this public GitHub repository.

Generated by :no_entry_sign: dangerJS against c72676faa83766659e03d917a32ed7ecb974715d

github-actions[bot] avatar May 23 '25 09:05 github-actions[bot]

Added the fixes, but two commits were added from a recent pull. Is this a problem? Sorry for the bad PR, I should have reviewed it better.

mauzigoe avatar May 23 '25 17:05 mauzigoe

Ok, now everything should be ready to merge

mauzigoe avatar May 24 '25 05:05 mauzigoe

Added the fixes, but two commits were added from a recent pull. Is this a problem? Sorry for the bad PR, I should have reviewed it better.

It's actually very nice PR! Those were just minor things..

kostaond avatar May 26 '25 05:05 kostaond

Is this PR ready to merge?

mauzigoe avatar Jun 02 '25 06:06 mauzigoe

sha=46b4aac263e9bf41bbe244c7268af50917878bc0

kostaond avatar Jun 02 '25 10:06 kostaond

Fixed an error

mauzigoe avatar Jun 04 '25 11:06 mauzigoe

I recognized some TAB/space formatting error in the PR (Fixed)

mauzigoe avatar Jun 09 '25 16:06 mauzigoe

sha=46b4aac263e9bf41bbe244c7268af50917878bc0

@kostaond This isn't the appropriate commit to be merged anymore. Can we change the commit to be merged to sha=c72676faa83766659e03d917a32ed7ecb974715d ?

mauzigoe avatar Jun 09 '25 16:06 mauzigoe

sha=46b4aac263e9bf41bbe244c7268af50917878bc0

@kostaond This isn't the appropriate commit to be merged anymore. Can we change the commit to be merged to sha=c72676faa83766659e03d917a32ed7ecb974715d ?

No, PR was merged yesterday to our internal repo and will be synce to GH soon... What exactly did you fixed?

kostaond avatar Jun 10 '25 05:06 kostaond

sha=46b4aac263e9bf41bbe244c7268af50917878bc0

@kostaond This isn't the appropriate commit to be merged anymore. Can we change the commit to be merged to sha=c72676faa83766659e03d917a32ed7ecb974715d ?

No, PR was merged yesterday to our internal repo and will be synce to GH soon... What exactly did you fixed?

In components/esp_eth/src/mac/esp_eth_mac_esp.c a semicolon is missing behind a case statement, so this will result in a compilation error. Furthermore there are some formatting error due to a wrong number of spaces (bad emacs setup), which weren't catched by pre-commit. Force-pushing to my fork probably wasn't a good idea/practise ...

diff --git a/components/esp_eth/src/mac/esp_eth_mac_esp.c b/components/esp_eth/src/mac/esp_eth_mac_esp.c
index 3ac7a483a1..ab5da7246a 100644
--- a/components/esp_eth/src/mac/esp_eth_mac_esp.c
+++ b/components/esp_eth/src/mac/esp_eth_mac_esp.c
@@ -365,10 +365,10 @@ esp_err_t emac_esp_custom_ioctl(esp_eth_mac_t *mac, int cmd, void *data)
         break;
     }
     case ETH_MAC_ESP_CMD_ENABLE_TS4ALL: {
-	ESP_RETURN_ON_FALSE(data, ESP_ERR_INVALID_ARG, TAG, "PTP enable TS for all invalid argument, cant' be NULL");
-	bool enable = *(bool *)data;
-	ESP_RETURN_ON_ERROR(emac_hal_ptp_enable_ts4all(&emac->hal, enable), TAG, "failed to enable timestamping for all frames");
-	break;
+        ESP_RETURN_ON_FALSE(data, ESP_ERR_INVALID_ARG, TAG, "PTP enable TS for all invalid argument, cant' be NULL");
+        bool enable = *(bool *)data;
+        ESP_RETURN_ON_ERROR(emac_hal_ptp_enable_ts4all(&emac->hal, enable), TAG, "failed to enable timestamping for all frames");
+        break;
     }
 #else
     case ETH_MAC_ESP_CMD_PTP_ENABLE:
@@ -378,8 +378,8 @@ esp_err_t emac_esp_custom_ioctl(esp_eth_mac_t *mac, int cmd, void *data)
     case ETH_MAC_ESP_CMD_ADJ_PTP_FREQ:
     case ETH_MAC_ESP_CMD_S_TARGET_CB:
     case ETH_MAC_ESP_CMD_S_TARGET_TIME:
-    case ETH_MAC_ESP_CMD_ENABLE_TS4ALL
-	return ESP_ERR_NOT_SUPPORTED;
+    case ETH_MAC_ESP_CMD_ENABLE_TS4ALL:
+        return ESP_ERR_NOT_SUPPORTED;
 #endif
     case ETH_MAC_ESP_CMD_SET_TDES0_CFG_BITS:
         ESP_RETURN_ON_FALSE(data != NULL, ESP_ERR_INVALID_ARG, TAG, "cannot set DMA tx desc flag to null");

mauzigoe avatar Jun 10 '25 07:06 mauzigoe

sha=46b4aac263e9bf41bbe244c7268af50917878bc0

@kostaond This isn't the appropriate commit to be merged anymore. Can we change the commit to be merged to sha=c72676faa83766659e03d917a32ed7ecb974715d ?

No, PR was merged yesterday to our internal repo and will be synce to GH soon... What exactly did you fixed?

@kostaond Were you able to add the fix?

mauzigoe avatar Jun 15 '25 20:06 mauzigoe

Sorry I forgot to reply... We merged the first fixed version by you (after https://github.com/espressif/esp-idf/pull/16016#issuecomment-2939628709). Please wait for changes to be synced to GH and then you can open new PR.

kostaond avatar Jun 16 '25 06:06 kostaond

Ok, I will do it.

mauzigoe avatar Jun 16 '25 07:06 mauzigoe

Thanks for contribution again, changes have been merged with https://github.com/espressif/esp-idf/commit/48b37dd56ee93b618a11e7746a32862b9296c128

Alvin1Zhang avatar Nov 28 '25 06:11 Alvin1Zhang