aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/xen-netfront.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/xen-netfront.c')
-rw-r--r--drivers/net/xen-netfront.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index ef671d1a3bf..902bbe78821 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -92,7 +92,7 @@ struct netfront_info {
92 */ 92 */
93 union skb_entry { 93 union skb_entry {
94 struct sk_buff *skb; 94 struct sk_buff *skb;
95 unsigned link; 95 unsigned long link;
96 } tx_skbs[NET_TX_RING_SIZE]; 96 } tx_skbs[NET_TX_RING_SIZE];
97 grant_ref_t gref_tx_head; 97 grant_ref_t gref_tx_head;
98 grant_ref_t grant_tx_ref[NET_TX_RING_SIZE]; 98 grant_ref_t grant_tx_ref[NET_TX_RING_SIZE];
@@ -125,6 +125,17 @@ struct netfront_rx_info {
125 struct xen_netif_extra_info extras[XEN_NETIF_EXTRA_TYPE_MAX - 1]; 125 struct xen_netif_extra_info extras[XEN_NETIF_EXTRA_TYPE_MAX - 1];
126}; 126};
127 127
128static void skb_entry_set_link(union skb_entry *list, unsigned short id)
129{
130 list->link = id;
131}
132
133static int skb_entry_is_link(const union skb_entry *list)
134{
135 BUILD_BUG_ON(sizeof(list->skb) != sizeof(list->link));
136 return ((unsigned long)list->skb < PAGE_OFFSET);
137}
138
128/* 139/*
129 * Access macros for acquiring freeing slots in tx_skbs[]. 140 * Access macros for acquiring freeing slots in tx_skbs[].
130 */ 141 */
@@ -132,7 +143,7 @@ struct netfront_rx_info {
132static void add_id_to_freelist(unsigned *head, union skb_entry *list, 143static void add_id_to_freelist(unsigned *head, union skb_entry *list,
133 unsigned short id) 144 unsigned short id)
134{ 145{
135 list[id].link = *head; 146 skb_entry_set_link(&list[id], *head);
136 *head = id; 147 *head = id;
137} 148}
138 149
@@ -993,7 +1004,7 @@ static void xennet_release_tx_bufs(struct netfront_info *np)
993 1004
994 for (i = 0; i < NET_TX_RING_SIZE; i++) { 1005 for (i = 0; i < NET_TX_RING_SIZE; i++) {
995 /* Skip over entries which are actually freelist references */ 1006 /* Skip over entries which are actually freelist references */
996 if ((unsigned long)np->tx_skbs[i].skb < PAGE_OFFSET) 1007 if (skb_entry_is_link(&np->tx_skbs[i]))
997 continue; 1008 continue;
998 1009
999 skb = np->tx_skbs[i].skb; 1010 skb = np->tx_skbs[i].skb;
@@ -1123,7 +1134,7 @@ static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev
1123 /* Initialise tx_skbs as a free chain containing every entry. */ 1134 /* Initialise tx_skbs as a free chain containing every entry. */
1124 np->tx_skb_freelist = 0; 1135 np->tx_skb_freelist = 0;
1125 for (i = 0; i < NET_TX_RING_SIZE; i++) { 1136 for (i = 0; i < NET_TX_RING_SIZE; i++) {
1126 np->tx_skbs[i].link = i+1; 1137 skb_entry_set_link(&np->tx_skbs[i], i+1);
1127 np->grant_tx_ref[i] = GRANT_INVALID_REF; 1138 np->grant_tx_ref[i] = GRANT_INVALID_REF;
1128 } 1139 }
1129 1140