Commit 145daab2 authored by Juergen Gross's avatar Juergen Gross

xen/netfront: switch netfront to use INVALID_GRANT_REF

Instead of using a private macro for an invalid grant reference use
the common one.
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
parent 21b53971
...@@ -78,8 +78,6 @@ struct netfront_cb { ...@@ -78,8 +78,6 @@ struct netfront_cb {
#define RX_COPY_THRESHOLD 256 #define RX_COPY_THRESHOLD 256
#define GRANT_INVALID_REF 0
#define NET_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, XEN_PAGE_SIZE) #define NET_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, XEN_PAGE_SIZE)
#define NET_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, XEN_PAGE_SIZE) #define NET_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, XEN_PAGE_SIZE)
...@@ -224,7 +222,7 @@ static grant_ref_t xennet_get_rx_ref(struct netfront_queue *queue, ...@@ -224,7 +222,7 @@ static grant_ref_t xennet_get_rx_ref(struct netfront_queue *queue,
{ {
int i = xennet_rxidx(ri); int i = xennet_rxidx(ri);
grant_ref_t ref = queue->grant_rx_ref[i]; grant_ref_t ref = queue->grant_rx_ref[i];
queue->grant_rx_ref[i] = GRANT_INVALID_REF; queue->grant_rx_ref[i] = INVALID_GRANT_REF;
return ref; return ref;
} }
...@@ -432,7 +430,7 @@ static bool xennet_tx_buf_gc(struct netfront_queue *queue) ...@@ -432,7 +430,7 @@ static bool xennet_tx_buf_gc(struct netfront_queue *queue)
} }
gnttab_release_grant_reference( gnttab_release_grant_reference(
&queue->gref_tx_head, queue->grant_tx_ref[id]); &queue->gref_tx_head, queue->grant_tx_ref[id]);
queue->grant_tx_ref[id] = GRANT_INVALID_REF; queue->grant_tx_ref[id] = INVALID_GRANT_REF;
queue->grant_tx_page[id] = NULL; queue->grant_tx_page[id] = NULL;
add_id_to_list(&queue->tx_skb_freelist, queue->tx_link, id); add_id_to_list(&queue->tx_skb_freelist, queue->tx_link, id);
dev_kfree_skb_irq(skb); dev_kfree_skb_irq(skb);
...@@ -1021,7 +1019,7 @@ static int xennet_get_responses(struct netfront_queue *queue, ...@@ -1021,7 +1019,7 @@ static int xennet_get_responses(struct netfront_queue *queue,
* the backend driver. In future this should flag the bad * the backend driver. In future this should flag the bad
* situation to the system controller to reboot the backend. * situation to the system controller to reboot the backend.
*/ */
if (ref == GRANT_INVALID_REF) { if (ref == INVALID_GRANT_REF) {
if (net_ratelimit()) if (net_ratelimit())
dev_warn(dev, "Bad rx response id %d.\n", dev_warn(dev, "Bad rx response id %d.\n",
rx->id); rx->id);
...@@ -1390,7 +1388,7 @@ static void xennet_release_tx_bufs(struct netfront_queue *queue) ...@@ -1390,7 +1388,7 @@ static void xennet_release_tx_bufs(struct netfront_queue *queue)
gnttab_end_foreign_access(queue->grant_tx_ref[i], gnttab_end_foreign_access(queue->grant_tx_ref[i],
(unsigned long)page_address(queue->grant_tx_page[i])); (unsigned long)page_address(queue->grant_tx_page[i]));
queue->grant_tx_page[i] = NULL; queue->grant_tx_page[i] = NULL;
queue->grant_tx_ref[i] = GRANT_INVALID_REF; queue->grant_tx_ref[i] = INVALID_GRANT_REF;
add_id_to_list(&queue->tx_skb_freelist, queue->tx_link, i); add_id_to_list(&queue->tx_skb_freelist, queue->tx_link, i);
dev_kfree_skb_irq(skb); dev_kfree_skb_irq(skb);
} }
...@@ -1411,7 +1409,7 @@ static void xennet_release_rx_bufs(struct netfront_queue *queue) ...@@ -1411,7 +1409,7 @@ static void xennet_release_rx_bufs(struct netfront_queue *queue)
continue; continue;
ref = queue->grant_rx_ref[id]; ref = queue->grant_rx_ref[id];
if (ref == GRANT_INVALID_REF) if (ref == INVALID_GRANT_REF)
continue; continue;
page = skb_frag_page(&skb_shinfo(skb)->frags[0]); page = skb_frag_page(&skb_shinfo(skb)->frags[0]);
...@@ -1422,7 +1420,7 @@ static void xennet_release_rx_bufs(struct netfront_queue *queue) ...@@ -1422,7 +1420,7 @@ static void xennet_release_rx_bufs(struct netfront_queue *queue)
get_page(page); get_page(page);
gnttab_end_foreign_access(ref, gnttab_end_foreign_access(ref,
(unsigned long)page_address(page)); (unsigned long)page_address(page));
queue->grant_rx_ref[id] = GRANT_INVALID_REF; queue->grant_rx_ref[id] = INVALID_GRANT_REF;
kfree_skb(skb); kfree_skb(skb);
} }
...@@ -1761,7 +1759,7 @@ static int netfront_probe(struct xenbus_device *dev, ...@@ -1761,7 +1759,7 @@ static int netfront_probe(struct xenbus_device *dev,
static void xennet_end_access(int ref, void *page) static void xennet_end_access(int ref, void *page)
{ {
/* This frees the page as a side-effect */ /* This frees the page as a side-effect */
if (ref != GRANT_INVALID_REF) if (ref != INVALID_GRANT_REF)
gnttab_end_foreign_access(ref, (unsigned long)page); gnttab_end_foreign_access(ref, (unsigned long)page);
} }
...@@ -1798,8 +1796,8 @@ static void xennet_disconnect_backend(struct netfront_info *info) ...@@ -1798,8 +1796,8 @@ static void xennet_disconnect_backend(struct netfront_info *info)
xennet_end_access(queue->tx_ring_ref, queue->tx.sring); xennet_end_access(queue->tx_ring_ref, queue->tx.sring);
xennet_end_access(queue->rx_ring_ref, queue->rx.sring); xennet_end_access(queue->rx_ring_ref, queue->rx.sring);
queue->tx_ring_ref = GRANT_INVALID_REF; queue->tx_ring_ref = INVALID_GRANT_REF;
queue->rx_ring_ref = GRANT_INVALID_REF; queue->rx_ring_ref = INVALID_GRANT_REF;
queue->tx.sring = NULL; queue->tx.sring = NULL;
queue->rx.sring = NULL; queue->rx.sring = NULL;
...@@ -1927,8 +1925,8 @@ static int setup_netfront(struct xenbus_device *dev, ...@@ -1927,8 +1925,8 @@ static int setup_netfront(struct xenbus_device *dev,
grant_ref_t gref; grant_ref_t gref;
int err; int err;
queue->tx_ring_ref = GRANT_INVALID_REF; queue->tx_ring_ref = INVALID_GRANT_REF;
queue->rx_ring_ref = GRANT_INVALID_REF; queue->rx_ring_ref = INVALID_GRANT_REF;
queue->rx.sring = NULL; queue->rx.sring = NULL;
queue->tx.sring = NULL; queue->tx.sring = NULL;
...@@ -1978,17 +1976,17 @@ static int setup_netfront(struct xenbus_device *dev, ...@@ -1978,17 +1976,17 @@ static int setup_netfront(struct xenbus_device *dev,
* granted pages because backend is not accessing it at this point. * granted pages because backend is not accessing it at this point.
*/ */
fail: fail:
if (queue->rx_ring_ref != GRANT_INVALID_REF) { if (queue->rx_ring_ref != INVALID_GRANT_REF) {
gnttab_end_foreign_access(queue->rx_ring_ref, gnttab_end_foreign_access(queue->rx_ring_ref,
(unsigned long)rxs); (unsigned long)rxs);
queue->rx_ring_ref = GRANT_INVALID_REF; queue->rx_ring_ref = INVALID_GRANT_REF;
} else { } else {
free_page((unsigned long)rxs); free_page((unsigned long)rxs);
} }
if (queue->tx_ring_ref != GRANT_INVALID_REF) { if (queue->tx_ring_ref != INVALID_GRANT_REF) {
gnttab_end_foreign_access(queue->tx_ring_ref, gnttab_end_foreign_access(queue->tx_ring_ref,
(unsigned long)txs); (unsigned long)txs);
queue->tx_ring_ref = GRANT_INVALID_REF; queue->tx_ring_ref = INVALID_GRANT_REF;
} else { } else {
free_page((unsigned long)txs); free_page((unsigned long)txs);
} }
...@@ -2020,7 +2018,7 @@ static int xennet_init_queue(struct netfront_queue *queue) ...@@ -2020,7 +2018,7 @@ static int xennet_init_queue(struct netfront_queue *queue)
queue->tx_pend_queue = TX_LINK_NONE; queue->tx_pend_queue = TX_LINK_NONE;
for (i = 0; i < NET_TX_RING_SIZE; i++) { for (i = 0; i < NET_TX_RING_SIZE; i++) {
queue->tx_link[i] = i + 1; queue->tx_link[i] = i + 1;
queue->grant_tx_ref[i] = GRANT_INVALID_REF; queue->grant_tx_ref[i] = INVALID_GRANT_REF;
queue->grant_tx_page[i] = NULL; queue->grant_tx_page[i] = NULL;
} }
queue->tx_link[NET_TX_RING_SIZE - 1] = TX_LINK_NONE; queue->tx_link[NET_TX_RING_SIZE - 1] = TX_LINK_NONE;
...@@ -2028,7 +2026,7 @@ static int xennet_init_queue(struct netfront_queue *queue) ...@@ -2028,7 +2026,7 @@ static int xennet_init_queue(struct netfront_queue *queue)
/* Clear out rx_skbs */ /* Clear out rx_skbs */
for (i = 0; i < NET_RX_RING_SIZE; i++) { for (i = 0; i < NET_RX_RING_SIZE; i++) {
queue->rx_skbs[i] = NULL; queue->rx_skbs[i] = NULL;
queue->grant_rx_ref[i] = GRANT_INVALID_REF; queue->grant_rx_ref[i] = INVALID_GRANT_REF;
} }
/* A grant for every tx ring slot */ /* A grant for every tx ring slot */
......
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