Skip to content

Conversation

@ThuBaNguyen
Copy link
Contributor

Add code to show the local EIDs in EIDs property in au.com.CodeConstruct.MCTP.Interface1 D-Bus interface.

busctl introspect au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/interfaces/mctpi2c3
NAME                                 TYPE      SIGNATURE RESULT/VALUE FLAGS
au.com.CodeConstruct.MCTP.Interface1 interface -         -            -
.EIDs                                property  ay        1 8          const

@amboar
Copy link
Contributor

amboar commented Nov 18, 2024

I'm not trying to block the change here, but I feel we might want a holistic treatment of Figure 9 from DSP0236 v1.3.3. I feel that requires a bit more thought about how EID associations are represented. I don't think the proposal is wrong as such, but it is incomplete.

@jk-ozlabs
Copy link
Member

From some chatting on Discord, my suggested approach was that we have an EIDs property on the network object, where an application can always pick the first to acquire a suitable local EID that can route to the local stack. Since the host will accept any local destination EID, it will always be valid on any incoming interface.

(the extension of that concept is that we may as well assign the same local EID to all interfaces, but that's entirely optional)

We may have a scenario in future where an application may need to query a local EID that is bound to a specific interface, but I don't think that's what's happening here.

@ThuBaNguyen
Copy link
Contributor Author

ThuBaNguyen commented Nov 18, 2024

From some chatting on Discord, my suggested approach was that we have an EIDs property on the network object, where an application can always pick the first to acquire a suitable local EID that can route to the local stack.

It seems I missed your idea in the Discord Chat. I thought we will add the EIDs property to au.com.CodeConstruct.MCTP.Interface1 D-Bus interface of interface D-Bus object such as /au/com/codeconstruct/mctp1/interfaces/mctpi2c3

In case, we want to add the EIDs property to network object path such as /au/com/codeconstruct/mctp1/networks/1, I wonder which D-Bus interface should we use to add EIDs property?

root@mtmitchell-dcscm:~# busctl introspect au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/networks/1
NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
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  -            -

Since the host will accept any local destination EID, it will always be valid on any incoming interface.

I'm agree with you that when the interfaces are belong to the same network, this will be true. Although, this will make the routing table in both BMC, the bridge between BMC and terminus (if have) and the terminus are more complicated.
Ampere team is still evaluating this solution. I will give more opinions in this solution later.

(the extension of that concept is that we may as well assign the same local EID to all interfaces, but that's entirely optional)

This option can only be applied when BMC is BO in all interfaces.

We may have a scenario in future where an application may need to query a local EID that is bound to a specific interface, but I don't think that's what's happening here.

@ThuBaNguyen
Copy link
Contributor Author

From some chatting on Discord, my suggested approach was that we have an EIDs property on the network object, where an application can always pick the first to acquire a suitable local EID that can route to the local stack. Since the host will accept any local destination EID, it will always be valid on any incoming interface.

What do you think about adding the D-Bus interface "au.com.CodeConstruct.MCTP.Network1" in network object path as below

 busctl introspect au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/networks/1
NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
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  -            -
au.com.CodeConstruct.MCTP.Network1  interface -         -                                      -
.EIDs                               property  ay        2 8 12                                    const

Where:

  1. au.com.CodeConstruct.MCTP.Network1 is interface name. 1 is version.
  2. There is one properties in the network D-Bus interfaces:
    a) EIDs will be BMC local EIDs in the network 1 as we discuss before.

@jk-ozlabs
Copy link
Member

Looks good, but maybe make it obvious that the EIDs are local to this endpoint? we could name it LocalEIDs, perhaps?

@ThuBaNguyen
Copy link
Contributor Author

Looks good, but maybe make it obvious that the EIDs are local to this endpoint? we could name it LocalEIDs, perhaps?

Sure. LocalEIDs is more details property name.

@jk-ozlabs
Copy link
Member

ok, super. Also, just check the capitalisation on the interface name.

@ThuBaNguyen ThuBaNguyen force-pushed the local-eids branch 2 times, most recently from cd541d6 to 41dd42a Compare December 8, 2024 07:17
@ThuBaNguyen ThuBaNguyen changed the title mctpd: Add EIDs property to show local EIDs Support LocaEids property in au.com.codeconstruct.MCTP.Network1 Dec 17, 2024
}

return ret_eids;
}
Copy link
Member

Choose a reason for hiding this comment

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

You have essentially the same logic repeated here. Just return the count and array from the one function.

Copy link
Member

Choose a reason for hiding this comment

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

This has been re-introduced in the recent changes; does this iteration code need to appear twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

