Skip to content

mctpd: add AssignBridgeStatic method#148

Open
potinlai wants to merge 2 commits into
CodeConstruct:mainfrom
potinlai:main
Open

mctpd: add AssignBridgeStatic method#148
potinlai wants to merge 2 commits into
CodeConstruct:mainfrom
potinlai:main

Conversation

@potinlai

@potinlai potinlai commented Mar 19, 2026

Copy link
Copy Markdown

Add AssignBridgeStatic method to assign static EID with bridge pool allocation.

Tested:

root@bmc:~# busctl call au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/interfaces/mcu1u2u1u4u1 au.com.codeconstruct.MCTP.BusOwner1 AssignBridgeStatic ayyyy 0 30 5 31
yisb 30 1 "/au/com/codeconstruct/mctp1/networks/1/endpoints/30" true
root@bmc:~# busctl introspect au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/networks/1/endpoints/30
NAME                                TYPE      SIGNATURE RESULT/VALUE                           FLAGS
au.com.codeconstruct.MCTP.Bridge1   interface -         -                                      -
.PoolEnd                            property  y         35                                     const
.PoolStart                          property  y         31                                     const
au.com.codeconstruct.MCTP.Endpoint1 interface -         -                                      -
.Recover                            method    -         -                                      -
.Remove                             method    -         -                                      -
.SetMTU                             method    u         -                                      -
.Connectivity                       property  s         "Available"                            emits-change
org.freedesktop.DBus.Introspectable interface -         -                                      -
.Introspect                         method    -         s                                      -
org.freedesktop.DBus.Peer           interface -         -                                      -
.GetMachineId                       method    -         s                                      -
.Ping                               method    -         -                                      -
org.freedesktop.DBus.Properties     interface -         -                                      -
.Get                                method    ss        v                                      -
.GetAll                             method    s         a{sv}                                  -
.Set                                method    ssv       -                                      -
.PropertiesChanged                  signal    sa{sv}as  -                                      -
xyz.openbmc_project.Common.UUID     interface -         -                                      -
.UUID                               property  s         "8b7e3d86-5fa5-298c-a9d6-a2d5d4baa6fa" const
xyz.openbmc_project.MCTP.Endpoint   interface -         -                                      -
.EID                                property  y         30                                     const
.NetworkId                          property  u         1                                      const
.SupportedMessageTypes              property  ay        4 1 5 126 127                          const
.VendorDefinedMessageTypes          property  a(yvq)    0                                      const

Signed-off-by: Potin Lai potin.lai@quantatw.com

@jk-ozlabs

Copy link
Copy Markdown
Member

I'm going to need more context than that commit message. What is the aim here?

Comment thread src/mctpd.c Outdated
Comment on lines +2305 to +2309
if (static_eid) {
new_eid = static_eid;
} else {
new_eid = alloc.start;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can't just redefine the allocated range like this, those EIDs at [static_eid, static_eid + alloc.extent] may not be available.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @jk-ozlabs,
Thank you for your suggestion in Discord.
I have updated the change to introduce a new method called AssignBridgeStatic.

@potinlai potinlai changed the title mctpd: allow bridge for assign static endpoint mctpd: add AssignBridgeStatic method Mar 26, 2026

@jk-ozlabs jk-ozlabs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few things inline, and the commit message needs more explanation. Rather than a chunk of 'Tested' output, can you include some details about the use case and what is implemented here?

Comment thread src/mctpd.c
Comment thread docs/mctpd.md Outdated
Comment thread docs/mctpd.md Outdated
Comment thread docs/mctpd.md
Comment thread src/mctpd.c Outdated
}

// Return existing record.
peer_path = path_from_peer(peer);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this valid here, and is the check sufficient? The existing peer may not be the bridge you expect...

@jk-ozlabs

Copy link
Copy Markdown
Member

Also, could you add some test cases here? We want to check the successful call, but also conflicts with existing EID allocations.

@potinlai

Copy link
Copy Markdown
Author

Also, could you add some test cases here? We want to check the successful call, but also conflicts with existing EID allocations.

Hi @jk-ozlabs,
I’m still trying to understand how to run the test cases. I copied the test-mctpd binary to the BMC and executed it, but I encountered the following error:

