Skip to contentSkip to conversation

net: mctp: Add MCTP PCIe VDM transport driver

PATCH In review aspeedyh 5 participants 17 messages Jul 14, 2025 – Jul 18, 2025

Subsystems (3)
lore
Share & tools
lore

aspeedyh

author
#0 lore raw

PATCH 1/1 net: mctp: Add MCTP PCIe VDM transport driver

Add an implementation for DMTF DSP0238 MCTP PCIe VDM transport spec.

Introduce struct mctp_pcie_vdm_dev to represent each PCIe VDM interface and its send/receive operations. Register a net_device with the MCTP core so packets traverse the standard networking socket API.

Because there is no generic PCIe VDM bus framework in-tree, this driver provides a transport interface for lower layers to implement vendor-specific read/write callbacks.

TX path uses a dedicated kernel thread and ptr_ring: skbs queued by the MCTP stack are enqueued on the ring and processed in-thread context.

RX path employs a workqueue; the lower layer notifies availability, and the work handler drains packets until the receive callback returns an ERR_PTR, avoiding per-packet notifications.

---
 drivers/net/mctp/Kconfig         |  10 +
 drivers/net/mctp/Makefile        |   1 +
 drivers/net/mctp/mctp-pcie-vdm.c | 673 +++++++++++++++++++++++++++++++
 include/linux/mctp-pcie-vdm.h    |  42 ++
 4 files changed, 726 insertions(+)
 create mode 100644 drivers/net/mctp/mctp-pcie-vdm.c
 create mode 100644 include/linux/mctp-pcie-vdm.h
drivers/net/mctp/Kconfig +10 -0
index cf325ab0b1ef..3355613bb04b 100644
@@ -57,6 +57,16 @@ config MCTP_TRANSPORT_USB
 	  MCTP-over-USB interfaces are peer-to-peer, so each interface
 	  represents a physical connection to one remote MCTP endpoint.
 
+config MCTP_TRANSPORT_PCIE_VDM
+	tristate "MCTP PCIe VDM transport"
+	depends on PCI
+	select MCTP_FLOWS
+	help
+	  Provides a driver to access MCTP devices over PCIe VDM transport,
+	  from DMTF specification DSP0238.
+	  A MCTP protocol network device is created for each PCIe VDM device
+	  that registers to this driver.
+
 endmenu
 
 endif
drivers/net/mctp/Makefile +1 -0
index c36006849a1e..4acd04d7eb32 100644
@@ -2,3 +2,4 @@ obj-$(CONFIG_MCTP_SERIAL) += mctp-serial.o
 obj-$(CONFIG_MCTP_TRANSPORT_I2C) += mctp-i2c.o
 obj-$(CONFIG_MCTP_TRANSPORT_I3C) += mctp-i3c.o
 obj-$(CONFIG_MCTP_TRANSPORT_USB) += mctp-usb.o
+obj-$(CONFIG_MCTP_TRANSPORT_PCIE_VDM) += mctp-pcie-vdm.o
drivers/net/mctp/mctp-pcie-vdm.c new file +673 -0

673 lines not on this page · raw message

include/linux/mctp-pcie-vdm.h new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer
#1 lore raw

Hi YH,

[+CC Khang]

I have some overall questions before we get into a full review of the series, inline below.

Quoted 10 lines

Add an implementation for DMTF DSP0238 MCTP PCIe VDM transport spec.

Introduce struct mctp_pcie_vdm_dev to represent each PCIe VDM interface and its send/receive operations.  Register a net_device with the MCTP core so packets traverse the standard networking socket API.

Because there is no generic PCIe VDM bus framework in-tree, this driver provides a transport interface for lower layers to implement vendor-specific read/write callbacks.

Do we really need an abstraction for MCTP VDM drivers? How many are you expecting? Can you point us to a client of the VDM abstraction?

There is some value in keeping consistency for the MCTP lladdr formats across PCIe transports, but I'm not convinced we need a whole abstraction layer for this.

Quoted 2 lines

TX path uses a dedicated kernel thread and ptr_ring: skbs queued by the MCTP stack are enqueued on the ring and processed in-thread context.

Is this somehow more suitable than the existing netdev queues?

drivers/net/mctp/mctp-pcie-vdm.c line 114

Quoted 6 lines
drivers/net/mctp/mctp-pcie-vdm.c new file +6 -0
+struct mctp_pcie_vdm_route_info {
+       u8 eid;
+       u8 dirty;
+       u16 bdf_addr;
+       struct hlist_node hnode;
+};

Why are you keeping your own routing table in the transport driver? We already have the route and neighbour tables in the MCTP core code.

Your assumption that you can intercept MCTP control messages to keep a separate routing table will not work.

drivers/net/mctp/mctp-pcie-vdm.c line 567

