#define NTB_EPF_DB_DATA(n) (0x34 + (n) * 4)
#define NTB_EPF_DB_OFFSET(n) (0xB4 + (n) * 4)
+/*
+ * Legacy doorbell slot layout when paired with pci-epf-*ntb:
+ *
+ * slot 0 : reserved for link events
+ * slot 1 : unused (historical extra offset)
+ * slot 2 : DB#0
+ * slot 3 : DB#1
+ * ...
+ *
+ * Thus, NTB_EPF_MIN_DB_COUNT=3 means that we at least create vectors for
+ * doorbells DB#0 and DB#1.
+ */
#define NTB_EPF_MIN_DB_COUNT 3
#define NTB_EPF_MAX_DB_COUNT 31
static int ntb_epf_peer_db_set(struct ntb_dev *ntb, u64 db_bits)
{
struct ntb_epf_dev *ndev = ntb_ndev(ntb);
+ /*
+ * ffs() returns a 1-based bit index (bit 0 -> 1).
+ *
+ * With slot 0 reserved for link events, DB#0 would naturally map to
+ * slot 1. Historically an extra +1 offset was added, so DB#0 maps to
+ * slot 2 and slot 1 remains unused. Keep this mapping for
+ * backward-compatibility.
+ */
u32 interrupt_num = ffs(db_bits) + 1;
struct device *dev = ndev->dev;
u32 db_entry_size;