<div dir="ltr">Hi Milton,<div><br></div><div>Yes, the child buses are traceable in the sysfs, but actually my question is, does entity-manager supports tracing child buses through the sysfs? If it does, how shall I write the JSON config to take advantage of this feature?</div><div><br></div><div>For example, we have a I2C device sitting at the same level as the mux, configured as {"Address": "0x40", "Bus": "$bus"}, and now I don't find the way to add or subtract a certain number to $bus to find a child bus. Do we have a feature with syntax like {"Address": "0x50", "Bus": "$bus.mux.0x70.channel.1"} to configure devices on child buses, with mux sitting on 0x70 of the parent bus?</div><div><br></div><div>Thank you!</div><div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">- Alex Qiu</div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 8, 2020 at 6:43 AM Milton Miller II <<a href="mailto:miltonm@us.ibm.com">miltonm@us.ibm.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">About 01/07/2020 07:14PM in some timezone, Alex Qiu wrote:<br>
>Hi folks,<br>
><br>
>We have a JSON file configuring I2C devices of a PCIe card which has<br>
>an 8-channel I2C mux for entity-manager. After we properly configure<br>
>the mux of the card, we get 8 new I2C buses in sysfs; however, we<br>
>don't find an arithmetic way to describe the relationship between the<br>
>new buses and their parent buses.<br>
><br>
>For example, we have a mux on physical BMC I2C bus i2c-8 spawning a<br>
>couple of child buses including i2c-24 and i2c-26, which are the<br>
>buses for each PCIe card. The mux on i2c-24 PCIe card spawned 8 buses<br>
>from i2c-70 to i2c-77, and the mux on i2c-26 PCIe card spawned ones<br>
>from i2c-62 to i2c-69. We have I2C devices on i2c-76 and i2c-68 needs<br>
>to be configured together with the PCIe card on i2c-24 and i2c-26<br>
>separately.<br>
><br>
>How do we implement this in the JSON file? If that's not possible to<br>
>do it in JSON merely, what's the suggested approach to implement this<br>
>feature? Device tree? Implement code in entity-manager to walk<br>
>through the I2C sysfs?<br>
<br>
<br>
I would expect the i2c buses provied by the mux to appear in sysfs<br>
under the hierarchy of the parent bus. Explore the sysfs directory<br>
structure, I'm making this up, but I've now peeked at i2c-mux.c and<br>
have a better chance getting reality.<br>
<br>
<br>
/sys/bus/i2c/devices/i2c-8 -> /sys/devices/platform/ahb-432000/i2c-8<br>
<br>
/sys/bus/i2c/devices/i2c-24 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24<br>
/sys/bus/i2c/devices/i2c-24 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-25<br>
/sys/bus/i2c/devices/i2c-24 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26<br>
<br>
/sys/bus/i2c/devices/i2c-62 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-62<br>
/sys/bus/i2c/devices/i2c-63 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-63<br>
/sys/bus/i2c/devices/i2c-64 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-64<br>
/sys/bus/i2c/devices/i2c-65 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-65<br>
/sys/bus/i2c/devices/i2c-66 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-66<br>
/sys/bus/i2c/devices/i2c-67 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-67<br>
/sys/bus/i2c/devices/i2c-68 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-68<br>
/sys/bus/i2c/devices/i2c-69 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-69<br>
/sys/bus/i2c/devices/i2c-70 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-70<br>
/sys/bus/i2c/devices/i2c-71 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-71<br>
/sys/bus/i2c/devices/i2c-72 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-72<br>
/sys/bus/i2c/devices/i2c-73 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-73<br>
/sys/bus/i2c/devices/i2c-74 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-74<br>
/sys/bus/i2c/devices/i2c-75 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-75<br>
/sys/bus/i2c/devices/i2c-76 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-76<br>
/sys/bus/i2c/devices/i2c-77 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-77<br>
<br>
/sys/bus/i2c/devices/i2c-24/mux_device -> /sys/devices/platform/ahb-432000/i2c-8/8-52<br>
/sys/bus/i2c/devices/i2c-25/mux_device -> /sys/devices/platform/ahb-432000/i2c-8/8-52<br>
/sys/bus/i2c/devices/i2c-26/mux_device -> /sys/devices/platform/ahb-432000/i2c-8/8-52<br>
<br>
/sys/bus/i2c/devices/8-52/channel-0 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24<br>
/sys/bus/i2c/devices/8-52/channel-1 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-25<br>
/sys/bus/i2c/devices/8-52/channel-2 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26<br>
<br>
/sys/bus/i2c/devices/24-52/channel-0 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-62<br>
/sys/bus/i2c/devices/24-52/channel-1 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-63<br>
/sys/bus/i2c/devices/24-52/channel-2 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-64<br>
/sys/bus/i2c/devices/24-52/channel-3 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-65<br>
/sys/bus/i2c/devices/24-52/channel-4 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-66<br>
/sys/bus/i2c/devices/24-52/channel-5 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-67<br>
/sys/bus/i2c/devices/24-52/channel-6 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-68<br>
/sys/bus/i2c/devices/24-52/channel-7 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-24/i2c-69<br>
/sys/bus/i2c/devices/26-52/channel-0 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-70<br>
/sys/bus/i2c/devices/26-52/channel-1 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-71<br>
/sys/bus/i2c/devices/26-52/channel-2 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-72<br>
/sys/bus/i2c/devices/26-52/channel-3 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-73<br>
/sys/bus/i2c/devices/26-52/channel-4 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-74<br>
/sys/bus/i2c/devices/26-52/channel-5 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-75<br>
/sys/bus/i2c/devices/26-52/channel-6 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-76<br>
/sys/bus/i2c/devices/26-52/channel-7 -> /sys/devices/platform/ahb-432000/i2c-8/i2c-26/i2c-77<br>
<br>
The child bus will have a symlink "mux_device" pointing to the mux.<br>
The mux device node will have n symlinks "channel-1" where 1 is <br>
the channel id.<br>
<br>
Hmm, there is no apparent code to put a "mux_channel" attribute in <br>
the adapter node. The adapter name attribute does include the channel <br>
id, but its long descriptive text. Regardless, you should be able to <br>
find the buses from the mux channel-3 symlinks.<br>
<br>
Note: I haven't looked at the JSON to see how much it will change once <br>
your find the bus. I'm guessing you will have to generate it by taking <br>
a template and substituting the bus numbers you find to make the slots<br>
common, alhtough you could just go from the 8-52/channel-3 symlink to<br>
the adapter bus (the device name will still have the bus number in it).<br>
<br>
I hope this helps you,<br>
<br>
milton<br>
<br>
</blockquote></div>