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

NCP support in ot-br-posix #2398

Open
12 of 17 tasks
Irving-cl opened this issue Jul 23, 2024 · 4 comments
Open
12 of 17 tasks

NCP support in ot-br-posix #2398

Irving-cl opened this issue Jul 23, 2024 · 4 comments
Assignees

Comments

@Irving-cl
Copy link
Contributor

Irving-cl commented Jul 23, 2024

Use this issue to track PRs and todo tasks to support NCP in ot-br-posix.

@Irving-cl Irving-cl self-assigned this Jul 23, 2024
@Vanperdung
Copy link

Hello @Irving-cl, I'm interested in this feature. Our product wants to support Matter over Thread on NCP arch. Hopefully, it will soon be completed.

@Irving-cl
Copy link
Contributor Author

Hi @Vanperdung, glad to hear that! However I cannot guarantee on the timeline. We will keep tracking the process on this issue.

@Irving-cl
Copy link
Contributor Author

Will start to submit the code for border routing. Since the code will be non-trivial, I will use this comment to give an abstraction of the implementation for reviewers to review more easily.

Implement NCP based version of otPlatInfraIf APIs

openthread/openthread#10638 has added an empty version of these APIs. The remaining work is to implement them.

  • otPlatInfraIfDiscoverNat64Prefix will not be implemented temporarily because NAT64 will be implemented later.
  • otPlatInfraIfHasAddress: we will sync the IPv6 addresses of the infra if on the host to NCP and save them on NCP. When calling this API, we will directly search in the replica on NCP.
  • otPlatInfraIfSendIcmp6Nd: We will send a spinel property from NCP to the host and let host send the ICMP6 ND message.

New spinel commands

  • SPINEL_PROP_INFRA_IF_SETUP (host -> NCP)
    • This is used to initialize the "InfraIf" on NCP. The host will send InfraIfIndex, isInfraIfRunning and InfraIfAddresses to the NCP. The handler on NCP will save the addresses, call otBorderRoutingInit and otBorderRoutingSetEnabled.
  • SPINEL_PROP_INFRA_IF_STATE (host -> NCP)
    • This is used to notify NCP the change of infra if state or addresses. The host will send isInfraIfRunning and InfraIfAddresses to the NCP whenever there is any changes.
  • SPINEL_PROP_INFRA_IF_RECV_ICMP6_ND (host -> NCP)
    • When the host received an ICMP6 ND message, it forwards this message to the NCP using this spinel prop. And NCP handler will simply call otPlatInfraIfRecvIcmp6Nd to let OT core to handle it.
  • SPINEL_PROP_INFRA_IF_SEND_ICMP6_ND (NCP -> host)
    • When otPlatInfraIfSendIcmp6Nd is called on NCP, NCP will send this spinel property to the host. The spinel frame contains the InfraIfIndex, destAddress, Icmp6NdPacket.

Host InfraIf module

Like the Netif module, we will add a new InfraIf module to interact with the infraIf on the platform.

  • Initialization: The NcpHost will initialize the InfraIf if BackboneInterface is passed when starting the executable. Then theInfraIf will send SPINEL_PROP_INFRA_IF_SETUP to the NCP. We will also provide an API to initialize/Update the Infra after the executable already started (for Android use case).
  • InfraIf state update: A netlink socket will be created to receive netlink message about the state change (ON/OFF state and addresses) of the InfraIf. Whenever receiving a message, the module will send SPINEL_PROP_INFRA_IF_STATE to the NCP to update the state.
  • Receive ICMP6 ND messages (RA, RS, NA): A Icmp6 socket will be created to receive these messages from the platform. Then the InfraIf module will send a SPINEL_PROP_INFRA_IF_RECV_ICMP6_ND to the NCP to forward these messages and let NCP handle them.
  • Send ICMP6 ND messages: The InfraIf module will provide a method SendIcmp6Nd which sends the message though the Icmp6 socket as well. The method SendIcmp6Nd will be called in NcpSpinel when it receives a spinel frame of SPINEL_PROP_INFRA_IF_SEND_ICMP6_ND.

@Irving-cl
Copy link
Contributor Author

This comment gives an abstraction of the implementation of SRP Server & Advertising Proxy under NCP for reviewers to review more easily.

Implement NCP based version of otPlatDnssd APIs

Similar as NCP based version of otPlatInfraIf APIs, we need to have an NCP version of otPlatDnssd APIs to make Advertising Proxy work on NCP side. For SrpAdvertisingProxy, these otPlatDnssd APIs are required:

  • otPlatDnssdGetState
    • The ot::Dnssd module need to get the state from platform and then start/stop. We will sync the state of the mDNS Publisher on the host to the NCP and on NCP we directly return this state.
  • otPlatDnssdRegisterService / otPlatDnssdUnregisterService
    • The ot::Dnssd use the methods to register/unregister a serivce. We will implement them as sending a spinel frame to the host and the host will do the registration/unregistration by mDNS Publisher.
  • otPlatDnssdRegisterHost / otPlatDnssdUnregisterHost
    • Similar as above.
  • otPlatDnssdRegisterKey / otPlatDnssdUnregisterKey
    • Similar as above.

New Spinel Properties

  • SPINEL_PROP_SRP_SERVER_ENABLED (host -> NCP)
    • This property is used to set SrpServer enabled/disabled on NCP. When NCP receives it, it simply calls otSrpServerSetEnabled.
  • SPINEL_PROP_SRP_SERVER_AUTO_ENABLE_MODE (host -> NCP)
    • This property is used to set SrpServer auto enable mode on NCP. When NCP receives it, it simply calls otSrpServerSetAutoEnableMode.
  • SPINEL_PROP_DNSSD_STATE (host -> NCP)
    • This property is used to sync the mDNS Publisher's state to the NCP. When receiving it, the NCP simply stores this state and call otPlatDnssdStateHandleStateChange.
  • SPINEL_PROP_DNSSD_HOST (NCP -> host, command: Inserted/Removed)
    • This property is used to start request to the host to register/unregister a DNS host. We only define one property here and use command INSERTED/REMOVED to indicate whether this is a registration or unregistration.
  • SPINEL_PROP_DNSSD_SERVICE (NCP -> host, command: Inserted/Removed)
    • Similar as above. This property is for DNS services.
  • SPINEL_PROP_DNSSD_KEY_RECORD (NCP -> host, command: Inserted/Removed)
    • Similar as above. This property is for DNS key records.
  • SPINEL_PROP_DNSSD_REQUEST_RESULT (host -> NCP)
    • This property is used to notify the NCP of the results for its DNSSD registration/unregistration requests. In the spinel frames of this property, there will be a request id to indicate the result is of which request.

Host side changes

  • The NcpHost will subscribe to mDNS publisher's state. Whenever there is a change, it will send SPINEL_PROP_DNSSD_STATE to the NCP.
  • When and how to start the Srp Server: Currently the host will either send SPINEL_PROP_SRP_SERVER_ENABLED or SPINEL_PROP_SRP_SERVER_AUTO_ENABLE_MODE in its initialization based on the build option. Later we may change this to starting SrpServer by an API.
  • Provide access of the mDNS publisher to NcpSpinel so that it can register Dnssd hosts/services/key records.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants