From owner-p4-projects@FreeBSD.ORG Tue Feb 26 15:42:30 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3E3611065675; Tue, 26 Feb 2008 15:42:30 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EDF7E10656F1 for ; Tue, 26 Feb 2008 15:42:29 +0000 (UTC) (envelope-from swise@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 19F3713C4D5 for ; Tue, 26 Feb 2008 15:42:29 +0000 (UTC) (envelope-from swise@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m1QFgSPo050705 for ; Tue, 26 Feb 2008 15:42:28 GMT (envelope-from swise@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m1QFgSGZ050702 for perforce@freebsd.org; Tue, 26 Feb 2008 15:42:28 GMT (envelope-from swise@FreeBSD.org) Date: Tue, 26 Feb 2008 15:42:28 GMT Message-Id: <200802261542.m1QFgSGZ050702@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to swise@FreeBSD.org using -f From: Steve Wise To: Perforce Change Reviews Cc: Subject: PERFORCE change 136263 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Feb 2008 15:42:30 -0000 http://perforce.freebsd.org/chv.cgi?CH=136263 Change 136263 by swise@swise:vic10:iwarp on 2008/02/26 15:42:22 Discover TOE capable devs via ifaddr events. - removed t3c_client registration. - register for ifaddr events. - when an addr is bound to a undiscovered TOE ifnet, then register the device with the rdma core. Affected files ... .. //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c#2 edit .. //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_hal.c#2 edit .. //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_hal.h#2 edit Differences ... ==== //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c#2 (text+ko) ==== @@ -52,6 +52,10 @@ #include #include #include +#include + +#include +#include #include @@ -88,18 +92,10 @@ static void open_rnic_dev(struct t3cdev *); static void close_rnic_dev(struct t3cdev *); -struct cxgb_client t3c_client = { - .name = "iw_cxgb3", - .add = open_rnic_dev, - .remove = close_rnic_dev, - .handlers = t3c_handlers, -#if 0 - .redirect = iwch_ep_redirect -#endif -}; - static TAILQ_HEAD( ,iwch_dev) dev_list; static struct mtx dev_mutex; +static eventhandler_tag event_tag; + static void rnic_init(struct iwch_dev *rnicp) { @@ -204,10 +200,24 @@ mtx_unlock(&dev_mutex); } +static ifaddr_event_handler_t ifaddr_event_handler(void *arg, struct ifnet *ifp) +{ + printf("%s if name %s \n", __FUNCTION__, ifp->if_xname); + if (ifp->if_capabilities & IFCAP_TOE4) { + KASSERT(T3CDEV(ifp) != NULL, ("null t3cdev ptr!")); + if (cxio_hal_find_rdev_by_t3cdev(T3CDEV(ifp)) == NULL) + open_rnic_dev(T3CDEV(ifp)); + } + return 0; +} + + static int __init iwch_init_module(void) { int err; + struct ifnet *ifp; + printf("%s enter\n", __FUNCTION__); TAILQ_INIT(&dev_list); mtx_init(&dev_mutex, "iwch dev_list lock", NULL, MTX_DEF); @@ -218,13 +228,23 @@ if (err) return err; cxio_register_ev_cb(iwch_ev_dispatch); - cxgb_register_client(&t3c_client); + + /* Register for ifaddr events to dynamically add TOE devs */ + event_tag = EVENTHANDLER_REGISTER(ifaddr_event, ifaddr_event_handler, + NULL, EVENTHANDLER_PRI_ANY); + + /* Register existing TOE interfaces by walking the ifnet chain */ + IFNET_RLOCK(); + TAILQ_FOREACH(ifp, &ifnet, if_link) { + (void)ifaddr_event_handler(NULL, ifp); + } + IFNET_RUNLOCK(); return 0; } static void __exit iwch_exit_module(void) { - cxgb_unregister_client(&t3c_client); + EVENTHANDLER_DEREGISTER(ifaddr_event, event_tag); cxio_unregister_ev_cb(iwch_ev_dispatch); iwch_cm_term(); cxio_hal_exit(); ==== //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_hal.c#2 (text+ko) ==== @@ -95,7 +95,7 @@ return NULL; } -static struct cxio_rdev * +struct cxio_rdev * cxio_hal_find_rdev_by_t3cdev(struct t3cdev *tdev) { struct cxio_rdev *rdev; ==== //depot/projects/iwarp/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_hal.h#2 (text+ko) ==== @@ -290,5 +290,6 @@ mtx_unlock_spin(lockp); \ __ret; \ }) +extern struct cxio_rdev *cxio_hal_find_rdev_by_t3cdev(struct t3cdev *tdev); #endif