We need to know the number of localEIDs first, then allocate ret_eids with number of localEIDs.
In the commit 17adff2, I tried to change combine find_local_eids_count_by_net and find_local_eids_by_net but eids is null event num is 1 in sd_bus_message_append_array(reply, 'y', eids, num);. That why I back to use two functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using two functions also makes the code is clearer.

Copy link
Member

Choose a reason for hiding this comment

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

Using two functions also makes the code is clearer.

I disagree. You already have divergence between the two implementations (code formatting), as well as a bug duplicated in both (&ctx->peers[x] can never be null)

The number of local EIDs is fairly well constrained; does this even need to be calculated in advance? just malloc the whole 256 bytes, and iterate once.

but eids is null event num is 1 in sd_bus_message_append_array(reply, 'y', eids, num);

not sure I understand this, can you rephrase?

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 number of local EIDs is fairly well constrained; does this even need to be calculated in advance? just malloc the whole 256 bytes, and iterate once.

I updated the latest code by malloc the localEIDs with 256 bytes as your suggest.
edc3f5f
Only need one functions and iterate once.

@ThuBaNguyen ThuBaNguyen force-pushed the local-eids branch 2 times, most recently from b8c4619 to bb6d0c9 Compare January 7, 2025 05:21
Copy link
Member

@jk-ozlabs jk-ozlabs 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. Just a wording change on the doc addition, but I can edit that as part of the merge (unless you happen to beat me to it!)

Thanks for the contribution!

@ThuBaNguyen
Copy link
Contributor Author

The PULL is WIP

@ThuBaNguyen ThuBaNguyen marked this pull request as draft January 7, 2025 06:34
@jk-ozlabs
Copy link
Member

OK, I'll wait on updates then!

@jk-ozlabs
Copy link
Member

OK, if you're updating, then a couple of build warnings present. You may already be working on these, but just in case not:

[20/24] Compiling C object test-mctpd.p/src_mctpd.c.o
../src/mctpd.c: In function ‘bus_network_get_prop’:
../src/mctpd.c:3047:22: warning: ‘eids’ may be used uninitialized [-Wmaybe-uninitialized]
 3047 |                 rc = find_local_eids_by_net(ctx, netid, &num, eids);
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/mctpd.c:3039:21: note: ‘eids’ was declared here
 3039 |         mctp_eid_t *eids;
      |                     ^~~~
[21/24] Compiling C object mctpd.p/src_mctpd.c.o
../src/mctpd.c: In function ‘bus_network_get_prop’:
../src/mctpd.c:3047:22: warning: ‘eids’ may be used uninitialized [-Wmaybe-uninitialized]
 3047 |                 rc = find_local_eids_by_net(ctx, netid, &num, eids);
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/mctpd.c:3039:21: note: ‘eids’ was declared here
 3039 |         mctp_eid_t *eids;
      |                     ^~~~

@jk-ozlabs jk-ozlabs self-requested a review January 7, 2025 06:38
@ThuBaNguyen ThuBaNguyen force-pushed the local-eids branch 2 times, most recently from c0491a3 to 17adff2 Compare January 7, 2025 08:03
@ThuBaNguyen ThuBaNguyen marked this pull request as ready for review January 7, 2025 08:08
@ThuBaNguyen ThuBaNguyen force-pushed the local-eids branch 2 times, most recently from 2b795f6 to 47880d1 Compare January 7, 2025 08:23
@ThuBaNguyen
Copy link
Contributor Author

The code is good now. I tested the code.

Add code to show the local EIDs in `LocalEIDs` property in
`au.com.codeconstruct.MCTP.Network1` D-Bus interface of the D-Bus
object path `/au/com/codeconstruct/mctp1/networks/<netId>`.

```
busctl introspect au.com.codeconstruct.MCTP1 /au/com/codeconstruct/mctp1/networks/1
NAME                                TYPE      SIGNATURE RESULT/VALUE
FLAGS
au.com.codeconstruct.MCTP.Network1  interface -         -            -
.LocalEIDs                          property  ay        1 8
const
org.freedesktop.DBus.Introspectable interface -         -            -
.Introspect                         method    -         s            -
```

Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Copy link
Member

@jk-ozlabs jk-ozlabs 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, thanks!

@jk-ozlabs
Copy link
Member

Merged as 6470f9e , along with a set of tests for the dbus interface.

I had fixed up the commit title (LocaEIDs -> LocalEIDs), so GH isn't autoclosing this.

Thanks for the contribution!

@jk-ozlabs jk-ozlabs closed this Jan 8, 2025
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.

3 participants