tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: change MSI/MSI-X APIs
Hi,
I'm sorry for late reply, too.
On 2015/05/18 22:05, Christos Zoulas wrote:
> On May 18, 3:57pm, k-nakahara%iij.ad.jp@localhost (Kengo NAKAHARA) wrote:
> -- Subject: Re: change MSI/MSI-X APIs
>
> | What do you think about below pci_intr_alloc() API?
> | http://mail-index.netbsd.org/tech-kern/2015/05/18/msg018725.html
> |
> | I think this API simplify for many device drivers to use, however I am
> | unsure this API meets your pointing out.
> | Could you comment?
>
> I am fine with it; just some clarifications:
>
> - by max (-1) I meant the maximum number that the bus will allow. The driver
> would then decide how to split the interrupts amongst functions.
OK, I implemented such "max" number.
> - I considered using unsigned int/size_t in the counts argument and then
> I thought that it is best if it agreed with the return type, since we
> overload the return type with (negative error/positive number of interrupts).
> Another way to do this would be to return the number of interrupts allocated
> in the 0'th member of the counts array.
I implemented like latter way, but I think 0'th member may cause
confusion. So, I implemented that the function sets really allocated
counts to the same member of the counts array.
e.g. if the driver call pci_intr_alloc() in following way
====================
int counts[PCI_INTR_TYPE_SIZE];
counts[PCI_INTR_TYPE_MSIX] = 5;
counts[PCI_INTR_TYPE_MSI] = 1;
counts[PCI_INTR_TYPE_INTX] = 1;
error = pci_intr_alloc(pa, ihps, counts, PCI_INTR_TYPE_MSIX);
====================
on success of MSI-X allocation, "counts" is overwritten below
====================
counts[PCI_INTR_TYPE_MSIX] == 5;
counts[PCI_INTR_TYPE_MSI] == 0;
counts[PCI_INTR_TYPE_INTX] == 0;
====================
on failed MSI-X but success of MSI allocation, "counts" is
overwritten below
====================
counts[PCI_INTR_TYPE_MSIX] == 0;
counts[PCI_INTR_TYPE_MSI] == 1;
counts[PCI_INTR_TYPE_INTX] == 0;
====================
on failed MSI-X and MSI, but success of INTx allocation,
"counts" is overwritten below
====================
counts[PCI_INTR_TYPE_MSIX] == 0;
counts[PCI_INTR_TYPE_MSI] == 0;
counts[PCI_INTR_TYPE_INTX] == 1;
====================
on failed (of all allocation functions), pci_intr_alloc() returns
non-zero value, and the all members of "counts" are 0.
On success, the driver can also use below simple way
====================
allocated_count = counts[pci_intr_type(intr_handlers[0]);
====================
Thus, here is the implementation of above specification (include man)
http://netbsd.org/~knakahara/unify-alloc-api/unify-alloc-api.patch
furthermore, here is if_wm usage example by msaitoh@n.o
http://netbsd.org/~knakahara/unify-alloc-api/unify-alloc-api-wm-example.patch
Could you comment this patch?
Thanks,
--
//////////////////////////////////////////////////////////////////////
Internet Initiative Japan Inc.
Device Engineering Section,
Core Product Development Department,
Product Division,
Technology Unit
Kengo NAKAHARA <k-nakahara%iij.ad.jp@localhost>
Home |
Main Index |
Thread Index |
Old Index