Quoted 9 lines
drivers/net/mctp/mctp-pcie-vdm.c new file +9 -0
+static void mctp_pcie_vdm_net_setup(struct net_device *ndev)
+{
+       ndev->type = ARPHRD_MCTP;
+
+       ndev->mtu = MCTP_PCIE_VDM_MIN_MTU;
+       ndev->min_mtu = MCTP_PCIE_VDM_MIN_MTU;
+       ndev->max_mtu = MCTP_PCIE_VDM_MAX_MTU;
+       ndev->tx_queue_len = MCTP_PCIE_VDM_NET_DEV_TX_QUEUE_LEN;
+       ndev->addr_len = 2; //PCIe bdf is 2 bytes

One of the critical things to get right is the lladdr format for PCIe VDM devices, as it will be visible to userspace. While the PCIe b/d/fn data is indeed two bytes, the MCTP addressing format for VDM data is not entirely representable in two bytes: we also have the routing type to encode. DSP0238 requires us to use Route to Root Complex and Broadcast from Root Complex for certain messages, so we need some way to represent that in your proposed lladdr format.

For this reason, you may want to encode this as [type, bdfn] data.

Also, in flit mode, we also have the segment byte to encode.

Cheers,

Jeremy

author
#2 lore raw

Hi Jeremy,
Appreciate for the feedback! Please check inline below.

Quoted 17 lines

Hi YH,

[+CC Khang]

I have some overall questions before we get into a full review of the series, inline below.

Quoted 9 lines

Add an implementation for DMTF DSP0238 MCTP PCIe VDM transport spec.

Introduce struct mctp_pcie_vdm_dev to represent each PCIe VDM interface and its send/receive operations. Register a net_device with the MCTP core so packets traverse the standard networking socket API.

Because there is no generic PCIe VDM bus framework in-tree, this driver provides a transport interface for lower layers to implement vendor-specific read/write callbacks.

Quoted 7 lines

Do we really need an abstraction for MCTP VDM drivers? How many are you expecting? Can you point us to a client of the VDM abstraction?

There is some value in keeping consistency for the MCTP lladdr formats across PCIe transports, but I'm not convinced we need a whole abstraction layer for this.

We plan to follow existing upstream MCTP transports—such as I²C, I³C, and USB—by abstracting the hardware-specific details into a common interface and focus on the transport binding protocol in this patch. This driver has been tested by our AST2600 and AST2700 MCTP driver.

Quoted 5 lines
Quoted 2 lines

TX path uses a dedicated kernel thread and ptr_ring: skbs queued by the MCTP stack are enqueued on the ring and processed in-thread context.

Is this somehow more suitable than the existing netdev queues?

Our current implementation has two operations that take time:
1) Configure the PCIe VDM routing type as DSP0238 requested if we are sending certain ctrl message command codes like Discovery Notify request or Endpoint Discovery response.
2) Update the BDF/EID routing table.

Since the netdev TX queue call-stack should be executed quickly, we offload these items to a dedicated kernel thread and use ptr_ring to process packets in batches.

Quoted 10 lines

drivers/net/mctp/mctp-pcie-vdm.c line 114

Quoted 6 lines
drivers/net/mctp/mctp-pcie-vdm.c new file +6 -0
+struct mctp_pcie_vdm_route_info {
+       u8 eid;
+       u8 dirty;
+       u16 bdf_addr;
+       struct hlist_node hnode;
+};

Why are you keeping your own routing table in the transport driver? We already have the route and neighbour tables in the MCTP core code.

Quoted 3 lines

Your assumption that you can intercept MCTP control messages to keep a separate routing table will not work.

We maintain a routing table in the transport driver to record the mapping between BDFs and EIDs, as the BDF is only present in the PCIe VDM header of received Endpoint Discovery Responses. This information is not forwarded to the MCTP core in the MCTP payload. We update the table with this mapping before forwarding the MCTP message to the core.

Additionally, if the MCTP Bus Owner operates in Endpoint (EP) role on the PCIe bus, it cannot obtain the physical addresses of other devices from the PCIe bus. Therefore, recording the physical address in the transport driver may be, in our view, a practical solution to this limitation.

Quoted 17 lines

drivers/net/mctp/mctp-pcie-vdm.c

Quoted 7 lines
drivers/net/mctp/mctp-pcie-vdm.c new file +7 -0
+static void mctp_pcie_vdm_net_setup(struct net_device *ndev) {
+       ndev->type = ARPHRD_MCTP;
+
+       ndev->mtu = MCTP_PCIE_VDM_MIN_MTU;
+       ndev->min_mtu = MCTP_PCIE_VDM_MIN_MTU;
+       ndev->max_mtu = MCTP_PCIE_VDM_MAX_MTU;
+       ndev->tx_queue_len =

MCTP_PCIE_VDM_NET_DEV_TX_QUEUE_LEN;

Quoted 1 line

+ ndev->addr_len = 2; //PCIe bdf is 2 bytes

One of the critical things to get right is the lladdr format for PCIe VDM devices, as it will be visible to userspace. While the PCIe b/d/fn data is indeed two bytes, the MCTP addressing format for VDM data is not entirely representable in two
bytes: we also have the routing type to encode. DSP0238 requires us to use Route to Root Complex and Broadcast from Root Complex for certain messages, so we need some way to represent that in your proposed lladdr format.

Quoted 4 lines

For this reason, you may want to encode this as [type, bdfn] data.

Also, in flit mode, we also have the segment byte to encode.

Agreed. In our implement, we always fill in the "Route By ID" type when core asks us to create the header, since we don't know the correct type to fill at that time. And later we update the Route type based on the ctrl message code when doing TX. I think it would be nice if we can have a uniformed address format to get the actual Route type by passed-in lladdr when creating the header.

Quoted 4 lines

Cheers,

Jeremy

************* Email Confidentiality Notice ********************
免責聲明:
本信件(或其附件)可能包含機密資訊,並受法律保護。如 台端非指定之收件者,請以電子郵件通知本電子郵件之發送者, 並請立即刪除本電子郵件及其附件和銷毀所有複印件。謝謝您的合作! 信驊科技以誠信正直原則永續經營企業,並已委由第三方公正單位勤業眾信及信驊科技獨立董事來管理匿名舉報系統,如各個利害關係人等有發現任何違法及違反公司從業道德、違反法令法規及專業準則、亦或霸凌及違反性別平等之情事,請直接透過以下可選擇匿名之舉報系統舉報,再次感謝您協助信驊持續邁向永續經營。信驊科技舉報網站連結:https://secure.conductwatch.com/aspeedtech/

DISCLAIMER:
This message (and any attachments) may contain legally privileged and/or other confidential information. If you have received it in error, please notify the sender by reply e-mail and immediately delete the e-mail and any attachments without copying or disclosing the contents. Thank you.
ASPEED Technology is committed to sustainable business practices based on integrity and honesty principles. In order to ensure that all information can be openly and transparently communicated, a third-party independent organization, Deloitte and ASPEED Technology's independent directors, have been entrusted to manage the anonymous reporting system. If any stakeholders discover any illegal activities, violations of the company's professional ethics, infringements of laws and regulations, or incidents of bullying and gender inequality, please directly report through the anonymous reporting system provided below. We thank you for your assistance in helping ASPEED Technology continue its journey towards sustainable operations: https://secure.conductwatch.com/aspeedtech/

maintainer
#3 lore raw

Hi YH,

Quoted 11 lines
Quoted 7 lines

Do we really need an abstraction for MCTP VDM drivers? How many are you expecting? Can you point us to a client of the VDM abstraction?

There is some value in keeping consistency for the MCTP lladdr formats across PCIe transports, but I'm not convinced we need a whole abstraction layer for this.

We plan to follow existing upstream MCTP transports—such as I²C, I³C, and USB—by abstracting the hardware-specific details into a common interface and focus on the transport binding protocol in this patch. This driver has been tested by our AST2600 and AST2700 MCTP driver.

Is that one driver (for both 2600 and 2700) or two?

I'm still not convinced you need an abstraction layer specifically for VDM transports, especially as you're forcing a specific driver model with the deferral of TX to a separate thread.

Even if this abstraction layer is a valid approach, it would not be merged until you also have an in-kernel user of it.

Quoted 10 lines
Quoted 5 lines
Quoted 2 lines

TX path uses a dedicated kernel thread and ptr_ring: skbs queued by the MCTP stack are enqueued on the ring and processed in-thread context.

Is this somehow more suitable than the existing netdev queues?

Our current implementation has two operations that take time: 1) Configure the PCIe VDM routing type as DSP0238 requested if we are sending certain ctrl message command codes like Discovery Notify request or Endpoint Discovery response. 2) Update the BDF/EID routing table.

