Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

PCI MSI for re(4)



Hi,

Attached is a patch that should enable PCI MSI for pci(4)-attached re(4)
NICs.  I would like both review of the code, and additional testing.

I've tested it successfully on amd64 -current with a
8100E/8101E/8102E/8102EL chip.

	Jonathan Kollasch
Index: src/sys/dev/pci/if_re_pci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_re_pci.c,v
retrieving revision 1.44
diff -d -u -a -p -r1.44 if_re_pci.c
--- src/sys/dev/pci/if_re_pci.c	3 May 2015 00:04:06 -0000	1.44
+++ src/sys/dev/pci/if_re_pci.c	13 Nov 2015 04:29:24 -0000
@@ -75,6 +75,7 @@ struct re_pci_softc {
 	struct rtk_softc sc_rtk;
 
 	void *sc_ih;
+	pci_intr_handle_t *sc_pihp;
 	pci_chipset_tag_t sc_pc;
 };
 
@@ -174,7 +175,6 @@ re_pci_attach(device_t parent, device_t 
 	struct rtk_softc *sc = &psc->sc_rtk;
 	struct pci_attach_args *pa = aux;
 	pci_chipset_tag_t pc = pa->pa_pc;
-	pci_intr_handle_t ih;
 	const char *intrstr = NULL;
 	const struct rtk_type *t;
 	uint32_t hwrev;
@@ -253,12 +253,14 @@ re_pci_attach(device_t parent, device_t 
 
 	/* Hook interrupt last to avoid having to lock softc */
 	/* Allocate interrupt */
-	if (pci_intr_map(pa, &ih)) {
+	if (pci_intr_alloc(pa, &psc->sc_pihp, NULL, 0)) {
 		aprint_error_dev(self, "couldn't map interrupt\n");
 		return;
 	}
-	intrstr = pci_intr_string(pc, ih, intrbuf, sizeof(intrbuf));
-	psc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, re_intr, sc);
+	intrstr = pci_intr_string(pc, psc->sc_pihp[0], intrbuf,
+	    sizeof(intrbuf));
+	psc->sc_ih = pci_intr_establish(pc, psc->sc_pihp[0], IPL_NET,
+	    re_intr, sc);
 	if (psc->sc_ih == NULL) {
 		aprint_error_dev(self, "couldn't establish interrupt");
 		if (intrstr != NULL)
@@ -305,6 +307,11 @@ re_pci_detach(device_t self, int flags)
 		psc->sc_ih = NULL;
 	}
 
+	if (psc->sc_pihp != NULL) {
+		pci_intr_release(psc->sc_pc, psc->sc_pihp, 1);
+		psc->sc_pihp = NULL;
+	}
+
 	if (sc->rtk_bsize != 0) {
 		bus_space_unmap(sc->rtk_btag, sc->rtk_bhandle, sc->rtk_bsize);
 		sc->rtk_bsize = 0;


Home | Main Index | Thread Index | Old Index