Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Jun 2012 20:50:41 +0000 (UTC)
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r236580 - user/np/toe_iwarp/sys/dev/cxgbe
Message-ID:  <201206042050.q54KoftF065013@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: np
Date: Mon Jun  4 20:50:41 2012
New Revision: 236580
URL: http://svn.freebsd.org/changeset/base/236580

Log:
  Add a mechanism for the iWARP driver to register a handler for async
  notifications.  Run the handler when such notifications are received.

Modified:
  user/np/toe_iwarp/sys/dev/cxgbe/adapter.h
  user/np/toe_iwarp/sys/dev/cxgbe/t4_main.c
  user/np/toe_iwarp/sys/dev/cxgbe/t4_sge.c

Modified: user/np/toe_iwarp/sys/dev/cxgbe/adapter.h
==============================================================================
--- user/np/toe_iwarp/sys/dev/cxgbe/adapter.h	Mon Jun  4 20:45:33 2012	(r236579)
+++ user/np/toe_iwarp/sys/dev/cxgbe/adapter.h	Mon Jun  4 20:50:41 2012	(r236580)
@@ -508,6 +508,7 @@ struct sge {
 struct rss_header;
 typedef int (*cpl_handler_t)(struct sge_iq *, const struct rss_header *,
     struct mbuf *);
+typedef int (*an_handler_t)(struct sge_iq *, const struct rsp_ctrl *);
 
 struct adapter {
 	SLIST_ENTRY(adapter) link;
@@ -579,7 +580,8 @@ struct adapter {
 	TAILQ_HEAD(, sge_fl) sfl;
 	struct callout sfl_callout;
 
-	cpl_handler_t cpl_handler[256] __aligned(CACHE_LINE_SIZE);
+	an_handler_t an_handler __aligned(CACHE_LINE_SIZE);
+	cpl_handler_t cpl_handler[256];
 };
 
 #define ADAPTER_LOCK(sc)		mtx_lock(&(sc)->sc_lock)
@@ -737,6 +739,7 @@ void t4_os_portmod_changed(const struct 
 void t4_os_link_changed(struct adapter *, int, int);
 void t4_iterate(void (*)(struct adapter *, void *), void *);
 int t4_register_cpl_handler(struct adapter *, int, cpl_handler_t);
+int t4_register_an_handler(struct adapter *, an_handler_t);
 
 /* t4_sge.c */
 void t4_sge_modload(void);

Modified: user/np/toe_iwarp/sys/dev/cxgbe/t4_main.c
==============================================================================
--- user/np/toe_iwarp/sys/dev/cxgbe/t4_main.c	Mon Jun  4 20:45:33 2012	(r236579)
+++ user/np/toe_iwarp/sys/dev/cxgbe/t4_main.c	Mon Jun  4 20:50:41 2012	(r236580)
@@ -304,6 +304,7 @@ static void cxgbe_tick(void *);
 static void cxgbe_vlan_config(void *, struct ifnet *, uint16_t);
 static int cpl_not_handled(struct sge_iq *, const struct rss_header *,
     struct mbuf *);
+static int an_not_handled(struct sge_iq *, const struct rsp_ctrl *);
 static int t4_sysctls(struct adapter *);
 static int cxgbe_sysctls(struct port_info *);
 static int sysctl_int_array(SYSCTL_HANDLER_ARGS);
@@ -443,6 +444,7 @@ t4_attach(device_t dev)
 		goto done; /* error message displayed already */
 
 	memset(sc->chan_map, 0xff, sizeof(sc->chan_map));
+	sc->an_handler = an_not_handled;
 	for (i = 0; i < ARRAY_SIZE(sc->cpl_handler); i++)
 		sc->cpl_handler[i] = cpl_not_handled;
 	t4_register_cpl_handler(sc, CPL_SET_TCB_RPL, filter_rpl);
@@ -2914,6 +2916,7 @@ cxgbe_vlan_config(void *arg, struct ifne
 static int
 cpl_not_handled(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
 {
+
 #ifdef INVARIANTS
 	panic("%s: opcode 0x%02x on iq %p with payload %p",
 	    __func__, rss->opcode, iq, m);
@@ -2941,6 +2944,31 @@ t4_register_cpl_handler(struct adapter *
 }
 
 static int
+an_not_handled(struct sge_iq *iq, const struct rsp_ctrl *ctrl)
+{
+
+#ifdef INVARIANTS
+	panic("%s: async notification on iq %p (ctrl %p)", __func__, iq, ctrl);
+#else
+	log(LOG_ERR, "%s: async notification on iq %p (ctrl %p)",
+	    __func__, iq, ctrl);
+#endif
+	return (EDOOFUS);
+}
+
+int
+t4_register_an_handler(struct adapter *sc, an_handler_t h)
+{
+	uintptr_t *loc, new;
+
+	new = h ? (uintptr_t)h : (uintptr_t)an_not_handled;
+	loc = (uintptr_t *) &sc->an_handler;
+	atomic_store_rel_ptr(loc, new);
+
+	return (0);
+}
+
+static int
 t4_sysctls(struct adapter *sc)
 {
 	struct sysctl_ctx_list *ctx;

Modified: user/np/toe_iwarp/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- user/np/toe_iwarp/sys/dev/cxgbe/t4_sge.c	Mon Jun  4 20:45:33 2012	(r236579)
+++ user/np/toe_iwarp/sys/dev/cxgbe/t4_sge.c	Mon Jun  4 20:50:41 2012	(r236580)
@@ -863,7 +863,8 @@ service_iq(struct sge_iq *iq, int budget
 				break;
 
 			default:
-				panic("%s: rsp_type %u", __func__, rsp_type);
+				sc->an_handler(iq, ctrl);
+				break;
 			}
 
 			iq_next(iq);



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