Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Feb 2008 02:01:53 GMT
From:      Kip Macy <kmacy@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 134948 for review
Message-ID:  <200802070201.m1721rpP068332@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=134948

Change 134948 by kmacy@kmacy:entropy:iwarp on 2008/02/07 02:01:40

	- start link at attach time - remove all other instances of callout_reset
	- fix unload for case where interface is never brought up so offload is uninitialized

Affected files ...

.. //depot/projects/iwarp/sys/dev/cxgb/cxgb_adapter.h#11 edit
.. //depot/projects/iwarp/sys/dev/cxgb/cxgb_main.c#13 edit
.. //depot/projects/iwarp/sys/dev/cxgb/cxgb_offload.c#15 edit

Differences ...

==== //depot/projects/iwarp/sys/dev/cxgb/cxgb_adapter.h#11 (text+ko) ====

@@ -144,6 +144,8 @@
 	QUEUES_BOUND	= (1 << 3),
 	FW_UPTODATE     = (1 << 4),
 	TPS_UPTODATE    = (1 << 5),
+	CXGB_SHUTDOWN	= (1 << 6),
+	CXGB_OFLD_INIT	= (1 << 7),
 };
 
 #define FL_Q_SIZE	4096

==== //depot/projects/iwarp/sys/dev/cxgb/cxgb_main.c#13 (text+ko) ====

@@ -119,6 +119,7 @@
 static int offload_open(struct port_info *pi);
 static void touch_bars(device_t dev);
 static int offload_close(struct t3cdev *tdev);
+static void cxgb_link_start(struct port_info *p);
 
 static device_method_t cxgb_controller_methods[] = {
 	DEVMETHOD(device_probe,		cxgb_controller_probe),
@@ -617,7 +618,7 @@
 	    G_FW_VERSION_MICRO(vers));
 
 	device_printf(sc->dev, "Firmware Version %s\n", &sc->fw_version[0]);
-
+	callout_reset(&sc->cxgb_tick_ch, hz, cxgb_tick, sc);
 	t3_add_attach_sysctls(sc);
 out:
 	if (error)
@@ -643,9 +644,9 @@
 {
 	int i;
 
-	
 	cxgb_pcpu_shutdown_threads(sc);
 	ADAPTER_LOCK(sc);
+	sc->flags |= CXGB_SHUTDOWN;
 /*
  * drops the lock
  */
@@ -691,7 +692,8 @@
 	} else
 		printf("not offloading set\n");	
 
-	cxgb_offload_deactivate(sc);
+	if (sc->flags & CXGB_OFLD_INIT)
+		cxgb_offload_deactivate(sc);
 	free(sc->filters, M_DEVBUF);
 	t3_sge_free(sc);
 	
@@ -887,9 +889,11 @@
 	struct port_info *p;
 	struct ifnet *ifp;
 	int err, media_flags;
+	struct adapter *sc;
+	
 	
 	p = device_get_softc(dev);
-
+	sc = p->adapter;
 	snprintf(p->lockbuf, PORT_NAME_LEN, "cxgb port lock %d:%d",
 	    device_get_unit(device_get_parent(dev)), p->port_id);
 	PORT_LOCK_INIT(p, p->lockbuf);
@@ -991,7 +995,8 @@
 	    taskqueue_thread_enqueue, &p->tq);
 #endif	
 	t3_sge_init_port(p);
-
+	cxgb_link_start(p);
+	t3_link_changed(sc, p->port_id);
 	return (0);
 }
 
@@ -1635,11 +1640,8 @@
 {
 	struct adapter *adapter = tdev2adap(tdev);
 
-	if (!isset(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT)) {
-		printf("offload_close: DEVMAP_BIT not set\n");
-	
+	if (!isset(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT))
 		return (0);
-	}
 	
 	/* Call back all registered clients */
 	cxgb_remove_clients(tdev);
@@ -1697,14 +1699,11 @@
 		else
 			printf("offload opened\n");
 	}
