BNX2X: loads the NIC at attach time

Other than being the "right way", it'll be necessary to have the edev attached
when we start receiving IRQs.
diff --git a/kern/drivers/net/bnx2x/bnx2x.h b/kern/drivers/net/bnx2x/bnx2x.h
index 059c2b0..c0c170e 100644
--- a/kern/drivers/net/bnx2x/bnx2x.h
+++ b/kern/drivers/net/bnx2x/bnx2x.h
@@ -1444,6 +1444,7 @@
 	struct ether				*edev;
 	TAILQ_ENTRY(bnx2x) 			link9ns;
 	const struct pci_device_id	*pci_id;			/* for navigating pci/pnp */
+	bool						attached;
 
 	/* These are in Linux's net_device */
 	void						*mem_start;
diff --git a/kern/drivers/net/bnx2x/bnx2x_dev.c b/kern/drivers/net/bnx2x/bnx2x_dev.c
index 83d72ff..e414149 100644
--- a/kern/drivers/net/bnx2x/bnx2x_dev.c
+++ b/kern/drivers/net/bnx2x/bnx2x_dev.c
@@ -261,11 +261,23 @@
 	ctlr = edev->ctlr;
 	ctlr->edev = edev;	/* point back to Ether* */
 
-	/* not sure if we'll need/want any of the 9ns stuff */
-	return;
-
 	qlock(&ctlr->alock);
-	/* TODO: make sure we haven't attached already.  If so, just return */
+	if (ctlr->attached) {
+		qunlock(&ctlr->alock);
+		return;
+	}
+
+	bnx2x_open(ctlr->edev);
+
+	//do this next: ndo_set_rx_mode
+
+	/* shut it up for now.  too much stats output */
+	ctlr->msg_enable = 0;
+
+	ctlr->attached = TRUE;
+	qunlock(&ctlr->alock);
+	/* not sure if we'll need/want any of the other 9ns stuff */
+	return;
 
 	/* Alloc all your ctrl crap. */
 
@@ -315,25 +327,6 @@
 	int ctrl, i, pause, r, swdpio, txcw;
 
 	bnx2x_init_one(ctlr->edev, ctlr, ctlr->pcidev, ctlr->pci_id);
-	bnx2x_open(ctlr->edev);
-	//next ndo_set_rx_mode
-	/* despite the name, we attach at reset time.  BXE attach has a lot of
-	 * mmio mappings that have to happen at boot (in akaros), instead of during
-	 * devether's attach (at runtime) */
-
-	/* shut it up for now.  too much stats output */
-	ctlr->msg_enable = 0;
-
-//extern int bnx2x_attach(struct bnx2x *sc);
-//	bnx2x_attach(ctlr);
-//
-//	/* normally done during BSD's ifconfig */
-//extern void bnx2x_init(void *xsc);
-//	bnx2x_init(ctlr);
-
-//	if (igbedetach(ctlr))
-//		return -1;
-
 	return 0;
 }
 
@@ -420,15 +413,6 @@
 	if (ctlr == NULL)
 		return -1;
 
-	/* TODO: super-dirty hack.  This lock is normally not init'd until after
-	 * reset reset/pnp.  But we want to use it earlier, since we call open
-	 * during reset, instead of attach.  And that happens because we register
-	 * IRQs in open, and MSIX IRQs need to be done at init time (Akaros could
-	 * fix this).
-	 *
-	 * Anyway, we init the qlock here *and* in netifinit.  Good luck. */
-	qlock_init(&edev->qlock);
-
 	edev->ctlr = ctlr;
 	ctlr->edev = edev;
 
diff --git a/kern/drivers/net/bnx2x/bnx2x_main.c b/kern/drivers/net/bnx2x/bnx2x_main.c
index 076f6da..768882b 100644
--- a/kern/drivers/net/bnx2x/bnx2x_main.c
+++ b/kern/drivers/net/bnx2x/bnx2x_main.c
@@ -8465,13 +8465,19 @@
  */
 int bnx2x_set_int_mode(struct bnx2x *bp)
 {
+	int ret;
 	/* This tries to set up MSIX in advance, registering vectors and whatnot.
 	 * The bulk is in bnx2x_enable_msix.
 	 *
-	 * We can check later if it worked after register_irq()
+	 * Since we're in devreset now, we're still part of the bootup process and
+	 * can init msix, and later at attach time we can register the irqs.
 	 *
-	 * We're going to try and use MSIX, so lets set it now.  Code in a few
-	 * places checks this. */
+	 * We can check later if getting apic vectors worked after register_irq().
+	 *
+	 * We're going to try and use MSIX, so let's set it now.  Code in a few
+	 * places checks the flag. */
+	if ((ret = pci_msix_init(bp->pdev)))
+		return ret;
 	bp->flags |= USING_MSIX_FLAG;
 	return 0;
 #if 0 // AKAROS_PORT