svn commit: r347212 - in stable/11/sys: net sys
Eric Joyner
erj at FreeBSD.org
Mon May 6 21:21:16 UTC 2019
Author: erj
Date: Mon May 6 21:21:15 2019
New Revision: 347212
URL: https://svnweb.freebsd.org/changeset/base/347212
Log:
MFC r345303, 345658, and partially MFC r345305
These are:
r345303: prevent possible infinite loop in iflib_encap
r345305: expose the Rx mbuf buffer size to drivers
r345658: return ENETDOWN when the network device is down
r345305 is only partially MFC'd with no mergeinfo because it includes
changes to iflib-using drivers, and none of the drivers it changes use
iflib in stable/11. This commit just makes the function it adds available
for use with iflib-using kernel modules.
Sponsored by: Intel Corporation
Modified:
stable/11/sys/net/iflib.c
stable/11/sys/net/iflib.h
stable/11/sys/sys/param.h
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/net/iflib.c
==============================================================================
--- stable/11/sys/net/iflib.c Mon May 6 20:56:41 2019 (r347211)
+++ stable/11/sys/net/iflib.c Mon May 6 21:21:15 2019 (r347212)
@@ -176,6 +176,7 @@ struct iflib_ctx {
uint32_t ifc_if_flags;
uint32_t ifc_flags;
uint32_t ifc_max_fl_buf_size;
+ uint32_t ifc_rx_mbuf_sz;
int ifc_link_state;
int ifc_link_irq;
@@ -2033,7 +2034,6 @@ iflib_fl_setup(iflib_fl_t fl)
{
iflib_rxq_t rxq = fl->ifl_rxq;
if_ctx_t ctx = rxq->ifr_ctx;
- if_softc_ctx_t sctx = &ctx->ifc_softc_ctx;
bit_nclear(fl->ifl_rx_bitmap, 0, fl->ifl_size - 1);
/*
@@ -2042,14 +2042,7 @@ iflib_fl_setup(iflib_fl_t fl)
iflib_fl_bufs_free(fl);
/* Now replenish the mbufs */
MPASS(fl->ifl_credits == 0);
- /*
- * XXX don't set the max_frame_size to larger
- * than the hardware can handle
- */
- if (sctx->isc_max_frame_size <= 2048)
- fl->ifl_buf_size = MCLBYTES;
- else
- fl->ifl_buf_size = MJUMPAGESIZE;
+ fl->ifl_buf_size = ctx->ifc_rx_mbuf_sz;
if (fl->ifl_buf_size > ctx->ifc_max_fl_buf_size)
ctx->ifc_max_fl_buf_size = fl->ifl_buf_size;
fl->ifl_cltype = m_gettype(fl->ifl_buf_size);
@@ -2151,6 +2144,27 @@ iflib_timer(void *arg)
}
static void
+iflib_calc_rx_mbuf_sz(if_ctx_t ctx)
+{
+ if_softc_ctx_t sctx = &ctx->ifc_softc_ctx;
+
+ /*
+ * XXX don't set the max_frame_size to larger
+ * than the hardware can handle
+ */
+ if (sctx->isc_max_frame_size <= MCLBYTES)
+ ctx->ifc_rx_mbuf_sz = MCLBYTES;
+ else
+ ctx->ifc_rx_mbuf_sz = MJUMPAGESIZE;
+}
+
+uint32_t
+iflib_get_rx_mbuf_sz(if_ctx_t ctx)
+{
+ return (ctx->ifc_rx_mbuf_sz);
+}
+
+static void
iflib_init_locked(if_ctx_t ctx)
{
if_softc_ctx_t sctx = &ctx->ifc_softc_ctx;
@@ -2184,6 +2198,14 @@ iflib_init_locked(if_ctx_t ctx)
CALLOUT_UNLOCK(txq);
iflib_netmap_txq_init(ctx, txq);
}
+
+ /*
+ * Calculate a suitable Rx mbuf size prior to calling IFDI_INIT, so
+ * that drivers can use the value when setting up the hardware receive
+ * buffers.
+ */
+ iflib_calc_rx_mbuf_sz(ctx);
+
#ifdef INVARIANTS
i = if_getdrvflags(ifp);
#endif
@@ -3251,9 +3273,14 @@ defrag:
}
if (remap == 1)
m_head = m_defrag(*m_headp, M_NOWAIT);
- remap++;
- if (__predict_false(m_head == NULL))
+ /*
+ * remap should never be >1 unless bus_dmamap_load_mbuf_sg
+ * failed to map an mbuf that was run through m_defrag
+ */
+ MPASS(remap <= 1);
+ if (__predict_false(m_head == NULL || remap > 1))
goto defrag_failed;
+ remap++;
txq->ift_mbuf_defrag++;
*m_headp = m_head;
goto retry;
@@ -3825,7 +3852,7 @@ iflib_if_transmit(if_t ifp, struct mbuf *m)
if (__predict_false((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || !LINK_ACTIVE(ctx))) {
DBG_COUNTER_INC(tx_frees);
m_freem(m);
- return (ENOBUFS);
+ return (ENETDOWN);
}
MPASS(m->m_nextpkt == NULL);
Modified: stable/11/sys/net/iflib.h
==============================================================================
--- stable/11/sys/net/iflib.h Mon May 6 20:56:41 2019 (r347211)
+++ stable/11/sys/net/iflib.h Mon May 6 21:21:15 2019 (r347212)
@@ -345,6 +345,8 @@ void iflib_set_mac(if_ctx_t ctx, uint8_t mac[ETHER_ADD
void iflib_request_reset(if_ctx_t ctx);
uint8_t iflib_in_detach(if_ctx_t ctx);
+uint32_t iflib_get_rx_mbuf_sz(if_ctx_t ctx);
+
/*
* If the driver can plug cleanly in to newbus use these
*/
Modified: stable/11/sys/sys/param.h
==============================================================================
--- stable/11/sys/sys/param.h Mon May 6 20:56:41 2019 (r347211)
+++ stable/11/sys/sys/param.h Mon May 6 21:21:15 2019 (r347212)
@@ -58,7 +58,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1102508 /* Master, propagated to newvers */
+#define __FreeBSD_version 1102509 /* Master, propagated to newvers */
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
More information about the svn-src-all
mailing list