More on this below, but: you don't need to handle either of those in a transport driver.

Quoted 13 lines
Quoted 10 lines

drivers/net/mctp/mctp-pcie-vdm.c line 114

Quoted 6 lines
drivers/net/mctp/mctp-pcie-vdm.c new file +6 -0
+struct mctp_pcie_vdm_route_info {
+       u8 eid;
+       u8 dirty;
+       u16 bdf_addr;
+       struct hlist_node hnode;
+};

Why are you keeping your own routing table in the transport driver? We already have the route and neighbour tables in the MCTP core code.

Quoted 3 lines

Your assumption that you can intercept MCTP control messages to keep a separate routing table will not work.

Quoted 6 lines

We maintain a routing table in the transport driver to record the mapping between BDFs and EIDs, as the BDF is only present in the PCIe VDM header of received Endpoint Discovery Responses. This information is not forwarded to the MCTP core in the MCTP payload. We update the table with this mapping before forwarding the MCTP message to the core.

There is already support for this in the MCTP core - the neighbour table maintains mappings between EID and link-layer addresses. In the case of a PCIe VDM transport, those link-layer addresses contain the bdf data.

The transport driver only needs to be involved in packet transmit and receive. Your bdf data is provided to the driver through the header_ops->create() op.

Any management of the neighbour table is performed by userspace, which has visibility of the link-layer addresses of incoming skbs - assuming your drivers are properly setting the cb->haddr data on receive.

This has already been established through the existing transports that consume lladdr data (i2c and i3c). You should not be handling the lladdr-to-EID mapping *at all* in the transport driver.

Quoted 3 lines

Additionally, if the MCTP Bus Owner operates in Endpoint (EP) role on the PCIe bus, it cannot obtain the physical addresses of other devices from the PCIe bus.

Sure it can, there are mechanisms for discovery. However, that's entirely handled by userspace, which can update the existing neighbour table.

Quoted 6 lines

Agreed. In our implement, we always fill in the "Route By ID" type when core asks us to create the header, since we don't know the correct type to fill at that time.  And later we update the Route type based on the ctrl message code when doing TX. I think it would be nice if we can have a uniformed address format to get the actual Route type by passed-in lladdr when creating the header.

OK, so we'd include the routing type in the lladdr data then.

Cheers,

Jeremy

author
#4 lore raw

Hi Jeremy,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Do we really need an abstraction for MCTP VDM drivers? How many are you expecting? Can you point us to a client of the VDM abstraction?

There is some value in keeping consistency for the MCTP lladdr formats across PCIe transports, but I'm not convinced we need a whole abstraction layer for this.

Quoted 7 lines
Quoted 4 lines

We plan to follow existing upstream MCTP transports-such as I²C, I³C, and USB-by abstracting the hardware-specific details into a common interface and focus on the transport binding protocol in this patch. This driver has been tested by our AST2600 and AST2700 MCTP driver.

Is that one driver (for both 2600 and 2700) or two?

It's written in one file to reuse common functions, but the behavior is slightly different depending on the hardware.

Quoted 4 lines

I'm still not convinced you need an abstraction layer specifically for VDM transports, especially as you're forcing a specific driver model with the deferral of TX to a separate thread.

We followed the same implementation pattern as mctp-i2c and mctp-i3c, both of which also abstract the hardware layer via the existing i2c/i3c device interface and use a kernel thread for TX data. That said, I believe it's reasonable to remove the kernel thread and instead send the packet directly downward after we remove the route table part.
Could you kindly help to share your thoughts on which approach might be preferable?

Quoted 3 lines

Even if this abstraction layer is a valid approach, it would not be merged until you also have an in-kernel user of it.

We have an MCTP controller driver (mentioned above, which we used for testing this driver) that utilizes this abstraction for transmission, which we're planning to upstream in the future. REF Link: https://github.com/AspeedTech-BMC/linux/blob/aspeed-master-v6.6/drivers/soc/aspeed/aspeed-mctp.c

