Make sure the transmit loop doesn't get starved in ipoib.

When the software send queue gets filled up, callbacks to
if_transmit will stop. Make sure the transmit callback
routine checks the send queue and outputs any remaining
mbufs. Else the remaining mbufs may simply sit in the
output queue blocking the transmit path.

MFC after:	3 days
Sponsored by:	Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2019-10-02 09:06:13 +00:00
parent e8f206cc60
commit 6fe20cefa3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=352955
4 changed files with 29 additions and 14 deletions

View File

@ -536,7 +536,7 @@ void ipoib_drain_cq(struct ipoib_dev_priv *priv);
int ipoib_dma_map_tx(struct ib_device *ca, struct ipoib_tx_buf *tx_req, int max);
void ipoib_dma_unmap_tx(struct ib_device *ca, struct ipoib_tx_buf *tx_req);
int ipoib_poll_tx(struct ipoib_dev_priv *priv);
int ipoib_poll_tx(struct ipoib_dev_priv *priv, bool do_start);
void ipoib_dma_unmap_rx(struct ipoib_dev_priv *priv, struct ipoib_rx_buf *rx_req);
void ipoib_dma_mb(struct ipoib_dev_priv *priv, struct mbuf *mb, unsigned int length);
@ -764,4 +764,6 @@ extern int ipoib_debug_level;
#define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff)
void ipoib_start_locked(struct ifnet *, struct ipoib_dev_priv *);
#endif /* _IPOIB_H */

View File

@ -618,8 +618,10 @@ void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm
struct ipoib_cm_tx_buf *tx_req;
struct ifnet *dev = priv->dev;
if (unlikely(priv->tx_outstanding > MAX_SEND_CQE))
while (ipoib_poll_tx(priv)); /* nothing */
if (unlikely(priv->tx_outstanding > MAX_SEND_CQE)) {
while (ipoib_poll_tx(priv, false))
; /* nothing */
}
m_adj(mb, sizeof(struct ipoib_pseudoheader));
if (unlikely(mb->m_pkthdr.len > tx->mtu)) {

View File

@ -366,7 +366,7 @@ static void ipoib_ib_handle_tx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc)
}
int
ipoib_poll_tx(struct ipoib_dev_priv *priv)
ipoib_poll_tx(struct ipoib_dev_priv *priv, bool do_start)
{
int n, i;
@ -379,6 +379,9 @@ ipoib_poll_tx(struct ipoib_dev_priv *priv)
ipoib_ib_handle_tx_wc(priv, wc);
}
if (do_start && n != 0)
ipoib_start_locked(priv->dev, priv);
return n == MAX_SEND_CQE;
}
@ -425,7 +428,7 @@ static void drain_tx_cq(struct ipoib_dev_priv *priv)
struct ifnet *dev = priv->dev;
spin_lock(&priv->lock);
while (ipoib_poll_tx(priv))
while (ipoib_poll_tx(priv, true))
; /* nothing */
if (dev->if_drv_flags & IFF_DRV_OACTIVE)
@ -482,7 +485,7 @@ ipoib_send(struct ipoib_dev_priv *priv, struct mbuf *mb,
void *phead;
if (unlikely(priv->tx_outstanding > MAX_SEND_CQE))
while (ipoib_poll_tx(priv))
while (ipoib_poll_tx(priv, false))
; /* nothing */
m_adj(mb, sizeof (struct ipoib_pseudoheader));
@ -762,7 +765,7 @@ void ipoib_drain_cq(struct ipoib_dev_priv *priv)
spin_unlock(&priv->drain_lock);
spin_lock(&priv->lock);
while (ipoib_poll_tx(priv))
while (ipoib_poll_tx(priv, true))
; /* nothing */
spin_unlock(&priv->lock);

View File

@ -773,17 +773,13 @@ ipoib_send_one(struct ipoib_dev_priv *priv, struct mbuf *mb)
return 0;
}
static void
_ipoib_start(struct ifnet *dev, struct ipoib_dev_priv *priv)
void
ipoib_start_locked(struct ifnet *dev, struct ipoib_dev_priv *priv)
{
struct mbuf *mb;
if ((dev->if_drv_flags & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING)
return;
assert_spin_locked(&priv->lock);
spin_lock(&priv->lock);
while (!IFQ_DRV_IS_EMPTY(&dev->if_snd) &&
(dev->if_drv_flags & IFF_DRV_OACTIVE) == 0) {
IFQ_DRV_DEQUEUE(&dev->if_snd, mb);
@ -792,6 +788,18 @@ _ipoib_start(struct ifnet *dev, struct ipoib_dev_priv *priv)
IPOIB_MTAP(dev, mb);
ipoib_send_one(priv, mb);
}
}
static void
_ipoib_start(struct ifnet *dev, struct ipoib_dev_priv *priv)
{
if ((dev->if_drv_flags & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) !=
IFF_DRV_RUNNING)
return;
spin_lock(&priv->lock);
ipoib_start_locked(dev, priv);
spin_unlock(&priv->lock);
}