diff options
author | Zoltan Kiss <zoltan.kiss@citrix.com> | 2014-03-06 22:48:23 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-03-07 21:56:34 +0100 |
commit | 8f13dd9612286cc0d38d32ff9543763b7c74f6a5 (patch) | |
tree | 90f0d6b5accf80a8a3cc0390c04a142f0c7b0bf1 /drivers | |
parent | l2tp: keep original skb ownership (diff) | |
download | linux-8f13dd9612286cc0d38d32ff9543763b7c74f6a5.tar.xz linux-8f13dd9612286cc0d38d32ff9543763b7c74f6a5.zip |
xen-netback: Use skb->cb for pending_idx
Storing the pending_idx at the first byte of the linear buffer never looked
good, skb->cb is a more proper place for this. It also prevents the header to
be directly grant copied there, and we don't have the pending_idx after we
copied the header here, so it's time to change it.
It also introduces helpers for the RX side
Signed-off-by: Zoltan Kiss <zoltan.kiss@citrix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/xen-netback/netback.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index e5284bca2d90..43ae4bad50c4 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c @@ -455,10 +455,12 @@ static void xenvif_add_frag_responses(struct xenvif *vif, int status, } } -struct skb_cb_overlay { +struct xenvif_rx_cb { int meta_slots_used; }; +#define XENVIF_RX_CB(skb) ((struct xenvif_rx_cb *)(skb)->cb) + void xenvif_kick_thread(struct xenvif *vif) { wake_up(&vif->wq); @@ -474,7 +476,6 @@ static void xenvif_rx_action(struct xenvif *vif) LIST_HEAD(notify); int ret; unsigned long offset; - struct skb_cb_overlay *sco; bool need_to_notify = false; struct netrx_pending_operations npo = { @@ -513,9 +514,8 @@ static void xenvif_rx_action(struct xenvif *vif) } else vif->rx_last_skb_slots = 0; - sco = (struct skb_cb_overlay *)skb->cb; - sco->meta_slots_used = xenvif_gop_skb(skb, &npo); - BUG_ON(sco->meta_slots_used > max_slots_needed); + XENVIF_RX_CB(skb)->meta_slots_used = xenvif_gop_skb(skb, &npo); + BUG_ON(XENVIF_RX_CB(skb)->meta_slots_used > max_slots_needed); __skb_queue_tail(&rxq, skb); } @@ -529,7 +529,6 @@ static void xenvif_rx_action(struct xenvif *vif) gnttab_batch_copy(vif->grant_copy_op, npo.copy_prod); while ((skb = __skb_dequeue(&rxq)) != NULL) { - sco = (struct skb_cb_overlay *)skb->cb; if ((1 << vif->meta[npo.meta_cons].gso_type) & vif->gso_prefix_mask) { @@ -540,19 +539,21 @@ static void xenvif_rx_action(struct xenvif *vif) resp->offset = vif->meta[npo.meta_cons].gso_size; resp->id = vif->meta[npo.meta_cons].id; - resp->status = sco->meta_slots_used; + resp->status = XENVIF_RX_CB(skb)->meta_slots_used; npo.meta_cons++; - sco->meta_slots_used--; + XENVIF_RX_CB(skb)->meta_slots_used--; } vif->dev->stats.tx_bytes += skb->len; vif->dev->stats.tx_packets++; - status = xenvif_check_gop(vif, sco->meta_slots_used, &npo); + status = xenvif_check_gop(vif, + XENVIF_RX_CB(skb)->meta_slots_used, + &npo); - if (sco->meta_slots_used == 1) + if (XENVIF_RX_CB(skb)->meta_slots_used == 1) flags = 0; else flags = XEN_NETRXF_more_data; @@ -589,13 +590,13 @@ static void xenvif_rx_action(struct xenvif *vif) xenvif_add_frag_responses(vif, status, vif->meta + npo.meta_cons + 1, - sco->meta_slots_used); + XENVIF_RX_CB(skb)->meta_slots_used); RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&vif->rx, ret); need_to_notify |= !!ret; - npo.meta_cons += sco->meta_slots_used; + npo.meta_cons += XENVIF_RX_CB(skb)->meta_slots_used; dev_kfree_skb(skb); } @@ -772,6 +773,13 @@ static struct page *xenvif_alloc_page(struct xenvif *vif, return page; } + +struct xenvif_tx_cb { + u16 pending_idx; +}; + +#define XENVIF_TX_CB(skb) ((struct xenvif_tx_cb *)(skb)->cb) + static struct gnttab_copy *xenvif_get_requests(struct xenvif *vif, struct sk_buff *skb, struct xen_netif_tx_request *txp, @@ -779,7 +787,7 @@ static struct gnttab_copy *xenvif_get_requests(struct xenvif *vif, { struct skb_shared_info *shinfo = skb_shinfo(skb); skb_frag_t *frags = shinfo->frags; - u16 pending_idx = *((u16 *)skb->data); + u16 pending_idx = XENVIF_TX_CB(skb)->pending_idx; u16 head_idx = 0; int slot, start; struct page *page; @@ -897,7 +905,7 @@ static int xenvif_tx_check_gop(struct xenvif *vif, struct gnttab_copy **gopp) { struct gnttab_copy *gop = *gopp; - u16 pending_idx = *((u16 *)skb->data); + u16 pending_idx = XENVIF_TX_CB(skb)->pending_idx; struct skb_shared_info *shinfo = skb_shinfo(skb); struct pending_tx_info *tx_info; int nr_frags = shinfo->nr_frags; @@ -944,7 +952,7 @@ static int xenvif_tx_check_gop(struct xenvif *vif, continue; /* First error: invalidate header and preceding fragments. */ - pending_idx = *((u16 *)skb->data); + pending_idx = XENVIF_TX_CB(skb)->pending_idx; xenvif_idx_release(vif, pending_idx, XEN_NETIF_RSP_OKAY); for (j = start; j < i; j++) { pending_idx = frag_get_pending_idx(&shinfo->frags[j]); @@ -1236,7 +1244,7 @@ static unsigned xenvif_tx_build_gops(struct xenvif *vif, int budget) memcpy(&vif->pending_tx_info[pending_idx].req, &txreq, sizeof(txreq)); vif->pending_tx_info[pending_idx].head = index; - *((u16 *)skb->data) = pending_idx; + XENVIF_TX_CB(skb)->pending_idx = pending_idx; __skb_put(skb, data_len); @@ -1283,7 +1291,7 @@ static int xenvif_tx_submit(struct xenvif *vif) u16 pending_idx; unsigned data_len; - pending_idx = *((u16 *)skb->data); + pending_idx = XENVIF_TX_CB(skb)->pending_idx; txp = &vif->pending_tx_info[pending_idx].req; /* Check the remap error code. */ |