struct hnae_desc *desc;
int truesize, size;
int last_offset;
+ bool twobufs;
+
+ twobufs = ((PAGE_SIZE < 8192) && hnae_buf_size(ring) == HNS_BUFFER_SIZE_2048);
desc = &ring->desc[ring->next_to_clean];
size = le16_to_cpu(desc->rx.size);
-#if (PAGE_SIZE < 8192)
- if (hnae_buf_size(ring) == HNS_BUFFER_SIZE_2048) {
+ if (twobufs) {
truesize = hnae_buf_size(ring);
} else {
truesize = ALIGN(size, L1_CACHE_BYTES);
last_offset = hnae_page_size(ring) - hnae_buf_size(ring);
}
-#else
- truesize = ALIGN(size, L1_CACHE_BYTES);
- last_offset = hnae_page_size(ring) - hnae_buf_size(ring);
-#endif
-
skb_add_rx_frag(skb, i, desc_cb->priv, desc_cb->page_offset + pull_len,
size - pull_len, truesize - pull_len);
/* avoid re-using remote pages,flag default unreuse */
- if (likely(page_to_nid(desc_cb->priv) == numa_node_id())) {
-#if (PAGE_SIZE < 8192)
- if (hnae_buf_size(ring) == HNS_BUFFER_SIZE_2048) {
- /* if we are only owner of page we can reuse it */
- if (likely(page_count(desc_cb->priv) == 1)) {
- /* flip page offset to other buffer */
- desc_cb->page_offset ^= truesize;
-
- desc_cb->reuse_flag = 1;
- /* bump ref count on page before it is given*/
- get_page(desc_cb->priv);
- }
- return;
- }
-#endif
- /* move offset up to the next cache line */
- desc_cb->page_offset += truesize;
+ if (unlikely(page_to_nid(desc_cb->priv) != numa_node_id()))
+ return;
+
+ if (twobufs) {
+ /* if we are only owner of page we can reuse it */
+ if (likely(page_count(desc_cb->priv) == 1)) {
+ /* flip page offset to other buffer */
+ desc_cb->page_offset ^= truesize;
- if (desc_cb->page_offset <= last_offset) {
desc_cb->reuse_flag = 1;
/* bump ref count on page before it is given*/
get_page(desc_cb->priv);
}
+ return;
+ }
+
+ /* move offset up to the next cache line */
+ desc_cb->page_offset += truesize;
+
+ if (desc_cb->page_offset <= last_offset) {
+ desc_cb->reuse_flag = 1;
+ /* bump ref count on page before it is given*/
+ get_page(desc_cb->priv);
}
}