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.
This commit is contained in:
Zbigniew Bodek 2017-07-04 00:10:29 +00:00
parent 8a573700af
commit 1b069f1c69
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=320632
3 changed files with 21 additions and 18 deletions

View File

@ -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 mbuf *mbuf)
}
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, struct mbuf **mbuf)
/* 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 **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);
}

View File

@ -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 {

View File

@ -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,