Date: Sun, 28 Oct 2007 03:33:34 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 128225 for review Message-ID: <200710280333.l9S3XYY6005485@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=128225 Change 128225 by kmacy@kmacy:storage:toestack on 2007/10/28 03:32:55 fix offload path so that offload can actually be enabled disable offload by default until an outstanding bug with t3_offload_tx is fixed Affected files ... .. //depot/projects/toestack/sys/dev/cxgb/cxgb_l2t.h#5 edit .. //depot/projects/toestack/sys/dev/cxgb/cxgb_main.c#11 edit .. //depot/projects/toestack/sys/dev/cxgb/cxgb_multiq.c#7 edit .. //depot/projects/toestack/sys/dev/cxgb/cxgb_offload.c#8 edit .. //depot/projects/toestack/sys/dev/cxgb/t3cdev.h#3 edit .. //depot/projects/toestack/sys/dev/cxgb/ulp/toecore/toedev.h#6 edit .. //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#2 edit .. //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_tom.c#2 edit Differences ... ==== //depot/projects/toestack/sys/dev/cxgb/cxgb_l2t.h#5 (text+ko) ==== @@ -95,6 +95,9 @@ typedef void (*arp_failure_handler_func)(struct t3cdev *dev, struct mbuf *m); +typedef void (*opaque_arp_failure_handler_func)(void *dev, + struct mbuf *m); + /* * Callback stored in an skb to handle address resolution failure. */ @@ -108,11 +111,13 @@ #define L2T_MBUF_CB(skb) ((struct l2t_mbuf_cb *)(skb)->cb) -static __inline void set_arp_failure_handler(struct toe_mbuf *m, +static __inline void set_arp_failure_handler(struct mbuf *m, arp_failure_handler_func hnd) { - m->m_toe.mt_arp_fail = hnd; - panic("implement me"); + struct toe_mbuf *tm = (struct toe_mbuf *)m; + + tm->m_toe.mt_arp_fail = (opaque_arp_failure_handler_func)hnd; + } /* ==== //depot/projects/toestack/sys/dev/cxgb/cxgb_main.c#11 (text+ko) ==== @@ -120,10 +120,7 @@ static int cxgb_get_regs_len(void); static int offload_open(struct port_info *pi); static void touch_bars(device_t dev); - -#ifdef notyet static int offload_close(struct t3cdev *tdev); -#endif static device_method_t cxgb_controller_methods[] = { DEVMETHOD(device_probe, cxgb_controller_probe), @@ -206,7 +203,7 @@ * The driver enables offload as a default. * To disable it, use ofld_disable = 1. */ -static int ofld_disable = 0; +static int ofld_disable = 1; TUNABLE_INT("hw.cxgb.ofld_disable", &ofld_disable); SYSCTL_UINT(_hw_cxgb, OID_AUTO, ofld_disable, CTLFLAG_RDTUN, &ofld_disable, 0, "disable ULP offload"); @@ -694,14 +691,14 @@ bus_generic_detach(sc->dev); if (sc->tq != NULL) taskqueue_free(sc->tq); -#ifdef notyet if (is_offload(sc)) { cxgb_adapter_unofld(sc); if (isset(&sc->open_device_map, OFFLOAD_DEVMAP_BIT)) offload_close(&sc->tdev); - } -#endif - + else + printf("cxgb_free: DEVMAP_BIT not set\n"); + } else + printf("not offloading set\n"); #ifndef IFNET_MULTIQUEUE t3_free_sge_resources(sc); #endif @@ -1039,7 +1036,7 @@ ether_ifdetach(p->ifp); printf("waiting for callout to stop ..."); - DELAY(100000); + DELAY(1000000); printf("done\n"); /* * the lock may be acquired in ifdetach @@ -1289,9 +1286,7 @@ { int ret; - critical_enter(); ret = t3_offload_tx(tdev, m); - critical_exit(); return (ret); } @@ -1606,15 +1601,22 @@ offload_open(struct port_info *pi) { struct adapter *adapter = pi->adapter; - struct t3cdev *tdev = T3CDEV(pi->ifp); + struct t3cdev *tdev = &adapter->tdev; +#ifdef notyet + T3CDEV(pi->ifp); +#endif int adap_up = adapter->open_device_map & PORT_MASK; int err = 0; + printf("device_map=0x%x\n", adapter->open_device_map); if (atomic_cmpset_int(&adapter->open_device_map, - (adapter->open_device_map & ~OFFLOAD_DEVMAP_BIT), - (adapter->open_device_map | OFFLOAD_DEVMAP_BIT)) == 0) + (adapter->open_device_map & ~(1<<OFFLOAD_DEVMAP_BIT)), + (adapter->open_device_map | (1<<OFFLOAD_DEVMAP_BIT))) == 0) return (0); + + if (!isset(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT)) + printf("offload_open: DEVMAP_BIT did not get set 0x%x\n", adapter->open_device_map); ADAPTER_LOCK(pi->adapter); if (!adap_up) err = cxgb_up(adapter); @@ -1623,7 +1625,7 @@ return (err); t3_tp_set_offload_mode(adapter, 1); - tdev->lldev = adapter->port[0].ifp; + tdev->lldev = pi->ifp; err = cxgb_offload_activate(adapter); if (err) goto out; @@ -1647,15 +1649,18 @@ } return (err); } -#ifdef notyet + static int offload_close(struct t3cdev *tdev) { struct adapter *adapter = tdev2adap(tdev); - if (!isset(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT)) + if (!isset(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT)) { + printf("offload_close: DEVMAP_BIT not set\n"); + return (0); - + } + /* Call back all registered clients */ cxgb_remove_clients(tdev); tdev->lldev = NULL; @@ -1663,13 +1668,15 @@ t3_tp_set_offload_mode(adapter, 0); clrbit(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT); + ADAPTER_LOCK(adapter); if (!adapter->open_device_map) - cxgb_down(adapter); - + cxgb_down_locked(adapter); + else + ADAPTER_UNLOCK(adapter); cxgb_offload_deactivate(adapter); return (0); } -#endif + static void cxgb_init(void *arg) ==== //depot/projects/toestack/sys/dev/cxgb/cxgb_multiq.c#7 (text+ko) ==== @@ -629,7 +629,7 @@ t3_free_qset(qs->port->adapter, qs); qs->qs_flags &= ~QS_RUNNING; - kthread_exit(0); + kproc_exit(0); } static int @@ -663,7 +663,7 @@ qs->qs_cpuid = ((pi->first_qset + j) % mp_ncpus); device_printf(sc->dev, "starting thread for %d\n", qs->qs_cpuid); - kthread_create(cxgb_pcpu_start_proc, qs, &p, + kproc_create(cxgb_pcpu_start_proc, qs, &p, RFNOWAIT, 0, "cxgbsp"); DELAY(200); } ==== //depot/projects/toestack/sys/dev/cxgb/cxgb_offload.c#8 (text+ko) ==== @@ -1281,7 +1281,7 @@ cxgb_alloc_mem(unsigned long size) { - return malloc(size, M_DEVBUF, M_ZERO); + return malloc(size, M_DEVBUF, M_ZERO|M_NOWAIT); } /* @@ -1320,8 +1320,8 @@ t->afree = NULL; t->stids_in_use = t->atids_in_use = 0; atomic_set_int(&t->tids_in_use, 0); - mtx_init(&t->stid_lock, "stid", NULL, MTX_DEF); - mtx_init(&t->atid_lock, "atid", NULL, MTX_DEF); + mtx_init(&t->stid_lock, "stid", NULL, MTX_DUPOK|MTX_DEF); + mtx_init(&t->atid_lock, "atid", NULL, MTX_DUPOK|MTX_DEF); /* * Setup the free lists for stid_tab and atid_tab. @@ -1376,7 +1376,7 @@ struct mtutab mtutab; unsigned int l2t_capacity; - t = malloc(sizeof(*t), M_DEVBUF, M_WAITOK); + t = malloc(sizeof(*t), M_DEVBUF, M_WAITOK|M_ZERO); if (!t) return (ENOMEM); @@ -1386,25 +1386,32 @@ dev->ctl(dev, GET_L2T_CAPACITY, &l2t_capacity) < 0 || dev->ctl(dev, GET_MTUS, &mtutab) < 0 || dev->ctl(dev, GET_TID_RANGE, &tid_range) < 0 || - dev->ctl(dev, GET_STID_RANGE, &stid_range) < 0) + dev->ctl(dev, GET_STID_RANGE, &stid_range) < 0) { + device_printf(adapter->dev, "%s: dev->ctl check failed\n", __FUNCTION__); goto out_free; - + } + err = (ENOMEM); L2DATA(dev) = t3_init_l2t(l2t_capacity); - if (!L2DATA(dev)) + if (!L2DATA(dev)) { + device_printf(adapter->dev, "%s: t3_init_l2t failed\n", __FUNCTION__); goto out_free; + } + natids = min(tid_range.num / 2, MAX_ATIDS); err = init_tid_tabs(&t->tid_maps, tid_range.num, natids, stid_range.num, ATID_BASE, stid_range.base); - if (err) + if (err) { + device_printf(adapter->dev, "%s: init_tid_tabs failed\n", __FUNCTION__); goto out_free_l2t; - + } + t->mtus = mtutab.mtus; t->nmtus = mtutab.size; TASK_INIT(&t->tid_release_task, 0 /* XXX? */, t3_process_tid_release_list, dev); - mtx_init(&t->tid_release_lock, "tid release", NULL, MTX_DEF); + mtx_init(&t->tid_release_lock, "tid release", NULL, MTX_DUPOK|MTX_DEF); t->dev = dev; T3C_DATA (dev) = t; @@ -1420,15 +1427,21 @@ log(LOG_ERR, "Unable to set offload capabilities\n"); #endif } + printf("adding adapter %p\n", adapter); add_adapter(adapter); - return 0; + device_printf(adapter->dev, "offload started\n"); +#if 0 + printf("failing as test\n"); + return (ENOMEM); +#endif + return (0); out_free_l2t: t3_free_l2t(L2DATA(dev)); L2DATA(dev) = NULL; out_free: free(t, M_DEVBUF); - return err; + return (err); } @@ -1438,6 +1451,7 @@ struct t3cdev *tdev = &adapter->tdev; struct t3c_data *t = T3C_DATA(tdev); + printf("removing adapter %p\n", adapter); remove_adapter(adapter); if (TAILQ_EMPTY(&adapter_list)) { #if defined(CONFIG_CHELSIO_T3_MODULE) @@ -1507,10 +1521,8 @@ { int i; - if (inited) + if (inited++) return; - else - inited = 1; mtx_init(&cxgb_db_lock, "ofld db", NULL, MTX_DEF); rw_init(&adapter_list_lock, "ofld adap list"); @@ -1554,12 +1566,10 @@ void cxgb_offload_exit(void) { - static int deinited = 0; - if (deinited) + if (--inited) return; - deinited = 1; mtx_destroy(&cxgb_db_lock); rw_destroy(&adapter_list_lock); #if 0 ==== //depot/projects/toestack/sys/dev/cxgb/t3cdev.h#3 (text+ko) ==== @@ -4,7 +4,7 @@ #define T3CNAMSIZ 16 /* Get the t3cdev associated with an ifnet */ -#define T3CDEV(ifp) (struct t3cdev *)((ifp)->if_spare2) +#define T3CDEV(ifp) (&(((struct port_info *)(ifp)->if_softc))->adapter->tdev) struct cxgb3_client; ==== //depot/projects/toestack/sys/dev/cxgb/ulp/toecore/toedev.h#6 (text+ko) ==== @@ -166,7 +166,7 @@ struct toepcb; struct m_toe_ { - void (*mt_arp_fail)(struct t3cdev *, struct mbuf *); + void (*mt_arp_fail)(void *, struct mbuf *); void (*mt_backlog_rcv)(struct toepcb *, struct mbuf *); int priority; struct toepcb *mt_toepcb; ==== //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#2 (text+ko) ==== @@ -406,7 +406,7 @@ m = (struct toe_mbuf *)m_gethdr(MT_DATA, M_WAITOK); m->m_toe.mt_toepcb = tp->t_toe; - set_arp_failure_handler(m, act_open_req_arp_failure); + set_arp_failure_handler((struct mbuf *)m, act_open_req_arp_failure); if ((err = init_offload_socket(so, tdev, atid, e, dst))) return (err); ==== //depot/projects/toestack/sys/dev/cxgb/ulp/tom/cxgb_tom.c#2 (text+ko) ==== @@ -64,6 +64,7 @@ #include <dev/cxgb/t3cdev.h> #include <dev/cxgb/common/cxgb_firmware_exports.h> #include <dev/cxgb/common/cxgb_tcb.h> +#include <dev/cxgb/cxgb_include.h> #include <dev/cxgb/common/cxgb_ctl_defs.h> #include <dev/cxgb/common/cxgb_t3_cpl.h> #include <dev/cxgb/cxgb_offload.h>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200710280333.l9S3XYY6005485>