root@bmc:~# /tmp/test-mctpd
test-mctpd: No MCTP_TEST_SOCK fd provided

Could you please advise on the correct way to run this test?

@jk-ozlabs

Copy link
Copy Markdown
Member

The binary doesn't need to run on the BMC; the idea behind the test infrastructure is that the test-mctpd build does not have any dependencies on the system MCTP stack (and is designed to run where there is no MCTP capabilities on the system)

The Testing section in the README has some details, but you just run the tests locally using something like:

$ python3 -m venv env
$ ./env/bin/pip install -r tests/requirements.txt
$ export PATH=$PWD/env/bin:$PATH
$ meson setup obj
$ ninja -C obj test

Comment thread docs/mctpd.md Outdated
@potinlai

Copy link
Copy Markdown
Author

Also, could you add some test cases here? We want to check the successful call, but also conflicts with existing EID allocations.

test cases updated.

@jk-ozlabs

Copy link
Copy Markdown
Member

Just traveling at the moment, but I'll take a look at the updates shortly. Thanks!

geissonator pushed a commit to openbmc/openbmc that referenced this pull request May 21, 2026
The `AssignEndpointStatic` method does not support EID allocation for
bridged endpoints.

Switch to `AssignBridgeStatic` to allow the MCU to allocate EID bridge
pool for downstream devices.

This change depends on the following patch:
[1] CodeConstruct/mctp#148

Change-Id: I4c42273928646ec76c2ec7ca4fb06e5aa0947c78
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
@jk-ozlabs

Copy link
Copy Markdown
Member

There was a pending question above:

@potinlai can you provide some details on your need for the static EID allocation, perhaps? Do you need the pool range to be static, or only the bridge EID?

Could you give us some details for your use-case? particularly around the requirement for pool addressing.

This will dictate what future changes might be applicable, and how we should structure the interface to suit those.

@potinlai

Copy link
Copy Markdown
Author

There was a pending question above:

@potinlai can you provide some details on your need for the static EID allocation, perhaps? Do you need the pool range to be static, or only the bridge EID?

Could you give us some details for your use-case? particularly around the requirement for pool addressing.

This will dictate what future changes might be applicable, and how we should structure the interface to suit those.

There are 7 SMA devices in system, and each SMA has its own downstream devices.
The SMA's static EID and EID pool allocation as below.

  • EID 10 : 11
  • EID 20 : 21
  • EID 30 : 31-35
  • EID 40 : 41-45
  • EID 50 : 51-55
  • EID 60 : 61-65
  • EID 70 : 71-72

Below is MCTP tree on my BMC.

root@bmc:~# busctl tree au.com.codeconstruct.MCTP1 
└─ /au
  └─ /au/com
    └─ /au/com/codeconstruct
      └─ /au/com/codeconstruct/mctp1
        ├─ /au/com/codeconstruct/mctp1/interfaces
        │ ├─ /au/com/codeconstruct/mctp1/interfaces/lo
        │ ├─ /au/com/codeconstruct/mctp1/interfaces/mctpi2c13
        │ ├─ /au/com/codeconstruct/mctp1/interfaces/mcu1u1u4u1
        │ ├─ /au/com/codeconstruct/mctp1/interfaces/mcu1u2u1u1
        │ ├─ /au/com/codeconstruct/mctp1/interfaces/mcu1u2u1u3u1
        │ ├─ /au/com/codeconstruct/mctp1/interfaces/mcu1u2u1u4u1
        │ ├─ /au/com/codeconstruct/mctp1/interfaces/mcu1u2u2u1
        │ ├─ /au/com/codeconstruct/mctp1/interfaces/mcu1u2u2u3u1
        │ ├─ /au/com/codeconstruct/mctp1/interfaces/mcu1u2u2u4u1
        │ └─ /au/com/codeconstruct/mctp1/interfaces/mcu1u3u2
        └─ /au/com/codeconstruct/mctp1/networks
          └─ /au/com/codeconstruct/mctp1/networks/1
            └─ /au/com/codeconstruct/mctp1/networks/1/endpoints
              ├─ /au/com/codeconstruct/mctp1/networks/1/endpoints/10
              ├─ /au/com/codeconstruct/mctp1/networks/1/endpoints/20
              ├─ /au/com/codeconstruct/mctp1/networks/1/endpoints/30
              ├─ /au/com/codeconstruct/mctp1/networks/1/endpoints/40
              ├─ /au/com/codeconstruct/mctp1/networks/1/endpoints/50
              ├─ /au/com/codeconstruct/mctp1/networks/1/endpoints/60
              ├─ /au/com/codeconstruct/mctp1/networks/1/endpoints/70
              └─ /au/com/codeconstruct/mctp1/networks/1/endpoints/8

