Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[controller] add schedule migration API #2435

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

Irving-cl
Copy link
Contributor

This PR adds the ScheduleMigration API to ThreadHost as well as the implementation for NcpHost.

The PR also replaces the empty implementation in DBusNcp with the real implementation by calling the API. The PR adds an expect test to verify the result of a migration.

Copy link

codecov bot commented Aug 14, 2024

Codecov Report

Attention: Patch coverage is 0% with 40 lines in your changes missing coverage. Please review.

Project coverage is 45.50%. Comparing base (2b41187) to head (0b4882f).
Report is 766 commits behind head on main.

Files Patch % Lines
src/ncp/ncp_spinel.cpp 0.00% 24 Missing ⚠️
src/ncp/ncp_host.cpp 0.00% 11 Missing ⚠️
src/dbus/server/dbus_thread_object_ncp.cpp 0.00% 3 Missing ⚠️
src/ncp/rcp_host.cpp 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2435       +/-   ##
===========================================
- Coverage   55.77%   45.50%   -10.28%     
===========================================
  Files          87      100       +13     
  Lines        6890    11311     +4421     
  Branches        0      815      +815     
===========================================
+ Hits         3843     5147     +1304     
- Misses       3047     5909     +2862     
- Partials        0      255      +255     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Irving-cl Irving-cl force-pushed the add_schedule_migrate_api branch 2 times, most recently from 5e4ac60 to b746aca Compare August 14, 2024 06:20
Copy link
Contributor

@zhanglongxia zhanglongxia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/ncp/ncp_spinel.hpp Outdated Show resolved Hide resolved
src/ncp/ncp_spinel.cpp Outdated Show resolved Hide resolved
src/ncp/ncp_spinel.cpp Outdated Show resolved Hide resolved
src/ncp/rcp_host.cpp Outdated Show resolved Hide resolved
void NcpSpinel::DatasetMgmtSetPending(const otOperationalDatasetTlvs &aPendingOpDatasetTlvs, AsyncTaskPtr aAsyncTask)
{
otError error = OT_ERROR_NONE;
EncodingFunc encodingFunc = [this, &aPendingOpDatasetTlvs] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can you ensure aPendingOpDatasetTlvs is always alive? IIUC it could be a local variable in DBusThreadObjectNcp::ScheduleMigrationHandler.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on same question?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call stack is: DBus API -> ThreadHost API -> NcpSpinel API -> encodingFunc(pendingDataset)

And the DBus API will only exit after calling the whole stack, including the encoding function. So the variable is still valid.

I agree it's a little confusing here. Here an encoding func is used in SetProperty NOT for async purposes but just for reusing the code of setting properties (get a tid, check if there is an available tid, encode a header, then encode the body, send the frame, etc). Another approach would be using templates: we templatize SetProperty and use template specialization for encoding the body. But I think that leads to an increasing of code size. Thoughts?

Copy link
Contributor

@superwhd superwhd Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO we may consider passing in aPendingOpDatasetTlvs by value or storing it into a shared_ptr and pass it in by value so that we can feel safer when reviewing/updating the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SG! Updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shared_ptr works nicely. 👍

Copy link
Member

@abtink abtink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall.
Have same question on lifetime of aPendingOpDatasetTlvs.

void NcpSpinel::DatasetMgmtSetPending(const otOperationalDatasetTlvs &aPendingOpDatasetTlvs, AsyncTaskPtr aAsyncTask)
{
otError error = OT_ERROR_NONE;
EncodingFunc encodingFunc = [this, &aPendingOpDatasetTlvs] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on same question?

@Irving-cl Irving-cl force-pushed the add_schedule_migrate_api branch 2 times, most recently from 60ecbc0 to 76f2882 Compare August 15, 2024 04:52
Copy link
Contributor

@superwhd superwhd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Member

@abtink abtink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Irving-cl Irving-cl requested a review from jwhui August 17, 2024 12:56
@jwhui jwhui merged commit 861ddf2 into openthread:main Aug 21, 2024
32 checks passed
@Irving-cl Irving-cl deleted the add_schedule_migrate_api branch August 22, 2024 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants