From owner-svn-src-user@FreeBSD.ORG Mon Jun 4 20:50:41 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F0A90106566B; Mon, 4 Jun 2012 20:50:41 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DB6B18FC17; Mon, 4 Jun 2012 20:50:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q54Kofw8065017; Mon, 4 Jun 2012 20:50:41 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q54KoftF065013; Mon, 4 Jun 2012 20:50:41 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201206042050.q54KoftF065013@svn.freebsd.org> From: Navdeep Parhar Date: Mon, 4 Jun 2012 20:50:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236580 - user/np/toe_iwarp/sys/dev/cxgbe X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jun 2012 20:50:42 -0000 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);