And below is introspect details of EID 30 .

root@bmc:~# busctl introspect au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/networks/1/endpoints/30                                  
NAME                                TYPE      SIGNATURE RESULT/VALUE                           FLAGS       
au.com.codeconstruct.MCTP.Bridge1   interface -         -                                      -           
.PoolEnd                            property  y         35                                     const
.PoolStart                          property  y         31                                     const
au.com.codeconstruct.MCTP.Endpoint1 interface -         -                                      -           
.Recover                            method    -         -                                      -           
.Remove                             method    -         -                                      -           
.SetMTU                             method    u         -                                      -           
.Connectivity                       property  s         "Available"                            emits-change
org.freedesktop.DBus.Introspectable interface -         -                                      -           
.Introspect                         method    -         s                                      -           
org.freedesktop.DBus.Peer           interface -         -                                      -           
.GetMachineId                       method    -         s                                      -           
.Ping                               method    -         -                                      -           
org.freedesktop.DBus.Properties     interface -         -                                      -           
.Get                                method    ss        v                                      -           
.GetAll                             method    s         a{sv}                                  -           
.Set                                method    ssv       -                                      -           
.PropertiesChanged                  signal    sa{sv}as  -                                      -           
xyz.openbmc_project.Common.UUID     interface -         -                                      -           
.UUID                               property  s         "8b7e3d86-5fa5-298c-a9d6-a2d5d4baa6fa" const
xyz.openbmc_project.MCTP.Endpoint   interface -         -                                      -           
.EID                                property  y         30                                     const
.NetworkId                          property  u         1                                      const
.SupportedMessageTypes              property  ay        4 1 5 126 127                          const

@jk-ozlabs

Copy link
Copy Markdown
Member

Thanks, but I was more after your current requirements around the EID allocation pool.

Particularly: do you require the pool to be static?

It will need to be at the moment, but future mctp spec versions will relax the requirement that the pool is contiguous with the bridge EID. In that case, the caller may choose a non-contiguous pool address, or mctpd may be able to choose a pool range that is free. The former is a bit tricky, as the caller has no idea whether the remote endpoint would support non-contiguous pools, so I suspect the latter option would be more popular.

To accommodate that, I think we would want to allow the pool_start argument to be zero, to indicate that mctpd can choose a pool start. And then the caller would need some way to return the chosen pool start address - so we would need an extra y output argument for that.

@potinlai

Copy link
Copy Markdown
Author

Thanks, but I was more after your current requirements around the EID allocation pool.

Particularly: do you require the pool to be static?

Yes, In my use case, I expected the pool is static arranged, so each downstream devices will have same EID assigned.

It will need to be at the moment, but future mctp spec versions will relax the requirement that the pool is contiguous with the bridge EID. In that case, the caller may choose a non-contiguous pool address, or mctpd may be able to choose a pool range that is free. The former is a bit tricky, as the caller has no idea whether the remote endpoint would support non-contiguous pools, so I suspect the latter option would be more popular.

To accommodate that, I think we would want to allow the pool_start argument to be zero, to indicate that mctpd can choose a pool start.

That’s a great point about allowing pool_start to be zero for mctpd-managed allocation.
However, I haven't verified if the devices (SMA) on our system support non-contiguous pools.
Could this feature be a seperate enhancement on top of the current changes?

And then the caller would need some way to return the chosen pool start address - so we would need an extra y output argument for that.

I can add extra y output.
Should it be yyisb? The 2nd y for final pool_start eid.

@jk-ozlabs

Copy link
Copy Markdown
Member

However, I haven't verified if the devices (SMA) on our system support non-contiguous pools.
Could this feature be a seperate enhancement on top of the current changes?

