Date: Tue, 4 Jul 2017 00:10:29 +0000 (UTC) From: Zbigniew Bodek <zbb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r320632 - head/sys/dev/ena Message-ID: <201707040010.v640ATAO083270@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: zbb Date: Tue Jul 4 00:10:29 2017 New Revision: 320632 URL: https://svnweb.freebsd.org/changeset/base/320632 Log: Replace mbuf defragmentation with collapse Collapse should be more effective than defragmentation. Added missing declaration of ena_check_and_collapse_mbuf(). Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon.com Inc. Modified: head/sys/dev/ena/ena.c head/sys/dev/ena/ena.h head/sys/dev/ena/ena_sysctl.c Modified: head/sys/dev/ena/ena.c ============================================================================== --- head/sys/dev/ena/ena.c Tue Jul 4 00:08:47 2017 (r320631) +++ head/sys/dev/ena/ena.c Tue Jul 4 00:10:29 2017 (r320632) @@ -156,6 +156,8 @@ static void ena_update_hwassist(struct ena_adapter *); static int ena_setup_ifnet(device_t, struct ena_adapter *, struct ena_com_dev_get_features_ctx *); static void ena_tx_csum(struct ena_com_tx_ctx *, struct mbuf *); +static int ena_check_and_collapse_mbuf(struct ena_ring *tx_ring, + struct mbuf **mbuf); static int ena_xmit_mbuf(struct ena_ring *, struct mbuf **); static void ena_start_xmit(struct ena_ring *); static int ena_mq_start(if_t, struct mbuf *); @@ -2623,10 +2625,10 @@ ena_tx_csum(struct ena_com_tx_ctx *ena_tx_ctx, struct } static int -ena_check_and_defragment_mbuf(struct ena_ring *tx_ring, struct mbuf **mbuf) +ena_check_and_collapse_mbuf(struct ena_ring *tx_ring, struct mbuf **mbuf) { struct ena_adapter *adapter; - struct mbuf *defrag_mbuf; + struct mbuf *collapsed_mbuf; int num_frags; adapter = tx_ring->adapter; @@ -2635,16 +2637,17 @@ ena_check_and_defragment_mbuf(struct ena_ring *tx_ring /* One segment must be reserved for configuration descriptor. */ if (num_frags < adapter->max_tx_sgl_size) return (0); - counter_u64_add(tx_ring->tx_stats.defragment, 1); + counter_u64_add(tx_ring->tx_stats.collapse, 1); - defrag_mbuf = m_defrag(*mbuf, M_NOWAIT); - if (defrag_mbuf == NULL) { - counter_u64_add(tx_ring->tx_stats.defragment_err, 1); + collapsed_mbuf = m_collapse(*mbuf, M_NOWAIT, + adapter->max_tx_sgl_size - 1); + if (collapsed_mbuf == NULL) { + counter_u64_add(tx_ring->tx_stats.collapse_err, 1); return (ENOMEM); } - /* If mbuf was defragmented succesfully, original mbuf is released. */ - *mbuf = defrag_mbuf; + /* If mbuf was collapsed succesfully, original mbuf is released. */ + *mbuf = collapsed_mbuf; return (0); } @@ -2675,10 +2678,10 @@ ena_xmit_mbuf(struct ena_ring *tx_ring, struct mbuf ** ENA_ASSERT(*mbuf, "mbuf is NULL\n"); - rc = ena_check_and_defragment_mbuf(tx_ring, mbuf); + rc = ena_check_and_collapse_mbuf(tx_ring, mbuf); if (rc) { ena_trace(ENA_WARNING, - "Failed to defragment mbuf! err: %d", rc); + "Failed to collapse mbuf! err: %d", rc); return (rc); } Modified: head/sys/dev/ena/ena.h ============================================================================== --- head/sys/dev/ena/ena.h Tue Jul 4 00:08:47 2017 (r320631) +++ head/sys/dev/ena/ena.h Tue Jul 4 00:10:29 2017 (r320632) @@ -226,8 +226,8 @@ struct ena_stats_tx { counter_u64_t doorbells; counter_u64_t missing_tx_comp; counter_u64_t bad_req_id; - counter_u64_t defragment; - counter_u64_t defragment_err; + counter_u64_t collapse; + counter_u64_t collapse_err; }; struct ena_stats_rx { Modified: head/sys/dev/ena/ena_sysctl.c ============================================================================== --- head/sys/dev/ena/ena_sysctl.c Tue Jul 4 00:08:47 2017 (r320631) +++ head/sys/dev/ena/ena_sysctl.c Tue Jul 4 00:10:29 2017 (r320632) @@ -156,13 +156,13 @@ ena_sysctl_add_stats(struct ena_adapter *adapter) "stops", CTLFLAG_RD, &tx_stats->queue_stop, "Queue stops"); SYSCTL_ADD_COUNTER_U64(ctx, tx_list, OID_AUTO, - "defragmentations", CTLFLAG_RD, - &tx_stats->defragment, - "Mbuf defragmentations"); + "mbuf_collapses", CTLFLAG_RD, + &tx_stats->collapse, + "Mbuf collapse count"); SYSCTL_ADD_COUNTER_U64(ctx, tx_list, OID_AUTO, - "defragmentation_err", CTLFLAG_RD, - &tx_stats->defragment_err, - "Mbuf defragmentation failures"); + "mbuf_collapse_err", CTLFLAG_RD, + &tx_stats->collapse_err, + "Mbuf collapse failures"); /* RX specific stats */ rx_node = SYSCTL_ADD_NODE(ctx, queue_list, OID_AUTO,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707040010.v640ATAO083270>