Re: [PATCH 10/10] NTB: epf: Implement db_vector_count/mask for doorbells
Frank Li <[email protected]> Wed, 25 Feb 2026 16:13:07 -0500
| Newsgroups | dev.linux.lists.ntb,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <aZ9l4z3UGX4o4-M-@lizhi-Precision-Tower-5810> |
On Tue, Feb 24, 2026 at 10:34:59PM +0900, Koichiro Den wrote: > Implement .db_vector_count and .db_vector_mask so ntb core/clients can > map doorbell events to per-vector work. > > Report vectors as 0..(db_count - 2) (skipping the unused slot) and > return BIT_ULL(db_vector) for the corresponding doorbell bit. > > Signed-off-by: Koichiro Den <[email protected]> > --- > drivers/ntb/hw/epf/ntb_hw_epf.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/drivers/ntb/hw/epf/ntb_hw_epf.c b/drivers/ntb/hw/epf/ntb_hw_epf.c > index 0018adc35f16..7c76039a79d2 100644 > --- a/drivers/ntb/hw/epf/ntb_hw_epf.c > +++ b/drivers/ntb/hw/epf/ntb_hw_epf.c > @@ -414,6 +414,34 @@ static u64 ntb_epf_db_valid_mask(struct ntb_dev *ntb) > return ntb_ndev(ntb)->db_valid_mask; > } > > +static int ntb_epf_db_vector_count(struct ntb_dev *ntb) > +{ > + struct ntb_epf_dev *ndev = ntb_ndev(ntb); > + > + /* > + * ndev->db_count includes an extra skipped slot due to the legacy > + * doorbell layout. Expose only the real doorbell vectors. > + */ > + if (ndev->db_count < 1) > + return 0; > + > + return ntb_ndev(ntb)->db_count - 1; return max(ntb_ndev(ntb)->db_count - 1, 0); Anyway: Reviewed-by: Frank Li <[email protected]> > +} > + > +static u64 ntb_epf_db_vector_mask(struct ntb_dev *ntb, int db_vector) > +{ > + struct ntb_epf_dev *ndev = ntb_ndev(ntb); > + > + /* > + * ndev->db_count includes one skipped slot in the legacy layout. Valid > + * doorbell vectors are therefore [0 .. (db_count - 2)]. > + */ > + if (db_vector < 0 || db_vector >= ndev->db_count - 1) > + return 0; > + > + return BIT_ULL(db_vector); > +} > + > static int ntb_epf_db_set_mask(struct ntb_dev *ntb, u64 db_bits) > { > return 0; > @@ -548,6 +576,8 @@ static const struct ntb_dev_ops ntb_epf_ops = { > .spad_count = ntb_epf_spad_count, > .peer_mw_count = ntb_epf_peer_mw_count, > .db_valid_mask = ntb_epf_db_valid_mask, > + .db_vector_count = ntb_epf_db_vector_count, > + .db_vector_mask = ntb_epf_db_vector_mask, > .db_set_mask = ntb_epf_db_set_mask, > .mw_set_trans = ntb_epf_mw_set_trans, > .mw_clear_trans = ntb_epf_mw_clear_trans, > -- > 2.51.0 >