-	cxgb_link_start(p);
-	t3_link_changed(sc, p->port_id);
 	ifp->if_baudrate = p->link_config.speed * 1000000;
 
 	device_printf(sc->dev, "enabling interrupts on port=%d\n", p->port_id);
 	t3_port_intr_enable(sc, p->port_id);
 
-	callout_reset(&sc->cxgb_tick_ch, hz, cxgb_tick, sc);
 	t3_sge_reset_adapter(sc);
 
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
@@ -1759,7 +1758,6 @@
 		PORT_LOCK(p);
 		ifp->if_mtu = mtu;
 		if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
-			callout_stop(&p->adapter->cxgb_tick_ch);
 			cxgb_stop_locked(p);
 			cxgb_init_locked(p);
 		}
@@ -1797,7 +1795,6 @@
 			error = ether_ioctl(ifp, command, data);
 		break;
 	case SIOCSIFFLAGS:
-		callout_drain(&p->adapter->cxgb_tick_ch);
 		PORT_LOCK(p);
 		if (ifp->if_flags & IFF_UP) {
 			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
@@ -1811,21 +1808,10 @@
 		} else if (ifp->if_drv_flags & IFF_DRV_RUNNING)
 			cxgb_stop_locked(p);
 				
-		if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
-			adapter_t *sc = p->adapter;
-			callout_reset(&sc->cxgb_tick_ch, hz,
-			    cxgb_tick, sc);
-		}
 		PORT_UNLOCK(p);
 		break;
 	case SIOCSIFMEDIA:
 	case SIOCGIFMEDIA:
-		/*
-		 * This is a convenient place to check the link status when
-		 * no interfaces are up and thus the callout is not running
-		 */
-		if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
-			cxgb_tick_handler(p->adapter, 0);
 		error = ifmedia_ioctl(ifp, ifr, &p->media, command);
 		break;
 	case SIOCSIFCAP:
@@ -1994,27 +1980,12 @@
 cxgb_tick(void *arg)
 {
 	adapter_t *sc = (adapter_t *)arg;
-	int i, running = 0;
-	
-	for_each_port(sc, i) {
-		
-		struct port_info *p = &sc->port[i];
-		struct ifnet *ifp = p->ifp;
 
-		if ((ifp->if_drv_flags & IFF_DRV_RUNNING) &&
-		    (ifp->if_flags & IFF_UP))
-			running = 1;
-	}	
-
-	if (running == 0)
+	if(sc->flags & CXGB_SHUTDOWN);
 		return;
-		
 
-	
-	if (sc->open_device_map != 0) {
-		taskqueue_enqueue(sc->tq, &sc->tick_task);
-		callout_reset(&sc->cxgb_tick_ch, hz, cxgb_tick, sc);
-	}
+	taskqueue_enqueue(sc->tq, &sc->tick_task);
+	callout_reset(&sc->cxgb_tick_ch, hz, cxgb_tick, sc);
 }
 
 static void
@@ -2028,12 +1999,12 @@
 		check_link_status(sc);
 
 	/*
-	 * adapter lock can currently only be acquire after the
+	 * adapter lock can currently only be acquired after the
 	 * port lock
 	 */
 	ADAPTER_UNLOCK(sc);
 
-	if (p->rev == T3_REV_B2 && p->nports < 4) 
+	if (p->rev == T3_REV_B2 && p->nports < 4 && sc->open_device_map) 
 		check_t3b2_mac(sc);
 }
 

==== //depot/projects/iwarp/sys/dev/cxgb/cxgb_offload.c#15 (text+ko) ====

@@ -1305,6 +1305,7 @@
 	printf("adding adapter %p\n", adapter); 
 	add_adapter(adapter);
 	device_printf(adapter->dev, "offload started\n");
+	adapter->flags |= CXGB_OFLD_INIT;
 #if 0
 	printf("failing as test\n");
 	return (ENOMEM);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802070201.m1721rpP068332>