From owner-svn-src-all@freebsd.org Thu Mar 8 15:53:05 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 55D59F3DEF6; Thu, 8 Mar 2018 15:53:05 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 042FC81A85; Thu, 8 Mar 2018 15:53:05 +0000 (UTC) (envelope-from hselasky@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D957012D2A; Thu, 8 Mar 2018 15:53:04 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w28Fr49R017273; Thu, 8 Mar 2018 15:53:04 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w28Fr418017272; Thu, 8 Mar 2018 15:53:04 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201803081553.w28Fr418017272@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 8 Mar 2018 15:53:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330658 - head/sys/dev/mlx5/mlx5_en X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/sys/dev/mlx5/mlx5_en X-SVN-Commit-Revision: 330658 X-SVN-Commit-Repository: base 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.25 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: Thu, 08 Mar 2018 15:53:05 -0000 Author: hselasky Date: Thu Mar 8 15:53:04 2018 New Revision: 330658 URL: https://svnweb.freebsd.org/changeset/base/330658 Log: Fix mlx5en(4) driver to properly call m_defrag(). When the mlx5en(4) driver was converted to using BUSDMA(9) the call to m_defrag() was moved after the part of the TX routine that strips the header from the mbuf chain. Before it called m_defrag it first trimmed off the now-empty mbufs from the start of the chain. This has the side effect of also removing the head of the chain that has M_PKTHDR set. m_defrag() will not defrag a chain that does not have M_PKTHDR set, thus it was effectively never defragging the mbuf chains. As it turns out, trimming the mbufs in this fashion is unnecessary since the call to bus_dmamap_load_mbuf_sg doesn't map empty mbufs anyway, so remove it. Differential Revision: https://reviews.freebsd.org/D12050 Submitted by: mjoras@ MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c ============================================================================== --- head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Mar 8 15:47:17 2018 (r330657) +++ head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Thu Mar 8 15:53:04 2018 (r330658) @@ -311,22 +311,9 @@ mlx5e_sq_xmit(struct mlx5e_sq *sq, struct mbuf **mbp) } dseg = ((struct mlx5_wqe_data_seg *)&wqe->ctrl) + ds_cnt; - /* Trim off empty mbufs */ - while (mb->m_len == 0) { - mb = m_free(mb); - /* Check if all data has been inlined */ - if (mb == NULL) - goto skip_dma; - } - err = bus_dmamap_load_mbuf_sg(sq->dma_tag, sq->mbuf[pi].dma_map, mb, segs, &nsegs, BUS_DMA_NOWAIT); if (err == EFBIG) { - /* - * Update *mbp before defrag in case it was trimmed in the - * loop above - */ - *mbp = mb; /* Update statistics */ sq->stats.defragged++; /* Too many mbuf fragments */ @@ -343,6 +330,17 @@ mlx5e_sq_xmit(struct mlx5e_sq *sq, struct mbuf **mbp) if (err != 0) goto tx_drop; + /* Make sure all mbuf data, if any, is written to RAM */ + if (nsegs != 0) { + bus_dmamap_sync(sq->dma_tag, sq->mbuf[pi].dma_map, + BUS_DMASYNC_PREWRITE); + } else { + /* All data was inlined, free the mbuf. */ + bus_dmamap_unload(sq->dma_tag, sq->mbuf[pi].dma_map); + m_freem(mb); + mb = NULL; + } + for (x = 0; x != nsegs; x++) { if (segs[x].ds_len == 0) continue; @@ -351,7 +349,7 @@ mlx5e_sq_xmit(struct mlx5e_sq *sq, struct mbuf **mbp) dseg->byte_count = cpu_to_be32((uint32_t)segs[x].ds_len); dseg++; } -skip_dma: + ds_cnt = (dseg - ((struct mlx5_wqe_data_seg *)&wqe->ctrl)); wqe->ctrl.opmod_idx_opcode = cpu_to_be32((sq->pc << 8) | opcode); @@ -368,10 +366,6 @@ skip_dma: sq->mbuf[pi].mbuf = mb; sq->mbuf[pi].num_wqebbs = DIV_ROUND_UP(ds_cnt, MLX5_SEND_WQEBB_NUM_DS); sq->pc += sq->mbuf[pi].num_wqebbs; - - /* Make sure all mbuf data is written to RAM */ - if (mb != NULL) - bus_dmamap_sync(sq->dma_tag, sq->mbuf[pi].dma_map, BUS_DMASYNC_PREWRITE); sq->stats.packets++; *mbp = NULL; /* safety clear */