diff options
Diffstat (limited to 'drivers/net/xen-netback/netback.c')
-rw-r--r-- | drivers/net/xen-netback/netback.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index 7367208ee8cd..a160b4ef5ba0 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c | |||
@@ -163,7 +163,8 @@ bool xenvif_rx_ring_slots_available(struct xenvif *vif, int needed) | |||
163 | * adding 'size' bytes to a buffer which currently contains 'offset' | 163 | * adding 'size' bytes to a buffer which currently contains 'offset' |
164 | * bytes. | 164 | * bytes. |
165 | */ | 165 | */ |
166 | static bool start_new_rx_buffer(int offset, unsigned long size, int head) | 166 | static bool start_new_rx_buffer(int offset, unsigned long size, int head, |
167 | bool full_coalesce) | ||
167 | { | 168 | { |
168 | /* simple case: we have completely filled the current buffer. */ | 169 | /* simple case: we have completely filled the current buffer. */ |
169 | if (offset == MAX_BUFFER_OFFSET) | 170 | if (offset == MAX_BUFFER_OFFSET) |
@@ -175,6 +176,7 @@ static bool start_new_rx_buffer(int offset, unsigned long size, int head) | |||
175 | * (i) this frag would fit completely in the next buffer | 176 | * (i) this frag would fit completely in the next buffer |
176 | * and (ii) there is already some data in the current buffer | 177 | * and (ii) there is already some data in the current buffer |
177 | * and (iii) this is not the head buffer. | 178 | * and (iii) this is not the head buffer. |
179 | * and (iv) there is no need to fully utilize the buffers | ||
178 | * | 180 | * |
179 | * Where: | 181 | * Where: |
180 | * - (i) stops us splitting a frag into two copies | 182 | * - (i) stops us splitting a frag into two copies |
@@ -185,6 +187,8 @@ static bool start_new_rx_buffer(int offset, unsigned long size, int head) | |||
185 | * by (ii) but is explicitly checked because | 187 | * by (ii) but is explicitly checked because |
186 | * netfront relies on the first buffer being | 188 | * netfront relies on the first buffer being |
187 | * non-empty and can crash otherwise. | 189 | * non-empty and can crash otherwise. |
190 | * - (iv) is needed for skbs which can use up more than MAX_SKB_FRAGS | ||
191 | * slot | ||
188 | * | 192 | * |
189 | * This means we will effectively linearise small | 193 | * This means we will effectively linearise small |
190 | * frags but do not needlessly split large buffers | 194 | * frags but do not needlessly split large buffers |
@@ -192,7 +196,8 @@ static bool start_new_rx_buffer(int offset, unsigned long size, int head) | |||
192 | * own buffers as before. | 196 | * own buffers as before. |
193 | */ | 197 | */ |
194 | BUG_ON(size > MAX_BUFFER_OFFSET); | 198 | BUG_ON(size > MAX_BUFFER_OFFSET); |
195 | if ((offset + size > MAX_BUFFER_OFFSET) && offset && !head) | 199 | if ((offset + size > MAX_BUFFER_OFFSET) && offset && !head && |
200 | !full_coalesce) | ||
196 | return true; | 201 | return true; |
197 | 202 | ||
198 | return false; | 203 | return false; |
@@ -227,6 +232,13 @@ static struct xenvif_rx_meta *get_next_rx_buffer(struct xenvif *vif, | |||
227 | return meta; | 232 | return meta; |
228 | } | 233 | } |
229 | 234 | ||
235 | struct xenvif_rx_cb { | ||
236 | int meta_slots_used; | ||
237 | bool full_coalesce; | ||
238 | }; | ||
239 | |||
240 | #define XENVIF_RX_CB(skb) ((struct xenvif_rx_cb *)(skb)->cb) | ||
241 | |||
230 | /* | 242 | /* |
231 | * Set up the grant operations for this fragment. If it's a flipping | 243 | * Set up the grant operations for this fragment. If it's a flipping |
232 | * interface, we also set up the unmap request from here. | 244 | * interface, we also set up the unmap request from here. |
@@ -261,7 +273,10 @@ static void xenvif_gop_frag_copy(struct xenvif *vif, struct sk_buff *skb, | |||
261 | if (bytes > size) | 273 | if (bytes > size) |
262 | bytes = size; | 274 | bytes = size; |
263 | 275 | ||
264 | if (start_new_rx_buffer(npo->copy_off, bytes, *head)) { | 276 | if (start_new_rx_buffer(npo->copy_off, |
277 | bytes, | ||
278 | *head, | ||
279 | XENVIF_RX_CB(skb)->full_coalesce)) { | ||
265 | /* | 280 | /* |
266 | * Netfront requires there to be some data in the head | 281 | * Netfront requires there to be some data in the head |
267 | * buffer. | 282 | * buffer. |
@@ -541,12 +556,6 @@ static void xenvif_add_frag_responses(struct xenvif *vif, int status, | |||
541 | } | 556 | } |
542 | } | 557 | } |
543 | 558 | ||
544 | struct xenvif_rx_cb { | ||
545 | int meta_slots_used; | ||
546 | }; | ||
547 | |||
548 | #define XENVIF_RX_CB(skb) ((struct xenvif_rx_cb *)(skb)->cb) | ||
549 | |||
550 | void xenvif_kick_thread(struct xenvif *vif) | 559 | void xenvif_kick_thread(struct xenvif *vif) |
551 | { | 560 | { |
552 | wake_up(&vif->wq); | 561 | wake_up(&vif->wq); |
@@ -602,10 +611,15 @@ static void xenvif_rx_action(struct xenvif *vif) | |||
602 | 611 | ||
603 | /* To avoid the estimate becoming too pessimal for some | 612 | /* To avoid the estimate becoming too pessimal for some |
604 | * frontends that limit posted rx requests, cap the estimate | 613 | * frontends that limit posted rx requests, cap the estimate |
605 | * at MAX_SKB_FRAGS. | 614 | * at MAX_SKB_FRAGS. In this case netback will fully coalesce |
615 | * the skb into the provided slots. | ||
606 | */ | 616 | */ |
607 | if (max_slots_needed > MAX_SKB_FRAGS) | 617 | if (max_slots_needed > MAX_SKB_FRAGS) { |
608 | max_slots_needed = MAX_SKB_FRAGS; | 618 | max_slots_needed = MAX_SKB_FRAGS; |
619 | XENVIF_RX_CB(skb)->full_coalesce = true; | ||
620 | } else { | ||
621 | XENVIF_RX_CB(skb)->full_coalesce = false; | ||
622 | } | ||
609 | 623 | ||
610 | /* We may need one more slot for GSO metadata */ | 624 | /* We may need one more slot for GSO metadata */ |
611 | if (skb_is_gso(skb) && | 625 | if (skb_is_gso(skb) && |