Skip to content

Commit 920fb45

Browse files
baileyforrestdavem330
authored andcommitted
gve: Make gve_rx_slot_page_info.page_offset an absolute offset
Using `page_offset` like a boolean means a page may only be split into two sections. With page sizes larger than 4k, this can be very wasteful. Future commits in this patchset use `struct gve_rx_slot_page_info` in a way which supports a fixed buffer size and a variable page size. Signed-off-by: Bailey Forrest <bcf@google.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Reviewed-by: Catherine Sullivan <csully@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 35f9b2f commit 920fb45

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

drivers/net/ethernet/google/gve/gve.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* SPDX-License-Identifier: (GPL-2.0 OR MIT)
22
* Google virtual Ethernet (gve) driver
33
*
4-
* Copyright (C) 2015-2019 Google, Inc.
4+
* Copyright (C) 2015-2021 Google, Inc.
55
*/
66

77
#ifndef _GVE_H_
@@ -51,7 +51,7 @@ struct gve_rx_desc_queue {
5151
struct gve_rx_slot_page_info {
5252
struct page *page;
5353
void *page_address;
54-
u8 page_offset; /* flipped to second half? */
54+
u32 page_offset; /* offset to write to in page */
5555
u8 can_flip;
5656
};
5757

drivers/net/ethernet/google/gve/gve_rx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static struct sk_buff *gve_rx_add_frags(struct napi_struct *napi,
272272
return NULL;
273273

274274
skb_add_rx_frag(skb, 0, page_info->page,
275-
(page_info->page_offset ? PAGE_SIZE / 2 : 0) +
275+
page_info->page_offset +
276276
GVE_RX_PAD, len, PAGE_SIZE / 2);
277277

278278
return skb;
@@ -283,7 +283,7 @@ static void gve_rx_flip_buff(struct gve_rx_slot_page_info *page_info, __be64 *sl
283283
const __be64 offset = cpu_to_be64(PAGE_SIZE / 2);
284284

285285
/* "flip" to other packet buffer on this page */
286-
page_info->page_offset ^= 0x1;
286+
page_info->page_offset ^= PAGE_SIZE / 2;
287287
*(slot_addr) ^= offset;
288288
}
289289

drivers/net/ethernet/google/gve/gve_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct sk_buff *gve_rx_copy(struct net_device *dev, struct napi_struct *napi,
5050
{
5151
struct sk_buff *skb = napi_alloc_skb(napi, len);
5252
void *va = page_info->page_address + pad +
53-
(page_info->page_offset ? PAGE_SIZE / 2 : 0);
53+
page_info->page_offset;
5454

5555
if (unlikely(!skb))
5656
return NULL;

0 commit comments

Comments
 (0)