PERFORCE change 136263 for review
Steve Wise
swise at FreeBSD.org
Tue Feb 26 15:42:30 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=136263
Change 136263 by swise at 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 <sys/queue.h>
#include <sys/taskqueue.h>
#include <sys/proc.h>
+#include <sys/eventhandler.h>
+
+#include <net/if.h>
+#include <net/if_var.h>
#include <netinet/in.h>
@@ -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
More information about the p4-projects
mailing list