svn commit: r198540 - in stable/6/sys: . conf contrib/pf dev/aac dev/cxgb

Ed Maste emaste at FreeBSD.org
Wed Oct 28 13:38:07 UTC 2009


Author: emaste
Date: Wed Oct 28 13:38:07 2009
New Revision: 198540
URL: http://svn.freebsd.org/changeset/base/198540

Log:
  MFC r188896
  
    Sync with the official Adaptec vendor driver:
  
    [1] Add the support for the NARK controller which seems a variant of
        the i960Rx.
    [2] Split up memory regions and other resources in 2 different parts
        as long as NARK uses them separately (it is not clear to me
        why though as long as there are no more informations available
        on this controller). Please note that in all the other cases,
        the regions overlaps leaving the default behaviour for all the
        other controllers.
    [3] Implement a clock daemon responsible for maintain updated the
        wall clock time of the controller (run any 30 minutes).
  
  (Replace callout_schedule with callout_reset for [3].)

Modified:
  stable/6/sys/   (props changed)
  stable/6/sys/conf/   (props changed)
  stable/6/sys/contrib/pf/   (props changed)
  stable/6/sys/dev/aac/aac.c
  stable/6/sys/dev/aac/aac_debug.c
  stable/6/sys/dev/aac/aac_pci.c
  stable/6/sys/dev/aac/aacreg.h
  stable/6/sys/dev/aac/aacvar.h
  stable/6/sys/dev/cxgb/   (props changed)

Modified: stable/6/sys/dev/aac/aac.c
==============================================================================
--- stable/6/sys/dev/aac/aac.c	Wed Oct 28 12:10:29 2009	(r198539)
+++ stable/6/sys/dev/aac/aac.c	Wed Oct 28 13:38:07 2009	(r198540)
@@ -71,6 +71,7 @@ static void	aac_startup(void *arg);
 static void	aac_add_container(struct aac_softc *sc,
 				  struct aac_mntinforesp *mir, int f);
 static void	aac_get_bus_info(struct aac_softc *sc);
+static void	aac_daemon(void *arg);
 
 /* Command Processing */
 static void	aac_timeout(struct aac_softc *sc);
@@ -292,6 +293,9 @@ aac_attach(struct aac_softc *sc)
 	TAILQ_INIT(&sc->aac_container_tqh);
 	TAILQ_INIT(&sc->aac_ev_cmfree);
 
+	/* Initialize the clock daemon callout. */
+	callout_init_mtx(&sc->aac_daemontime, &sc->aac_io_lock, 0);
+
 	/*
 	 * Initialize the adapter.
 	 */
@@ -349,9 +353,34 @@ aac_attach(struct aac_softc *sc)
 		aac_get_bus_info(sc);
 	}
 
+	mtx_lock(&sc->aac_io_lock);
+	callout_reset(&sc->aac_daemontime, 30 * 60 * hz, aac_daemon, sc);
+	mtx_unlock(&sc->aac_io_lock);
+
 	return(0);
 }
 
+static void
+aac_daemon(void *arg)
+{
+	struct timeval tv;
+	struct aac_softc *sc;
+	struct aac_fib *fib;
+
+	sc = arg;
+	mtx_assert(&sc->aac_io_lock, MA_OWNED);
+
+	if (callout_pending(&sc->aac_daemontime) ||
+	    callout_active(&sc->aac_daemontime) == 0)
+		return;
+	getmicrotime(&tv);
+	aac_alloc_sync_fib(sc, &fib);
+	*(uint32_t *)fib->data = tv.tv_sec;
+	aac_sync_fib(sc, SendHostTime, 0, fib, sizeof(uint32_t));
+	aac_release_sync_fib(sc);
+	callout_schedule(&sc->aac_daemontime, 30 * 60 * hz);
+}
+
 void
 aac_add_event(struct aac_softc *sc, struct aac_event *event)
 {
@@ -632,9 +661,12 @@ aac_free(struct aac_softc *sc)
 		bus_dma_tag_destroy(sc->aac_parent_dmat);
 
 	/* release the register window mapping */
-	if (sc->aac_regs_resource != NULL)
+	if (sc->aac_regs_res0 != NULL)
+		bus_release_resource(sc->aac_dev, SYS_RES_MEMORY,
+				     sc->aac_regs_rid0, sc->aac_regs_res0);
+	if (sc->aac_hwif == AAC_HWIF_NARK && sc->aac_regs_res1 != NULL)
 		bus_release_resource(sc->aac_dev, SYS_RES_MEMORY,
-				     sc->aac_regs_rid, sc->aac_regs_resource);
+				     sc->aac_regs_rid1, sc->aac_regs_res1);
 }
 
 /*
@@ -654,6 +686,8 @@ aac_detach(device_t dev)
 	if (sc->aac_state & AAC_STATE_OPEN)
 		return(EBUSY);
 
+	callout_drain(&sc->aac_daemontime);
+
 	/* Remove the child containers */
 	while ((co = TAILQ_FIRST(&sc->aac_container_tqh)) != NULL) {
 		error = device_delete_child(dev, co->co_disk);
@@ -834,7 +868,7 @@ aac_new_intr(void *arg)
 			}
 			index &= ~2;
 			for (i = 0; i < sizeof(struct aac_fib)/4; ++i)
