dpaa: Use if_transmit instead of legacy if_start

This avoids a lock contention on the send queue.
This commit is contained in:
Sebastian Huber 2019-01-15 07:56:36 +01:00
parent a1bad53dc1
commit 5aa6ee55fc

View File

@ -113,15 +113,11 @@ fman_mac_enable_tx_csum(struct mbuf *m, struct qm_fd *fd,
fd->cmd |= FM_FD_CMD_RPD | FM_FD_CMD_DTC;
}
static void
fman_mac_txstart_locked(struct ifnet *ifp, struct fman_mac_softc *sc)
static int
fman_mac_tx(struct ifnet *ifp, struct mbuf *m)
{
FMAN_MAC_ASSERT_LOCKED(sc);
for (;;) {
struct fman_mac_softc *sc;
struct fman_mac_sgt *sgt;
struct mbuf *m;
struct mbuf *n;
struct qm_fd fd;
struct dpaa_priv *priv;
@ -130,16 +126,13 @@ fman_mac_txstart_locked(struct ifnet *ifp, struct fman_mac_softc *sc)
size_t i;
int err;
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
if (m == NULL) {
break;
}
sc = ifp->if_softc;
sgt = uma_zalloc(fman_mac_sgt_zone, M_NOWAIT);
if (sgt == NULL) {
if (unlikely(sgt == NULL)) {
if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1);
m_freem(m);
continue;
return (ENOBUFS);
}
qm_fd_clear_fd(&fd);
@ -169,7 +162,7 @@ repeat_with_collapsed_mbuf_chain:
n = n->m_next;
}
if (n != NULL && i == DPAA_SGT_MAX_ENTRIES) {
if (unlikely(n != NULL && i == DPAA_SGT_MAX_ENTRIES)) {
struct mbuf *c;
c = m_collapse(m, M_NOWAIT, DPAA_SGT_MAX_ENTRIES);
@ -177,7 +170,7 @@ repeat_with_collapsed_mbuf_chain:
if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1);
m_freem(m);
uma_zfree(fman_mac_sgt_zone, sgt);
continue;
return (ENOBUFS);
}
m = c;
@ -192,7 +185,7 @@ repeat_with_collapsed_mbuf_chain:
for (i = 0; i < DPAA_ENQUEUE_RETRIES; ++i) {
err = qman_enqueue(egress_fq, &fd);
if (err != -EBUSY) {
if (likely(err != -EBUSY)) {
break;
}
}
@ -200,21 +193,10 @@ repeat_with_collapsed_mbuf_chain:
if (unlikely(err < 0)) {
if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1);
m_freem(m);
continue;
return (ENOBUFS);
}
}
}
static void
fman_mac_txstart(struct ifnet *ifp)
{
struct fman_mac_softc *sc;
sc = ifp->if_softc;
FMAN_MAC_LOCK(sc);
fman_mac_txstart_locked(ifp, sc);
FMAN_MAC_UNLOCK(sc);
return (0);
}
static void
@ -447,7 +429,8 @@ fman_mac_dev_attach(device_t dev)
IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU;
ifp->if_capenable = ifp->if_capabilities;
ifp->if_hwassist = FMAN_MAC_CSUM;
ifp->if_start = fman_mac_txstart;
ifp->if_transmit = fman_mac_tx;
ifp->if_qflush = if_qflush;
ifp->if_ioctl = fman_mac_ioctl;
ifp->if_init = fman_mac_init;
IFQ_SET_MAXLEN(&ifp->if_snd, 128);