forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
add pseudo header split #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nwochtma
wants to merge
1
commit into
walking-machine:ixgbevf-libeth
Choose a base branch
from
nwochtma:larysa-check-2025-09-12
base: ixgbevf-libeth
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -568,6 +568,12 @@ static void ixgbevf_alloc_rx_buffers(struct ixgbevf_ring *rx_ring, | |
| .truesize = rx_ring->truesize, | ||
| .count = rx_ring->count, | ||
| }; | ||
| const struct libeth_fq_fp hdr_fq = { | ||
| .pp = rx_ring->hdr_pp, | ||
| .fqes = rx_ring->hdr_fqes, | ||
| .truesize = rx_ring->hdr_truesize, | ||
| .count = rx_ring->count, | ||
| }; | ||
| u16 ntu = rx_ring->next_to_use; | ||
|
|
||
| /* nothing to do or no valid netdev defined */ | ||
|
|
@@ -584,6 +590,14 @@ static void ixgbevf_alloc_rx_buffers(struct ixgbevf_ring *rx_ring, | |
|
|
||
| rx_desc->read.pkt_addr = cpu_to_le64(addr); | ||
|
|
||
| if (!hdr_fq.pp) | ||
| goto next; | ||
|
|
||
| addr = libeth_rx_alloc(&hdr_fq, ntu); | ||
| if (addr == DMA_MAPPING_ERROR) | ||
| return; | ||
|
|
||
| next: | ||
| rx_desc++; | ||
| ntu++; | ||
| if (unlikely(ntu == fq.count)) { | ||
|
|
@@ -781,6 +795,32 @@ static int ixgbevf_run_xdp(struct ixgbevf_adapter *adapter, | |
| return result; | ||
| } | ||
|
|
||
| static u32 ixgbevf_rx_hsplit_wa(const struct libeth_fqe *hdr, | ||
| struct libeth_fqe *buf, u32 data_len) | ||
| { | ||
| u32 copy = data_len <= L1_CACHE_BYTES ? data_len : ETH_HLEN; | ||
| struct page *hdr_page, *buf_page; | ||
| const void *src; | ||
| void *dst; | ||
|
|
||
| if (unlikely(netmem_is_net_iov(buf->netmem)) || | ||
nwochtma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| !libeth_rx_sync_for_cpu(buf, copy)) | ||
| return 0; | ||
|
|
||
| hdr_page = __netmem_to_page(hdr->netmem); | ||
| buf_page = __netmem_to_page(buf->netmem); | ||
|
|
||
| dst = page_address(hdr_page) + hdr->offset + | ||
| pp_page_to_nmdesc(hdr_page)->pp->p.offset; | ||
| src = page_address(buf_page) + buf->offset + | ||
| pp_page_to_nmdesc(buf_page)->pp->p.offset; | ||
|
|
||
| memcpy(dst, src, LARGEST_ALIGN(copy)); | ||
| buf->offset += copy; | ||
|
|
||
| return copy; | ||
| } | ||
|
|
||
| static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector, | ||
| struct ixgbevf_ring *rx_ring, | ||
| int budget) | ||
|
|
@@ -818,6 +858,23 @@ static int ixgbevf_clean_rx_irq(struct ixgbevf_q_vector *q_vector, | |
| rmb(); | ||
|
|
||
| rx_buffer = &rx_ring->rx_fqes[rx_ring->next_to_clean]; | ||
|
|
||
| if (unlikely(rx_ring->hdr_pp)) { | ||
| struct libeth_fqe *hdr_buff; | ||
| unsigned int hdr_size = 0; | ||
|
|
||
| hdr_buff = &rx_ring->hdr_fqes[rx_ring->next_to_clean]; | ||
|
|
||
| if (!xdp->data) { | ||
| hdr_size = ixgbevf_rx_hsplit_wa(hdr_buff, | ||
| rx_buffer, | ||
| size); | ||
| size -= hdr_size ? : size; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if we cannot copy from the buffer, we zero its size, so it is dropped? |
||
| } | ||
|
|
||
| libeth_xdp_process_buff(xdp, hdr_buff, hdr_size); | ||
| } | ||
|
|
||
| libeth_xdp_process_buff(xdp, rx_buffer, size); | ||
|
|
||
| cleaned_count++; | ||
|
|
@@ -3054,19 +3111,38 @@ static int ixgbevf_setup_all_tx_resources(struct ixgbevf_adapter *adapter) | |
| return err; | ||
| } | ||
|
|
||
| /** | ||
| * ixgbevf_setup_rx_resources - allocate Rx resources (Descriptors) | ||
| * @adapter: board private structure | ||
| * @rx_ring: Rx descriptor ring (for a specific queue) to setup | ||
| * | ||
| * Returns 0 on success, negative on failure | ||
| **/ | ||
| int ixgbevf_setup_rx_resources(struct ixgbevf_adapter *adapter, | ||
| struct ixgbevf_ring *rx_ring) | ||
| static void ixgbvf_rx_destroy_pp(struct ixgbevf_ring *rx_ring) | ||
| { | ||
| struct libeth_fq fq = { | ||
| .pp = rx_ring->pp, | ||
| .fqes = rx_ring->rx_fqes, | ||
| }; | ||
|
|
||
| libeth_rx_fq_destroy(&fq); | ||
| rx_ring->rx_fqes = NULL; | ||
| rx_ring->pp = NULL; | ||
|
|
||
| if (!rx_ring->hdr_pp) | ||
| return; | ||
|
|
||
| fq = (struct libeth_fq) { | ||
| .pp = rx_ring->hdr_pp, | ||
| .fqes = rx_ring->hdr_fqes, | ||
| }; | ||
|
|
||
| libeth_rx_fq_destroy(&fq); | ||
| rx_ring->hdr_fqes = NULL; | ||
| rx_ring->hdr_pp = NULL; | ||
| } | ||
|
|
||
| static int ixgbvf_rx_create_pp(struct ixgbevf_ring *rx_ring) | ||
| { | ||
| u32 adapter_flags = rx_ring->q_vector->adapter->flags; | ||
|
|
||
| struct libeth_fq fq = { | ||
| .count = rx_ring->count, | ||
| .nid = NUMA_NO_NODE, | ||
| .hsplit = adapter_flags & IXGBEVF_FLAG_HSPLIT, | ||
| .type = LIBETH_FQE_MTU, | ||
| .xdp = !!rx_ring->xdp_prog, | ||
| .buf_len = IXGBEVF_RX_PAGE_LEN(rx_ring->xdp_prog ? | ||
|
|
@@ -3084,34 +3160,75 @@ int ixgbevf_setup_rx_resources(struct ixgbevf_adapter *adapter, | |
| rx_ring->truesize = fq.truesize; | ||
| rx_ring->rx_buf_len = fq.buf_len; | ||
|
|
||
| if (!fq.hsplit) | ||
| return 0; | ||
|
|
||
| fq = (struct libeth_fq) { | ||
| .count = rx_ring->count, | ||
| .nid = NUMA_NO_NODE, | ||
| .type = LIBETH_FQE_HDR, | ||
| .xdp = !!rx_ring->xdp_prog, | ||
| }; | ||
|
|
||
| ret = libeth_rx_fq_create(&fq, &rx_ring->q_vector->napi); | ||
| if (ret) | ||
| goto err; | ||
|
|
||
| rx_ring->hdr_pp = fq.pp; | ||
| rx_ring->hdr_fqes = fq.fqes; | ||
| rx_ring->hdr_truesize = fq.truesize; | ||
| rx_ring->hdr_buf_len = fq.buf_len; | ||
|
|
||
| return 0; | ||
|
|
||
| err: | ||
| ixgbvf_rx_destroy_pp(rx_ring); | ||
| return ret; | ||
| } | ||
|
|
||
| /** | ||
| * ixgbevf_setup_rx_resources - allocate Rx resources | ||
| * @adapter: board private structure | ||
| * @rx_ring: Rx descriptor ring (for a specific queue) to setup | ||
| * | ||
| * Returns: 0 on success, negative on failure. | ||
| **/ | ||
| int ixgbevf_setup_rx_resources(struct ixgbevf_adapter *adapter, | ||
| struct ixgbevf_ring *rx_ring) | ||
| { | ||
| int ret; | ||
|
|
||
| ret = ixgbvf_rx_create_pp(rx_ring); | ||
| if (ret) | ||
| return ret; | ||
|
|
||
| u64_stats_init(&rx_ring->syncp); | ||
|
|
||
| /* Round up to nearest 4K */ | ||
| rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc); | ||
| rx_ring->size = ALIGN(rx_ring->size, 4096); | ||
|
|
||
| rx_ring->desc = dma_alloc_coherent(fq.pp->p.dev, rx_ring->size, | ||
| rx_ring->desc = dma_alloc_coherent(rx_ring->pp->p.dev, rx_ring->size, | ||
| &rx_ring->dma, GFP_KERNEL); | ||
|
|
||
| if (!rx_ring->desc) | ||
| goto err; | ||
|
|
||
| /* XDP RX-queue info */ | ||
| ret = __xdp_rxq_info_reg(&rx_ring->xdp_rxq, adapter->netdev, | ||
| rx_ring->queue_index, 0, fq.buf_len); | ||
| rx_ring->queue_index, 0, rx_ring->rx_buf_len); | ||
| if (ret) | ||
| goto err; | ||
|
|
||
| xdp_rxq_info_attach_page_pool(&rx_ring->xdp_rxq, fq.pp); | ||
| xdp_rxq_info_attach_page_pool(&rx_ring->xdp_rxq, rx_ring->pp); | ||
|
|
||
| rx_ring->xdp_prog = adapter->xdp_prog; | ||
|
|
||
| return 0; | ||
| err: | ||
| libeth_rx_fq_destroy(&fq); | ||
| rx_ring->rx_fqes = NULL; | ||
| rx_ring->pp = NULL; | ||
| ixgbvf_rx_destroy_pp(rx_ring); | ||
| dev_err(rx_ring->dev, "Unable to allocate memory for the Rx descriptor ring\n"); | ||
|
|
||
| return ret; | ||
nwochtma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
|
|
@@ -4222,6 +4339,9 @@ static int ixgbevf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |
| netdev->priv_flags |= IFF_UNICAST_FLT; | ||
| netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_RX_SG; | ||
|
|
||
| if (adapter->hw.mac.type == ixgbe_mac_82599_vf) | ||
| adapter->flags |= IXGBEVF_FLAG_HSPLIT; | ||
|
|
||
| /* MTU range: 68 - 1504 or 9710 */ | ||
| netdev->min_mtu = ETH_MIN_MTU; | ||
| switch (adapter->hw.api_version) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.