aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGordon Tetlow <gordon@FreeBSD.org>2020-06-09 16:10:57 +0000
committerGordon Tetlow <gordon@FreeBSD.org>2020-06-09 16:10:57 +0000
commitc8c559b872457509bef5e25533d4030c70a93e31 (patch)
tree968a2de36acf64ea04a1798a4bf913471c7e8850
parentf132e99efa0e23b3a93beb5556923e2f865bbb76 (diff)
downloadsrc-c8c559b872457509bef5e25533d4030c70a93e31.tar.gz
src-c8c559b872457509bef5e25533d4030c70a93e31.zip
Fix stability issues in ena(4) driver.
Approved by: so Security: FreeBSD-EN-20:11.ena
Notes
Notes: svn path=/releng/12.1/; revision=361970
-rw-r--r--sys/dev/ena/ena.c23
-rw-r--r--sys/dev/ena/ena.h10
2 files changed, 26 insertions, 7 deletions
diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c
index 2b4ec83f93e7..9ce7d0f1bdca 100644
--- a/sys/dev/ena/ena.c
+++ b/sys/dev/ena/ena.c
@@ -200,6 +200,19 @@ int ena_log_level = ENA_ALERT | ENA_WARNING;
SYSCTL_INT(_hw_ena, OID_AUTO, log_level, CTLFLAG_RWTUN,
&ena_log_level, 0, "Logging level indicating verbosity of the logs");
+/*
+ * Use 9k mbufs for the Rx buffers. Default to 0 (use page size mbufs instead).
+ * Using 9k mbufs in low memory conditions might cause allocation to take a lot
+ * of time and lead to the OS instability as it needs to look for the contiguous
+ * pages.
+ * However, page size mbufs has a bit smaller throughput than 9k mbufs, so if
+ * the network performance is the priority, the 9k mbufs can be used.
+ */
+int ena_enable_9k_mbufs = 0;
+SYSCTL_INT(_hw_ena, OID_AUTO, enable_9k_mbufs, CTLFLAG_RDTUN,
+ &ena_enable_9k_mbufs, 0, "Use 9 kB mbufs for Rx descriptors");
+#define ena_mbuf_sz (ena_enable_9k_mbufs ? MJUM9BYTES : MJUMPAGESIZE)
+
static ena_vendor_info_t ena_vendor_info_array[] = {
{ PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_PF, 0},
{ PCI_VENDOR_ID_AMAZON, PCI_DEV_ID_ENA_LLQ_PF, 0},
@@ -470,6 +483,7 @@ ena_init_io_rings(struct ena_adapter *adapter)
rxr->que = que;
rxr->empty_rx_queue = 0;
+ rxr->rx_mbuf_sz = ena_mbuf_sz;
}
}
@@ -548,9 +562,9 @@ ena_setup_rx_dma_tag(struct ena_adapter *adapter)
ENA_DMA_BIT_MASK(adapter->dma_width), /* lowaddr of excl window */
BUS_SPACE_MAXADDR, /* highaddr of excl window */
NULL, NULL, /* filter, filterarg */
- MJUM16BYTES, /* maxsize */
+ ena_mbuf_sz, /* maxsize */
adapter->max_rx_sgl_size, /* nsegments */
- MJUM16BYTES, /* maxsegsize */
+ ena_mbuf_sz, /* maxsegsize */
0, /* flags */
NULL, /* lockfunc */
NULL, /* lockarg */
@@ -957,7 +971,8 @@ ena_alloc_rx_mbuf(struct ena_adapter *adapter,
return (0);
/* Get mbuf using UMA allocator */
- rx_info->mbuf = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, MJUM16BYTES);
+ rx_info->mbuf = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR,
+ rx_ring->rx_mbuf_sz);
if (unlikely(rx_info->mbuf == NULL)) {
counter_u64_add(rx_ring->rx_stats.mjum_alloc_fail, 1);
@@ -968,7 +983,7 @@ ena_alloc_rx_mbuf(struct ena_adapter *adapter,
}
mlen = MCLBYTES;
} else {
- mlen = MJUM16BYTES;
+ mlen = rx_ring->rx_mbuf_sz;
}
/* Set mbuf length*/
rx_info->mbuf->m_pkthdr.len = rx_info->mbuf->m_len = mlen;
diff --git a/sys/dev/ena/ena.h b/sys/dev/ena/ena.h
index 1d9194e24616..94f842ecf448 100644
--- a/sys/dev/ena/ena.h
+++ b/sys/dev/ena/ena.h
@@ -41,7 +41,7 @@
#define DRV_MODULE_VER_MAJOR 0
#define DRV_MODULE_VER_MINOR 8
-#define DRV_MODULE_VER_SUBMINOR 4
+#define DRV_MODULE_VER_SUBMINOR 5
#define DRV_MODULE_NAME "ena"
@@ -238,8 +238,12 @@ struct ena_ring {
/* Determines if device will use LLQ or normal mode for TX */
enum ena_admin_placement_policy_type tx_mem_queue_type;
- /* The maximum length the driver can push to the device (For LLQ) */
- uint8_t tx_max_header_size;
+ union {
+ /* The maximum length the driver can push to the device (For LLQ) */
+ uint8_t tx_max_header_size;
+ /* The maximum (and default) mbuf size for the Rx descriptor. */
+ uint16_t rx_mbuf_sz;
+ };
struct ena_com_rx_buf_info ena_bufs[ENA_PKT_MAX_BUFS];