From owner-svn-src-all@freebsd.org Tue May 24 08:44:47 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6667BB48B78; Tue, 24 May 2016 08:44:47 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 40B1A19B3; Tue, 24 May 2016 08:44:47 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4O8ikb1005089; Tue, 24 May 2016 08:44:46 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4O8ijkn005083; Tue, 24 May 2016 08:44:45 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201605240844.u4O8ijkn005083@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Tue, 24 May 2016 08:44:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300592 - in head/sys: cam/ctl dev/cxgbe/cxgbei dev/iscsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 May 2016 08:44:47 -0000 Author: trasz Date: Tue May 24 08:44:45 2016 New Revision: 300592 URL: https://svnweb.freebsd.org/changeset/base/300592 Log: Add mechanism for choosing iSER-capable ICL modules. MFC after: 1 month Sponsored by: The FreeBSD Foundation Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c head/sys/dev/cxgbe/cxgbei/icl_cxgbei.c head/sys/dev/iscsi/icl.c head/sys/dev/iscsi/icl.h head/sys/dev/iscsi/icl_soft.c head/sys/dev/iscsi/iscsi.c Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c ============================================================================== --- head/sys/cam/ctl/ctl_frontend_iscsi.c Tue May 24 07:52:53 2016 (r300591) +++ head/sys/cam/ctl/ctl_frontend_iscsi.c Tue May 24 08:44:45 2016 (r300592) @@ -1264,7 +1264,7 @@ cfiscsi_session_new(struct cfiscsi_softc cv_init(&cs->cs_login_cv, "cfiscsi_login"); #endif - cs->cs_conn = icl_new_conn(offload, "cfiscsi", &cs->cs_lock); + cs->cs_conn = icl_new_conn(offload, false, "cfiscsi", &cs->cs_lock); if (cs->cs_conn == NULL) { free(cs, M_CFISCSI); return (NULL); @@ -1793,7 +1793,8 @@ cfiscsi_ioctl_limits(struct ctl_iscsi *c cilp = (struct ctl_iscsi_limits_params *)&(ci->data); - error = icl_limits(cilp->offload, &cilp->data_segment_limit); + error = icl_limits(cilp->offload, false, + &cilp->data_segment_limit); if (error != 0) { ci->status = CTL_ISCSI_ERROR; snprintf(ci->error_str, sizeof(ci->error_str), Modified: head/sys/dev/cxgbe/cxgbei/icl_cxgbei.c ============================================================================== --- head/sys/dev/cxgbe/cxgbei/icl_cxgbei.c Tue May 24 07:52:53 2016 (r300591) +++ head/sys/dev/cxgbe/cxgbei/icl_cxgbei.c Tue May 24 08:44:45 2016 (r300592) @@ -850,7 +850,7 @@ icl_cxgbei_load(void) refcount_init(&icl_cxgbei_ncons, 0); - error = icl_register("cxgbei", 100, icl_cxgbei_limits, + error = icl_register("cxgbei", false, 100, icl_cxgbei_limits, icl_cxgbei_new_conn); KASSERT(error == 0, ("failed to register")); @@ -864,7 +864,7 @@ icl_cxgbei_unload(void) if (icl_cxgbei_ncons != 0) return (EBUSY); - icl_unregister("cxgbei"); + icl_unregister("cxgbei", false); uma_zdestroy(icl_transfer_zone); Modified: head/sys/dev/iscsi/icl.c ============================================================================== --- head/sys/dev/iscsi/icl.c Tue May 24 07:52:53 2016 (r300591) +++ head/sys/dev/iscsi/icl.c Tue May 24 08:44:45 2016 (r300592) @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); struct icl_module { TAILQ_ENTRY(icl_module) im_next; char *im_name; + bool im_iser; int im_priority; int (*im_limits)(size_t *limitp); struct icl_conn *(*im_new_conn)(const char *name, @@ -106,7 +107,7 @@ sysctl_kern_icl_drivers(SYSCTL_HANDLER_A } static struct icl_module * -icl_find(const char *name) +icl_find(const char *name, bool iser, bool quiet) { struct icl_module *im, *im_max; @@ -117,34 +118,52 @@ icl_find(const char *name) * priority. */ if (name == NULL || name[0] == '\0') { - im_max = TAILQ_FIRST(&sc->sc_modules); + im_max = NULL; TAILQ_FOREACH(im, &sc->sc_modules, im_next) { - if (im->im_priority > im_max->im_priority) + if (im->im_iser != iser) + continue; + if (im_max == NULL || + im->im_priority > im_max->im_priority) im_max = im; } + if (iser && im_max == NULL && !quiet) + ICL_WARN("no iSER-capable offload found"); + return (im_max); } TAILQ_FOREACH(im, &sc->sc_modules, im_next) { - if (strcasecmp(im->im_name, name) == 0) - return (im); + if (strcasecmp(im->im_name, name) != 0) + continue; + + if (!im->im_iser && iser && !quiet) { + ICL_WARN("offload \"%s\" is not iSER-capable", name); + return (NULL); + } + if (im->im_iser && !iser && !quiet) { + ICL_WARN("offload \"%s\" is iSER-only", name); + return (NULL); + } + + return (im); } + if (!quiet) + ICL_WARN("offload \"%s\" not found", name); + return (NULL); } struct icl_conn * -icl_new_conn(const char *offload, const char *name, struct mtx *lock) +icl_new_conn(const char *offload, bool iser, const char *name, struct mtx *lock) { struct icl_module *im; struct icl_conn *ic; sx_slock(&sc->sc_lock); - im = icl_find(offload); - + im = icl_find(offload, iser, false); if (im == NULL) { - ICL_WARN("offload \"%s\" not found", offload); sx_sunlock(&sc->sc_lock); return (NULL); } @@ -156,16 +175,14 @@ icl_new_conn(const char *offload, const } int -icl_limits(const char *offload, size_t *limitp) +icl_limits(const char *offload, bool iser, size_t *limitp) { struct icl_module *im; int error; sx_slock(&sc->sc_lock); - im = icl_find(offload); - + im = icl_find(offload, iser, false); if (im == NULL) { - ICL_WARN("offload \"%s\" not found", offload); sx_sunlock(&sc->sc_lock); return (ENXIO); } @@ -176,16 +193,14 @@ icl_limits(const char *offload, size_t * return (error); } - int -icl_register(const char *offload, int priority, int (*limits)(size_t *), +icl_register(const char *offload, bool iser, int priority, int (*limits)(size_t *), struct icl_conn *(*new_conn)(const char *, struct mtx *)) { struct icl_module *im; sx_xlock(&sc->sc_lock); - im = icl_find(offload); - + im = icl_find(offload, iser, true); if (im != NULL) { ICL_WARN("offload \"%s\" already registered", offload); sx_xunlock(&sc->sc_lock); @@ -194,6 +209,7 @@ icl_register(const char *offload, int pr im = malloc(sizeof(*im), M_ICL, M_ZERO | M_WAITOK); im->im_name = strdup(offload, M_ICL); + im->im_iser = iser; im->im_priority = priority; im->im_limits = limits; im->im_new_conn = new_conn; @@ -206,13 +222,12 @@ icl_register(const char *offload, int pr } int -icl_unregister(const char *offload) +icl_unregister(const char *offload, bool rdma) { struct icl_module *im; sx_xlock(&sc->sc_lock); - im = icl_find(offload); - + im = icl_find(offload, rdma, true); if (im == NULL) { ICL_WARN("offload \"%s\" not registered", offload); sx_xunlock(&sc->sc_lock); Modified: head/sys/dev/iscsi/icl.h ============================================================================== --- head/sys/dev/iscsi/icl.h Tue May 24 07:52:53 2016 (r300591) +++ head/sys/dev/iscsi/icl.h Tue May 24 08:44:45 2016 (r300592) @@ -126,14 +126,14 @@ struct icl_conn { void *ic_prv0; }; -struct icl_conn *icl_new_conn(const char *offload, const char *name, +struct icl_conn *icl_new_conn(const char *offload, bool iser, const char *name, struct mtx *lock); -int icl_limits(const char *offload, size_t *limitp); +int icl_limits(const char *offload, bool iser, size_t *limitp); -int icl_register(const char *offload, int priority, +int icl_register(const char *offload, bool iser, int priority, int (*limits)(size_t *), struct icl_conn *(*new_conn)(const char *, struct mtx *)); -int icl_unregister(const char *offload); +int icl_unregister(const char *offload, bool rdma); #ifdef ICL_KERNEL_PROXY Modified: head/sys/dev/iscsi/icl_soft.c ============================================================================== --- head/sys/dev/iscsi/icl_soft.c Tue May 24 07:52:53 2016 (r300591) +++ head/sys/dev/iscsi/icl_soft.c Tue May 24 08:44:45 2016 (r300592) @@ -1531,9 +1531,19 @@ icl_soft_load(void) * it's known as "offload driver"; "offload driver: soft" * doesn't make much sense. */ - error = icl_register("none", 0, icl_soft_limits, icl_soft_new_conn); + error = icl_register("none", false, 0, + icl_soft_limits, icl_soft_new_conn); KASSERT(error == 0, ("failed to register")); +#if defined(ICL_KERNEL_PROXY) && 0 + /* + * Debugging aid for kernel proxy functionality. + */ + error = icl_register("proxytest", true, 0, + icl_soft_limits, icl_soft_new_conn); + KASSERT(error == 0, ("failed to register")); +#endif + return (error); } @@ -1544,7 +1554,10 @@ icl_soft_unload(void) if (icl_ncons != 0) return (EBUSY); - icl_unregister("none"); + icl_unregister("none", false); +#if defined(ICL_KERNEL_PROXY) && 0 + icl_unregister("proxytest", true); +#endif uma_zdestroy(icl_pdu_zone); Modified: head/sys/dev/iscsi/iscsi.c ============================================================================== --- head/sys/dev/iscsi/iscsi.c Tue May 24 07:52:53 2016 (r300591) +++ head/sys/dev/iscsi/iscsi.c Tue May 24 08:44:45 2016 (r300592) @@ -1324,6 +1324,7 @@ iscsi_ioctl_daemon_wait(struct iscsi_sof sizeof(request->idr_conf)); error = icl_limits(is->is_conf.isc_offload, + is->is_conf.isc_iser, &request->idr_limits.isl_max_data_segment_length); if (error != 0) { ISCSI_SESSION_WARN(is, "icl_limits for offload \"%s\" " @@ -1773,7 +1774,7 @@ iscsi_ioctl_session_add(struct iscsi_sof } is->is_conn = icl_new_conn(is->is_conf.isc_offload, - "iscsi", &is->is_lock); + is->is_conf.isc_iser, "iscsi", &is->is_lock); if (is->is_conn == NULL) { sx_xunlock(&sc->sc_lock); free(is, M_ISCSI);