Since the PCIe VDM driver is implemented as an abstraction layer, our current plan is to submit it separately as we believe the review process for each driver can proceed independently. Would you recommend submitting both drivers together in the same patch series for review, or is it preferable to keep them separate?

Quoted 39 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

TX path uses a dedicated kernel thread and ptr_ring: skbs queued by the MCTP stack are enqueued on the ring and processed in-thread

context.

Quoted 8 lines
Quoted 3 lines

Is this somehow more suitable than the existing netdev queues?

Our current implementation has two operations that take time: 1) Configure the PCIe VDM routing type as DSP0238 requested if we are sending certain ctrl message command codes like Discovery Notify request or Endpoint Discovery response. 2) Update the BDF/EID routing table.

More on this below, but: you don't need to handle either of those in a transport driver.

Quoted 13 lines
Quoted 10 lines

drivers/net/mctp/mctp-pcie-vdm.c line 114

Quoted 6 lines
drivers/net/mctp/mctp-pcie-vdm.c new file +6 -0
+struct mctp_pcie_vdm_route_info {
+       u8 eid;
+       u8 dirty;
+       u16 bdf_addr;
+       struct hlist_node hnode;
+};

Why are you keeping your own routing table in the transport driver? We already have the route and neighbour tables in the MCTP core code.

Quoted 3 lines

Your assumption that you can intercept MCTP control messages to keep a separate routing table will not work.

Quoted 6 lines

We maintain a routing table in the transport driver to record the mapping between BDFs and EIDs, as the BDF is only present in the PCIe VDM header of received Endpoint Discovery Responses. This information is not forwarded to the MCTP core in the MCTP payload. We update the table with this mapping before forwarding the MCTP message to the core.

There is already support for this in the MCTP core - the neighbour table maintains mappings between EID and link-layer addresses. In the case of a PCIe VDM transport, those link-layer addresses contain the bdf data.

Quoted 8 lines

The transport driver only needs to be involved in packet transmit and receive. Your bdf data is provided to the driver through the header_ops->create() op.

Any management of the neighbour table is performed by userspace, which has visibility of the link-layer addresses of incoming skbs - assuming your drivers are properly setting the cb->haddr data on receive.

Agreed, we'll remove the table.

Quoted 11 lines

This has already been established through the existing transports that consume lladdr data (i2c and i3c). You should not be handling the lladdr-to-EID mapping *at all* in the transport driver.

Quoted 3 lines

Additionally, if the MCTP Bus Owner operates in Endpoint (EP) role on the PCIe bus, it cannot obtain the physical addresses of other devices from the PCIe bus.

Sure it can, there are mechanisms for discovery. However, that's entirely handled by userspace, which can update the existing neighbour table.

Quoted 9 lines
Quoted 6 lines

Agreed. In our implement, we always fill in the "Route By ID" type when core asks us to create the header, since we don't know the correct type to fill at that time.  And later we update the Route type based on the ctrl message code when doing TX. I think it would be nice if we can have a uniformed address format to get the actual Route type by passed-in lladdr when creating the header.

OK, so we'd include the routing type in the lladdr data then.

Could you share if there's any preliminary prototype or idea for the format of the lladdr that core plans to implement, particularly regarding how the route type should be encoded or parsed?

For example, should we expect the first byte of the daddr parameter in the create_hdr op to indicate the route type?

Quoted 4 lines

Cheers,

Jeremy

maintainer
#5 lore raw

Hi YH,

Quoted 4 lines
Quoted 2 lines

Is that one driver (for both 2600 and 2700) or two?

It's written in one file to reuse common functions, but the behavior is slightly different depending on the hardware.

OK, but it's still the one driver (one struct platform_driver handling multiple of_device_id matches), and there's only one instance where you're interacting with the mctp_pcie_vdm API. So that would be a single user of the proposed abstraction.

Quoted 7 lines
Quoted 4 lines

I'm still not convinced you need an abstraction layer specifically for VDM transports, especially as you're forcing a specific driver model with the deferral of TX to a separate thread.

We followed the same implementation pattern as mctp-i2c and mctp-i3c, both of which also abstract the hardware layer via the existing i2c/i3c device interface and use a kernel thread for TX data.

You're combing two concepts there: the use of a workqueue for transmit, and the use of a driver abstraction layer between the hardware and the MCTP netdev.

Some existing MCTP transport drivers have the deferred TX via workqueue, but none have an abstraction layer like you are proposing here.

In the case of I2C and I3C, we cannot transmit directly from the ->ndo_start_xmit() op, because i2c/i3c operations are done in a sleepable context. Hence the requirement for the defer for those.

However, I would be surprised if transmitting via your platform PCIe VDM interface would require blocking operations. From what I can see, it can all be atomic for your driver. As you say:

Quoted 6 lines

That said, I believe it's reasonable to remove the kernel thread and instead send the packet directly downward after we remove the route table part.

Could you kindly help to share your thoughts on which approach might be preferable?

The direct approach would definitely be preferable, if possible.

Now, given:

1) you don't need the routing table
2) you probably don't need a workqueue
3) there is only one driver using the proposed abstraction

- then it sounds like you don't need an abstraction layer at all. Just implement your hardware driver to use the netdev operations directly, as a self-contained drivers/net/mctp/mctp-pcie-aspeed.c.

Quoted 2 lines

Would you recommend submitting both drivers together in the same patch series for review, or is it preferable to keep them separate?

I would recommend removing the abstraction altogether.

If, for some reason, we do end up needing it, I would prefer they they be submitted together. This allows us to review against an actual use-case.

Quoted 5 lines
Quoted 2 lines

OK, so we'd include the routing type in the lladdr data then.

