From owner-svn-src-projects@freebsd.org Tue Nov 24 02:01:02 2015 Return-Path: Delivered-To: svn-src-projects@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 605ACA3648D for ; Tue, 24 Nov 2015 02:01:02 +0000 (UTC) (envelope-from np@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 31E4A127D; Tue, 24 Nov 2015 02:01:02 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tAO211Vu005032; Tue, 24 Nov 2015 02:01:01 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tAO2115n005030; Tue, 24 Nov 2015 02:01:01 GMT (envelope-from np@FreeBSD.org) Message-Id: <201511240201.tAO2115n005030@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 24 Nov 2015 02:01:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r291229 - projects/cxl_iscsi/sys/dev/cxgbe/cxgbei X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Nov 2015 02:01:02 -0000 Author: np Date: Tue Nov 24 02:01:01 2015 New Revision: 291229 URL: https://svnweb.freebsd.org/changeset/base/291229 Log: Allow an icl_cxgbei_pdu to be allocated without being associated with an icl_conn right at the time of allocation. Modified: projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/cxgbei.c projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/icl_cxgbei.c Modified: projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/cxgbei.c ============================================================================== --- projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/cxgbei.c Tue Nov 24 01:12:17 2015 (r291228) +++ projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/cxgbei.c Tue Nov 24 02:01:01 2015 (r291229) @@ -90,9 +90,9 @@ __FBSDID("$FreeBSD$"); #include "cxgbei.h" #include "cxgbei_ulp2_ddp.h" -/* XXX some header instead. */ -struct icl_pdu *icl_cxgbei_conn_new_pdu(struct icl_conn *, int); -void icl_cxgbei_conn_pdu_free(struct icl_conn *, struct icl_pdu *); +/* XXXNP some header instead. */ +struct icl_pdu *icl_cxgbei_new_pdu(int); +void icl_cxgbei_new_pdu_set_conn(struct icl_pdu *, struct icl_conn *); /* * Direct Data Placement - @@ -538,9 +538,10 @@ do_rx_iscsi_hdr(struct sge_iq *iq, const MPASS(icc->icc_signature == CXGBEI_CONN_SIGNATURE); M_ASSERTPKTHDR(m); - ip = icl_cxgbei_conn_new_pdu(&icc->ic, M_NOWAIT); + ip = icl_cxgbei_new_pdu(M_NOWAIT); if (ip == NULL) CXGBE_UNIMPLEMENTED("PDU allocation failure"); + icl_cxgbei_new_pdu_set_conn(ip, &icc->ic); icp = ip_to_icp(ip); bcopy(mtod(m, caddr_t) + sizeof(*cpl), icp->ip.ip_bhs, sizeof(struct iscsi_bhs)); Modified: projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/icl_cxgbei.c ============================================================================== --- projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/icl_cxgbei.c Tue Nov 24 01:12:17 2015 (r291228) +++ projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/icl_cxgbei.c Tue Nov 24 02:01:01 2015 (r291229) @@ -97,6 +97,9 @@ static volatile u_int icl_cxgbei_ncons; #define ICL_CONN_LOCK_ASSERT(X) mtx_assert(X->ic_lock, MA_OWNED) #define ICL_CONN_LOCK_ASSERT_NOT(X) mtx_assert(X->ic_lock, MA_NOTOWNED) +struct icl_pdu *icl_cxgbei_new_pdu(int); +void icl_cxgbei_new_pdu_set_conn(struct icl_pdu *, struct icl_conn *); + static icl_conn_new_pdu_t icl_cxgbei_conn_new_pdu; static icl_conn_pdu_free_t icl_cxgbei_conn_pdu_free; static icl_conn_pdu_data_segment_length_t @@ -138,7 +141,7 @@ DEFINE_CLASS(icl_cxgbei, icl_cxgbei_meth #define CXGBEI_MAX_PDU 16224 #define CXGBEI_MAX_DSL (CXGBEI_MAX_PDU - sizeof(struct iscsi_bhs) - 8) -void +static void icl_cxgbei_conn_pdu_free(struct icl_conn *ic, struct icl_pdu *ip) { #ifdef INVARIANTS @@ -154,15 +157,13 @@ icl_cxgbei_conn_pdu_free(struct icl_conn m_freem(ip->ip_bhs_mbuf); /* storage for icl_cxgbei_pdu itself */ #ifdef DIAGNOSTIC - refcount_release(&ic->ic_outstanding_pdus); + if (ic != NULL) + refcount_release(&ic->ic_outstanding_pdus); #endif } -/* - * Allocate icl_pdu with empty BHS to fill up by the caller. - */ struct icl_pdu * -icl_cxgbei_conn_new_pdu(struct icl_conn *ic, int flags) +icl_cxgbei_new_pdu(int flags) { struct icl_cxgbei_pdu *icp; struct icl_pdu *ip; @@ -170,7 +171,7 @@ icl_cxgbei_conn_new_pdu(struct icl_conn uintptr_t a; m = m_gethdr(flags, MT_DATA); - if (m == NULL) + if (__predict_false(m == NULL)) return (NULL); a = roundup2(mtod(m, uintptr_t), _Alignof(struct icl_cxgbei_pdu)); @@ -179,7 +180,6 @@ icl_cxgbei_conn_new_pdu(struct icl_conn icp->icp_signature = CXGBEI_PDU_SIGNATURE; ip = &icp->ip; - ip->ip_conn = ic; ip->ip_bhs_mbuf = m; a = roundup2((uintptr_t)(icp + 1), _Alignof(struct iscsi_bhs *)); @@ -195,10 +195,32 @@ icl_cxgbei_conn_new_pdu(struct icl_conn m->m_len = sizeof(struct iscsi_bhs); m->m_pkthdr.len = m->m_len; + return (ip); +} + +void +icl_cxgbei_new_pdu_set_conn(struct icl_pdu *ip, struct icl_conn *ic) +{ + ip->ip_conn = ic; #ifdef DIAGNOSTIC refcount_acquire(&ic->ic_outstanding_pdus); #endif +} + +/* + * Allocate icl_pdu with empty BHS to fill up by the caller. + */ +static struct icl_pdu * +icl_cxgbei_conn_new_pdu(struct icl_conn *ic, int flags) +{ + struct icl_pdu *ip; + + ip = icl_cxgbei_new_pdu(flags); + if (__predict_false(ip == NULL)) + return (NULL); + icl_cxgbei_new_pdu_set_conn(ip, ic); + return (ip); }