On 16-11-2026 19:47, Prusty, Subhransu Sekhar wrote:
Hi Stephen,
PCI ID and PF/VF model (you asked about devargs). The ID table is
vendor 0x1172, device 0x0000, i.e. the Altera default IDs. Any
Altera design left at default IDs will probe as MCDMA. Whether a
function is PF or VF is decided by the presence of pf_index=, and a
VF needs parent_pf_idx= to find its channel count. The usual way to
do this in DPDK is distinct device IDs for PF and VF (and a real
Since ours is FPGA drivers this will be tricky as the IP configuration
in a design may not always have the device IDs assigned and even though
assigned every design can have a different device IDs which may be
difficult to add in the enumeration list. This is why we have this
approach to distinguish with devargs. Is there any other way we can
approach this?
Hi Stephen and all,
Thank you for reviewing the MCDMA RFC. Before preparing the next
revision, we would appreciate guidance on the PCI device identification
and PF/VF discovery model.
For context, the original RFC and review discussion are available here:
https://lore-kernel.gnuweeb.org/all/[email protected]/T/
The accompanying RFC patch shows our latest proposed change to replace
the PF/VF index devargs with topology-based discovery. It is a
preliminary proposal for discussion and does not change PCI device matching.
There are two separate questions we would like to resolve:
1. How should the PMD safely identify a PCI function as an MCDMA device?
2. After identifying it, how should the PMD determine its PF/VF role and
the hardware PF index needed to interpret the channel configuration?
Background
----------
MCDMA is an FPGA IP block incorporated into different FPGA designs. PCI
device IDs can vary between those designs, which makes maintaining a
fixed device-ID table less straightforward than for a single NIC product.
The submitted RFC matches the Altera default vendor/device IDs,
0x1172:0x0000. It uses pf_index and parent_pf_idx devargs to supply
information needed during initialization.
We understand the concern that the default IDs do not uniquely identify
MCDMA: another FPGA design using those IDs could match the PMD
incorrectly. Removing the index devargs does not resolve that matching
problem.
PCI device identification
-------------------------
Your recommendation is to use an assigned MCDMA device identity, with
distinct device IDs for PFs and VFs.
One option is to require supported FPGA designs to use explicit MCDMA
PF/VF IDs and register those IDs with the PMD. This would establish a
clear identification contract, but would place a requirement on designs
integrating the IP.
For designs using different assigned IDs, we would appreciate guidance
on the expected upstream model:
- Should support require adding each supported PF/VF ID pair to the
PMD's match table?
- Is there an existing explicit driver-selection mechanism appropriate
for designs whose IDs are not in that table?
- If additional hardware identification is needed, what information
should the FPGA expose so the PMD can validate the device safely
before accessing MCDMA-specific registers?
We are not proposing a vendor-wide match as a substitute for reliable
device identification.
Proposed PF/VF discovery change
-------------------------------
Separately, the accompanying patch (inline below) proposes replacing the
index devargs with discovery from PCI configuration and Linux sysfs.
The proposed approach identifies PFs through their SR-IOV capability,
uses the physfn relationship to locate a VF's parent PF, and derives the
hardware PF index from the corresponding PF's PCI function number.
This would remove the need for applications to supply the index values
in supported host configurations. It would not change which PCI IDs
match the PMD.
Before adopting this as the upstream interface, we need to establish
the assumptions and limitations:
- Whether every supported MCDMA PF configuration exposes the SR-IOV
capability needed for this classification.
- Whether the hardware PF index always corresponds to the PCI function
number, including any supported ARI configuration.
- How a passed-through VF obtains the required information when its
guest cannot see the parent PF or a usable physfn relationship.
We do not want to make host topology an implicit requirement if it
cannot reliably support the intended deployment cases. If topology is
insufficient, we would appreciate feedback on whether the role and
PF-index information should instead be exposed through a defined
hardware interface.
Requested feedback
------------------
Would maintainers prefer an explicit supported-PCI-ID contract combined
with hardware-based PF/VF identification, or is the proposed
topology-based discovery approach acceptable with clearly documented
restrictions?
Our immediate goal is agreement on the identification and discovery
contract before revising the enumeration code further. The other review
findings and the requested testpmd validation remain work for the next
revision; this patch is intended to make the discovery proposal concrete
for discussion.
Here is
+static int
+mcdma_pf_idx_from_function(uint8_t function, uint8_t *idx)
+{
+ if (function >= MCDMA_MAX_PF) {
+ PMD_DRV_LOG(ERR, "PCI function %u is outside the PF
index range",
+ function);
+ return -EINVAL;
+ }
+
+ *idx = function;
+ return 0;
+}
+
+/* Parent of a VF is the PCI function behind sysfs physfn. */
+static int
+mcdma_parent_pf_idx(const struct rte_pci_device *pci_dev, uint8_t *idx)
+{
+ char path[PATH_MAX];
+ char link[PATH_MAX];
+ const char *bdf;
+ struct rte_pci_addr addr;
+ ssize_t len;
+ int ret;
+
+ ret = snprintf(path, sizeof(path), "%s/" PCI_PRI_FMT "/physfn",
+ rte_pci_get_sysfs_path(),
+ pci_dev->addr.domain, pci_dev->addr.bus,
+ pci_dev->addr.devid, pci_dev->addr.function);
+ if (ret < 0 || (size_t)ret >= sizeof(path))
+ return -ENAMETOOLONG;
+
+ len = readlink(path, link, sizeof(link) - 1);
+ if (len < 0) {
+ PMD_DRV_LOG(ERR, "VF %s has no physfn", pci_dev->name);
+ return -ENODEV;
+ }
+ link[len] = '\0';
+
+ bdf = strrchr(link, '/');
+ bdf = (bdf == NULL) ? link : bdf + 1;
+ if (rte_pci_addr_parse(bdf, &addr) != 0) {
+ PMD_DRV_LOG(ERR, "Cannot parse parent PF address %s",
bdf);
+ return -EINVAL;
+ }
+
+ if (addr.devid > 0) {
+ PMD_DRV_LOG(ERR, "Currently supports max 8PFsr, does
support ARI ", bdf);
+ return -EIO;
+ }
+
+ return mcdma_pf_idx_from_function(addr.function, idx);
+}
+
+static int
+mcdma_function_role(struct mcdma_pci_device *priv,
+ const struct rte_pci_device *pci_dev)
+{
+ off_t pos;
+
+ pos = rte_pci_find_ext_capability(pci_dev,
RTE_PCI_EXT_CAP_ID_SRIOV);
+ if (pos < 0)
+ return -EIO;
+
+ priv->is_pf = pos > 0;
+ if (priv->is_pf)
+ return mcdma_pf_idx_from_function(pci_dev->addr.function,
+ &priv->pf_idx);
+
+ return mcdma_parent_pf_idx(pci_dev, &priv->parent_pf_idx);
+}
+
static int mcdma_eth_dev_init(struct rte_eth_dev *dev)
{
struct mcdma_pci_device *priv = dev->data->dev_private;
@@ -265,6 +279,10 @@ static int mcdma_eth_dev_init(struct rte_eth_dev
*dev)
priv->dev = dev;
priv->bar_base = pci_dev->mem_resource[MCDMA_CONFIG_BAR].addr;
+ ret = mcdma_function_role(priv, pci_dev);
+ if (ret != 0)
+ return ret;
ret = mcmda_parse_args(priv, pci_dev);
if (ret) {
Regards,
Subhransu