Could you share if there's any preliminary prototype or idea for the format of the lladdr that core plans to implement, particularly regarding how the route type should be encoded or parsed?

Excellent question! I suspect we would want a four-byte representation, being:

[0]: routing type (bits 0:2, others reserved)
[1]: segment (or 0 for non-flit mode)
[2]: bus
[3]: device / function

which assumes there is some value in combining formats between flit- and non-flit modes. I am happy to adjust if there are better ideas.

Khang: any inputs from your side there?

Cheers,

Jeremy

author
#6 lore raw

Hi Jeremy,

Quoted 17 lines
Quoted 4 lines
Quoted 2 lines

Is that one driver (for both 2600 and 2700) or two?

It's written in one file to reuse common functions, but the behavior is slightly different depending on the hardware.

OK, but it's still the one driver (one struct platform_driver handling multiple of_device_id matches), and there's only one instance where you're interacting with the mctp_pcie_vdm API. So that would be a single user of the proposed abstraction.

Quoted 7 lines
Quoted 4 lines

I'm still not convinced you need an abstraction layer specifically for VDM transports, especially as you're forcing a specific driver model with the deferral of TX to a separate thread.

We followed the same implementation pattern as mctp-i2c and mctp-i3c, both of which also abstract the hardware layer via the existing i2c/i3c device interface and use a kernel thread for TX data.

Quoted 7 lines

You're combing two concepts there: the use of a workqueue for transmit, and the use of a driver abstraction layer between the hardware and the MCTP netdev.

Some existing MCTP transport drivers have the deferred TX via workqueue, but none have an abstraction layer like you are proposing here.

From my perspective, the other MCTP transport drivers do make use of abstraction layers that already exist in the kernel tree. For example, mctp-i3c uses i3c_device_do_priv_xfers(), which ultimately invokes operations registered by the underlying I3C driver. This is effectively an abstraction layer handling the hardware-specific details of TX packet transmission.

In our case, there is no standard interface—like those for I2C/I3C—that serves PCIe VDM. So, the proposed driver tries to introduce a unified interface, defined in mctp-pcie-vdm.h, to provide a reusable interface that allows developers to focus on hardware-specific implementation without needing to duplicate or rework the transport binding logic each time.

Could you kindly share your thoughts or guidance on how the abstraction model used in our PCIe VDM driver compares to the existing abstractions used in I2C/I3C transport implementations?

Quoted 4 lines

In the case of I2C and I3C, we cannot transmit directly from the ->ndo_start_xmit() op, because i2c/i3c operations are done in a sleepable context. Hence the requirement for the defer for those.

Understood, thanks for the clarification!

Quoted 4 lines

However, I would be surprised if transmitting via your platform PCIe VDM interface would require blocking operations. From what I can see, it can all be atomic for your driver. As you say:

Quoted 9 lines
Quoted 6 lines

That said, I believe it's reasonable to remove the kernel thread and instead send the packet directly downward after we remove the route table part.

Could you kindly help to share your thoughts on which approach might be preferable?

The direct approach would definitely be preferable, if possible.

Got it. Then we'll remove the kernel thread and do TX directly.

Quoted 10 lines

Now, given:

1) you don't need the routing table
2) you probably don't need a workqueue
3) there is only one driver using the proposed abstraction

- then it sounds like you don't need an abstraction layer at all. Just implement your hardware driver to use the netdev operations directly, as a self-contained drivers/net/mctp/mctp-pcie-aspeed.c.

Quoted 8 lines
Quoted 2 lines

Would you recommend submitting both drivers together in the same patch series for review, or is it preferable to keep them separate?

I would recommend removing the abstraction altogether.

If, for some reason, we do end up needing it, I would prefer they they be submitted together. This allows us to review against an actual use-case.

Okay, we’ll include it in the next patch series once we’ve reached a conclusion on the abstraction.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

OK, so we'd include the routing type in the lladdr data then.

Could you share if there's any preliminary prototype or idea for the format of the lladdr that core plans to implement, particularly regarding how the route type should be encoded or parsed?

Excellent question! I suspect we would want a four-byte representation, being:

Quoted 8 lines

[0]: routing type (bits 0:2, others reserved)
[1]: segment (or 0 for non-flit mode)
[2]: bus
[3]: device / function

which assumes there is some value in combining formats between flit- and non-flit modes. I am happy to adjust if there are better ideas.

This looks good to me—thanks for sharing!

Quoted 6 lines

Khang: any inputs from your side there?

Cheers,

Jeremy

maintainer
#7 lore raw

Hi YH,

Quoted 9 lines

From my perspective, the other MCTP transport drivers do make use of abstraction layers that already exist in the kernel tree. For example, mctp-i3c uses i3c_device_do_priv_xfers(), which ultimately invokes operations registered by the underlying I3C driver. This is effectively an abstraction layer handling the hardware-specific details of TX packet transmission.

In our case, there is no standard interface—like those for I2C/I3C—that serves PCIe VDM.

But that's not what you're proposing here - your abstraction layer serves one type of PCIe VDM messaging (MCTP), for only one PCIe VDM MCTP driver.

If you were proposing adding a *generic* PCIe VDM interface, that is suitable for all messaging types (not just MCTP), and all PCIe VDM hardware (not just ASPEED's) that would make more sense. But I think that would be a much larger task than what you're intending here.

Start small. If we have other use-cases for an abstraction layer, we can introduce it at that point - where we have real-world design inputs for it.

Regardless, we have worked out that there is nothing to actually abstract *anyway*.

Quoted 3 lines
Quoted 2 lines

The direct approach would definitely be preferable, if possible.

Got it. Then we'll remove the kernel thread and do TX directly.

Super!

Quoted 8 lines
Quoted 8 lines

Excellent question! I suspect we would want a four-byte representation, being:

[0]: routing type (bits 0:2, others reserved)
[1]: segment (or 0 for non-flit mode)
[2]: bus
[3]: device / function

Quoted 4 lines
Quoted 3 lines

which assumes there is some value in combining formats between flit- and non-flit modes. I am happy to adjust if there are better ideas.

This looks good to me—thanks for sharing!

No problem! We'll still want a bit of wider consensus on this, because we cannot change it once upstreamed.

Cheers,

Jeremy

author
#8 lore raw

Hi Jeremy,

Quoted 10 lines
Quoted 9 lines

From my perspective, the other MCTP transport drivers do make use of abstraction layers that already exist in the kernel tree. For example, mctp-i3c uses i3c_device_do_priv_xfers(), which ultimately invokes operations registered by the underlying I3C driver. This is effectively an abstraction layer handling the hardware-specific details of TX packet transmission.

In our case, there is no standard interface-like those for I2C/I3C-that serves PCIe VDM.

Quoted 8 lines

But that's not what you're proposing here - your abstraction layer serves one type of PCIe VDM messaging (MCTP), for only one PCIe VDM MCTP driver.

If you were proposing adding a *generic* PCIe VDM interface, that is suitable for all messaging types (not just MCTP), and all PCIe VDM hardware (not just ASPEED's) that would make more sense. But I think that would be a much larger task than what you're intending here.

Agreed. Our proposed interface is intended only for MCTP, and thus not generic for all VDM messages.

Quoted 3 lines

Start small. If we have other use-cases for an abstraction layer, we can introduce it at that point - where we have real-world design inputs for it.

We're planning to split the MCTP controller driver into two separate drivers for AST2600 and AST2700, removing the AST2600-specific workarounds in the process for improving long-term maintainability. And it's part of the reason we want to decouple the binding protocol logic into its own layer.

Would it be preferable to create a directory such as net/mctp/aspeed/ to host the abstraction layer alongside the hardware-specific drivers? We're considering this structure to help encapsulate the shared logic and keep the MCTP PCIe VDM-related components organized. Appreciate any guidance on whether this aligns with the expected upstream organization.

Quoted 30 lines

Regardless, we have worked out that there is nothing to actually abstract *anyway*.

Quoted 3 lines
Quoted 2 lines

The direct approach would definitely be preferable, if possible.

Got it. Then we'll remove the kernel thread and do TX directly.

Super!

Quoted 9 lines
Quoted 9 lines

Excellent question! I suspect we would want a four-byte representation,
being:

[0]: routing type (bits 0:2, others reserved)
[1]: segment (or 0 for non-flit mode)
[2]: bus
[3]: device / function

Quoted 4 lines
Quoted 3 lines

which assumes there is some value in combining formats between flit- and non-flit modes. I am happy to adjust if there are better ideas.

This looks good to me-thanks for sharing!

No problem! We'll still want a bit of wider consensus on this, because we cannot change it once upstreamed.

Cheers,

Jeremy

#9 lore raw
Quoted 2 lines · YH Chung

Would it be preferable to create a directory such as net/mctp/aspeed/ to host the abstraction layer alongside the hardware-specific drivers? We're considering this structure to help encapsulate the shared logic and keep the MCTP PCIe VDM-related components organized.

My suggestiong  is: Keep it simple.  There are only a handful of mctp device drivers thus far, and there seems to be little justification for a deeper hierarchy.

Just focus on the cleanest implementation.  Having two drivers plus a single common source code for each in drivers/net/mctp seems to be easier to manage for now.

maintainer
#10 lore raw
In reply to YH Chung

Hi YH,

Quoted 5 lines

We're planning to split the MCTP controller driver into two separate drivers for AST2600 and AST2700, removing the AST2600-specific workarounds in the process for improving long-term maintainability. And it's part of the reason we want to decouple the binding protocol logic into its own layer.

The split is entirely up to you (and sounds reasonable), but the "binding protocol logic" is really minimal. I would think a couple of shared helper functions should be sufficient?

Quoted 3 lines

Would it be preferable to create a directory such as net/mctp/aspeed/ to host the abstraction layer alongside the hardware-specific drivers?

Just put them in the top-level at drivers/net/mctp/ for now. There's not much in there at present, so will be simple to keep organised. If you end up with two drivers and a common set of utils between the two, that's a total of four files, which I think we can manage.

Cheers,

Jeremy

#11 lore raw
In reply to YH Chung
Quoted 5 lines · YH Chung

From my perspective, the other MCTP transport drivers do make use of abstraction layers that already exist in the kernel tree. For example, mctp-i3c uses i3c_device_do_priv_xfers(), which ultimately invokes operations registered by the underlying I3C driver. This is effectively an abstraction layer handling the hardware-specific details of TX packet transmission.

In our case, there is no standard interface—like those for I2C/I3C—that serves PCIe VDM. So, the proposed driver tries to introduce a unified interface, defined in mctp-pcie-vdm.h, to provide a reusable interface that allows developers to focus on hardware-specific implementation without needing to duplicate or rework the transport binding logic each time.

Could you kindly share your thoughts or guidance on how the abstraction model used in our PCIe VDM driver compares to the existing abstractions used in I2C/I3C transport implementations?

Would the mailbox abstraction work for this?  It is what I am using in the MCTP over PCC code.  Perhaps a PCIe VDM mailbox implementation will have a wider use  than just MCTP.

#12 lore raw
In reply to Jeremy Kerr

Hi YH and Jeremy,

[+CC Hieu]

Quoted 12 lines
Quoted 3 lines

Could you share if there's any preliminary prototype or idea for the format of the lladdr that core plans to implement, particularly regarding how the route type should be encoded or parsed?

Excellent question! I suspect we would want a four-byte representation, being:

[0]: routing type (bits 0:2, others reserved)
[1]: segment (or 0 for non-flit mode)
[2]: bus
[3]: device / function

Quoted 4 lines

which assumes there is some value in combining formats between flit- and non-flit modes. I am happy to adjust if there are better ideas.

Khang: any inputs from your side there?

I believe segment 0 is a common valid segment and is not reserved. If we want to combine, we might need another bit in the first byte to represent if it is flit-mode or not. But I am not sure if it is worth the effort, rather than just separate them.

As far as I understand, I think we have been discussing the address format for each "Transport Binding" (e.g, I2C vs PCIe-VDM vs ...).

According to DSP0239, I suggest we should decide the lladdr format based on the more precise "Physical Medium Identifier" (e.g, PCIe 5.0 or PCIe 6.0 non-Flit or PCIe 6.0 Flit Mode), rather than the more general "Physical Transport Binding Identifier". The specification seems to suggest this by the wording "primarily".

The identifier is primarily used to identify which physical addressing format is used for MCTP packets on the bus.

Transport Binding Identifier used to be enough, until they separate the address for PCIe-VDM non-Flit and Flit Mode. I am afraid if they add something new again, we might not be able to retrofit.

It should be safer and easier to get the format right for each Physical Medium Identifier, rather than for each Physical Transport Binding.

So my opinion:

- 3-byte for non-Flit (0x08-0x0E medium type)
4-byte for Flit Mode (0x40 medium type)
- Drivers should be able to advertise their Physical Medium Identifier alongside the existing Physical Transport Binding Identifier.
- We can document a stable lladdr / Linux kernel physical format used for sockets for each Physical Medium Identifier, not Physical Transport Binding.

Sincerely,
Khang

maintainer
#13 lore raw

Hi Khang,

Thanks for the input, I appreciate it.

Quoted 3 lines
Quoted 1 line

Khang: any inputs from your side there?

I believe segment 0 is a common valid segment and is not reserved.

0 would not have a special meaning in flit mode (ie, when we're using the segment number); this was more a reference to being optional in non-flit mode.

Quoted 3 lines

If we want to combine, we might need another bit in the first byte to represent if it is flit-mode or not. But I am not sure if it is worth the effort, rather than just separate them.

Yep, had the same line of thinking here too.

I agree that it would make sense to have the address format reflect the actual hardware transport. Having variation across the binding identifier should not be a problem.

Quoted 6 lines

It should be safer and easier to get the format right for each Physical Medium Identifier, rather than for each Physical Transport Binding.

So my opinion:

Quoted 7 lines

- 3-byte for non-Flit (0x08-0x0E medium type)
   4-byte for Flit Mode (0x40 medium type)
- Drivers should be able to advertise their Physical Medium Identifier alongside the existing Physical Transport Binding Identifier.
- We can document a stable lladdr / Linux kernel physical format used for sockets for each Physical Medium Identifier, not Physical Transport Binding.

Agreed, sounds like a good plan. I'll look at options for the physical medium identifier.

YH: so we would just have the three-byte format for your proposed driver:

[0]: routing type (bits 0:2, others reserved)
[1]: bus
[2]: device / function

- assuming you're only handling non-flit mode for now.

Cheers,

Jeremy

author
#14 lore raw

Hi Jeremy,

Quoted 4 lines

Just put them in the top-level at drivers/net/mctp/ for now. There's not much in there at present, so will be simple to keep organised. If you end up with two drivers and a common set of utils between the two, that's a total of four files, which I think we can manage.

Understood, thanks for the guidance!
We plan to start with the AST2700 driver in the next submission, along with the shared utility code.

Quoted 9 lines

YH: so we would just have the three-byte format for your proposed driver:

[0]: routing type (bits 0:2, others reserved)
[1]: bus
[2]: device / function

- assuming you're only handling non-flit mode for now.

Sounds good-We'll apply this format in the next patch.

Hi Adam,

Quoted 2 lines

Would the mailbox abstraction work for this? It is what I am using in the MCTP over PCC code. Perhaps a PCIe VDM mailbox implementation will have a wider use than just MCTP.

Thanks a lot for the suggestion! For now, we're planning to remove the current abstraction and use a set of common utility functions shared between the AST2600 and AST2700 drivers. As Jeremy mentioned, we'd prefer to hold off on introducing a PCIe VDM abstraction layer until there are more concrete use cases that would benefit from it.

Quoted 6 lines

My suggestiong is: Keep it simple. There are only a handful of mctp device drivers thus far, and there seems to be little justification for a deeper hierarchy.

Just focus on the cleanest implementation. Having two drivers plus a single common source code for each in drivers/net/mctp seems to be easier to manage for now.

Appreciate the guidance!
We'll proceed as you and Jeremy suggested and keep everything under drivers/net/mctp for now.

#15 lore raw
In reply to aspeedyh
kernel test robot noticed the following build warnings:

Hi aspeedyh,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]
[also build test WARNING on net/main linus/master v6.16-rc6 next-20250714] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/aspeedyh/net-mctp-Add-MCTP-PCIe-VDM-transport-driver/20250714-142656
base:   net-next/main
patch link:    https://lore.kernel.org/r/20250714062544.2612693-1-yh_chung%40aspeedtech.com
patch subject: [PATCH] net: mctp: Add MCTP PCIe VDM transport driver
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20250715/[email protected]/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250715/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/net/mctp/mctp-pcie-vdm.c:491:4: warning: variable 'vdm_dev' is uninitialized when used here [-Wuninitialized]
     491 |                  vdm_dev->ndev->name);
         |                  ^~~~~~~
   include/linux/printk.h:631:26: note: expanded from macro 'pr_debug'
     631 |         dynamic_pr_debug(fmt, ##__VA_ARGS__)
         |                                 ^~~~~~~~~~~
   include/linux/dynamic_debug.h:270:22: note: expanded from macro 'dynamic_pr_debug'
     270 |                            pr_fmt(fmt), ##__VA_ARGS__)
         |                                           ^~~~~~~~~~~
   include/linux/dynamic_debug.h:250:59: note: expanded from macro '_dynamic_func_call'
     250 |         _dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__)
         |                                                                  ^~~~~~~~~~~
   include/linux/dynamic_debug.h:248:65: note: expanded from macro '_dynamic_func_call_cls'
     248 |         __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS__)
         |                                                                        ^~~~~~~~~~~
   include/linux/dynamic_debug.h:224:15: note: expanded from macro '__dynamic_func_call_cls'
     224 |                 func(&id, ##__VA_ARGS__);                       \
         |                             ^~~~~~~~~~~
   drivers/net/mctp/mctp-pcie-vdm.c:484:35: note: initialize the variable 'vdm_dev' to silence this warning
     484 |         struct mctp_pcie_vdm_dev *vdm_dev;
         |                                          ^
         |                                           = NULL

1 warning generated.

vim +/vdm_dev +491 drivers/net/mctp/mctp-pcie-vdm.c

481
482 static void mctp_pcie_vdm_uninit(struct net_device *ndev)
483 {
484 struct mctp_pcie_vdm_dev *vdm_dev;
485
486 struct mctp_pcie_vdm_route_info *route;
487 struct hlist_node *tmp;
488 int bkt;
489
490 pr_debug("%s: uninitializing vdm_dev %s\n", __func__,

 > 491			 vdm_dev->ndev->name);

492
493 vdm_dev = netdev_priv(ndev);
494 vdm_dev->callback_ops->uninit(vdm_dev->dev);
495
496 hash_for_each_safe(vdm_dev->route_table, bkt, tmp, route, hnode) {
497 hash_del(&route->hnode);
498 kfree(route);
499 }
500
501 if (vdm_dev->tx_thread) {
502 kthread_stop(vdm_dev->tx_thread);
503 vdm_dev->tx_thread = NULL;
504 }
505
506 if (mctp_pcie_vdm_wq) {
507 cancel_work_sync(&vdm_dev->rx_work);
508 flush_workqueue(mctp_pcie_vdm_wq);
509 destroy_workqueue(mctp_pcie_vdm_wq);
510 mctp_pcie_vdm_wq = NULL;
511 }
512
513 while (__ptr_ring_peek(&vdm_dev->tx_queue)) {
514 struct sk_buff *skb;
515
516 skb = ptr_ring_consume(&vdm_dev->tx_queue);
517
518 if (skb)
519 kfree_skb(skb);
520 }
521
522 mutex_lock(&mctp_pcie_vdm_dev_mutex);
523 list_del(&vdm_dev->list);
524 mutex_unlock(&mctp_pcie_vdm_dev_mutex);
525 }
526

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#16 lore raw
In reply to aspeedyh
kernel test robot noticed the following build warnings:

Hi aspeedyh,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]
[also build test WARNING on net/main linus/master v6.16-rc6 next-20250716] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/aspeedyh/net-mctp-Add-MCTP-PCIe-VDM-transport-driver/20250714-142656
base:   net-next/main
patch link:    https://lore.kernel.org/r/20250714062544.2612693-1-yh_chung%40aspeedtech.com
patch subject: [PATCH] net: mctp: Add MCTP PCIe VDM transport driver
config: powerpc64-randconfig-r122-20250717 (https://download.01.org/0day-ci/archive/20250717/[email protected]/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 16534d19bf50bde879a83f0ae62875e2c5120e64)
reproduce: (https://download.01.org/0day-ci/archive/20250717/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

>> drivers/net/mctp/mctp-pcie-vdm.c:130:1: sparse: sparse: symbol 'mctp_pcie_vdm_dev_mutex' was not declared. Should it be static?
>> drivers/net/mctp/mctp-pcie-vdm.c:131:1: sparse: sparse: symbol 'mctp_pcie_vdm_devs' was not declared. Should it be static?
>> drivers/net/mctp/mctp-pcie-vdm.c:132:25: sparse: sparse: symbol 'mctp_pcie_vdm_wq' was not declared. Should it be static?
>> drivers/net/mctp/mctp-pcie-vdm.c:343:9: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] @@     got restricted __be32 [usertype] @@
   drivers/net/mctp/mctp-pcie-vdm.c:343:9: sparse:     expected unsigned int [usertype]
   drivers/net/mctp/mctp-pcie-vdm.c:343:9: sparse:     got restricted __be32 [usertype]
>> drivers/net/mctp/mctp-pcie-vdm.c:398:17: sparse: sparse: cast to restricted __be32
>> drivers/net/mctp/mctp-pcie-vdm.c:398:17: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] @@     got restricted __le32 [usertype] @@

drivers/net/mctp/mctp-pcie-vdm.c:398:17: sparse: expected unsigned int [usertype]
drivers/net/mctp/mctp-pcie-vdm.c:398:17: sparse: got restricted __le32 [usertype]
drivers/net/mctp/mctp-pcie-vdm.c:453:25: sparse: sparse: cast to restricted __be32
drivers/net/mctp/mctp-pcie-vdm.c:453:25: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] @@ got restricted __le32 [usertype] @@
drivers/net/mctp/mctp-pcie-vdm.c:453:25: sparse: expected unsigned int [usertype]
drivers/net/mctp/mctp-pcie-vdm.c:453:25: sparse: got restricted __le32 [usertype]

vim +/mctp_pcie_vdm_dev_mutex +130 drivers/net/mctp/mctp-pcie-vdm.c

128
129 /* mutex for vdm_devs add/delete */

 > 130	DEFINE_MUTEX(mctp_pcie_vdm_dev_mutex);
 > 131	LIST_HEAD(mctp_pcie_vdm_devs);
 > 132	struct workqueue_struct *mctp_pcie_vdm_wq;

133

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki