svn commit: r331675 - in user/markj/netdump/sys: dev/alc dev/bge dev/re dev/virtio/network net netinet/netdump
Mark Johnston
markj at FreeBSD.org
Wed Mar 28 14:31:13 UTC 2018
Author: markj
Date: Wed Mar 28 14:31:12 2018
New Revision: 331675
URL: https://svnweb.freebsd.org/changeset/base/331675
Log:
Simplify the driver configuration routine, and use ifnet accessors.
Modified:
user/markj/netdump/sys/dev/alc/if_alc.c
user/markj/netdump/sys/dev/bge/if_bge.c
user/markj/netdump/sys/dev/re/if_re.c
user/markj/netdump/sys/dev/virtio/network/if_vtnet.c
user/markj/netdump/sys/net/iflib.c
user/markj/netdump/sys/netinet/netdump/netdump.h
user/markj/netdump/sys/netinet/netdump/netdump_client.c
Modified: user/markj/netdump/sys/dev/alc/if_alc.c
==============================================================================
--- user/markj/netdump/sys/dev/alc/if_alc.c Wed Mar 28 14:29:34 2018 (r331674)
+++ user/markj/netdump/sys/dev/alc/if_alc.c Wed Mar 28 14:31:12 2018 (r331675)
@@ -4658,11 +4658,10 @@ sysctl_hw_alc_int_mod(SYSCTL_HANDLER_ARGS)
#ifdef NETDUMP
static void
-alc_netdump_init(struct ifnet *ifp, int *nmbufp, int *nclustp)
+alc_netdump_init(struct ifnet *ifp __unused, int *nrxr)
{
- *nmbufp += ALC_RX_RING_CNT;
- *nclustp += ALC_RX_RING_CNT;
+ *nrxr = ALC_RX_RING_CNT;
}
static void
@@ -4670,7 +4669,7 @@ alc_netdump_event(struct ifnet *ifp, enum netdump_ev e
{
struct alc_softc *sc;
- sc = ifp->if_softc;
+ sc = if_getsoftc(ifp);
switch (event) {
case NETDUMP_START:
sc->alc_buf_size = imin(sc->alc_buf_size, MCLBYTES);
@@ -4686,8 +4685,7 @@ alc_netdump_transmit(struct ifnet *ifp, struct mbuf *m
struct alc_softc *sc;
int error;
- sc = ifp->if_softc;
-
+ sc = if_getsoftc(ifp);
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING)
return (EBUSY);
@@ -4703,8 +4701,7 @@ alc_netdump_poll(struct ifnet *ifp, int count)
{
struct alc_softc *sc;
- sc = ifp->if_softc;
-
+ sc = if_getsoftc(ifp);
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING)
return (EBUSY);
Modified: user/markj/netdump/sys/dev/bge/if_bge.c
==============================================================================
--- user/markj/netdump/sys/dev/bge/if_bge.c Wed Mar 28 14:29:34 2018 (r331674)
+++ user/markj/netdump/sys/dev/bge/if_bge.c Wed Mar 28 14:31:12 2018 (r331675)
@@ -6811,13 +6811,12 @@ bge_get_counter(if_t ifp, ift_counter cnt)
#ifdef NETDUMP
static void
-bge_netdump_init(if_t ifp, int *nmbufp, int *nclustp)
+bge_netdump_init(if_t ifp, int *nrxr)
{
struct bge_softc *sc;
sc = if_getsoftc(ifp);
- *nmbufp += sc->bge_return_ring_cnt;
- *nclustp += sc->bge_return_ring_cnt;
+ *nrxr = sc->bge_return_ring_cnt;
}
static void
@@ -6842,11 +6841,11 @@ bge_netdump_transmit(if_t ifp, struct mbuf *m)
uint32_t prodidx;
int error;
+ sc = if_getsoftc(ifp);
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING)
return (1);
- sc = if_getsoftc(ifp);
prodidx = sc->bge_tx_prodidx;
error = bge_encap(sc, &m, &prodidx);
if (error == 0)
@@ -6861,7 +6860,6 @@ bge_netdump_poll(if_t ifp, int count)
uint32_t rx_prod, tx_cons;
sc = if_getsoftc(ifp);
-
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING)
return (1);
Modified: user/markj/netdump/sys/dev/re/if_re.c
==============================================================================
--- user/markj/netdump/sys/dev/re/if_re.c Wed Mar 28 14:29:34 2018 (r331674)
+++ user/markj/netdump/sys/dev/re/if_re.c Wed Mar 28 14:31:12 2018 (r331675)
@@ -4095,14 +4095,12 @@ sysctl_hw_re_int_mod(SYSCTL_HANDLER_ARGS)
#ifdef NETDUMP
static void
-re_netdump_init(struct ifnet *ifp, int *nmbufp, int *nclustp)
+re_netdump_init(struct ifnet *ifp, int *nrxr)
{
struct rl_softc *sc;
- sc = ifp->if_softc;
-
- *nmbufp += sc->rl_ldata.rl_rx_desc_cnt;
- *nclustp += sc->rl_ldata.rl_rx_desc_cnt;
+ sc = if_getsoftc(ifp);
+ *nrxr = sc->rl_ldata.rl_rx_desc_cnt;
}
static void
@@ -4110,8 +4108,7 @@ re_netdump_event(struct ifnet *ifp, enum netdump_ev ev
{
struct rl_softc *sc;
- sc = ifp->if_softc;
-
+ sc = if_getsoftc(ifp);
switch (event) {
case NETDUMP_START:
sc->rl_flags &= ~RL_FLAG_JUMBOV2;
@@ -4127,9 +4124,8 @@ re_netdump_transmit(struct ifnet *ifp, struct mbuf *m)
struct rl_softc *sc;
int error;
- sc = ifp->if_softc;
-
- if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
+ sc = if_getsoftc(ifp);
+ if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING || (sc->rl_flags & RL_FLAG_LINK) == 0)
return (EBUSY);
@@ -4145,10 +4141,9 @@ re_netdump_poll(struct ifnet *ifp, int count)
struct rl_softc *sc;
int error;
- sc = ifp->if_softc;
-
- if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
- IFF_DRV_RUNNING || (sc->rl_flags & RL_FLAG_LINK) == 0)
+ sc = if_getsoftc(ifp);
+ if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0 ||
+ (sc->rl_flags & RL_FLAG_LINK) == 0)
return (EBUSY);
re_txeof(sc);
Modified: user/markj/netdump/sys/dev/virtio/network/if_vtnet.c
==============================================================================
--- user/markj/netdump/sys/dev/virtio/network/if_vtnet.c Wed Mar 28 14:29:34 2018 (r331674)
+++ user/markj/netdump/sys/dev/virtio/network/if_vtnet.c Wed Mar 28 14:31:12 2018 (r331675)
@@ -3984,20 +3984,14 @@ vtnet_tunable_int(struct vtnet_softc *sc, const char *
#ifdef NETDUMP
static void
-vtnet_netdump_init(struct ifnet *ifp, int *nmbufp, int *nclustp)
+vtnet_netdump_init(struct ifnet *ifp, int *nrxr)
{
struct vtnet_softc *sc;
- sc = ifp->if_softc;
+ sc = if_getsoftc(ifp);
+ *nrxr = sc->vtnet_max_vq_pairs;
/*
- * Allocate enough packet buffers to fill an entire queue. This ought
- * to be enough provided that we don't have many queues.
- */
- *nmbufp += virtqueue_size(sc->vtnet_rxqs[0].vtnrx_vq);
- *nclustp += virtqueue_size(sc->vtnet_rxqs[0].vtnrx_vq);
-
- /*
* We need to allocate from this zone in the transmit path, so ensure
* that we have at least one item per header available.
* XXX add a separate zone like we do for mbufs? otherwise we may alloc
@@ -4012,8 +4006,7 @@ vtnet_netdump_event(struct ifnet *ifp, enum netdump_ev
{
struct vtnet_softc *sc;
- sc = ifp->if_softc;
-
+ sc = if_getsoftc(ifp);
switch (event) {
case NETDUMP_START:
sc->vtnet_rx_clsize = MCLBYTES;
@@ -4030,8 +4023,7 @@ vtnet_netdump_transmit(struct ifnet *ifp, struct mbuf
struct vtnet_txq *txq;
int error;
- sc = ifp->if_softc;
-
+ sc = if_getsoftc(ifp);
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING)
return (EBUSY);
@@ -4049,8 +4041,7 @@ vtnet_netdump_poll(struct ifnet *ifp, int count)
struct vtnet_softc *sc;
int i;
- sc = ifp->if_softc;
-
+ sc = if_getsoftc(ifp);
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING)
return (EBUSY);
Modified: user/markj/netdump/sys/net/iflib.c
==============================================================================
--- user/markj/netdump/sys/net/iflib.c Wed Mar 28 14:29:34 2018 (r331674)
+++ user/markj/netdump/sys/net/iflib.c Wed Mar 28 14:31:12 2018 (r331675)
@@ -5973,14 +5973,12 @@ iflib_fixup_rx(struct mbuf *m)
#ifdef NETDUMP
static void
-iflib_netdump_init(struct ifnet *ifp, int *nmbufp, int *nclustp)
+iflib_netdump_init(struct ifnet *ifp, int *nrxr)
{
if_ctx_t ctx;
- ctx = ifp->if_softc;
-
- *nmbufp += ctx->ifc_rxqs[0].ifr_fl->ifl_size;
- *nclustp += ctx->ifc_rxqs[0].ifr_fl->ifl_size;
+ ctx = if_getsoftc(ifp);
+ *nrxr = NRXQSETS(ctx);
}
static void
@@ -5990,7 +5988,7 @@ iflib_netdump_event(struct ifnet *ifp, enum netdump_ev
if_softc_ctx_t scctx;
int i;
- ctx = ifp->if_softc;
+ ctx = if_getsoftc(ifp);
scctx = &ctx->ifc_softc_ctx;
switch (event) {
@@ -6011,8 +6009,7 @@ iflib_netdump_transmit(struct ifnet *ifp, struct mbuf
iflib_txq_t txq;
int error;
- ctx = ifp->if_softc;
-
+ ctx = if_getsoftc(ifp);
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING)
return (EBUSY);
@@ -6032,7 +6029,7 @@ iflib_netdump_poll(struct ifnet *ifp, int count)
iflib_txq_t txq;
int i;
- ctx = ifp->if_softc;
+ ctx = if_getsoftc(ifp);
scctx = &ctx->ifc_softc_ctx;
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
Modified: user/markj/netdump/sys/netinet/netdump/netdump.h
==============================================================================
--- user/markj/netdump/sys/netinet/netdump/netdump.h Wed Mar 28 14:29:34 2018 (r331674)
+++ user/markj/netdump/sys/netinet/netdump/netdump.h Wed Mar 28 14:31:12 2018 (r331675)
@@ -86,7 +86,7 @@ enum netdump_ev {
struct ifnet;
struct mbuf;
-typedef void netdump_init_t(struct ifnet *, int *nmbufp, int *nclustp);
+typedef void netdump_init_t(struct ifnet *, int *nrxr);
typedef void netdump_event_t(struct ifnet *, enum netdump_ev);
typedef int netdump_transmit_t(struct ifnet *, struct mbuf *);
typedef int netdump_poll_t(struct ifnet *, int);
Modified: user/markj/netdump/sys/netinet/netdump/netdump_client.c
==============================================================================
--- user/markj/netdump/sys/netinet/netdump/netdump_client.c Wed Mar 28 14:29:34 2018 (r331674)
+++ user/markj/netdump/sys/netinet/netdump/netdump_client.c Wed Mar 28 14:31:12 2018 (r331675)
@@ -1048,7 +1048,7 @@ static int
netdump_configure(struct netdump_conf *conf)
{
struct ifnet *ifp;
- int nmbuf, nclust;
+ int nmbuf, nclust, nrxr;
IFNET_RLOCK_NOSLEEP();
TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
@@ -1067,13 +1067,15 @@ netdump_configure(struct netdump_conf *conf)
return (1);
}
+ ifp->if_netdump_methods->nd_init(ifp, &nrxr);
+ KASSERT(nrxr > 0, ("invalid receive ring count %d", nrxr));
+
/*
- * We need two headers per message. Multiply by four to give us some
- * breathing room.
+ * We need two headers per message on the transmit side. Multiply by
+ * four to give us some breathing room.
*/
- nmbuf = NETDUMP_MAX_IN_FLIGHT * 4;
- nclust = 0;
- ifp->if_netdump_methods->nd_init(ifp, &nmbuf, &nclust);
+ nmbuf = NETDUMP_MAX_IN_FLIGHT * (4 + nrxr);
+ nclust = NETDUMP_MAX_IN_FLIGHT * nrxr;
netdump_mbuf_init(nmbuf, nclust);
nd_ifp = ifp;
More information about the svn-src-user
mailing list