if (IS_ERR(port))
                return port;
 
+       if (parent_port)
+               port->depth = parent_port->depth + 1;
        dev = &port->dev;
        if (parent_port)
                rc = dev_set_name(dev, "port%d", port->id);
 
  * @dports: cxl_dport instances referenced by decoders
  * @decoder_ida: allocator for decoder ids
  * @component_reg_phys: component register capability base address (optional)
+ * @depth: How deep this port is relative to the root. depth 0 is the root.
  */
 struct cxl_port {
        struct device dev;
        struct list_head dports;
        struct ida decoder_ida;
        resource_size_t component_reg_phys;
+       unsigned int depth;
 };
 
 /**