It is unlikely that they support non-contiguous pools, the spec change is quite recent. I am not proposing that we implement that at this stage - only that the APIs we introduce now would be able to support it.

So, the only behaviour we need now is for the pool-start argument, if passed as zero, is set to the bridge-eid+1. Everything else can be a later change.

I can add extra y output.
Should it be yyisb? The 2nd y for final pool_start eid.

Sounds great.

@potinlai potinlai force-pushed the main branch 2 times, most recently from edf0504 to 6903064 Compare June 11, 2026 01:09
@potinlai

Copy link
Copy Markdown
Author

However, I haven't verified if the devices (SMA) on our system support non-contiguous pools.
Could this feature be a seperate enhancement on top of the current changes?

It is unlikely that they support non-contiguous pools, the spec change is quite recent. I am not proposing that we implement that at this stage - only that the APIs we introduce now would be able to support it.

So, the only behaviour we need now is for the pool-start argument, if passed as zero, is set to the bridge-eid+1. Everything else can be a later change.

I can add extra y output.
Should it be yyisb? The 2nd y for final pool_start eid.

Sounds great.

Thank you for the feedback.
I have updated the change as requested.

@jk-ozlabs jk-ozlabs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The core code looks good, just a few comments on the doc and tests.

Also, could you rebase on top of current main? Just to make sure that we haven't created conflicts in the meantime.

Comment thread docs/mctpd.md Outdated
Comment thread docs/mctpd.md
Comment thread src/mctpd.c Outdated
Comment thread src/mctpd.c
peer->eid, req_pool_size, peer->pool_size);
} else {
// peer will likely have requested less than the available range
peer->pool_size = req_pool_size;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this mean we should also return the pool size? Or would the caller not really care?

Comment thread docs/mctpd.md
Comment thread tests/test_mctpd.py Outdated
Comment thread tests/test_mctpd.py Outdated
Comment thread tests/test_mctpd.py
potinlai and others added 2 commits June 11, 2026 14:32
Add AssignBridgeStatic method to assign static EID with bridge pool allocation.

Tested:
```
root@bmc:~# busctl call au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/interfaces/mcu1u2u1u4u1 au.com.codeconstruct.MCTP.BusOwner1 AssignBridgeStatic ayyyy 0 30 31 5
yyisb 30 31 1 "/au/com/codeconstruct/mctp1/networks/1/endpoints/30" true
root@bmc:~# busctl introspect au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/networks/1/endpoints/30
NAME                                TYPE      SIGNATURE RESULT/VALUE                           FLAGS
au.com.codeconstruct.MCTP.Bridge1   interface -         -                                      -
.PoolEnd                            property  y         35                                     const
.PoolStart                          property  y         31                                     const
au.com.codeconstruct.MCTP.Endpoint1 interface -         -                                      -
.Recover                            method    -         -                                      -
.Remove                             method    -         -                                      -
.SetMTU                             method    u         -                                      -
.Connectivity                       property  s         "Available"                            emits-change
org.freedesktop.DBus.Introspectable interface -         -                                      -
.Introspect                         method    -         s                                      -
org.freedesktop.DBus.Peer           interface -         -                                      -
.GetMachineId                       method    -         s                                      -
.Ping                               method    -         -                                      -
org.freedesktop.DBus.Properties     interface -         -                                      -
.Get                                method    ss        v                                      -
.GetAll                             method    s         a{sv}                                  -
.Set                                method    ssv       -                                      -
.PropertiesChanged                  signal    sa{sv}as  -                                      -
xyz.openbmc_project.Common.UUID     interface -         -                                      -
.UUID                               property  s         "8b7e3d86-5fa5-298c-a9d6-a2d5d4baa6fa" const
xyz.openbmc_project.MCTP.Endpoint   interface -         -                                      -
.EID                                property  y         30                                     const
.NetworkId                          property  u         1                                      const
.SupportedMessageTypes              property  ay        4 1 5 126 127                          const
.VendorDefinedMessageTypes          property  a(yvq)    0                                      const
```

Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Add test cases to verify successful static EID and pool assignment,
zero pool start auto-allocation, and rejection on conflict with an
existing EID allocation.

Signed-off-by: Freddie Jheng <Freddie.Jheng@quantatw.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants