Date: Tue, 24 Nov 2015 02:01:01 +0000 (UTC) From: Navdeep Parhar <np@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r291229 - projects/cxl_iscsi/sys/dev/cxgbe/cxgbei Message-ID: <201511240201.tAO2115n005030@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511240201.tAO2115n005030>