-				((u_int32_t *)fib)[i] = AAC_GETREG4(sc, index + i*4);
+				((u_int32_t *)fib)[i] = AAC_MEM1_GETREG4(sc, index + i*4);
 			aac_handle_aif(sc, fib);
 			free(fib, M_AACBUF);
 
@@ -1753,26 +1787,33 @@ aac_check_firmware(struct aac_softc *sc)
 
 	/* Remap mem. resource, if required */
 	if ((sc->flags & AAC_FLAGS_NEW_COMM) &&
-		atu_size > rman_get_size(sc->aac_regs_resource)) {
+		atu_size > rman_get_size(sc->aac_regs_res1)) {
 		bus_release_resource(
 			sc->aac_dev, SYS_RES_MEMORY,
-			sc->aac_regs_rid, sc->aac_regs_resource);
-		sc->aac_regs_resource = bus_alloc_resource(
-			sc->aac_dev, SYS_RES_MEMORY, &sc->aac_regs_rid,
+			sc->aac_regs_rid1, sc->aac_regs_res1);
+		sc->aac_regs_res1 = bus_alloc_resource(
+			sc->aac_dev, SYS_RES_MEMORY, &sc->aac_regs_rid1,
 			0ul, ~0ul, atu_size, RF_ACTIVE);
-		if (sc->aac_regs_resource == NULL) {
-			sc->aac_regs_resource = bus_alloc_resource_any(
+		if (sc->aac_regs_res1 == NULL) {
+			sc->aac_regs_res1 = bus_alloc_resource_any(
 				sc->aac_dev, SYS_RES_MEMORY,
-				&sc->aac_regs_rid, RF_ACTIVE);
-			if (sc->aac_regs_resource == NULL) {
+				&sc->aac_regs_rid1, RF_ACTIVE);
+			if (sc->aac_regs_res1 == NULL) {
 				device_printf(sc->aac_dev,
 				    "couldn't allocate register window\n");
 				return (ENXIO);
 			}
 			sc->flags &= ~AAC_FLAGS_NEW_COMM;
 		}
-		sc->aac_btag = rman_get_bustag(sc->aac_regs_resource);
-		sc->aac_bhandle = rman_get_bushandle(sc->aac_regs_resource);
+		sc->aac_btag1 = rman_get_bustag(sc->aac_regs_res1);
+		sc->aac_bhandle1 = rman_get_bushandle(sc->aac_regs_res1);
+
+		if (sc->aac_hwif == AAC_HWIF_NARK) {
+			sc->aac_regs_res0 = sc->aac_regs_res1;
+			sc->aac_regs_rid0 = sc->aac_regs_rid1;
+			sc->aac_btag0 = sc->aac_btag1;
+			sc->aac_bhandle0 = sc->aac_bhandle1;
+		}
 	}
 
 	/* Read preferred settings */
@@ -1943,10 +1984,10 @@ aac_init(struct aac_softc *sc)
 	 */
 	switch (sc->aac_hwif) {
 	case AAC_HWIF_I960RX:
-		AAC_SETREG4(sc, AAC_RX_ODBR, ~0);
+		AAC_MEM0_SETREG4(sc, AAC_RX_ODBR, ~0);
 		break;
 	case AAC_HWIF_RKT:
-		AAC_SETREG4(sc, AAC_RKT_ODBR, ~0);
+		AAC_MEM0_SETREG4(sc, AAC_RKT_ODBR, ~0);
 		break;
 	default:
 		break;
@@ -2365,7 +2406,7 @@ aac_sa_get_fwstatus(struct aac_softc *sc
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	return(AAC_GETREG4(sc, AAC_SA_FWSTATUS));
+	return(AAC_MEM0_GETREG4(sc, AAC_SA_FWSTATUS));
 }
 
 static int
@@ -2373,7 +2414,7 @@ aac_rx_get_fwstatus(struct aac_softc *sc
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	return(AAC_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ?
+	return(AAC_MEM0_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ?
 	    AAC_RX_OMR0 : AAC_RX_FWSTATUS));
 }
 
@@ -2384,7 +2425,7 @@ aac_fa_get_fwstatus(struct aac_softc *sc
 
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	val = AAC_GETREG4(sc, AAC_FA_FWSTATUS);
+	val = AAC_MEM0_GETREG4(sc, AAC_FA_FWSTATUS);
 	return (val);
 }
 
@@ -2393,7 +2434,7 @@ aac_rkt_get_fwstatus(struct aac_softc *s
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	return(AAC_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ?
+	return(AAC_MEM0_GETREG4(sc, sc->flags & AAC_FLAGS_NEW_COMM ?
 	    AAC_RKT_OMR0 : AAC_RKT_FWSTATUS));
 }
 
@@ -2406,7 +2447,7 @@ aac_sa_qnotify(struct aac_softc *sc, int
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG2(sc, AAC_SA_DOORBELL1_SET, qbit);
+	AAC_MEM0_SETREG2(sc, AAC_SA_DOORBELL1_SET, qbit);
 }
 
 static void
@@ -2414,7 +2455,7 @@ aac_rx_qnotify(struct aac_softc *sc, int
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG4(sc, AAC_RX_IDBR, qbit);
+	AAC_MEM0_SETREG4(sc, AAC_RX_IDBR, qbit);
 }
 
 static void
@@ -2422,7 +2463,7 @@ aac_fa_qnotify(struct aac_softc *sc, int
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG2(sc, AAC_FA_DOORBELL1, qbit);
+	AAC_MEM0_SETREG2(sc, AAC_FA_DOORBELL1, qbit);
 	AAC_FA_HACK(sc);
 }
 
@@ -2431,7 +2472,7 @@ aac_rkt_qnotify(struct aac_softc *sc, in
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG4(sc, AAC_RKT_IDBR, qbit);
+	AAC_MEM0_SETREG4(sc, AAC_RKT_IDBR, qbit);
 }
 
 /*
@@ -2442,7 +2483,7 @@ aac_sa_get_istatus(struct aac_softc *sc)
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	return(AAC_GETREG2(sc, AAC_SA_DOORBELL0));
+	return(AAC_MEM0_GETREG2(sc, AAC_SA_DOORBELL0));
 }
 
 static int
@@ -2450,7 +2491,7 @@ aac_rx_get_istatus(struct aac_softc *sc)
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	return(AAC_GETREG4(sc, AAC_RX_ODBR));
+	return(AAC_MEM0_GETREG4(sc, AAC_RX_ODBR));
 }
 
 static int
@@ -2460,7 +2501,7 @@ aac_fa_get_istatus(struct aac_softc *sc)
 
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	val = AAC_GETREG2(sc, AAC_FA_DOORBELL0);
+	val = AAC_MEM0_GETREG2(sc, AAC_FA_DOORBELL0);
 	return (val);
 }
 
@@ -2469,7 +2510,7 @@ aac_rkt_get_istatus(struct aac_softc *sc
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	return(AAC_GETREG4(sc, AAC_RKT_ODBR));
+	return(AAC_MEM0_GETREG4(sc, AAC_RKT_ODBR));
 }
 
 /*
@@ -2480,7 +2521,7 @@ aac_sa_clear_istatus(struct aac_softc *s
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG2(sc, AAC_SA_DOORBELL0_CLEAR, mask);
+	AAC_MEM0_SETREG2(sc, AAC_SA_DOORBELL0_CLEAR, mask);
 }
 
 static void
@@ -2488,7 +2529,7 @@ aac_rx_clear_istatus(struct aac_softc *s
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG4(sc, AAC_RX_ODBR, mask);
+	AAC_MEM0_SETREG4(sc, AAC_RX_ODBR, mask);
 }
 
 static void
@@ -2496,7 +2537,7 @@ aac_fa_clear_istatus(struct aac_softc *s
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG2(sc, AAC_FA_DOORBELL0_CLEAR, mask);
+	AAC_MEM0_SETREG2(sc, AAC_FA_DOORBELL0_CLEAR, mask);
 	AAC_FA_HACK(sc);
 }
 
@@ -2505,7 +2546,7 @@ aac_rkt_clear_istatus(struct aac_softc *
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG4(sc, AAC_RKT_ODBR, mask);
+	AAC_MEM0_SETREG4(sc, AAC_RKT_ODBR, mask);
 }
 
 /*
@@ -2517,11 +2558,11 @@ aac_sa_set_mailbox(struct aac_softc *sc,
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG4(sc, AAC_SA_MAILBOX, command);
-	AAC_SETREG4(sc, AAC_SA_MAILBOX + 4, arg0);
-	AAC_SETREG4(sc, AAC_SA_MAILBOX + 8, arg1);
-	AAC_SETREG4(sc, AAC_SA_MAILBOX + 12, arg2);
-	AAC_SETREG4(sc, AAC_SA_MAILBOX + 16, arg3);
+	AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX, command);
+	AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX + 4, arg0);
+	AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX + 8, arg1);
+	AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX + 12, arg2);
+	AAC_MEM1_SETREG4(sc, AAC_SA_MAILBOX + 16, arg3);
 }
 
 static void
@@ -2530,11 +2571,11 @@ aac_rx_set_mailbox(struct aac_softc *sc,
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG4(sc, AAC_RX_MAILBOX, command);
-	AAC_SETREG4(sc, AAC_RX_MAILBOX + 4, arg0);
-	AAC_SETREG4(sc, AAC_RX_MAILBOX + 8, arg1);
-	AAC_SETREG4(sc, AAC_RX_MAILBOX + 12, arg2);
-	AAC_SETREG4(sc, AAC_RX_MAILBOX + 16, arg3);
+	AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX, command);
+	AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX + 4, arg0);
+	AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX + 8, arg1);
+	AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX + 12, arg2);
+	AAC_MEM1_SETREG4(sc, AAC_RX_MAILBOX + 16, arg3);
 }
 
 static void
@@ -2543,15 +2584,15 @@ aac_fa_set_mailbox(struct aac_softc *sc,
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG4(sc, AAC_FA_MAILBOX, command);
+	AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX, command);
 	AAC_FA_HACK(sc);
-	AAC_SETREG4(sc, AAC_FA_MAILBOX + 4, arg0);
+	AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX + 4, arg0);
 	AAC_FA_HACK(sc);
-	AAC_SETREG4(sc, AAC_FA_MAILBOX + 8, arg1);
+	AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX + 8, arg1);
 	AAC_FA_HACK(sc);
-	AAC_SETREG4(sc, AAC_FA_MAILBOX + 12, arg2);
+	AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX + 12, arg2);
 	AAC_FA_HACK(sc);
-	AAC_SETREG4(sc, AAC_FA_MAILBOX + 16, arg3);
+	AAC_MEM1_SETREG4(sc, AAC_FA_MAILBOX + 16, arg3);
 	AAC_FA_HACK(sc);
 }
 
@@ -2561,11 +2602,11 @@ aac_rkt_set_mailbox(struct aac_softc *sc
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG4(sc, AAC_RKT_MAILBOX, command);
-	AAC_SETREG4(sc, AAC_RKT_MAILBOX + 4, arg0);
-	AAC_SETREG4(sc, AAC_RKT_MAILBOX + 8, arg1);
-	AAC_SETREG4(sc, AAC_RKT_MAILBOX + 12, arg2);
-	AAC_SETREG4(sc, AAC_RKT_MAILBOX + 16, arg3);
+	AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX, command);
+	AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX + 4, arg0);
+	AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX + 8, arg1);
+	AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX + 12, arg2);
+	AAC_MEM1_SETREG4(sc, AAC_RKT_MAILBOX + 16, arg3);
 }
 
 /*
@@ -2576,7 +2617,7 @@ aac_sa_get_mailbox(struct aac_softc *sc,
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	return(AAC_GETREG4(sc, AAC_SA_MAILBOX + (mb * 4)));
+	return(AAC_MEM1_GETREG4(sc, AAC_SA_MAILBOX + (mb * 4)));
 }
 
 static int
@@ -2584,7 +2625,7 @@ aac_rx_get_mailbox(struct aac_softc *sc,
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	return(AAC_GETREG4(sc, AAC_RX_MAILBOX + (mb * 4)));
+	return(AAC_MEM1_GETREG4(sc, AAC_RX_MAILBOX + (mb * 4)));
 }
 
 static int
@@ -2594,7 +2635,7 @@ aac_fa_get_mailbox(struct aac_softc *sc,
 
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	val = AAC_GETREG4(sc, AAC_FA_MAILBOX + (mb * 4));
+	val = AAC_MEM1_GETREG4(sc, AAC_FA_MAILBOX + (mb * 4));
 	return (val);
 }
 
@@ -2603,7 +2644,7 @@ aac_rkt_get_mailbox(struct aac_softc *sc
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	return(AAC_GETREG4(sc, AAC_RKT_MAILBOX + (mb * 4)));
+	return(AAC_MEM1_GETREG4(sc, AAC_RKT_MAILBOX + (mb * 4)));
 }
 
 /*
@@ -2615,9 +2656,9 @@ aac_sa_set_interrupts(struct aac_softc *
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "%sable interrupts", enable ? "en" : "dis");
 
 	if (enable) {
-		AAC_SETREG2((sc), AAC_SA_MASK0_CLEAR, AAC_DB_INTERRUPTS);
+		AAC_MEM0_SETREG2((sc), AAC_SA_MASK0_CLEAR, AAC_DB_INTERRUPTS);
 	} else {
-		AAC_SETREG2((sc), AAC_SA_MASK0_SET, ~0);
+		AAC_MEM0_SETREG2((sc), AAC_SA_MASK0_SET, ~0);
 	}
 }
 
@@ -2628,11 +2669,11 @@ aac_rx_set_interrupts(struct aac_softc *
 
 	if (enable) {
 		if (sc->flags & AAC_FLAGS_NEW_COMM)
-			AAC_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INT_NEW_COMM);
+			AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INT_NEW_COMM);
 		else
-			AAC_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INTERRUPTS);
+			AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INTERRUPTS);
 	} else {
-		AAC_SETREG4(sc, AAC_RX_OIMR, ~0);
+		AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, ~0);
 	}
 }
 
@@ -2642,10 +2683,10 @@ aac_fa_set_interrupts(struct aac_softc *
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "%sable interrupts", enable ? "en" : "dis");
 
 	if (enable) {
-		AAC_SETREG2((sc), AAC_FA_MASK0_CLEAR, AAC_DB_INTERRUPTS);
+		AAC_MEM0_SETREG2((sc), AAC_FA_MASK0_CLEAR, AAC_DB_INTERRUPTS);
 		AAC_FA_HACK(sc);
 	} else {
-		AAC_SETREG2((sc), AAC_FA_MASK0, ~0);
+		AAC_MEM0_SETREG2((sc), AAC_FA_MASK0, ~0);
 		AAC_FA_HACK(sc);
 	}
 }
@@ -2657,11 +2698,11 @@ aac_rkt_set_interrupts(struct aac_softc 
 
 	if (enable) {
 		if (sc->flags & AAC_FLAGS_NEW_COMM)
-			AAC_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INT_NEW_COMM);
+			AAC_MEM0_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INT_NEW_COMM);
 		else
-			AAC_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INTERRUPTS);
+			AAC_MEM0_SETREG4(sc, AAC_RKT_OIMR, ~AAC_DB_INTERRUPTS);
 	} else {
-		AAC_SETREG4(sc, AAC_RKT_OIMR, ~0);
+		AAC_MEM0_SETREG4(sc, AAC_RKT_OIMR, ~0);
 	}
 }
 
@@ -2675,19 +2716,19 @@ aac_rx_send_command(struct aac_softc *sc
 
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "send command (new comm.)");
 
-	index = AAC_GETREG4(sc, AAC_RX_IQUE);
+	index = AAC_MEM0_GETREG4(sc, AAC_RX_IQUE);
 	if (index == 0xffffffffL)
-		index = AAC_GETREG4(sc, AAC_RX_IQUE);
+		index = AAC_MEM0_GETREG4(sc, AAC_RX_IQUE);
 	if (index == 0xffffffffL)
 		return index;
 	aac_enqueue_busy(cm);
 	device = index;
-	AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL));
+	AAC_MEM1_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL));
 	device += 4;
-	AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32));
+	AAC_MEM1_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32));
 	device += 4;
-	AAC_SETREG4(sc, device, cm->cm_fib->Header.Size);
-	AAC_SETREG4(sc, AAC_RX_IQUE, index);
+	AAC_MEM1_SETREG4(sc, device, cm->cm_fib->Header.Size);
+	AAC_MEM0_SETREG4(sc, AAC_RX_IQUE, index);
 	return 0;
 }
 
@@ -2698,19 +2739,19 @@ aac_rkt_send_command(struct aac_softc *s
 
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "send command (new comm.)");
 
-	index = AAC_GETREG4(sc, AAC_RKT_IQUE);
+	index = AAC_MEM0_GETREG4(sc, AAC_RKT_IQUE);
 	if (index == 0xffffffffL)
-		index = AAC_GETREG4(sc, AAC_RKT_IQUE);
+		index = AAC_MEM0_GETREG4(sc, AAC_RKT_IQUE);
 	if (index == 0xffffffffL)
 		return index;
 	aac_enqueue_busy(cm);
 	device = index;
-	AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL));
+	AAC_MEM1_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys & 0xffffffffUL));
 	device += 4;
-	AAC_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32));
+	AAC_MEM1_SETREG4(sc, device, (u_int32_t)(cm->cm_fibphys >> 32));
 	device += 4;
-	AAC_SETREG4(sc, device, cm->cm_fib->Header.Size);
-	AAC_SETREG4(sc, AAC_RKT_IQUE, index);
+	AAC_MEM1_SETREG4(sc, device, cm->cm_fib->Header.Size);
+	AAC_MEM0_SETREG4(sc, AAC_RKT_IQUE, index);
 	return 0;
 }
 
@@ -2722,7 +2763,7 @@ aac_rx_get_outb_queue(struct aac_softc *
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	return(AAC_GETREG4(sc, AAC_RX_OQUE));
+	return(AAC_MEM0_GETREG4(sc, AAC_RX_OQUE));
 }
 
 static int
@@ -2730,7 +2771,7 @@ aac_rkt_get_outb_queue(struct aac_softc 
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	return(AAC_GETREG4(sc, AAC_RKT_OQUE));
+	return(AAC_MEM0_GETREG4(sc, AAC_RKT_OQUE));
 }
 
 static void
@@ -2738,7 +2779,7 @@ aac_rx_set_outb_queue(struct aac_softc *
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG4(sc, AAC_RX_OQUE, index);
+	AAC_MEM0_SETREG4(sc, AAC_RX_OQUE, index);
 }
 
 static void
@@ -2746,7 +2787,7 @@ aac_rkt_set_outb_queue(struct aac_softc 
 {
 	fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-	AAC_SETREG4(sc, AAC_RKT_OQUE, index);
+	AAC_MEM0_SETREG4(sc, AAC_RKT_OQUE, index);
 }
 
 /*

Modified: stable/6/sys/dev/aac/aac_debug.c
==============================================================================
--- stable/6/sys/dev/aac/aac_debug.c	Wed Oct 28 12:10:29 2009	(r198539)
+++ stable/6/sys/dev/aac/aac_debug.c	Wed Oct 28 13:38:07 2009	(r198540)
@@ -134,17 +134,18 @@ aac_printstate0(void)
 	aac_print_queues(sc);
 	switch (sc->aac_hwif) {
 	case AAC_HWIF_I960RX:
+	case AAC_HWIF_NARK:
 		device_printf(sc->aac_dev, "IDBR 0x%08x  IIMR 0x%08x  "
-		    "IISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_IDBR),
-		    AAC_GETREG4(sc, AAC_RX_IIMR), AAC_GETREG4(sc, AAC_RX_IISR));
+		    "IISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_IDBR),
+		    AAC_MEM0_GETREG4(sc, AAC_RX_IIMR), AAC_MEM0_GETREG4(sc, AAC_RX_IISR));
 		device_printf(sc->aac_dev, "ODBR 0x%08x  OIMR 0x%08x  "
-		    "OISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_ODBR),
-		    AAC_GETREG4(sc, AAC_RX_OIMR), AAC_GETREG4(sc, AAC_RX_OISR));
-		AAC_SETREG4(sc, AAC_RX_OIMR, 0/*~(AAC_DB_COMMAND_READY |
+		    "OISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_ODBR),
+		    AAC_MEM0_GETREG4(sc, AAC_RX_OIMR), AAC_MEM0_GETREG4(sc, AAC_RX_OISR));
+		AAC_MEM0_SETREG4(sc, AAC_RX_OIMR, 0/*~(AAC_DB_COMMAND_READY |
 			    AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)*/);
 		device_printf(sc->aac_dev, "ODBR 0x%08x  OIMR 0x%08x  "
-		    "OISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_ODBR),
-		    AAC_GETREG4(sc, AAC_RX_OIMR), AAC_GETREG4(sc, AAC_RX_OISR));
+		    "OISR 0x%08x\n", AAC_MEM0_GETREG4(sc, AAC_RX_ODBR),
+		    AAC_MEM0_GETREG4(sc, AAC_RX_OIMR), AAC_MEM0_GETREG4(sc, AAC_RX_OISR));
 		break;
 	case AAC_HWIF_STRONGARM:
 		/* XXX implement */

Modified: stable/6/sys/dev/aac/aac_pci.c
==============================================================================
--- stable/6/sys/dev/aac/aac_pci.c	Wed Oct 28 12:10:29 2009	(r198539)
+++ stable/6/sys/dev/aac/aac_pci.c	Wed Oct 28 13:38:07 2009	(r198540)
@@ -374,21 +374,32 @@ aac_pci_attach(device_t dev)
 	/*
 	 * Allocate the PCI register window.
 	 */
-	sc->aac_regs_rid = PCIR_BAR(0);
-	if ((sc->aac_regs_resource = bus_alloc_resource_any(sc->aac_dev,
-							    SYS_RES_MEMORY,
-							    &sc->aac_regs_rid,
-							    RF_ACTIVE)) ==
-							    NULL) {
+	sc->aac_regs_rid0 = PCIR_BAR(0);
+	if ((sc->aac_regs_res0 = bus_alloc_resource_any(sc->aac_dev,
+	    SYS_RES_MEMORY, &sc->aac_regs_rid0, RF_ACTIVE)) == NULL) {
 		device_printf(sc->aac_dev,
-			      "couldn't allocate register window\n");
+		    "couldn't allocate register window 0\n");
 		goto out;
 	}
-	sc->aac_btag = rman_get_bustag(sc->aac_regs_resource);
-	sc->aac_bhandle = rman_get_bushandle(sc->aac_regs_resource);
+	sc->aac_btag0 = rman_get_bustag(sc->aac_regs_res0);
+	sc->aac_bhandle0 = rman_get_bushandle(sc->aac_regs_res0);
 
-	/* assume failure is 'out of memory' */
-	error = ENOMEM;
+	if (sc->aac_hwif == AAC_HWIF_NARK) {
+		sc->aac_regs_rid1 = PCIR_BAR(1);
+		if ((sc->aac_regs_res1 = bus_alloc_resource_any(sc->aac_dev,
+		    SYS_RES_MEMORY, &sc->aac_regs_rid1, RF_ACTIVE)) == NULL) {
+			device_printf(sc->aac_dev,
+			    "couldn't allocate register window 1\n");
+			goto out;
+		}
+		sc->aac_btag1 = rman_get_bustag(sc->aac_regs_res1);
+		sc->aac_bhandle1 = rman_get_bushandle(sc->aac_regs_res1);
+	} else {
+		sc->aac_regs_res1 = sc->aac_regs_res0;
+		sc->aac_regs_rid1 = sc->aac_regs_rid0;
+		sc->aac_btag1 = sc->aac_btag0;
+		sc->aac_bhandle1 = sc->aac_bhandle0;
+	}
 
 	/*
 	 * Allocate the parent bus DMA tag appropriate for our PCI interface.
@@ -418,7 +429,8 @@ aac_pci_attach(device_t dev)
 	sc->aac_hwif = id->hwif;
 	switch(sc->aac_hwif) {
 	case AAC_HWIF_I960RX:
-		fwprintf(sc, HBA_FLAGS_DBG_INIT_B, "set hardware up for i960Rx");
+	case AAC_HWIF_NARK:
+		fwprintf(sc, HBA_FLAGS_DBG_INIT_B, "set hardware up for i960Rx/NARK");
 		sc->aac_if = aac_rx_interface;
 		break;
 	case AAC_HWIF_STRONGARM:

Modified: stable/6/sys/dev/aac/aacreg.h
==============================================================================
--- stable/6/sys/dev/aac/aacreg.h	Wed Oct 28 12:10:29 2009	(r198539)
+++ stable/6/sys/dev/aac/aacreg.h	Wed Oct 28 13:38:07 2009	(r198540)
@@ -1468,7 +1468,7 @@ enum {
 #define	AAC_FA_FWSTATUS			0x2c	/* Mailbox 7 */
 #define	AAC_FA_INTSRC			0x900
 
-#define AAC_FA_HACK(sc)	(void)AAC_GETREG4(sc, AAC_FA_INTSRC)
+#define AAC_FA_HACK(sc)	(void)AAC_MEM0_GETREG4(sc, AAC_FA_INTSRC)
 
 /*
  * Register definitions for the Adaptec AAC-364 'Jalapeno I/II' adapters, based

Modified: stable/6/sys/dev/aac/aacvar.h
==============================================================================
--- stable/6/sys/dev/aac/aacvar.h	Wed Oct 28 12:10:29 2009	(r198539)
+++ stable/6/sys/dev/aac/aacvar.h	Wed Oct 28 13:38:07 2009	(r198540)
@@ -30,6 +30,7 @@
  */
 
 #include <sys/bio.h>
+#include <sys/callout.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/taskqueue.h>
@@ -259,18 +260,31 @@ extern struct aac_interface	aac_rkt_inte
 #define AAC_GET_OUTB_QUEUE(sc)		((sc)->aac_if.aif_get_outb_queue((sc)))
 #define AAC_SET_OUTB_QUEUE(sc, idx)	((sc)->aac_if.aif_set_outb_queue((sc), (idx)))
 
-#define AAC_SETREG4(sc, reg, val)	bus_space_write_4(sc->aac_btag, \
-					sc->aac_bhandle, reg, val)
-#define AAC_GETREG4(sc, reg)		bus_space_read_4 (sc->aac_btag, \
-					sc->aac_bhandle, reg)
-#define AAC_SETREG2(sc, reg, val)	bus_space_write_2(sc->aac_btag, \
-					sc->aac_bhandle, reg, val)
-#define AAC_GETREG2(sc, reg)		bus_space_read_2 (sc->aac_btag, \
-					sc->aac_bhandle, reg)
-#define AAC_SETREG1(sc, reg, val)	bus_space_write_1(sc->aac_btag, \
-					sc->aac_bhandle, reg, val)
-#define AAC_GETREG1(sc, reg)		bus_space_read_1 (sc->aac_btag, \
-					sc->aac_bhandle, reg)
+#define AAC_MEM0_SETREG4(sc, reg, val)	bus_space_write_4(sc->aac_btag0, \
+					sc->aac_bhandle0, reg, val)
+#define AAC_MEM0_GETREG4(sc, reg)	bus_space_read_4(sc->aac_btag0, \
+					sc->aac_bhandle0, reg)
+#define AAC_MEM0_SETREG2(sc, reg, val)	bus_space_write_2(sc->aac_btag0, \
+					sc->aac_bhandle0, reg, val)
+#define AAC_MEM0_GETREG2(sc, reg)	bus_space_read_2(sc->aac_btag0, \
+					sc->aac_bhandle0, reg)
+#define AAC_MEM0_SETREG1(sc, reg, val)	bus_space_write_1(sc->aac_btag0, \
+					sc->aac_bhandle0, reg, val)
+#define AAC_MEM0_GETREG1(sc, reg)	bus_space_read_1(sc->aac_btag0, \
+					sc->aac_bhandle0, reg)
+
+#define AAC_MEM1_SETREG4(sc, reg, val)	bus_space_write_4(sc->aac_btag1, \
+					sc->aac_bhandle1, reg, val)
+#define AAC_MEM1_GETREG4(sc, reg)	bus_space_read_4(sc->aac_btag1, \
+					sc->aac_bhandle1, reg)
+#define AAC_MEM1_SETREG2(sc, reg, val)	bus_space_write_2(sc->aac_btag1, \
+					sc->aac_bhandle1, reg, val)
+#define AAC_MEM1_GETREG2(sc, reg)	bus_space_read_2(sc->aac_btag1, \
+					sc->aac_bhandle1, reg)
+#define AAC_MEM1_SETREG1(sc, reg, val)	bus_space_write_1(sc->aac_btag1, \
+					sc->aac_bhandle1, reg, val)
+#define AAC_MEM1_GETREG1(sc, reg)	bus_space_read_1(sc->aac_btag1, \
+					sc->aac_bhandle1, reg)
 
 /* fib context (IOCTL) */
 struct aac_fib_context {
@@ -287,11 +301,10 @@ struct aac_softc 
 {
 	/* bus connections */
 	device_t		aac_dev;
-	struct resource		*aac_regs_resource;	/* register interface
-							 * window */
-	int			aac_regs_rid;		/* resource ID */
-	bus_space_handle_t	aac_bhandle;		/* bus space handle */
-	bus_space_tag_t		aac_btag;		/* bus space tag */
+	struct resource		*aac_regs_res0, *aac_regs_res1; /* reg. if. window */
+	int			aac_regs_rid0, aac_regs_rid1;		/* resource ID */
+	bus_space_handle_t	aac_bhandle0, aac_bhandle1;		/* bus space handle */
+	bus_space_tag_t		aac_btag0, aac_btag1;		/* bus space tag */
 	bus_dma_tag_t		aac_parent_dmat;	/* parent DMA tag */
 	bus_dma_tag_t		aac_buffer_dmat;	/* data buffer/command
 							 * DMA tag */
@@ -315,6 +328,7 @@ struct aac_softc 
 #define AAC_HWIF_STRONGARM	1
 #define AAC_HWIF_FALCON		2
 #define AAC_HWIF_RKT		3
+#define	AAC_HWIF_NARK		4
 #define AAC_HWIF_UNKNOWN	-1
 	bus_dma_tag_t		aac_common_dmat;	/* common structure
 							 * DMA tag */
@@ -398,6 +412,8 @@ struct aac_softc 
 	u_int32_t		scsi_method_id;
 	TAILQ_HEAD(,aac_sim)	aac_sim_tqh;
 
+	struct callout	aac_daemontime;		/* clock daemon callout */
+
 	u_int32_t	aac_max_fibs;           /* max. FIB count */
 	u_int32_t	aac_max_fibs_alloc;		/* max. alloc. per alloc_commands() */
 	u_int32_t	aac_max_fib_size;		/* max. FIB size */


More information about the svn-src-stable-6 mailing list