From owner-svn-src-head@freebsd.org Thu Sep 1 22:40:56 2016 Return-Path: Delivered-To: svn-src-head@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 84652BCCF20; Thu, 1 Sep 2016 22:40:56 +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 5BA6EC70; Thu, 1 Sep 2016 22:40:56 +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 u81MetY4094238; Thu, 1 Sep 2016 22:40:55 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u81Meth4094206; Thu, 1 Sep 2016 22:40:55 GMT (envelope-from np@FreeBSD.org) Message-Id: <201609012240.u81Meth4094206@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Thu, 1 Sep 2016 22:40:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305251 - head/sys/dev/cxgbe/cxgbei X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Sep 2016 22:40:56 -0000 Author: np Date: Thu Sep 1 22:40:55 2016 New Revision: 305251 URL: https://svnweb.freebsd.org/changeset/base/305251 Log: cxgbe/cxgbei: Minor changes in the iSCSI CPL handlers. - Use m_copydata instead of bcopy. - Add new assertions. - Log some more information. Sponsored by: Chelsio Communications Modified: head/sys/dev/cxgbe/cxgbei/cxgbei.c Modified: head/sys/dev/cxgbe/cxgbei/cxgbei.c ============================================================================== --- head/sys/dev/cxgbe/cxgbei/cxgbei.c Thu Sep 1 22:27:47 2016 (r305250) +++ head/sys/dev/cxgbe/cxgbei/cxgbei.c Thu Sep 1 22:40:55 2016 (r305251) @@ -181,15 +181,18 @@ do_rx_iscsi_hdr(struct sge_iq *iq, const struct toepcb *toep = lookup_tid(sc, tid); struct icl_pdu *ip; struct icl_cxgbei_pdu *icp; + uint16_t len_ddp = be16toh(cpl->pdu_len_ddp); + uint16_t len = be16toh(cpl->len); M_ASSERTPKTHDR(m); + MPASS(m->m_pkthdr.len == len + sizeof(*cpl)); ip = icl_cxgbei_new_pdu(M_NOWAIT); if (ip == NULL) CXGBE_UNIMPLEMENTED("PDU allocation failure"); + m_copydata(m, sizeof(*cpl), ISCSI_BHS_SIZE, (caddr_t)ip->ip_bhs); + ip->ip_data_len = G_ISCSI_PDU_LEN(len_ddp) - len; icp = ip_to_icp(ip); - bcopy(mtod(m, caddr_t) + sizeof(*cpl), icp->ip.ip_bhs, sizeof(struct - iscsi_bhs)); icp->icp_seq = ntohl(cpl->seq); icp->icp_flags = ICPF_RX_HDR; @@ -198,8 +201,8 @@ do_rx_iscsi_hdr(struct sge_iq *iq, const toep->ulpcb2 = icp; #if 0 - CTR4(KTR_CXGBE, "%s: tid %u, cpl->len hlen %u, m->m_len hlen %u", - __func__, tid, ntohs(cpl->len), m->m_len); + CTR5(KTR_CXGBE, "%s: tid %u, cpl->len %u, pdu_len_ddp 0x%04x, icp %p", + __func__, tid, len, len_ddp, icp); #endif m_freem(m); @@ -216,22 +219,23 @@ do_rx_iscsi_data(struct sge_iq *iq, cons struct icl_cxgbei_pdu *icp = toep->ulpcb2; M_ASSERTPKTHDR(m); + MPASS(m->m_pkthdr.len == be16toh(cpl->len) + sizeof(*cpl)); /* Must already have received the header (but not the data). */ MPASS(icp != NULL); MPASS(icp->icp_flags == ICPF_RX_HDR); MPASS(icp->ip.ip_data_mbuf == NULL); - MPASS(icp->ip.ip_data_len == 0); + m_adj(m, sizeof(*cpl)); + MPASS(icp->ip.ip_data_len == m->m_pkthdr.len); icp->icp_flags |= ICPF_RX_FLBUF; icp->ip.ip_data_mbuf = m; - icp->ip.ip_data_len = m->m_pkthdr.len; #if 0 - CTR4(KTR_CXGBE, "%s: tid %u, cpl->len dlen %u, m->m_len dlen %u", - __func__, tid, ntohs(cpl->len), m->m_len); + CTR3(KTR_CXGBE, "%s: tid %u, cpl->len %u", __func__, tid, + be16toh(cpl->len)); #endif return (0); @@ -259,20 +263,30 @@ do_rx_iscsi_ddp(struct sge_iq *iq, const /* Must already be assembling a PDU. */ MPASS(icp != NULL); MPASS(icp->icp_flags & ICPF_RX_HDR); /* Data is optional. */ - ip = &icp->ip; + MPASS((icp->icp_flags & ICPF_RX_STATUS) == 0); + + pdu_len = be16toh(cpl->len); /* includes everything. */ + val = be32toh(cpl->ddpvld); + +#if 0 + CTR4(KTR_CXGBE, + "%s: tid %u, cpl->len %u, ddpvld 0x%08x, icp_flags 0x%08x", + __func__, tid, pdu_len, val, icp->icp_flags); +#endif + icp->icp_flags |= ICPF_RX_STATUS; - val = ntohl(cpl->ddpvld); + ip = &icp->ip; if (val & F_DDP_PADDING_ERR) icp->icp_flags |= ICPF_PAD_ERR; if (val & F_DDP_HDRCRC_ERR) icp->icp_flags |= ICPF_HCRC_ERR; if (val & F_DDP_DATACRC_ERR) icp->icp_flags |= ICPF_DCRC_ERR; - if (ip->ip_data_mbuf == NULL) { - /* XXXNP: what should ip->ip_data_len be, and why? */ + if (val & F_DDP_PDU && ip->ip_data_mbuf == NULL) { + MPASS((icp->icp_flags & ICPF_RX_FLBUF) == 0); + MPASS(ip->ip_data_len > 0); icp->icp_flags |= ICPF_RX_DDP; } - pdu_len = ntohs(cpl->len); /* includes everything. */ INP_WLOCK(inp); if (__predict_false(inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT))) { @@ -358,11 +372,6 @@ do_rx_iscsi_ddp(struct sge_iq *iq, const m_freem(m); } -#if 0 - CTR4(KTR_CXGBE, "%s: tid %u, pdu_len %u, pdu_flags 0x%x", - __func__, tid, pdu_len, icp->icp_flags); -#endif - STAILQ_INSERT_TAIL(&icc->rcvd_pdus, ip, ip_next); if ((icc->rx_flags & RXF_ACTIVE) == 0) { struct cxgbei_worker_thread_softc *cwt = &cwt_softc[icc->cwt];