diff options
author | Zoltan Kiss <zoltan.kiss@citrix.com> | 2014-03-06 16:48:24 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-03-07 15:56:34 -0500 |
commit | 121fa4b77775549c3c5eb41eb335d7dcbb801f90 (patch) | |
tree | cac1ae8a3d4ac72411312d27090e0a9106b6586c /drivers/net/xen-netback/netback.c | |
parent | 8f13dd9612286cc0d38d32ff9543763b7c74f6a5 (diff) |
xen-netback: Minor refactoring of netback code
This patch contains a few bits of refactoring before introducing the grant
mapping changes:
- introducing xenvif_tx_pending_slots_available(), as this is used several
times, and will be used more often
- rename the thread to vifX.Y-guest-rx, to signify it does RX work from the
guest point of view
Signed-off-by: Zoltan Kiss <zoltan.kiss@citrix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/xen-netback/netback.c')
-rw-r--r-- | drivers/net/xen-netback/netback.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index 43ae4bad50c4..715d810124eb 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c | |||
@@ -63,14 +63,6 @@ static unsigned int fatal_skb_slots = FATAL_SKB_SLOTS_DEFAULT; | |||
63 | module_param(fatal_skb_slots, uint, 0444); | 63 | module_param(fatal_skb_slots, uint, 0444); |
64 | 64 | ||
65 | /* | 65 | /* |
66 | * To avoid confusion, we define XEN_NETBK_LEGACY_SLOTS_MAX indicating | ||
67 | * the maximum slots a valid packet can use. Now this value is defined | ||
68 | * to be XEN_NETIF_NR_SLOTS_MIN, which is supposed to be supported by | ||
69 | * all backend. | ||
70 | */ | ||
71 | #define XEN_NETBK_LEGACY_SLOTS_MAX XEN_NETIF_NR_SLOTS_MIN | ||
72 | |||
73 | /* | ||
74 | * If head != INVALID_PENDING_RING_IDX, it means this tx request is head of | 66 | * If head != INVALID_PENDING_RING_IDX, it means this tx request is head of |
75 | * one or more merged tx requests, otherwise it is the continuation of | 67 | * one or more merged tx requests, otherwise it is the continuation of |
76 | * previous tx request. | 68 | * previous tx request. |
@@ -131,12 +123,6 @@ static inline pending_ring_idx_t pending_index(unsigned i) | |||
131 | return i & (MAX_PENDING_REQS-1); | 123 | return i & (MAX_PENDING_REQS-1); |
132 | } | 124 | } |
133 | 125 | ||
134 | static inline pending_ring_idx_t nr_pending_reqs(struct xenvif *vif) | ||
135 | { | ||
136 | return MAX_PENDING_REQS - | ||
137 | vif->pending_prod + vif->pending_cons; | ||
138 | } | ||
139 | |||
140 | bool xenvif_rx_ring_slots_available(struct xenvif *vif, int needed) | 126 | bool xenvif_rx_ring_slots_available(struct xenvif *vif, int needed) |
141 | { | 127 | { |
142 | RING_IDX prod, cons; | 128 | RING_IDX prod, cons; |
@@ -1116,8 +1102,7 @@ static unsigned xenvif_tx_build_gops(struct xenvif *vif, int budget) | |||
1116 | struct sk_buff *skb; | 1102 | struct sk_buff *skb; |
1117 | int ret; | 1103 | int ret; |
1118 | 1104 | ||
1119 | while ((nr_pending_reqs(vif) + XEN_NETBK_LEGACY_SLOTS_MAX | 1105 | while (xenvif_tx_pending_slots_available(vif) && |
1120 | < MAX_PENDING_REQS) && | ||
1121 | (skb_queue_len(&vif->tx_queue) < budget)) { | 1106 | (skb_queue_len(&vif->tx_queue) < budget)) { |
1122 | struct xen_netif_tx_request txreq; | 1107 | struct xen_netif_tx_request txreq; |
1123 | struct xen_netif_tx_request txfrags[XEN_NETBK_LEGACY_SLOTS_MAX]; | 1108 | struct xen_netif_tx_request txfrags[XEN_NETBK_LEGACY_SLOTS_MAX]; |
@@ -1487,8 +1472,7 @@ static inline int tx_work_todo(struct xenvif *vif) | |||
1487 | { | 1472 | { |
1488 | 1473 | ||
1489 | if (likely(RING_HAS_UNCONSUMED_REQUESTS(&vif->tx)) && | 1474 | if (likely(RING_HAS_UNCONSUMED_REQUESTS(&vif->tx)) && |
1490 | (nr_pending_reqs(vif) + XEN_NETBK_LEGACY_SLOTS_MAX | 1475 | xenvif_tx_pending_slots_available(vif)) |
1491 | < MAX_PENDING_REQS)) | ||
1492 | return 1; | 1476 | return 1; |
1493 | 1477 | ||
1494 | return 0; | 1478 | return 0; |
@@ -1551,7 +1535,7 @@ static void xenvif_start_queue(struct xenvif *vif) | |||
1551 | netif_wake_queue(vif->dev); | 1535 | netif_wake_queue(vif->dev); |
1552 | } | 1536 | } |
1553 | 1537 | ||
1554 | int xenvif_kthread(void *data) | 1538 | int xenvif_kthread_guest_rx(void *data) |
1555 | { | 1539 | { |
1556 | struct xenvif *vif = data; | 1540 | struct xenvif *vif = data; |
1557 | struct sk_buff *skb; | 1541 | struct sk_buff *skb; |