Commit 2439a6e6 authored by Roland Dreier's avatar Roland Dreier

IPoIB: Refactor completion handling

Split up ipoib_ib_handle_wc() into ipoib_ib_handle_rx_wc() and
ipoib_ib_handle_tx_wc() to make the code easier to read.  This will
also help implement NAPI in the future.
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent d8111028
...@@ -169,21 +169,24 @@ static int ipoib_ib_post_receives(struct net_device *dev) ...@@ -169,21 +169,24 @@ static int ipoib_ib_post_receives(struct net_device *dev)
return 0; return 0;
} }
static void ipoib_ib_handle_wc(struct net_device *dev, static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
struct ib_wc *wc)
{ {
struct ipoib_dev_priv *priv = netdev_priv(dev); struct ipoib_dev_priv *priv = netdev_priv(dev);
unsigned int wr_id = wc->wr_id; unsigned int wr_id = wc->wr_id & ~IPOIB_OP_RECV;
struct sk_buff *skb;
dma_addr_t addr;
ipoib_dbg_data(priv, "called: id %d, op %d, status: %d\n", ipoib_dbg_data(priv, "recv completion: id %d, op %d, status: %d\n",
wr_id, wc->opcode, wc->status); wr_id, wc->opcode, wc->status);
if (wr_id & IPOIB_OP_RECV) { if (unlikely(wr_id >= ipoib_recvq_size)) {
wr_id &= ~IPOIB_OP_RECV; ipoib_warn(priv, "recv completion event with wrid %d (> %d)\n",
wr_id, ipoib_recvq_size);
return;
}
if (wr_id < ipoib_recvq_size) { skb = priv->rx_ring[wr_id].skb;
struct sk_buff *skb = priv->rx_ring[wr_id].skb; addr = priv->rx_ring[wr_id].mapping;
dma_addr_t addr = priv->rx_ring[wr_id].mapping;
if (unlikely(wc->status != IB_WC_SUCCESS)) { if (unlikely(wc->status != IB_WC_SUCCESS)) {
if (wc->status != IB_WC_WR_FLUSH_ERR) if (wc->status != IB_WC_WR_FLUSH_ERR)
...@@ -234,26 +237,28 @@ static void ipoib_ib_handle_wc(struct net_device *dev, ...@@ -234,26 +237,28 @@ static void ipoib_ib_handle_wc(struct net_device *dev,
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
} }
repost: repost:
if (unlikely(ipoib_ib_post_receive(dev, wr_id))) if (unlikely(ipoib_ib_post_receive(dev, wr_id)))
ipoib_warn(priv, "ipoib_ib_post_receive failed " ipoib_warn(priv, "ipoib_ib_post_receive failed "
"for buf %d\n", wr_id); "for buf %d\n", wr_id);
} else }
ipoib_warn(priv, "completion event with wrid %d\n",
wr_id);
} else { static void ipoib_ib_handle_tx_wc(struct net_device *dev, struct ib_wc *wc)
{
struct ipoib_dev_priv *priv = netdev_priv(dev);
unsigned int wr_id = wc->wr_id;
struct ipoib_tx_buf *tx_req; struct ipoib_tx_buf *tx_req;
unsigned long flags; unsigned long flags;
if (wr_id >= ipoib_sendq_size) { ipoib_dbg_data(priv, "send completion: id %d, op %d, status: %d\n",
ipoib_warn(priv, "completion event with wrid %d (> %d)\n", wr_id, wc->opcode, wc->status);
if (unlikely(wr_id >= ipoib_sendq_size)) {
ipoib_warn(priv, "send completion event with wrid %d (> %d)\n",
wr_id, ipoib_sendq_size); wr_id, ipoib_sendq_size);
return; return;
} }
ipoib_dbg_data(priv, "send complete, wrid %d\n", wr_id);
tx_req = &priv->tx_ring[wr_id]; tx_req = &priv->tx_ring[wr_id];
dma_unmap_single(priv->ca->dma_device, dma_unmap_single(priv->ca->dma_device,
...@@ -279,7 +284,14 @@ static void ipoib_ib_handle_wc(struct net_device *dev, ...@@ -279,7 +284,14 @@ static void ipoib_ib_handle_wc(struct net_device *dev,
ipoib_warn(priv, "failed send event " ipoib_warn(priv, "failed send event "
"(status=%d, wrid=%d vend_err %x)\n", "(status=%d, wrid=%d vend_err %x)\n",
wc->status, wr_id, wc->vendor_err); wc->status, wr_id, wc->vendor_err);
} }
static void ipoib_ib_handle_wc(struct net_device *dev, struct ib_wc *wc)
{
if (wc->wr_id & IPOIB_OP_RECV)
ipoib_ib_handle_rx_wc(dev, wc);
else
ipoib_ib_handle_tx_wc(dev, wc);
} }
void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr) void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment