* [PATCH net-next v5 0/6] e1000e: add XDP support
@ 2026-12-04 20:43 Matteo Croce
2026-12-04 20:43 ` [PATCH net-next v5 1/6] e1000e: clean the Tx ring from NAPI in MSI-X mode Matteo Croce
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Matteo Croce @ 2026-12-04 20:43 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Mohsin Bashir, Nemo D'ACREMONT
Cc: netdev, bpf, intel-wired-lan, linux-kernel
This series adds XDP support to the e1000e driver, with multi-buffer
frames, XDP_TX, XDP_REDIRECT and .ndo_xdp_xmit.
As suggested in the v4 review, the Rx path is reworked first: the three
Rx routines, and the clean_rx and alloc_rx_buf function pointers, are
replaced by a single routine using the libeth helpers, and XDP is built
on top of it:
- patch 1 processes Tx completions from NAPI also in MSI-X mode (82574),
as page_pool buffers can't be returned from hard interrupt context;
- patch 2 disables NAPI in e1000e_down(), as a page_pool tied to a NAPI
instance can only be destroyed while the NAPI is disabled;
- patch 3 removes the packet split Rx routine;
- patch 4 replaces the two remaining Rx routines with a single one:
buffers are allocated from a libeth page_pool and assembled into an
xdp_buff, which can span multiple descriptors, then converted into an
skb;
- patch 5 adds XDP support, including XDP_TX and XDP_REDIRECT, for both
single and multi-buffer frames;
- patch 6 adds .ndo_xdp_xmit, so that the device can be a redirect
target, with or without a program attached.
The hardware only supports power of two Rx buffer sizes, so it is always
programmed for 2 KB buffers, and frames bigger than that span multiple
descriptors. With the standard MTU, long packet reception is disabled
and frames never exceed a VLAN tagged frame, so the buffers are
allocated just big enough for it, two per 4 KB page.
The device has a single Tx queue, shared with the regular transmit path,
so XDP_TX and .ndo_xdp_xmit place the frames on it with the Tx queue lock
held. The libeth_xdp Tx helpers assume dedicated XDP queues, e.g. a frame
can be split across bulk flushes, so like ice the Tx side is handled by
the driver.
Attaching or removing a program resets the device, as the Rx buffers
are reallocated with the XDP headroom. Programs without frags support
are rejected when the MTU allows jumbo frames, and the MTU can't be
raised above 1500 while one is attached.
User visible changes: the copybreak module parameter and the
rx_header_split ethtool statistic are removed, as the copy and the
header split Rx paths they refer to are gone.
Tested in QEMU, with three emulated 82574L devices connected to the same
hub, one of them moved into a network namespace as the remote end:
- drivers/net/xdp.py selftest: 21 of 27 tests pass, the other 6 are the
qstats ones, as e1000e doesn't report queue stats; same result with
MSI-X and with legacy interrupts;
- UDP frames reflected with XDP_TX, with a redirect to the same device
and with a redirect to another e1000e without a program attached:
250 single buffer frames of 18 to 1472 bytes and 450 multi-buffer
frames of up to 8972 bytes in each mode, none lost or corrupted;
- 60 seconds of bidirectional TCP traffic (8.95 GB) while about 180k
frames were reflected onto the same Tx rings with XDP_TX and redirect,
with 17 reconfigurations in the meantime (ring sizes, MTU, program,
link down and up): no corrupted frame, and the device works normally
afterwards;
- no page_pool left with in-flight pages after the interfaces go down;
- the same on a kernel with KASAN, lockdep, DMA API debugging, kmemleak
and a strict IOMMU, without any warning or leak report.
The other driver selftests give the same results with and without this
series. ping.py's native XDP tests fail, as they ping right after
attaching the program, while the link is still down after the device
reset; without this series one of them is skipped, the other fails.
Tested on an Intel 82574L (PCIe x1), connected at 1 Gbps through a
switch to a Realtek RTL8111, which generates the traffic with pktgen.
The RTL8111 can't send more than about 0.53 Mpps of 64 byte frames,
below the 82574L line rate, and the 82574L handles all of them in every
mode, so this is the load of the CPU handling its interrupts at that
rate, with generic XDP before the series and native XDP after it:
before after
no program 53% 51%
XDP_DROP 19% 4.5%
XDP_PASS 58% 54%
XDP_TX 28% 8.5%
XDP_REDIRECT 28% 11%
XDP_REDIRECT sends the frames back on the same device, as there is no
other e1000e. TCP throughput is 941 Mbit/s in both directions, with and
without the series, and with and without a program attached. The
XDP_TX and redirect tests done in QEMU pass also on hardware, with
MSI-X, MSI and legacy interrupts, and with the link at 100 Mbps. The
device keeps working after 12 reconfigurations under 0.15 Mpps of
XDP_TX and redirect traffic, without leaving page_pool pages in flight.
v4: https://lore.kernel.org/all/20260323182823.5813-1-teknoraver@meta.com/
v5:
- rework the Rx path to use libeth with a single Rx routine, and add
multi-buffer support (Maciej)
- take the Tx queue lock for XDP_TX, as the ring is shared with the
regular transmit path (Aleksandr)
- don't put the program reference on ndo_bpf failure, it's done by the
core (Aleksandr), the interface is now reset with down/up which can't
fail
- .ndo_xdp_xmit still stops at the first frame which doesn't fit: the
caller frees the remaining ones and reports them as dropped with the
xdp_devmap_xmit tracepoint, so they are not lost silently (Aleksandr)
- clean the Tx ring from NAPI also in MSI-X mode, freeing XDP buffers
from the hard interrupt handler was not allowed
- fix the cover letter, this series is not about AF_XDP (Maciej)
v4: bugfixes
v3: removed a leftover file.
v2: added a missing 'select PAGE_POOL' which triggered a build failure
with some configurations.
Matteo Croce (6):
e1000e: clean the Tx ring from NAPI in MSI-X mode
e1000e: disable NAPI when bringing the interface down
e1000e: remove packet split Rx
e1000e: use libeth for Rx buffer management
e1000e: add XDP support
e1000e: add .ndo_xdp_xmit support
.../device_drivers/ethernet/intel/e1000e.rst | 15 -
drivers/net/ethernet/intel/Kconfig | 1 +
drivers/net/ethernet/intel/e1000e/e1000.h | 66 +-
drivers/net/ethernet/intel/e1000e/ethtool.c | 1 -
drivers/net/ethernet/intel/e1000e/netdev.c | 1853 +++++++----------
drivers/net/ethernet/intel/e1000e/param.c | 6 -
6 files changed, 792 insertions(+), 1150 deletions(-)
base-commit: d5cf954cebe4f175dfd834e1dc471a3aa203ec7d
--
2.56.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next v5 1/6] e1000e: clean the Tx ring from NAPI in MSI-X mode
2026-12-04 20:43 [PATCH net-next v5 0/6] e1000e: add XDP support Matteo Croce
@ 2026-12-04 20:43 ` Matteo Croce
2026-12-04 20:43 ` [PATCH net-next v5 2/6] e1000e: disable NAPI when bringing the interface down Matteo Croce
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Matteo Croce @ 2026-12-04 20:43 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Mohsin Bashir, Nemo D'ACREMONT
Cc: netdev, bpf, intel-wired-lan, linux-kernel
In MSI-X mode, which is only used by 82574, Tx completions are processed
directly in the Tx hard interrupt handler, while in MSI and legacy
interrupt modes they are processed by the NAPI poll routine.
Freeing buffers coming from a page_pool, as it will happen with XDP_TX,
is not allowed from hard interrupt context.
Make the MSI-X Tx interrupt schedule NAPI as the Rx one does, always
clean the Tx ring from the poll routine, and re-enable both the Rx and
Tx interrupt causes when polling is complete.
Signed-off-by: Matteo Croce <technoboy85@gmail.com>
---
drivers/net/ethernet/intel/e1000e/netdev.c | 32 +++++++++++-----------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 6f85dab5c55c..996bd6f5fa83 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -1934,18 +1934,17 @@ static irqreturn_t e1000_intr_msix_tx(int __always_unused irq, void *data)
{
struct net_device *netdev = data;
struct e1000_adapter *adapter = netdev_priv(netdev);
- struct e1000_hw *hw = &adapter->hw;
- struct e1000_ring *tx_ring = adapter->tx_ring;
-
- adapter->total_tx_bytes = 0;
- adapter->total_tx_packets = 0;
-
- if (!e1000_clean_tx_irq(tx_ring))
- /* Ring was not completely cleaned, so fire another interrupt */
- ew32(ICS, tx_ring->ims_val);
- if (!test_bit(__E1000_DOWN, &adapter->state))
- ew32(IMS, adapter->tx_ring->ims_val);
+ /* Tx completions are processed in NAPI context, the Tx interrupt is
+ * re-enabled when polling is done.
+ */
+ if (napi_schedule_prep(&adapter->napi)) {
+ adapter->total_tx_bytes = 0;
+ adapter->total_tx_packets = 0;
+ adapter->total_rx_bytes = 0;
+ adapter->total_rx_packets = 0;
+ __napi_schedule_irqoff(&adapter->napi);
+ }
return IRQ_HANDLED;
}
@@ -1968,6 +1967,8 @@ static irqreturn_t e1000_intr_msix_rx(int __always_unused irq, void *data)
}
if (napi_schedule_prep(&adapter->napi)) {
+ adapter->total_tx_bytes = 0;
+ adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
__napi_schedule_irqoff(&adapter->napi);
@@ -2683,13 +2684,11 @@ static int e1000e_poll(struct napi_struct *napi, int budget)
napi);
struct e1000_hw *hw = &adapter->hw;
struct net_device *poll_dev = adapter->netdev;
- int tx_cleaned = 1, work_done = 0;
+ int tx_cleaned, work_done = 0;
adapter = netdev_priv(poll_dev);
- if (!adapter->msix_entries ||
- (adapter->rx_ring->ims_val & adapter->tx_ring->ims_val))
- tx_cleaned = e1000_clean_tx_irq(adapter->tx_ring);
+ tx_cleaned = e1000_clean_tx_irq(adapter->tx_ring);
adapter->clean_rx(adapter->rx_ring, &work_done, budget);
@@ -2704,7 +2703,8 @@ static int e1000e_poll(struct napi_struct *napi, int budget)
e1000_set_itr(adapter);
if (!test_bit(__E1000_DOWN, &adapter->state)) {
if (adapter->msix_entries)
- ew32(IMS, adapter->rx_ring->ims_val);
+ ew32(IMS, adapter->rx_ring->ims_val |
+ adapter->tx_ring->ims_val);
else
e1000_irq_enable(adapter);
}
--
2.56.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v5 2/6] e1000e: disable NAPI when bringing the interface down
2026-12-04 20:43 [PATCH net-next v5 0/6] e1000e: add XDP support Matteo Croce
2026-12-04 20:43 ` [PATCH net-next v5 1/6] e1000e: clean the Tx ring from NAPI in MSI-X mode Matteo Croce
@ 2026-12-04 20:43 ` Matteo Croce
2026-12-04 20:43 ` [PATCH net-next v5 3/6] e1000e: remove packet split Rx Matteo Croce
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Matteo Croce @ 2026-12-04 20:43 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Mohsin Bashir, Nemo D'ACREMONT
Cc: netdev, bpf, intel-wired-lan, linux-kernel
e1000e_down() only synchronizes with a running NAPI poll, leaving NAPI
enabled, and NAPI is only disabled in e1000e_close().
A page_pool tied to a NAPI instance can only be destroyed when the NAPI
is disabled, as there must be no concurrent users of the pool's direct
recycling cache. This is needed to allocate the Rx buffers from a
page_pool which is created and destroyed when the interface is brought
up and down, e.g. on MTU changes.
Disable NAPI in e1000e_down() and enable it in e1000e_up(), as most
drivers do. e1000e_close() no longer needs to disable it, as when the
device is present it calls e1000e_down(), and when it is not present it
was already brought down when it was detached.
Signed-off-by: Matteo Croce <technoboy85@gmail.com>
---
drivers/net/ethernet/intel/e1000e/netdev.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 996bd6f5fa83..4badd502f3ce 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -4257,6 +4257,8 @@ void e1000e_up(struct e1000_adapter *adapter)
clear_bit(__E1000_DOWN, &adapter->state);
+ napi_enable(&adapter->napi);
+
if (adapter->msix_entries)
e1000_configure_msix(adapter);
e1000_irq_enable(adapter);
@@ -4329,7 +4331,7 @@ void e1000e_down(struct e1000_adapter *adapter, bool reset)
e1000_irq_disable(adapter);
- napi_synchronize(&adapter->napi);
+ napi_disable(&adapter->napi);
timer_delete_sync(&adapter->watchdog_timer);
timer_delete_sync(&adapter->phy_info_timer);
@@ -4774,6 +4776,9 @@ int e1000e_close(struct net_device *netdev)
pm_runtime_get_sync(&pdev->dev);
+ /* A device which is not present was already brought down, and its
+ * NAPI disabled, when it was detached.
+ */
if (netif_device_present(netdev)) {
e1000e_down(adapter, true);
e1000_free_irq(adapter);
@@ -4784,7 +4789,6 @@ int e1000e_close(struct net_device *netdev)
netif_queue_set_napi(netdev, 0, NETDEV_QUEUE_TYPE_RX, NULL);
netif_queue_set_napi(netdev, 0, NETDEV_QUEUE_TYPE_TX, NULL);
- napi_disable(&adapter->napi);
e1000e_free_tx_resources(adapter->tx_ring);
e1000e_free_rx_resources(adapter->rx_ring);
--
2.56.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v5 3/6] e1000e: remove packet split Rx
2026-12-04 20:43 [PATCH net-next v5 0/6] e1000e: add XDP support Matteo Croce
2026-12-04 20:43 ` [PATCH net-next v5 1/6] e1000e: clean the Tx ring from NAPI in MSI-X mode Matteo Croce
2026-12-04 20:43 ` [PATCH net-next v5 2/6] e1000e: disable NAPI when bringing the interface down Matteo Croce
@ 2026-12-04 20:43 ` Matteo Croce
2026-12-04 20:43 ` [PATCH net-next v5 4/6] e1000e: use libeth for Rx buffer management Matteo Croce
2026-12-04 20:44 ` [PATCH net-next v5 6/6] e1000e: add .ndo_xdp_xmit support Matteo Croce
4 siblings, 0 replies; 6+ messages in thread
From: Matteo Croce @ 2026-12-04 20:43 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Mohsin Bashir, Nemo D'ACREMONT
Cc: netdev, bpf, intel-wired-lan, linux-kernel
The driver has three Rx routines: one which receives into linear skbs
for the standard MTU, one which receives jumbo frames into pages, and
one using packet split descriptors, which places the protocol headers
into an skb and the payload into pages, used for jumbo frames when the
MTU fits in up to three pages and PAGE_SIZE is at most 16 KB.
Remove the packet split routine, jumbo frames are always received with
the page based routine, which is already used on systems with bigger
pages or with an MTU not fitting into three pages.
This is a preparation to unify the Rx paths into a single page_pool
based routine. As packet split is gone, also remove the rx_header_split
ethtool statistic.
Signed-off-by: Matteo Croce <technoboy85@gmail.com>
---
drivers/net/ethernet/intel/e1000e/e1000.h | 16 +-
drivers/net/ethernet/intel/e1000e/ethtool.c | 1 -
drivers/net/ethernet/intel/e1000e/netdev.c | 603 +++-----------------
3 files changed, 67 insertions(+), 553 deletions(-)
diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h
index 63ebe00376f5..533d1981eb5e 100644
--- a/drivers/net/ethernet/intel/e1000e/e1000.h
+++ b/drivers/net/ethernet/intel/e1000e/e1000.h
@@ -121,11 +121,6 @@ enum e1000_boards {
board_pch_ptp
};
-struct e1000_ps_page {
- struct page *page;
- u64 dma; /* must be u64 - written to hw */
-};
-
/* wrappers around a pointer to a socket buffer,
* so a DMA handle can be stored along with the buffer
*/
@@ -143,11 +138,7 @@ struct e1000_buffer {
u16 mapped_as_page;
};
/* Rx */
- struct {
- /* arrays of page information for packet split */
- struct e1000_ps_page *ps_pages;
- struct page *page;
- };
+ struct page *page;
};
};
@@ -265,15 +256,12 @@ struct e1000_adapter {
/* Rx stats */
u64 hw_csum_err;
u64 hw_csum_good;
- u64 rx_hdr_split;
u32 gorc;
u64 gorc_old;
u32 alloc_rx_buff_failed;
u32 rx_dma_failed;
u32 rx_hwtstamp_cleared;
- unsigned int rx_ps_pages;
- u16 rx_ps_bsize0;
u32 max_frame_size;
u32 min_frame_size;
@@ -464,8 +452,6 @@ s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca);
#define FLAG2_ENABLE_S0IX_FLOWS BIT(15)
#define FLAG2_DISABLE_K1 BIT(16)
-#define E1000_RX_DESC_PS(R, i) \
- (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
#define E1000_RX_DESC_EXT(R, i) \
(&(((union e1000_rx_desc_extended *)((R).desc))[i]))
#define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c
index 6f45a37b17d4..fe0b394ce276 100644
--- a/drivers/net/ethernet/intel/e1000e/ethtool.c
+++ b/drivers/net/ethernet/intel/e1000e/ethtool.c
@@ -85,7 +85,6 @@ static const struct e1000_stats e1000_gstrings_stats[] = {
E1000_STAT("tx_flow_control_xoff", stats.xofftxc),
E1000_STAT("rx_csum_offload_good", hw_csum_good),
E1000_STAT("rx_csum_offload_errors", hw_csum_err),
- E1000_STAT("rx_header_split", rx_hdr_split),
E1000_STAT("alloc_rx_buff_failed", alloc_rx_buff_failed),
E1000_STAT("tx_smbus", stats.mgptc),
E1000_STAT("rx_smbus", stats.mgprc),
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 4badd502f3ce..391ff8f91ab5 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -190,24 +190,6 @@ static void e1000_regdump(struct e1000_hw *hw, struct e1000_reg_info *reginfo)
pr_info("%-15s %08x %08x\n", rname, regs[0], regs[1]);
}
-static void e1000e_dump_ps_pages(struct e1000_adapter *adapter,
- struct e1000_buffer *bi)
-{
- int i;
- struct e1000_ps_page *ps_page;
-
- for (i = 0; i < adapter->rx_ps_pages; i++) {
- ps_page = &bi->ps_pages[i];
-
- if (ps_page->page) {
- pr_info("packet dump for ps_page %d:\n", i);
- print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS,
- 16, 1, page_address(ps_page->page),
- PAGE_SIZE, true);
- }
- }
-}
-
/**
* e1000e_dump - Print registers, Tx-ring and Rx-ring
* @adapter: board private structure
@@ -225,13 +207,10 @@ static void e1000e_dump(struct e1000_adapter *adapter)
} *u0;
struct e1000_buffer *buffer_info;
struct e1000_ring *rx_ring = adapter->rx_ring;
- union e1000_rx_desc_packet_split *rx_desc_ps;
union e1000_rx_desc_extended *rx_desc;
struct my_u1 {
__le64 a;
__le64 b;
- __le64 c;
- __le64 d;
} *u1;
u32 staterr;
int i = 0;
@@ -347,140 +326,68 @@ static void e1000e_dump(struct e1000_adapter *adapter)
return;
dev_info(&adapter->pdev->dev, "Rx Ring Dump\n");
- switch (adapter->rx_ps_pages) {
- case 1:
- case 2:
- case 3:
- /* [Extended] Packet Split Receive Descriptor Format
- *
- * +-----------------------------------------------------+
- * 0 | Buffer Address 0 [63:0] |
- * +-----------------------------------------------------+
- * 8 | Buffer Address 1 [63:0] |
- * +-----------------------------------------------------+
- * 16 | Buffer Address 2 [63:0] |
- * +-----------------------------------------------------+
- * 24 | Buffer Address 3 [63:0] |
- * +-----------------------------------------------------+
- */
- pr_info("R [desc] [buffer 0 63:0 ] [buffer 1 63:0 ] [buffer 2 63:0 ] [buffer 3 63:0 ] [bi->dma ] [bi->skb] <-- Ext Pkt Split format\n");
- /* [Extended] Receive Descriptor (Write-Back) Format
- *
- * 63 48 47 32 31 13 12 8 7 4 3 0
- * +------------------------------------------------------+
- * 0 | Packet | IP | Rsvd | MRQ | Rsvd | MRQ RSS |
- * | Checksum | Ident | | Queue | | Type |
- * +------------------------------------------------------+
- * 8 | VLAN Tag | Length | Extended Error | Extended Status |
- * +------------------------------------------------------+
- * 63 48 47 32 31 20 19 0
- */
- pr_info("RWB[desc] [ck ipid mrqhsh] [vl l0 ee es] [ l3 l2 l1 hs] [reserved ] ---------------- [bi->skb] <-- Ext Rx Write-Back format\n");
- for (i = 0; i < rx_ring->count; i++) {
- const char *next_desc;
- buffer_info = &rx_ring->buffer_info[i];
- rx_desc_ps = E1000_RX_DESC_PS(*rx_ring, i);
- u1 = (struct my_u1 *)rx_desc_ps;
- staterr =
- le32_to_cpu(rx_desc_ps->wb.middle.status_error);
-
- if (i == rx_ring->next_to_use)
- next_desc = " NTU";
- else if (i == rx_ring->next_to_clean)
- next_desc = " NTC";
- else
- next_desc = "";
-
- if (staterr & E1000_RXD_STAT_DD) {
- /* Descriptor Done */
- pr_info("%s[0x%03X] %016llX %016llX %016llX %016llX ---------------- %p%s\n",
- "RWB", i,
- (unsigned long long)le64_to_cpu(u1->a),
- (unsigned long long)le64_to_cpu(u1->b),
- (unsigned long long)le64_to_cpu(u1->c),
- (unsigned long long)le64_to_cpu(u1->d),
- buffer_info->skb, next_desc);
- } else {
- pr_info("%s[0x%03X] %016llX %016llX %016llX %016llX %016llX %p%s\n",
- "R ", i,
- (unsigned long long)le64_to_cpu(u1->a),
- (unsigned long long)le64_to_cpu(u1->b),
- (unsigned long long)le64_to_cpu(u1->c),
- (unsigned long long)le64_to_cpu(u1->d),
- (unsigned long long)buffer_info->dma,
- buffer_info->skb, next_desc);
-
- if (netif_msg_pktdata(adapter))
- e1000e_dump_ps_pages(adapter,
- buffer_info);
- }
- }
- break;
- default:
- case 0:
- /* Extended Receive Descriptor (Read) Format
- *
- * +-----------------------------------------------------+
- * 0 | Buffer Address [63:0] |
- * +-----------------------------------------------------+
- * 8 | Reserved |
- * +-----------------------------------------------------+
- */
- pr_info("R [desc] [buf addr 63:0 ] [reserved 63:0 ] [bi->dma ] [bi->skb] <-- Ext (Read) format\n");
- /* Extended Receive Descriptor (Write-Back) Format
- *
- * 63 48 47 32 31 24 23 4 3 0
- * +------------------------------------------------------+
- * | RSS Hash | | | |
- * 0 +-------------------+ Rsvd | Reserved | MRQ RSS |
- * | Packet | IP | | | Type |
- * | Checksum | Ident | | | |
- * +------------------------------------------------------+
- * 8 | VLAN Tag | Length | Extended Error | Extended Status |
- * +------------------------------------------------------+
- * 63 48 47 32 31 20 19 0
- */
- pr_info("RWB[desc] [cs ipid mrq] [vt ln xe xs] [bi->skb] <-- Ext (Write-Back) format\n");
+ /* Extended Receive Descriptor (Read) Format
+ *
+ * +-----------------------------------------------------+
+ * 0 | Buffer Address [63:0] |
+ * +-----------------------------------------------------+
+ * 8 | Reserved |
+ * +-----------------------------------------------------+
+ */
+ pr_info("R [desc] [buf addr 63:0 ] [reserved 63:0 ] [bi->dma ] [bi->skb] <-- Ext (Read) format\n");
+ /* Extended Receive Descriptor (Write-Back) Format
+ *
+ * 63 48 47 32 31 24 23 4 3 0
+ * +------------------------------------------------------+
+ * | RSS Hash | | | |
+ * 0 +-------------------+ Rsvd | Reserved | MRQ RSS |
+ * | Packet | IP | | | Type |
+ * | Checksum | Ident | | | |
+ * +------------------------------------------------------+
+ * 8 | VLAN Tag | Length | Extended Error | Extended Status |
+ * +------------------------------------------------------+
+ * 63 48 47 32 31 20 19 0
+ */
+ pr_info("RWB[desc] [cs ipid mrq] [vt ln xe xs] [bi->skb] <-- Ext (Write-Back) format\n");
- for (i = 0; i < rx_ring->count; i++) {
- const char *next_desc;
+ for (i = 0; i < rx_ring->count; i++) {
+ const char *next_desc;
- buffer_info = &rx_ring->buffer_info[i];
- rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
- u1 = (struct my_u1 *)rx_desc;
- staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
+ buffer_info = &rx_ring->buffer_info[i];
+ rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
+ u1 = (struct my_u1 *)rx_desc;
+ staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
- if (i == rx_ring->next_to_use)
- next_desc = " NTU";
- else if (i == rx_ring->next_to_clean)
- next_desc = " NTC";
- else
- next_desc = "";
-
- if (staterr & E1000_RXD_STAT_DD) {
- /* Descriptor Done */
- pr_info("%s[0x%03X] %016llX %016llX ---------------- %p%s\n",
- "RWB", i,
- (unsigned long long)le64_to_cpu(u1->a),
- (unsigned long long)le64_to_cpu(u1->b),
- buffer_info->skb, next_desc);
- } else {
- pr_info("%s[0x%03X] %016llX %016llX %016llX %p%s\n",
- "R ", i,
- (unsigned long long)le64_to_cpu(u1->a),
- (unsigned long long)le64_to_cpu(u1->b),
- (unsigned long long)buffer_info->dma,
- buffer_info->skb, next_desc);
-
- if (netif_msg_pktdata(adapter) &&
- buffer_info->skb)
- print_hex_dump(KERN_INFO, "",
- DUMP_PREFIX_ADDRESS, 16,
- 1,
- buffer_info->skb->data,
- adapter->rx_buffer_len,
- true);
- }
+ if (i == rx_ring->next_to_use)
+ next_desc = " NTU";
+ else if (i == rx_ring->next_to_clean)
+ next_desc = " NTC";
+ else
+ next_desc = "";
+
+ if (staterr & E1000_RXD_STAT_DD) {
+ /* Descriptor Done */
+ pr_info("%s[0x%03X] %016llX %016llX ---------------- %p%s\n",
+ "RWB", i,
+ (unsigned long long)le64_to_cpu(u1->a),
+ (unsigned long long)le64_to_cpu(u1->b),
+ buffer_info->skb, next_desc);
+ } else {
+ pr_info("%s[0x%03X] %016llX %016llX %016llX %p%s\n",
+ "R ", i,
+ (unsigned long long)le64_to_cpu(u1->a),
+ (unsigned long long)le64_to_cpu(u1->b),
+ (unsigned long long)buffer_info->dma,
+ buffer_info->skb, next_desc);
+
+ if (netif_msg_pktdata(adapter) &&
+ buffer_info->skb)
+ print_hex_dump(KERN_INFO, "",
+ DUMP_PREFIX_ADDRESS, 16,
+ 1,
+ buffer_info->skb->data,
+ adapter->rx_buffer_len,
+ true);
}
}
}
@@ -727,110 +634,6 @@ static void e1000_alloc_rx_buffers(struct e1000_ring *rx_ring,
rx_ring->next_to_use = i;
}
-/**
- * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split
- * @rx_ring: Rx descriptor ring
- * @cleaned_count: number to reallocate
- * @gfp: flags for allocation
- **/
-static void e1000_alloc_rx_buffers_ps(struct e1000_ring *rx_ring,
- int cleaned_count, gfp_t gfp)
-{
- struct e1000_adapter *adapter = rx_ring->adapter;
- struct net_device *netdev = adapter->netdev;
- struct pci_dev *pdev = adapter->pdev;
- union e1000_rx_desc_packet_split *rx_desc;
- struct e1000_buffer *buffer_info;
- struct e1000_ps_page *ps_page;
- struct sk_buff *skb;
- unsigned int i, j;
-
- i = rx_ring->next_to_use;
- buffer_info = &rx_ring->buffer_info[i];
-
- while (cleaned_count--) {
- rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
-
- for (j = 0; j < PS_PAGE_BUFFERS; j++) {
- ps_page = &buffer_info->ps_pages[j];
- if (j >= adapter->rx_ps_pages) {
- /* all unused desc entries get hw null ptr */
- rx_desc->read.buffer_addr[j + 1] =
- ~cpu_to_le64(0);
- continue;
- }
- if (!ps_page->page) {
- ps_page->page = alloc_page(gfp);
- if (!ps_page->page) {
- adapter->alloc_rx_buff_failed++;
- goto no_buffers;
- }
- ps_page->dma = dma_map_page(&pdev->dev,
- ps_page->page,
- 0, PAGE_SIZE,
- DMA_FROM_DEVICE);
- if (dma_mapping_error(&pdev->dev,
- ps_page->dma)) {
- dev_err(&adapter->pdev->dev,
- "Rx DMA page map failed\n");
- adapter->rx_dma_failed++;
- goto no_buffers;
- }
- }
- /* Refresh the desc even if buffer_addrs
- * didn't change because each write-back
- * erases this info.
- */
- rx_desc->read.buffer_addr[j + 1] =
- cpu_to_le64(ps_page->dma);
- }
-
- skb = __netdev_alloc_skb_ip_align(netdev, adapter->rx_ps_bsize0,
- gfp);
-
- if (!skb) {
- adapter->alloc_rx_buff_failed++;
- break;
- }
-
- buffer_info->skb = skb;
- buffer_info->dma = dma_map_single(&pdev->dev, skb->data,
- adapter->rx_ps_bsize0,
- DMA_FROM_DEVICE);
- if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
- dev_err(&pdev->dev, "Rx DMA map failed\n");
- adapter->rx_dma_failed++;
- /* cleanup skb */
- dev_kfree_skb_any(skb);
- buffer_info->skb = NULL;
- break;
- }
-
- rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma);
-
- if (unlikely(!(i & (E1000_RX_BUFFER_WRITE - 1)))) {
- /* Force memory writes to complete before letting h/w
- * know there are new descriptors to fetch. (Only
- * applicable for weak-ordered memory model archs,
- * such as IA-64).
- */
- wmb();
- if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
- e1000e_update_rdt_wa(rx_ring, i << 1);
- else
- writel(i << 1, rx_ring->tail);
- }
-
- i++;
- if (i == rx_ring->count)
- i = 0;
- buffer_info = &rx_ring->buffer_info[i];
- }
-
-no_buffers:
- rx_ring->next_to_use = i;
-}
-
/**
* e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers
* @rx_ring: Rx descriptor ring
@@ -1318,193 +1121,6 @@ static bool e1000_clean_tx_irq(struct e1000_ring *tx_ring)
return count < tx_ring->count;
}
-/**
- * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split
- * @rx_ring: Rx descriptor ring
- * @work_done: output parameter for indicating completed work
- * @work_to_do: how many packets we can clean
- *
- * the return value indicates whether actual cleaning was done, there
- * is no guarantee that everything was cleaned
- **/
-static bool e1000_clean_rx_irq_ps(struct e1000_ring *rx_ring, int *work_done,
- int work_to_do)
-{
- struct e1000_adapter *adapter = rx_ring->adapter;
- struct e1000_hw *hw = &adapter->hw;
- union e1000_rx_desc_packet_split *rx_desc, *next_rxd;
- struct net_device *netdev = adapter->netdev;
- struct pci_dev *pdev = adapter->pdev;
- struct e1000_buffer *buffer_info, *next_buffer;
- struct e1000_ps_page *ps_page;
- struct sk_buff *skb;
- unsigned int i, j;
- u32 length, staterr;
- int cleaned_count = 0;
- bool cleaned = false;
- unsigned int total_rx_bytes = 0, total_rx_packets = 0;
-
- i = rx_ring->next_to_clean;
- rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
- staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
- buffer_info = &rx_ring->buffer_info[i];
-
- while (staterr & E1000_RXD_STAT_DD) {
- if (*work_done >= work_to_do)
- break;
- (*work_done)++;
- skb = buffer_info->skb;
- dma_rmb(); /* read descriptor and rx_buffer_info after status DD */
-
- /* in the packet split case this is header only */
- prefetch(skb->data - NET_IP_ALIGN);
-
- i++;
- if (i == rx_ring->count)
- i = 0;
- next_rxd = E1000_RX_DESC_PS(*rx_ring, i);
- prefetch(next_rxd);
-
- next_buffer = &rx_ring->buffer_info[i];
-
- cleaned = true;
- cleaned_count++;
- dma_unmap_single(&pdev->dev, buffer_info->dma,
- adapter->rx_ps_bsize0, DMA_FROM_DEVICE);
- buffer_info->dma = 0;
-
- /* see !EOP comment in other Rx routine */
- if (!(staterr & E1000_RXD_STAT_EOP))
- adapter->flags2 |= FLAG2_IS_DISCARDING;
-
- if (adapter->flags2 & FLAG2_IS_DISCARDING) {
- e_dbg("Packet Split buffers didn't pick up the full packet\n");
- dev_kfree_skb_irq(skb);
- if (staterr & E1000_RXD_STAT_EOP)
- adapter->flags2 &= ~FLAG2_IS_DISCARDING;
- goto next_desc;
- }
-
- if (unlikely((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) &&
- !(netdev->features & NETIF_F_RXALL))) {
- dev_kfree_skb_irq(skb);
- goto next_desc;
- }
-
- length = le16_to_cpu(rx_desc->wb.middle.length0);
-
- if (!length) {
- e_dbg("Last part of the packet spanning multiple descriptors\n");
- dev_kfree_skb_irq(skb);
- goto next_desc;
- }
-
- /* Good Receive */
- skb_put(skb, length);
-
- {
- /* this looks ugly, but it seems compiler issues make
- * it more efficient than reusing j
- */
- int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]);
-
- /* page alloc/put takes too long and effects small
- * packet throughput, so unsplit small packets and
- * save the alloc/put
- */
- if (l1 && (l1 <= copybreak) &&
- ((length + l1) <= adapter->rx_ps_bsize0)) {
- ps_page = &buffer_info->ps_pages[0];
-
- dma_sync_single_for_cpu(&pdev->dev,
- ps_page->dma,
- PAGE_SIZE,
- DMA_FROM_DEVICE);
- memcpy(skb_tail_pointer(skb),
- page_address(ps_page->page), l1);
- dma_sync_single_for_device(&pdev->dev,
- ps_page->dma,
- PAGE_SIZE,
- DMA_FROM_DEVICE);
-
- /* remove the CRC */
- if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) {
- if (!(netdev->features & NETIF_F_RXFCS))
- l1 -= 4;
- }
-
- skb_put(skb, l1);
- goto copydone;
- } /* if */
- }
-
- for (j = 0; j < PS_PAGE_BUFFERS; j++) {
- length = le16_to_cpu(rx_desc->wb.upper.length[j]);
- if (!length)
- break;
-
- ps_page = &buffer_info->ps_pages[j];
- dma_unmap_page(&pdev->dev, ps_page->dma, PAGE_SIZE,
- DMA_FROM_DEVICE);
- ps_page->dma = 0;
- skb_fill_page_desc(skb, j, ps_page->page, 0, length);
- ps_page->page = NULL;
- skb->len += length;
- skb->data_len += length;
- skb->truesize += PAGE_SIZE;
- }
-
- /* strip the ethernet crc, problem is we're using pages now so
- * this whole operation can get a little cpu intensive
- */
- if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) {
- if (!(netdev->features & NETIF_F_RXFCS))
- pskb_trim(skb, skb->len - 4);
- }
-
-copydone:
- total_rx_bytes += skb->len;
- total_rx_packets++;
-
- e1000_rx_checksum(adapter, staterr, skb);
-
- e1000_rx_hash(netdev, rx_desc->wb.lower.hi_dword.rss, skb);
-
- if (rx_desc->wb.upper.header_status &
- cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP))
- adapter->rx_hdr_split++;
-
- e1000_receive_skb(adapter, netdev, skb, staterr,
- rx_desc->wb.middle.vlan);
-
-next_desc:
- rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF);
- buffer_info->skb = NULL;
-
- /* return some buffers to hardware, one at a time is too slow */
- if (cleaned_count >= E1000_RX_BUFFER_WRITE) {
- adapter->alloc_rx_buf(rx_ring, cleaned_count,
- GFP_ATOMIC);
- cleaned_count = 0;
- }
-
- /* use prefetched values */
- rx_desc = next_rxd;
- buffer_info = next_buffer;
-
- staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
- }
- rx_ring->next_to_clean = i;
-
- cleaned_count = e1000_desc_unused(rx_ring);
- if (cleaned_count)
- adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC);
-
- adapter->total_rx_bytes += total_rx_bytes;
- adapter->total_rx_packets += total_rx_packets;
- return cleaned;
-}
-
static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb,
u16 length)
{
@@ -1692,9 +1308,8 @@ static void e1000_clean_rx_ring(struct e1000_ring *rx_ring)
{
struct e1000_adapter *adapter = rx_ring->adapter;
struct e1000_buffer *buffer_info;
- struct e1000_ps_page *ps_page;
struct pci_dev *pdev = adapter->pdev;
- unsigned int i, j;
+ unsigned int i;
/* Free all the Rx ring sk_buffs */
for (i = 0; i < rx_ring->count; i++) {
@@ -1707,10 +1322,6 @@ static void e1000_clean_rx_ring(struct e1000_ring *rx_ring)
else if (adapter->clean_rx == e1000_clean_jumbo_rx_irq)
dma_unmap_page(&pdev->dev, buffer_info->dma,
PAGE_SIZE, DMA_FROM_DEVICE);
- else if (adapter->clean_rx == e1000_clean_rx_irq_ps)
- dma_unmap_single(&pdev->dev, buffer_info->dma,
- adapter->rx_ps_bsize0,
- DMA_FROM_DEVICE);
buffer_info->dma = 0;
}
@@ -1723,17 +1334,6 @@ static void e1000_clean_rx_ring(struct e1000_ring *rx_ring)
dev_kfree_skb(buffer_info->skb);
buffer_info->skb = NULL;
}
-
- for (j = 0; j < PS_PAGE_BUFFERS; j++) {
- ps_page = &buffer_info->ps_pages[j];
- if (!ps_page->page)
- break;
- dma_unmap_page(&pdev->dev, ps_page->dma, PAGE_SIZE,
- DMA_FROM_DEVICE);
- ps_page->dma = 0;
- put_page(ps_page->page);
- ps_page->page = NULL;
- }
}
/* there also may be some cached data from a chained receive */
@@ -2384,31 +1984,20 @@ int e1000e_setup_tx_resources(struct e1000_ring *tx_ring)
int e1000e_setup_rx_resources(struct e1000_ring *rx_ring)
{
struct e1000_adapter *adapter = rx_ring->adapter;
- struct e1000_buffer *buffer_info;
- int i, size, desc_len, err = -ENOMEM;
+ int size, err = -ENOMEM;
size = sizeof(struct e1000_buffer) * rx_ring->count;
rx_ring->buffer_info = vzalloc(size);
if (!rx_ring->buffer_info)
goto err;
- for (i = 0; i < rx_ring->count; i++) {
- buffer_info = &rx_ring->buffer_info[i];
- buffer_info->ps_pages = kzalloc_objs(struct e1000_ps_page,
- PS_PAGE_BUFFERS);
- if (!buffer_info->ps_pages)
- goto err_pages;
- }
-
- desc_len = sizeof(union e1000_rx_desc_packet_split);
-
/* Round up to nearest 4K */
- rx_ring->size = rx_ring->count * desc_len;
+ rx_ring->size = rx_ring->count * sizeof(union e1000_rx_desc_extended);
rx_ring->size = ALIGN(rx_ring->size, 4096);
err = e1000_alloc_ring_dma(adapter, rx_ring);
if (err)
- goto err_pages;
+ goto err;
rx_ring->next_to_clean = 0;
rx_ring->next_to_use = 0;
@@ -2416,11 +2005,6 @@ int e1000e_setup_rx_resources(struct e1000_ring *rx_ring)
return 0;
-err_pages:
- for (i = 0; i < rx_ring->count; i++) {
- buffer_info = &rx_ring->buffer_info[i];
- kfree(buffer_info->ps_pages);
- }
err:
vfree(rx_ring->buffer_info);
e_err("Unable to allocate memory for the receive descriptor ring\n");
@@ -2484,13 +2068,9 @@ void e1000e_free_rx_resources(struct e1000_ring *rx_ring)
{
struct e1000_adapter *adapter = rx_ring->adapter;
struct pci_dev *pdev = adapter->pdev;
- int i;
e1000_clean_rx_ring(rx_ring);
- for (i = 0; i < rx_ring->count; i++)
- kfree(rx_ring->buffer_info[i].ps_pages);
-
vfree(rx_ring->buffer_info);
rx_ring->buffer_info = NULL;
@@ -3037,9 +2617,6 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)
}
}
-#define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
- (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
-
/**
* e1000_setup_rctl - configure the receive control registers
* @adapter: Board private structure
@@ -3048,7 +2625,6 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
u32 rctl, rfctl;
- u32 pages = 0;
/* Workaround Si errata on PCHx - configure jumbo frame flow.
* If jumbo frames not set, program related MAC/PHY registers
@@ -3131,48 +2707,8 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
rfctl |= E1000_RFCTL_EXTEN;
ew32(RFCTL, rfctl);
- /* 82571 and greater support packet-split where the protocol
- * header is placed in skb->data and the packet data is
- * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
- * In the case of a non-split, skb->data is linearly filled,
- * followed by the page buffers. Therefore, skb->data is
- * sized to hold the largest protocol header.
- *
- * allocations using alloc_page take too long for regular MTU
- * so only enable packet split for jumbo frames
- *
- * Using pages when the page size is greater than 16k wastes
- * a lot of memory, since we allocate 3 pages at all times
- * per packet.
- */
- pages = PAGE_USE_COUNT(adapter->netdev->mtu);
- if ((pages <= 3) && (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE))
- adapter->rx_ps_pages = pages;
- else
- adapter->rx_ps_pages = 0;
-
- if (adapter->rx_ps_pages) {
- u32 psrctl = 0;
-
- /* Enable Packet split descriptors */
- rctl |= E1000_RCTL_DTYP_PS;
-
- psrctl |= adapter->rx_ps_bsize0 >> E1000_PSRCTL_BSIZE0_SHIFT;
-
- switch (adapter->rx_ps_pages) {
- case 3:
- psrctl |= PAGE_SIZE << E1000_PSRCTL_BSIZE3_SHIFT;
- fallthrough;
- case 2:
- psrctl |= PAGE_SIZE << E1000_PSRCTL_BSIZE2_SHIFT;
- fallthrough;
- case 1:
- psrctl |= PAGE_SIZE >> E1000_PSRCTL_BSIZE1_SHIFT;
- break;
- }
-
- ew32(PSRCTL, psrctl);
- }
+ /* Use the extended descriptor format, not packet split */
+ rctl &= ~E1000_RCTL_DTYP_PS;
/* This is useful for sniffing bad packets. */
if (adapter->netdev->features & NETIF_F_RXALL) {
@@ -3209,13 +2745,7 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
u64 rdba;
u32 rdlen, rctl, rxcsum, ctrl_ext;
- if (adapter->rx_ps_pages) {
- /* this is a 32 byte descriptor */
- rdlen = rx_ring->count *
- sizeof(union e1000_rx_desc_packet_split);
- adapter->clean_rx = e1000_clean_rx_irq_ps;
- adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
- } else if (adapter->netdev->mtu > ETH_FRAME_LEN + ETH_FCS_LEN) {
+ if (adapter->netdev->mtu > ETH_FRAME_LEN + ETH_FCS_LEN) {
rdlen = rx_ring->count * sizeof(union e1000_rx_desc_extended);
adapter->clean_rx = e1000_clean_jumbo_rx_irq;
adapter->alloc_rx_buf = e1000_alloc_jumbo_rx_buffers;
@@ -4481,7 +4011,6 @@ static int e1000_sw_init(struct e1000_adapter *adapter)
struct net_device *netdev = adapter->netdev;
adapter->rx_buffer_len = VLAN_ETH_FRAME_LEN + ETH_FCS_LEN;
- adapter->rx_ps_bsize0 = 128;
adapter->max_frame_size = netdev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
adapter->tx_ring_count = E1000_DEFAULT_TXD;
--
2.56.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v5 4/6] e1000e: use libeth for Rx buffer management
2026-12-04 20:43 [PATCH net-next v5 0/6] e1000e: add XDP support Matteo Croce
` (2 preceding siblings ...)
2026-12-04 20:43 ` [PATCH net-next v5 3/6] e1000e: remove packet split Rx Matteo Croce
@ 2026-12-04 20:43 ` Matteo Croce
2026-12-04 20:44 ` [PATCH net-next v5 6/6] e1000e: add .ndo_xdp_xmit support Matteo Croce
4 siblings, 0 replies; 6+ messages in thread
From: Matteo Croce @ 2026-12-04 20:43 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Mohsin Bashir, Nemo D'ACREMONT
Cc: netdev, bpf, intel-wired-lan, linux-kernel
The driver has two Rx routines, selected at configuration time via
function pointers: one for the standard MTU, which receives into linear
skbs and drops frames spanning more than one descriptor, and one for
jumbo frames, which receives into pages and chains them into skb frags.
Replace both with a single Rx routine, using the libeth helpers to
manage the buffers:
- the Rx buffers are allocated from a page_pool created by libeth when
the interface is brought up, and destroyed when it goes down;
- the received buffers are assembled into an xdp_buff, which can span
multiple descriptors and NAPI polls, and then converted into an skb;
- the hardware is always programmed for 2 KB buffers, as it only
supports buffer sizes which are powers of two, and frames which don't
fit in a single buffer span multiple descriptors. When long packet
reception is disabled, frames are never bigger than a VLAN tagged
frame, so the buffers are allocated just big enough to fit them,
allowing two buffers per 4 KB page.
The adapter->clean_rx and adapter->alloc_rx_buf function pointers are
removed, together with rx_buffer_len, as the buffer size no longer
depends on the MTU.
As the buffers are recycled by the page_pool, copying small frames into
a new skb is no longer useful, so remove the copybreak module parameter.
Signed-off-by: Matteo Croce <technoboy85@gmail.com>
---
.../device_drivers/ethernet/intel/e1000e.rst | 15 -
drivers/net/ethernet/intel/Kconfig | 1 +
drivers/net/ethernet/intel/e1000e/e1000.h | 46 +-
drivers/net/ethernet/intel/e1000e/netdev.c | 789 ++++++------------
drivers/net/ethernet/intel/e1000e/param.c | 6 -
5 files changed, 261 insertions(+), 596 deletions(-)
diff --git a/Documentation/networking/device_drivers/ethernet/intel/e1000e.rst b/Documentation/networking/device_drivers/ethernet/intel/e1000e.rst
index d8f810afdd49..fab6ebc0cf95 100644
--- a/Documentation/networking/device_drivers/ethernet/intel/e1000e.rst
+++ b/Documentation/networking/device_drivers/ethernet/intel/e1000e.rst
@@ -163,21 +163,6 @@ It ensures that an interrupt is generated after the initial Packet is sent on
the wire within the set amount of time. Proper tuning, along with TxIntDelay,
may improve traffic throughput in specific network conditions.
-copybreak
----------
-:Valid Range: 0-xxxxxxx (0=off)
-:Default Value: 256
-
-The driver copies all packets below or equaling this size to a fresh receive
-buffer before handing it up the stack.
-This parameter differs from other parameters because it is a single (not 1,1,1
-etc.) parameter applied to all driver instances and it is also available
-during runtime at /sys/module/e1000e/parameters/copybreak.
-
-To use copybreak, type::
-
- modprobe e1000e.ko copybreak=128
-
SmartPowerDownEnable
--------------------
:Valid Range: 0,1
diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/intel/Kconfig
index 780f113986ea..786237a093c7 100644
--- a/drivers/net/ethernet/intel/Kconfig
+++ b/drivers/net/ethernet/intel/Kconfig
@@ -63,6 +63,7 @@ config E1000E
depends on PCI && (!SPARC32 || BROKEN)
depends on PTP_1588_CLOCK_OPTIONAL
select CRC32
+ select LIBETH_XDP
help
This driver supports the PCI-Express Intel(R) PRO/1000 gigabit
ethernet family of adapters. For PCI or PCI-X e1000 adapters,
diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h
index 533d1981eb5e..41c96edf1a9c 100644
--- a/drivers/net/ethernet/intel/e1000e/e1000.h
+++ b/drivers/net/ethernet/intel/e1000e/e1000.h
@@ -23,6 +23,8 @@
#include <linux/mdio.h>
#include <linux/mutex.h>
#include <linux/pm_qos.h>
+#include <net/libeth/types.h>
+#include <net/xdp.h>
#include "hw.h"
struct e1000_info;
@@ -61,6 +63,9 @@ struct e1000_info;
/* How many Rx Buffers do we bundle into one write to the hardware ? */
#define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */
+/* Rx buffer size programmed into the hardware */
+#define E1000_RX_BUFFER_LEN 2048
+
#define AUTO_ALL_MODES 0
#define E1000_EEPROM_APME 0x0400
@@ -127,19 +132,12 @@ enum e1000_boards {
struct e1000_buffer {
dma_addr_t dma;
struct sk_buff *skb;
- union {
- /* Tx */
- struct {
- unsigned long time_stamp;
- u16 length;
- u16 next_to_watch;
- unsigned int segs;
- unsigned int bytecount;
- u16 mapped_as_page;
- };
- /* Rx */
- struct page *page;
- };
+ unsigned long time_stamp;
+ u16 length;
+ u16 next_to_watch;
+ unsigned int segs;
+ unsigned int bytecount;
+ u16 mapped_as_page;
};
struct e1000_ring {
@@ -155,16 +153,22 @@ struct e1000_ring {
void __iomem *head;
void __iomem *tail;
- /* array of buffer information structs */
+ /* array of buffer information structs, Tx only */
struct e1000_buffer *buffer_info;
+ /* Rx buffers and the page_pool they are allocated from */
+ struct libeth_fqe *rx_fqes;
+ struct page_pool *pp;
+ u32 truesize;
+ /* frame spanning multiple NAPI polls */
+ struct libeth_xdp_buff_stash xdp;
+ struct xdp_rxq_info xdp_rxq;
+
char name[IFNAMSIZ + 5];
u32 ims_val;
u32 itr_val;
void __iomem *itr_register;
int set_itr;
-
- struct sk_buff *rx_skb_top;
};
/* PHY register snapshot values */
@@ -192,7 +196,6 @@ struct e1000_adapter {
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
u32 bd_number;
- u32 rx_buffer_len;
u16 mng_vlan_id;
u16 link_speed;
u16 link_duplex;
@@ -244,11 +247,7 @@ struct e1000_adapter {
u32 tx_hwtstamp_skipped;
/* Rx */
- bool (*clean_rx)(struct e1000_ring *ring, int *work_done,
- int work_to_do) ____cacheline_aligned_in_smp;
- void (*alloc_rx_buf)(struct e1000_ring *ring, int cleaned_count,
- gfp_t gfp);
- struct e1000_ring *rx_ring;
+ struct e1000_ring *rx_ring ____cacheline_aligned_in_smp;
u32 rx_int_delay;
u32 rx_abs_int_delay;
@@ -436,7 +435,6 @@ s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca);
#define FLAG2_CRC_STRIPPING BIT(0)
#define FLAG2_HAS_PHY_WAKEUP BIT(1)
-#define FLAG2_IS_DISCARDING BIT(2)
#define FLAG2_DISABLE_ASPM_L1 BIT(3)
#define FLAG2_HAS_PHY_STATS BIT(4)
#define FLAG2_HAS_EEE BIT(5)
@@ -496,8 +494,6 @@ void e1000e_get_hw_control(struct e1000_adapter *adapter);
void e1000e_release_hw_control(struct e1000_adapter *adapter);
void e1000e_write_itr(struct e1000_adapter *adapter, u32 itr);
-extern unsigned int copybreak;
-
extern const struct e1000_info e1000_82571_info;
extern const struct e1000_info e1000_82572_info;
extern const struct e1000_info e1000_82573_info;
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 391ff8f91ab5..155dc8d32348 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -26,6 +26,7 @@
#include <linux/prefetch.h>
#include <linux/suspend.h>
#include <linux/dmi.h>
+#include <net/libeth/xdp.h>
#include "e1000.h"
#define CREATE_TRACE_POINTS
@@ -334,7 +335,7 @@ static void e1000e_dump(struct e1000_adapter *adapter)
* 8 | Reserved |
* +-----------------------------------------------------+
*/
- pr_info("R [desc] [buf addr 63:0 ] [reserved 63:0 ] [bi->dma ] [bi->skb] <-- Ext (Read) format\n");
+ pr_info("R [desc] [buf addr 63:0 ] [reserved 63:0 ] [netmem ] <-- Ext (Read) format\n");
/* Extended Receive Descriptor (Write-Back) Format
*
* 63 48 47 32 31 24 23 4 3 0
@@ -348,12 +349,14 @@ static void e1000e_dump(struct e1000_adapter *adapter)
* +------------------------------------------------------+
* 63 48 47 32 31 20 19 0
*/
- pr_info("RWB[desc] [cs ipid mrq] [vt ln xe xs] [bi->skb] <-- Ext (Write-Back) format\n");
+ pr_info("RWB[desc] [cs ipid mrq] [vt ln xe xs] <-- Ext (Write-Back) format\n");
for (i = 0; i < rx_ring->count; i++) {
+ unsigned long netmem = 0;
const char *next_desc;
- buffer_info = &rx_ring->buffer_info[i];
+ if (rx_ring->rx_fqes)
+ netmem = (__force unsigned long)rx_ring->rx_fqes[i].netmem;
rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
u1 = (struct my_u1 *)rx_desc;
staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
@@ -367,27 +370,17 @@ static void e1000e_dump(struct e1000_adapter *adapter)
if (staterr & E1000_RXD_STAT_DD) {
/* Descriptor Done */
- pr_info("%s[0x%03X] %016llX %016llX ---------------- %p%s\n",
+ pr_info("%s[0x%03X] %016llX %016llX%s\n",
"RWB", i,
(unsigned long long)le64_to_cpu(u1->a),
(unsigned long long)le64_to_cpu(u1->b),
- buffer_info->skb, next_desc);
+ next_desc);
} else {
- pr_info("%s[0x%03X] %016llX %016llX %016llX %p%s\n",
+ pr_info("%s[0x%03X] %016llX %016llX %016lX%s\n",
"R ", i,
(unsigned long long)le64_to_cpu(u1->a),
(unsigned long long)le64_to_cpu(u1->b),
- (unsigned long long)buffer_info->dma,
- buffer_info->skb, next_desc);
-
- if (netif_msg_pktdata(adapter) &&
- buffer_info->skb)
- print_hex_dump(KERN_INFO, "",
- DUMP_PREFIX_ADDRESS, 16,
- 1,
- buffer_info->skb->data,
- adapter->rx_buffer_len,
- true);
+ netmem, next_desc);
}
}
}
@@ -468,30 +461,6 @@ static void e1000e_rx_hwtstamp(struct e1000_adapter *adapter, u32 status,
adapter->flags2 &= ~FLAG2_CHECK_RX_HWTSTAMP;
}
-/**
- * e1000_receive_skb - helper function to handle Rx indications
- * @adapter: board private structure
- * @netdev: pointer to netdev struct
- * @staterr: descriptor extended error and status field as written by hardware
- * @vlan: descriptor vlan field as written by hardware (no le/be conversion)
- * @skb: pointer to sk_buff to be indicated to stack
- **/
-static void e1000_receive_skb(struct e1000_adapter *adapter,
- struct net_device *netdev, struct sk_buff *skb,
- u32 staterr, __le16 vlan)
-{
- u16 tag = le16_to_cpu(vlan);
-
- e1000e_rx_hwtstamp(adapter, staterr, skb);
-
- skb->protocol = eth_type_trans(skb, netdev);
-
- if (staterr & E1000_RXD_STAT_VP)
- __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), tag);
-
- napi_gro_receive(&adapter->napi, skb);
-}
-
/**
* e1000_rx_checksum - Receive Checksum Offload
* @adapter: board private structure
@@ -567,143 +536,45 @@ static void e1000e_update_tdt_wa(struct e1000_ring *tx_ring, unsigned int i)
/**
* e1000_alloc_rx_buffers - Replace used receive buffers
* @rx_ring: Rx descriptor ring
- * @cleaned_count: number to reallocate
- * @gfp: flags for allocation
- **/
-static void e1000_alloc_rx_buffers(struct e1000_ring *rx_ring,
- int cleaned_count, gfp_t gfp)
-{
- struct e1000_adapter *adapter = rx_ring->adapter;
- struct net_device *netdev = adapter->netdev;
- struct pci_dev *pdev = adapter->pdev;
- union e1000_rx_desc_extended *rx_desc;
- struct e1000_buffer *buffer_info;
- struct sk_buff *skb;
- unsigned int i;
- unsigned int bufsz = adapter->rx_buffer_len;
-
- i = rx_ring->next_to_use;
- buffer_info = &rx_ring->buffer_info[i];
-
- while (cleaned_count--) {
- skb = buffer_info->skb;
- if (skb) {
- skb_trim(skb, 0);
- goto map_skb;
- }
-
- skb = __netdev_alloc_skb_ip_align(netdev, bufsz, gfp);
- if (!skb) {
- /* Better luck next round */
- adapter->alloc_rx_buff_failed++;
- break;
- }
-
- buffer_info->skb = skb;
-map_skb:
- buffer_info->dma = dma_map_single(&pdev->dev, skb->data,
- adapter->rx_buffer_len,
- DMA_FROM_DEVICE);
- if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
- dev_err(&pdev->dev, "Rx DMA map failed\n");
- adapter->rx_dma_failed++;
- break;
- }
-
- rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
- rx_desc->read.buffer_addr = cpu_to_le64(buffer_info->dma);
-
- if (unlikely(!(i & (E1000_RX_BUFFER_WRITE - 1)))) {
- /* Force memory writes to complete before letting h/w
- * know there are new descriptors to fetch. (Only
- * applicable for weak-ordered memory model archs,
- * such as IA-64).
- */
- wmb();
- if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
- e1000e_update_rdt_wa(rx_ring, i);
- else
- writel(i, rx_ring->tail);
- }
- i++;
- if (i == rx_ring->count)
- i = 0;
- buffer_info = &rx_ring->buffer_info[i];
- }
-
- rx_ring->next_to_use = i;
-}
-
-/**
- * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers
- * @rx_ring: Rx descriptor ring
- * @cleaned_count: number of buffers to allocate this pass
- * @gfp: flags for allocation
+ * @count: number of buffers to allocate
**/
-
-static void e1000_alloc_jumbo_rx_buffers(struct e1000_ring *rx_ring,
- int cleaned_count, gfp_t gfp)
-{
+static void e1000_alloc_rx_buffers(struct e1000_ring *rx_ring, u32 count)
+{
+ const struct libeth_fq_fp fq = {
+ .pp = rx_ring->pp,
+ .fqes = rx_ring->rx_fqes,
+ .truesize = rx_ring->truesize,
+ .count = rx_ring->count,
+ };
struct e1000_adapter *adapter = rx_ring->adapter;
- struct net_device *netdev = adapter->netdev;
- struct pci_dev *pdev = adapter->pdev;
- union e1000_rx_desc_extended *rx_desc;
- struct e1000_buffer *buffer_info;
- struct sk_buff *skb;
- unsigned int i;
- unsigned int bufsz = 256 - 16; /* for skb_reserve */
+ u32 ntu = rx_ring->next_to_use;
- i = rx_ring->next_to_use;
- buffer_info = &rx_ring->buffer_info[i];
+ /* the buffer queue may be missing if the interface failed to go up */
+ if (unlikely(!count || !fq.fqes))
+ return;
- while (cleaned_count--) {
- skb = buffer_info->skb;
- if (skb) {
- skb_trim(skb, 0);
- goto check_page;
- }
+ do {
+ union e1000_rx_desc_extended *rx_desc;
+ dma_addr_t addr;
- skb = __netdev_alloc_skb_ip_align(netdev, bufsz, gfp);
- if (unlikely(!skb)) {
+ addr = libeth_rx_alloc(&fq, ntu);
+ if (addr == DMA_MAPPING_ERROR) {
/* Better luck next round */
adapter->alloc_rx_buff_failed++;
break;
}
- buffer_info->skb = skb;
-check_page:
- /* allocate a new page if necessary */
- if (!buffer_info->page) {
- buffer_info->page = alloc_page(gfp);
- if (unlikely(!buffer_info->page)) {
- adapter->alloc_rx_buff_failed++;
- break;
- }
- }
-
- if (!buffer_info->dma) {
- buffer_info->dma = dma_map_page(&pdev->dev,
- buffer_info->page, 0,
- PAGE_SIZE,
- DMA_FROM_DEVICE);
- if (dma_mapping_error(&pdev->dev, buffer_info->dma)) {
- adapter->alloc_rx_buff_failed++;
- break;
- }
- }
+ rx_desc = E1000_RX_DESC_EXT(*rx_ring, ntu);
+ rx_desc->read.buffer_addr = cpu_to_le64(addr);
- rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
- rx_desc->read.buffer_addr = cpu_to_le64(buffer_info->dma);
-
- if (unlikely(++i == rx_ring->count))
- i = 0;
- buffer_info = &rx_ring->buffer_info[i];
- }
+ if (unlikely(++ntu == rx_ring->count))
+ ntu = 0;
+ } while (--count);
- if (likely(rx_ring->next_to_use != i)) {
- rx_ring->next_to_use = i;
- if (unlikely(i-- == 0))
- i = (rx_ring->count - 1);
+ if (likely(rx_ring->next_to_use != ntu)) {
+ rx_ring->next_to_use = ntu;
+ if (unlikely(ntu-- == 0))
+ ntu = rx_ring->count - 1;
/* Force memory writes to complete before letting h/w
* know there are new descriptors to fetch. (Only
@@ -712,9 +583,9 @@ static void e1000_alloc_jumbo_rx_buffers(struct e1000_ring *rx_ring,
*/
wmb();
if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
- e1000e_update_rdt_wa(rx_ring, i);
+ e1000e_update_rdt_wa(rx_ring, ntu);
else
- writel(i, rx_ring->tail);
+ writel(ntu, rx_ring->tail);
}
}
@@ -726,160 +597,148 @@ static inline void e1000_rx_hash(struct net_device *netdev, __le32 rss,
}
/**
- * e1000_clean_rx_irq - Send received data up the network stack
- * @rx_ring: Rx descriptor ring
- * @work_done: output parameter for indicating completed work
- * @work_to_do: how many packets we can clean
+ * e1000_rx_strip_fcs - remove the Ethernet FCS from a received frame
+ * @xdp: buffer holding the frame received so far
+ * @len: length of the last buffer of the frame, as written by the hardware
*
- * the return value indicates whether actual cleaning was done, there
- * is no guarantee that everything was cleaned
+ * Used when the hardware is not stripping the FCS. As the frame can span
+ * multiple buffers, the FCS can be split between the last two of them.
+ *
+ * Return: the length of the last buffer without the FCS.
**/
-static bool e1000_clean_rx_irq(struct e1000_ring *rx_ring, int *work_done,
- int work_to_do)
+static u32 e1000_rx_strip_fcs(struct libeth_xdp_buff *xdp, u32 len)
{
- struct e1000_adapter *adapter = rx_ring->adapter;
- struct net_device *netdev = adapter->netdev;
- struct pci_dev *pdev = adapter->pdev;
- struct e1000_hw *hw = &adapter->hw;
- union e1000_rx_desc_extended *rx_desc, *next_rxd;
- struct e1000_buffer *buffer_info, *next_buffer;
- u32 length, staterr;
- unsigned int i;
- int cleaned_count = 0;
- bool cleaned = false;
- unsigned int total_rx_bytes = 0, total_rx_packets = 0;
+ struct skb_shared_info *sinfo;
+ u32 trim;
- i = rx_ring->next_to_clean;
- rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
- staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
- buffer_info = &rx_ring->buffer_info[i];
+ if (likely(len >= ETH_FCS_LEN))
+ return len - ETH_FCS_LEN;
- while (staterr & E1000_RXD_STAT_DD) {
- struct sk_buff *skb;
+ /* part of the FCS is at the end of the previous buffer */
+ trim = ETH_FCS_LEN - len;
- if (*work_done >= work_to_do)
- break;
- (*work_done)++;
- dma_rmb(); /* read descriptor and rx_buffer_info after status DD */
+ if (!xdp->data)
+ return 0;
- skb = buffer_info->skb;
- buffer_info->skb = NULL;
+ if (!xdp_buff_has_frags(&xdp->base)) {
+ xdp->base.data_end -= trim;
+ return 0;
+ }
- prefetch(skb->data - NET_IP_ALIGN);
+ sinfo = xdp_get_shared_info_from_buff(&xdp->base);
+ skb_frag_size_sub(&sinfo->frags[sinfo->nr_frags - 1], trim);
+ sinfo->xdp_frags_size -= trim;
- i++;
- if (i == rx_ring->count)
- i = 0;
- next_rxd = E1000_RX_DESC_EXT(*rx_ring, i);
- prefetch(next_rxd);
+ return 0;
+}
- next_buffer = &rx_ring->buffer_info[i];
+/**
+ * e1000_rx_populate_skb - fill an skb with the Rx descriptor information
+ * @skb: skb built from the received frame
+ * @xdp: buffer holding the received frame
+ * @rs: Rx NAPI statistics
+ *
+ * Return: always true, the skb is passed up the stack.
+ **/
+static bool e1000_rx_populate_skb(struct sk_buff *skb,
+ const struct libeth_xdp_buff *xdp,
+ struct libeth_rq_napi_stats *rs)
+{
+ const union e1000_rx_desc_extended *rx_desc = xdp->desc;
+ const struct e1000_ring *rx_ring;
+ struct e1000_adapter *adapter;
+ u32 staterr;
- cleaned = true;
- cleaned_count++;
- dma_unmap_single(&pdev->dev, buffer_info->dma,
- adapter->rx_buffer_len, DMA_FROM_DEVICE);
- buffer_info->dma = 0;
+ rx_ring = libeth_xdp_buff_to_rq(xdp, typeof(*rx_ring), xdp_rxq);
+ adapter = rx_ring->adapter;
+ staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
- length = le16_to_cpu(rx_desc->wb.upper.length);
+ e1000_rx_checksum(adapter, staterr, skb);
+ e1000_rx_hash(adapter->netdev, rx_desc->wb.lower.hi_dword.rss, skb);
+ e1000e_rx_hwtstamp(adapter, staterr, skb);
- /* !EOP means multiple descriptors were used to store a single
- * packet, if that's the case we need to toss it. In fact, we
- * need to toss every packet with the EOP bit clear and the
- * next frame that _does_ have the EOP bit set, as it is by
- * definition only a frame fragment
- */
- if (unlikely(!(staterr & E1000_RXD_STAT_EOP)))
- adapter->flags2 |= FLAG2_IS_DISCARDING;
-
- if (adapter->flags2 & FLAG2_IS_DISCARDING) {
- /* All receives must fit into a single buffer */
- e_dbg("Receive packet consumed multiple buffers\n");
- /* recycle */
- buffer_info->skb = skb;
- if (staterr & E1000_RXD_STAT_EOP)
- adapter->flags2 &= ~FLAG2_IS_DISCARDING;
- goto next_desc;
- }
+ if (staterr & E1000_RXD_STAT_VP)
+ __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
+ le16_to_cpu(rx_desc->wb.upper.vlan));
- if (unlikely((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) &&
- !(netdev->features & NETIF_F_RXALL))) {
- /* recycle */
- buffer_info->skb = skb;
- goto next_desc;
- }
+ return true;
+}
- /* adjust length to remove Ethernet CRC */
- if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) {
- /* If configured to store CRC, don't subtract FCS,
- * but keep the FCS bytes out of the total_rx_bytes
- * counter
- */
- if (netdev->features & NETIF_F_RXFCS)
- total_rx_bytes -= 4;
- else
- length -= 4;
- }
+/**
+ * e1000_clean_rx_irq - Send received data up the network stack
+ * @rx_ring: Rx descriptor ring
+ * @budget: maximum number of frames to process
+ *
+ * Return: the number of frames processed.
+ **/
+static int e1000_clean_rx_irq(struct e1000_ring *rx_ring, int budget)
+{
+ LIBETH_XDP_ONSTACK_BUFF(xdp);
+ struct e1000_adapter *adapter = rx_ring->adapter;
+ struct net_device *netdev = adapter->netdev;
+ struct libeth_rq_napi_stats rs = { };
+ u32 ntc = rx_ring->next_to_clean;
+ u32 cleaned_count = 0;
+ bool strip_fcs;
- total_rx_bytes += length;
- total_rx_packets++;
+ strip_fcs = !(adapter->flags2 & FLAG2_CRC_STRIPPING) &&
+ !(netdev->features & NETIF_F_RXFCS);
- /* code added for copybreak, this should improve
- * performance for small packets with large amounts
- * of reassembly being done in the stack
- */
- if (length < copybreak) {
- struct sk_buff *new_skb =
- napi_alloc_skb(&adapter->napi, length);
- if (new_skb) {
- skb_copy_to_linear_data_offset(new_skb,
- -NET_IP_ALIGN,
- (skb->data -
- NET_IP_ALIGN),
- (length +
- NET_IP_ALIGN));
- /* save the skb in buffer_info as good */
- buffer_info->skb = skb;
- skb = new_skb;
- }
- /* else just continue with the old one */
- }
- /* end copybreak code */
- skb_put(skb, length);
+ libeth_xdp_init_buff(xdp, &rx_ring->xdp, &rx_ring->xdp_rxq);
+
+ while (likely(rs.packets < budget)) {
+ union e1000_rx_desc_extended *rx_desc;
+ u32 staterr, len;
+
+ rx_desc = E1000_RX_DESC_EXT(*rx_ring, ntc);
+ staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
+ if (!(staterr & E1000_RXD_STAT_DD))
+ break;
- /* Receive Checksum Offload */
- e1000_rx_checksum(adapter, staterr, skb);
+ /* read descriptor and rx buffer after status DD */
+ dma_rmb();
- e1000_rx_hash(netdev, rx_desc->wb.lower.hi_dword.rss, skb);
+ len = le16_to_cpu(rx_desc->wb.upper.length);
+ if (unlikely(strip_fcs) && (staterr & E1000_RXD_STAT_EOP))
+ len = e1000_rx_strip_fcs(xdp, len);
- e1000_receive_skb(adapter, netdev, skb, staterr,
- rx_desc->wb.upper.vlan);
+ libeth_xdp_process_buff(xdp, &rx_ring->rx_fqes[ntc], len);
+
+ if (unlikely(++ntc == rx_ring->count))
+ ntc = 0;
+ cleaned_count++;
+
+ /* errors are only valid for DD + EOP descriptors */
+ if ((staterr & E1000_RXD_STAT_EOP) && likely(xdp->data)) {
+ if (unlikely((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) &&
+ !(netdev->features & NETIF_F_RXALL)))
+ libeth_xdp_return_buff_slow(xdp);
+ else
+ libeth_xdp_run_pass(xdp, NULL, &adapter->napi,
+ &rs, rx_desc, NULL,
+ e1000_rx_populate_skb);
+ }
-next_desc:
rx_desc->wb.upper.status_error &= cpu_to_le32(~0xFF);
/* return some buffers to hardware, one at a time is too slow */
if (cleaned_count >= E1000_RX_BUFFER_WRITE) {
- adapter->alloc_rx_buf(rx_ring, cleaned_count,
- GFP_ATOMIC);
+ e1000_alloc_rx_buffers(rx_ring, cleaned_count);
cleaned_count = 0;
}
-
- /* use prefetched values */
- rx_desc = next_rxd;
- buffer_info = next_buffer;
-
- staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
}
- rx_ring->next_to_clean = i;
+
+ rx_ring->next_to_clean = ntc;
+ libeth_xdp_save_buff(&rx_ring->xdp, xdp);
cleaned_count = e1000_desc_unused(rx_ring);
if (cleaned_count)
- adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC);
+ e1000_alloc_rx_buffers(rx_ring, cleaned_count);
- adapter->total_rx_bytes += total_rx_bytes;
- adapter->total_rx_packets += total_rx_packets;
- return cleaned;
+ adapter->total_rx_bytes += rs.bytes;
+ adapter->total_rx_packets += rs.packets;
+
+ return rs.packets;
}
static void e1000_put_txbuf(struct e1000_ring *tx_ring,
@@ -1121,183 +980,65 @@ static bool e1000_clean_tx_irq(struct e1000_ring *tx_ring)
return count < tx_ring->count;
}
-static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb,
- u16 length)
-{
- bi->page = NULL;
- skb->len += length;
- skb->data_len += length;
- skb->truesize += PAGE_SIZE;
-}
-
/**
- * e1000_clean_jumbo_rx_irq - Send received data up the network stack; legacy
+ * e1000_rx_fq_create - create the Rx buffer queue
* @rx_ring: Rx descriptor ring
- * @work_done: output parameter for indicating completed work
- * @work_to_do: how many packets we can clean
*
- * the return value indicates whether actual cleaning was done, there
- * is no guarantee that everything was cleaned
+ * The hardware can only use Rx buffers with a size which is a power of two
+ * (see e1000_setup_rctl()), so use 2 KB buffers and let it chain multiple
+ * descriptors for bigger frames. When long packet reception is disabled,
+ * received frames are never bigger than a VLAN tagged frame, so smaller
+ * buffers are enough even if the hardware is set to 2 KB.
+ *
+ * Return: 0 on success, negative on failure
**/
-static bool e1000_clean_jumbo_rx_irq(struct e1000_ring *rx_ring, int *work_done,
- int work_to_do)
+static int e1000_rx_fq_create(struct e1000_ring *rx_ring)
{
struct e1000_adapter *adapter = rx_ring->adapter;
struct net_device *netdev = adapter->netdev;
- struct pci_dev *pdev = adapter->pdev;
- union e1000_rx_desc_extended *rx_desc, *next_rxd;
- struct e1000_buffer *buffer_info, *next_buffer;
- u32 length, staterr;
- unsigned int i;
- int cleaned_count = 0;
- bool cleaned = false;
- unsigned int total_rx_bytes = 0, total_rx_packets = 0;
- struct skb_shared_info *shinfo;
-
- i = rx_ring->next_to_clean;
- rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
- staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
- buffer_info = &rx_ring->buffer_info[i];
-
- while (staterr & E1000_RXD_STAT_DD) {
- struct sk_buff *skb;
-
- if (*work_done >= work_to_do)
- break;
- (*work_done)++;
- dma_rmb(); /* read descriptor and rx_buffer_info after status DD */
-
- skb = buffer_info->skb;
- buffer_info->skb = NULL;
-
- ++i;
- if (i == rx_ring->count)
- i = 0;
- next_rxd = E1000_RX_DESC_EXT(*rx_ring, i);
- prefetch(next_rxd);
-
- next_buffer = &rx_ring->buffer_info[i];
-
- cleaned = true;
- cleaned_count++;
- dma_unmap_page(&pdev->dev, buffer_info->dma, PAGE_SIZE,
- DMA_FROM_DEVICE);
- buffer_info->dma = 0;
-
- length = le16_to_cpu(rx_desc->wb.upper.length);
-
- /* errors is only valid for DD + EOP descriptors */
- if (unlikely((staterr & E1000_RXD_STAT_EOP) &&
- ((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) &&
- !(netdev->features & NETIF_F_RXALL)))) {
- /* recycle both page and skb */
- buffer_info->skb = skb;
- /* an error means any chain goes out the window too */
- if (rx_ring->rx_skb_top)
- dev_kfree_skb_irq(rx_ring->rx_skb_top);
- rx_ring->rx_skb_top = NULL;
- goto next_desc;
- }
-#define rxtop (rx_ring->rx_skb_top)
- if (!(staterr & E1000_RXD_STAT_EOP)) {
- /* this descriptor is only the beginning (or middle) */
- if (!rxtop) {
- /* this is the beginning of a chain */
- rxtop = skb;
- skb_fill_page_desc(rxtop, 0, buffer_info->page,
- 0, length);
- } else {
- /* this is the middle of a chain */
- shinfo = skb_shinfo(rxtop);
- skb_fill_page_desc(rxtop, shinfo->nr_frags,
- buffer_info->page, 0,
- length);
- /* re-use the skb, only consumed the page */
- buffer_info->skb = skb;
- }
- e1000_consume_page(buffer_info, rxtop, length);
- goto next_desc;
- } else {
- if (rxtop) {
- /* end of the chain */
- shinfo = skb_shinfo(rxtop);
- skb_fill_page_desc(rxtop, shinfo->nr_frags,
- buffer_info->page, 0,
- length);
- /* re-use the current skb, we only consumed the
- * page
- */
- buffer_info->skb = skb;
- skb = rxtop;
- rxtop = NULL;
- e1000_consume_page(buffer_info, skb, length);
- } else {
- /* no chain, got EOP, this buf is the packet
- * copybreak to save the put_page/alloc_page
- */
- if (length <= copybreak &&
- skb_tailroom(skb) >= length) {
- memcpy(skb_tail_pointer(skb),
- page_address(buffer_info->page),
- length);
- /* re-use the page, so don't erase
- * buffer_info->page
- */
- skb_put(skb, length);
- } else {
- skb_fill_page_desc(skb, 0,
- buffer_info->page, 0,
- length);
- e1000_consume_page(buffer_info, skb,
- length);
- }
- }
- }
-
- /* Receive Checksum Offload */
- e1000_rx_checksum(adapter, staterr, skb);
+ struct libeth_fq fq = {
+ .count = rx_ring->count,
+ .type = LIBETH_FQE_SHORT,
+ .truesize = PAGE_SIZE,
+ .nid = NUMA_NO_NODE,
+ };
+ u32 len;
+ int err;
- e1000_rx_hash(netdev, rx_desc->wb.lower.hi_dword.rss, skb);
+ if (netdev->mtu > ETH_DATA_LEN)
+ len = E1000_RX_BUFFER_LEN;
+ else
+ len = VLAN_ETH_FRAME_LEN + ETH_FCS_LEN;
- /* probably a little skewed due to removing CRC */
- total_rx_bytes += skb->len;
- total_rx_packets++;
+ /* the smallest buffer able to hold len bytes, up to a page */
+ fq.buf_len = ALIGN(len, LIBETH_RX_BUF_STRIDE);
- /* eth type trans needs skb->data to point to something */
- if (!pskb_may_pull(skb, ETH_HLEN)) {
- e_err("pskb_may_pull failed.\n");
- dev_kfree_skb_irq(skb);
- goto next_desc;
- }
+ err = libeth_rx_fq_create(&fq, &adapter->napi);
+ if (err)
+ return err;
- e1000_receive_skb(adapter, netdev, skb, staterr,
- rx_desc->wb.upper.vlan);
+ if (WARN_ON_ONCE(fq.buf_len < len)) {
+ err = -EINVAL;
+ goto err_destroy;
+ }
-next_desc:
- rx_desc->wb.upper.status_error &= cpu_to_le32(~0xFF);
+ err = __xdp_rxq_info_reg(&rx_ring->xdp_rxq, netdev, 0,
+ adapter->napi.napi_id, fq.truesize);
+ if (err)
+ goto err_destroy;
- /* return some buffers to hardware, one at a time is too slow */
- if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
- adapter->alloc_rx_buf(rx_ring, cleaned_count,
- GFP_ATOMIC);
- cleaned_count = 0;
- }
+ xdp_rxq_info_attach_page_pool(&rx_ring->xdp_rxq, fq.pp);
- /* use prefetched values */
- rx_desc = next_rxd;
- buffer_info = next_buffer;
+ rx_ring->pp = fq.pp;
+ rx_ring->rx_fqes = fq.fqes;
+ rx_ring->truesize = fq.truesize;
- staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
- }
- rx_ring->next_to_clean = i;
+ return 0;
- cleaned_count = e1000_desc_unused(rx_ring);
- if (cleaned_count)
- adapter->alloc_rx_buf(rx_ring, cleaned_count, GFP_ATOMIC);
+err_destroy:
+ libeth_rx_fq_destroy(&fq);
- adapter->total_rx_bytes += total_rx_bytes;
- adapter->total_rx_packets += total_rx_packets;
- return cleaned;
+ return err;
}
/**
@@ -1306,40 +1047,30 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_ring *rx_ring, int *work_done,
**/
static void e1000_clean_rx_ring(struct e1000_ring *rx_ring)
{
- struct e1000_adapter *adapter = rx_ring->adapter;
- struct e1000_buffer *buffer_info;
- struct pci_dev *pdev = adapter->pdev;
- unsigned int i;
+ struct libeth_fq fq = {
+ .fqes = rx_ring->rx_fqes,
+ .pp = rx_ring->pp,
+ };
- /* Free all the Rx ring sk_buffs */
- for (i = 0; i < rx_ring->count; i++) {
- buffer_info = &rx_ring->buffer_info[i];
- if (buffer_info->dma) {
- if (adapter->clean_rx == e1000_clean_rx_irq)
- dma_unmap_single(&pdev->dev, buffer_info->dma,
- adapter->rx_buffer_len,
- DMA_FROM_DEVICE);
- else if (adapter->clean_rx == e1000_clean_jumbo_rx_irq)
- dma_unmap_page(&pdev->dev, buffer_info->dma,
- PAGE_SIZE, DMA_FROM_DEVICE);
- buffer_info->dma = 0;
- }
+ if (rx_ring->rx_fqes) {
+ u32 i = rx_ring->next_to_clean;
- if (buffer_info->page) {
- put_page(buffer_info->page);
- buffer_info->page = NULL;
- }
+ libeth_xdp_return_stash(&rx_ring->xdp);
- if (buffer_info->skb) {
- dev_kfree_skb(buffer_info->skb);
- buffer_info->skb = NULL;
+ /* Free all the buffers owned by the hardware */
+ while (i != rx_ring->next_to_use) {
+ libeth_rx_recycle_slow(rx_ring->rx_fqes[i].netmem);
+
+ if (unlikely(++i == rx_ring->count))
+ i = 0;
}
- }
- /* there also may be some cached data from a chained receive */
- if (rx_ring->rx_skb_top) {
- dev_kfree_skb(rx_ring->rx_skb_top);
- rx_ring->rx_skb_top = NULL;
+ xdp_rxq_info_detach_mem_model(&rx_ring->xdp_rxq);
+ xdp_rxq_info_unreg(&rx_ring->xdp_rxq);
+
+ libeth_rx_fq_destroy(&fq);
+ rx_ring->rx_fqes = NULL;
+ rx_ring->pp = NULL;
}
/* Zero out the descriptor ring */
@@ -1347,7 +1078,6 @@ static void e1000_clean_rx_ring(struct e1000_ring *rx_ring)
rx_ring->next_to_clean = 0;
rx_ring->next_to_use = 0;
- adapter->flags2 &= ~FLAG2_IS_DISCARDING;
}
static void e1000e_downshift_workaround(struct work_struct *work)
@@ -1984,31 +1714,22 @@ int e1000e_setup_tx_resources(struct e1000_ring *tx_ring)
int e1000e_setup_rx_resources(struct e1000_ring *rx_ring)
{
struct e1000_adapter *adapter = rx_ring->adapter;
- int size, err = -ENOMEM;
-
- size = sizeof(struct e1000_buffer) * rx_ring->count;
- rx_ring->buffer_info = vzalloc(size);
- if (!rx_ring->buffer_info)
- goto err;
+ int err;
/* Round up to nearest 4K */
rx_ring->size = rx_ring->count * sizeof(union e1000_rx_desc_extended);
rx_ring->size = ALIGN(rx_ring->size, 4096);
err = e1000_alloc_ring_dma(adapter, rx_ring);
- if (err)
- goto err;
+ if (err) {
+ e_err("Unable to allocate memory for the receive descriptor ring\n");
+ return err;
+ }
rx_ring->next_to_clean = 0;
rx_ring->next_to_use = 0;
- rx_ring->rx_skb_top = NULL;
return 0;
-
-err:
- vfree(rx_ring->buffer_info);
- e_err("Unable to allocate memory for the receive descriptor ring\n");
- return err;
}
/**
@@ -2071,9 +1792,6 @@ void e1000e_free_rx_resources(struct e1000_ring *rx_ring)
e1000_clean_rx_ring(rx_ring);
- vfree(rx_ring->buffer_info);
- rx_ring->buffer_info = NULL;
-
dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc,
rx_ring->dma);
rx_ring->desc = NULL;
@@ -2264,13 +1982,13 @@ static int e1000e_poll(struct napi_struct *napi, int budget)
napi);
struct e1000_hw *hw = &adapter->hw;
struct net_device *poll_dev = adapter->netdev;
- int tx_cleaned, work_done = 0;
+ int tx_cleaned, work_done;
adapter = netdev_priv(poll_dev);
tx_cleaned = e1000_clean_tx_irq(adapter->tx_ring);
- adapter->clean_rx(adapter->rx_ring, &work_done, budget);
+ work_done = e1000_clean_rx_irq(adapter->rx_ring, budget);
if (!tx_cleaned || work_done == budget)
return budget;
@@ -2682,25 +2400,9 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
e1e_wphy(hw, 22, phy_data);
}
- /* Setup buffer sizes */
- rctl &= ~E1000_RCTL_SZ_4096;
- rctl |= E1000_RCTL_BSEX;
- switch (adapter->rx_buffer_len) {
- case 2048:
- default:
- rctl |= E1000_RCTL_SZ_2048;
- rctl &= ~E1000_RCTL_BSEX;
- break;
- case 4096:
- rctl |= E1000_RCTL_SZ_4096;
- break;
- case 8192:
- rctl |= E1000_RCTL_SZ_8192;
- break;
- case 16384:
- rctl |= E1000_RCTL_SZ_16384;
- break;
- }
+ /* Setup buffer sizes, bigger frames span multiple descriptors */
+ rctl &= ~(E1000_RCTL_SZ_4096 | E1000_RCTL_BSEX);
+ rctl |= E1000_RCTL_SZ_2048;
/* Enable Extended Status in all Receive Descriptors */
rfctl = er32(RFCTL);
@@ -2745,15 +2447,7 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
u64 rdba;
u32 rdlen, rctl, rxcsum, ctrl_ext;
- if (adapter->netdev->mtu > ETH_FRAME_LEN + ETH_FCS_LEN) {
- rdlen = rx_ring->count * sizeof(union e1000_rx_desc_extended);
- adapter->clean_rx = e1000_clean_jumbo_rx_irq;
- adapter->alloc_rx_buf = e1000_alloc_jumbo_rx_buffers;
- } else {
- rdlen = rx_ring->count * sizeof(union e1000_rx_desc_extended);
- adapter->clean_rx = e1000_clean_rx_irq;
- adapter->alloc_rx_buf = e1000_alloc_rx_buffers;
- }
+ rdlen = rx_ring->count * sizeof(union e1000_rx_desc_extended);
/* disable receives while setting up the descriptors */
rctl = er32(RCTL);
@@ -3305,9 +2999,10 @@ static int e1000e_config_hwtstamp(struct e1000_adapter *adapter,
* e1000_configure - configure the hardware for Rx and Tx
* @adapter: private board structure
**/
-static void e1000_configure(struct e1000_adapter *adapter)
+static int e1000_configure(struct e1000_adapter *adapter)
{
struct e1000_ring *rx_ring = adapter->rx_ring;
+ int err;
e1000e_set_rx_mode(adapter->netdev);
@@ -3320,7 +3015,14 @@ static void e1000_configure(struct e1000_adapter *adapter)
e1000e_setup_rss_hash(adapter);
e1000_setup_rctl(adapter);
e1000_configure_rx(adapter);
- adapter->alloc_rx_buf(rx_ring, e1000_desc_unused(rx_ring), GFP_KERNEL);
+
+ err = e1000_rx_fq_create(rx_ring);
+ if (err)
+ return err;
+
+ e1000_alloc_rx_buffers(rx_ring, e1000_desc_unused(rx_ring));
+
+ return 0;
}
/**
@@ -3783,7 +3485,8 @@ static void e1000e_trigger_lsc(struct e1000_adapter *adapter)
void e1000e_up(struct e1000_adapter *adapter)
{
/* hardware has been reset, we need to reload some things */
- e1000_configure(adapter);
+ if (e1000_configure(adapter))
+ e_err("Unable to allocate the Rx buffers\n");
clear_bit(__E1000_DOWN, &adapter->state);
@@ -4010,7 +3713,6 @@ static int e1000_sw_init(struct e1000_adapter *adapter)
{
struct net_device *netdev = adapter->netdev;
- adapter->rx_buffer_len = VLAN_ETH_FRAME_LEN + ETH_FCS_LEN;
adapter->max_frame_size = netdev->mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
adapter->tx_ring_count = E1000_DEFAULT_TXD;
@@ -4223,9 +3925,11 @@ int e1000e_open(struct net_device *netdev)
/* before we allocate an interrupt, we must be ready to handle it.
* Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
* as soon as we call pci_request_irq, so we have to setup our
- * clean_rx handler before we do so.
+ * Rx buffers before we do so.
*/
- e1000_configure(adapter);
+ err = e1000_configure(adapter);
+ if (err)
+ goto err_req_irq;
err = e1000_request_irq(adapter);
if (err)
@@ -5627,23 +5331,6 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
if (netif_running(netdev))
e1000e_down(adapter, true);
- /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN
- * means we reserve 2 more, this pushes us to allocate from the next
- * larger slab size.
- * i.e. RXBUFFER_2048 --> size-4096 slab
- * However with the new *_jumbo_rx* routines, jumbo receives will use
- * fragmented skbs
- */
-
- if (max_frame <= 2048)
- adapter->rx_buffer_len = 2048;
- else
- adapter->rx_buffer_len = 4096;
-
- /* adjust allocation if LPE protects us, and we aren't using SBP */
- if (max_frame <= (VLAN_ETH_FRAME_LEN + ETH_FCS_LEN))
- adapter->rx_buffer_len = VLAN_ETH_FRAME_LEN + ETH_FCS_LEN;
-
if (netif_running(netdev))
e1000e_up(adapter);
else
@@ -7782,5 +7469,7 @@ module_exit(e1000_exit_module);
MODULE_DESCRIPTION("Intel(R) PRO/1000 Network Driver");
MODULE_LICENSE("GPL v2");
+MODULE_IMPORT_NS("LIBETH");
+MODULE_IMPORT_NS("LIBETH_XDP");
/* netdev.c */
diff --git a/drivers/net/ethernet/intel/e1000e/param.c b/drivers/net/ethernet/intel/e1000e/param.c
index c6f400e6cdea..548e34b9ecfd 100644
--- a/drivers/net/ethernet/intel/e1000e/param.c
+++ b/drivers/net/ethernet/intel/e1000e/param.c
@@ -17,12 +17,6 @@
#define OPTION_DISABLED 0
#define OPTION_ENABLED 1
-#define COPYBREAK_DEFAULT 256
-unsigned int copybreak = COPYBREAK_DEFAULT;
-module_param(copybreak, uint, 0644);
-MODULE_PARM_DESC(copybreak,
- "Maximum size of packet that is copied to a new buffer on receive");
-
/* All parameters are treated the same, as an integer array of values.
* This macro just reduces the need to repeat the same declaration code
* over and over (plus this helps to avoid typo bugs).
--
2.56.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v5 6/6] e1000e: add .ndo_xdp_xmit support
2026-12-04 20:43 [PATCH net-next v5 0/6] e1000e: add XDP support Matteo Croce
` (3 preceding siblings ...)
2026-12-04 20:43 ` [PATCH net-next v5 4/6] e1000e: use libeth for Rx buffer management Matteo Croce
@ 2026-12-04 20:44 ` Matteo Croce
4 siblings, 0 replies; 6+ messages in thread
From: Matteo Croce @ 2026-12-04 20:44 UTC (permalink / raw)
To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexei Starovoitov,
Daniel Borkmann, Jesper Dangaard Brouer, John Fastabend,
Mohsin Bashir, Nemo D'ACREMONT
Cc: netdev, bpf, intel-wired-lan, linux-kernel
Allow the device to be the target of XDP_REDIRECT, by implementing
.ndo_xdp_xmit, including frames spanning multiple buffers.
The redirected frames are placed on the Tx ring with the Tx queue lock
held, as it is shared with the regular transmit path, and are returned
on Tx completion. As the Tx ring is always available when the interface
is up, the feature doesn't depend on an XDP program being attached.
To make sure the Tx ring is not cleaned while frames are being placed on
it, e1000e_down() now takes the Tx queue lock when stopping the queue,
after flagging the device as down.
Signed-off-by: Matteo Croce <technoboy85@gmail.com>
---
drivers/net/ethernet/intel/e1000e/e1000.h | 9 +-
drivers/net/ethernet/intel/e1000e/netdev.c | 158 +++++++++++++++++++--
2 files changed, 156 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h
index b11b0bb38d5e..fd33ed337248 100644
--- a/drivers/net/ethernet/intel/e1000e/e1000.h
+++ b/drivers/net/ethernet/intel/e1000e/e1000.h
@@ -129,6 +129,7 @@ enum e1000_boards {
enum e1000_tx_buf_type {
E1000_TX_BUF_SKB = 0,
E1000_TX_BUF_XDP_TX,
+ E1000_TX_BUF_XDP_XMIT,
};
/* wrappers around a pointer to a socket buffer,
@@ -137,8 +138,12 @@ enum e1000_tx_buf_type {
struct e1000_buffer {
dma_addr_t dma;
struct sk_buff *skb;
- /* XDP_TX buffer, returned to its page_pool on completion */
- netmem_ref netmem;
+ union {
+ /* XDP_TX buffer, returned to its page_pool on completion */
+ netmem_ref netmem;
+ /* frame from .ndo_xdp_xmit(), set on its first buffer */
+ struct xdp_frame *xdpf;
+ };
unsigned long time_stamp;
u16 length;
u16 next_to_watch;
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 9926cd84ce21..607da8121d42 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -987,13 +987,21 @@ static void e1000_put_txbuf(struct e1000_ring *tx_ring,
dev_consume_skb_any(buffer_info->skb);
buffer_info->skb = NULL;
}
- if (buffer_info->type == E1000_TX_BUF_XDP_TX) {
- netmem_ref netmem = buffer_info->netmem;
-
- page_pool_put_full_netmem(netmem_get_pp(netmem), netmem, false);
+ switch (buffer_info->type) {
+ case E1000_TX_BUF_XDP_TX:
+ page_pool_put_full_netmem(netmem_get_pp(buffer_info->netmem),
+ buffer_info->netmem, false);
buffer_info->netmem = 0;
- buffer_info->type = E1000_TX_BUF_SKB;
+ break;
+ case E1000_TX_BUF_XDP_XMIT:
+ if (buffer_info->xdpf)
+ xdp_return_frame(buffer_info->xdpf);
+ buffer_info->xdpf = NULL;
+ break;
+ default:
+ break;
}
+ buffer_info->type = E1000_TX_BUF_SKB;
buffer_info->time_stamp = 0;
}
@@ -3790,7 +3798,8 @@ void e1000e_down(struct e1000_adapter *adapter, bool reset)
ew32(RCTL, rctl & ~E1000_RCTL_EN);
/* flush and sleep below */
- netif_stop_queue(netdev);
+ /* also waits for .ndo_xdp_xmit() to release the Tx ring */
+ netif_tx_disable(netdev);
/* disable transmits in the hardware */
tctl = er32(TCTL);
@@ -6875,6 +6884,138 @@ static int e1000_xdp(struct net_device *netdev, struct netdev_bpf *xdp)
}
}
+/**
+ * e1000_xdp_xmit_frame - place a redirected XDP frame on the Tx ring
+ * @tx_ring: Tx descriptor ring
+ * @xdpf: frame to transmit
+ *
+ * Must be called with the Tx queue lock held, as the ring is shared with
+ * the regular transmit path.
+ *
+ * Return: true on success, false if the frame was not placed on the ring.
+ **/
+static bool e1000_xdp_xmit_frame(struct e1000_ring *tx_ring,
+ struct xdp_frame *xdpf)
+{
+ struct device *dev = &tx_ring->adapter->pdev->dev;
+ const struct skb_shared_info *sinfo = NULL;
+ u32 i, first, last, nr_frags = 0;
+ struct e1000_buffer *buffer_info;
+
+ if (unlikely(xdp_frame_has_frags(xdpf))) {
+ sinfo = xdp_get_shared_info_from_frame(xdpf);
+ nr_frags = sinfo->nr_frags;
+ }
+
+ if (unlikely(e1000_desc_unused(tx_ring) < nr_frags + 1))
+ return false;
+
+ first = tx_ring->next_to_use;
+ i = first;
+
+ for (u32 f = 0; f <= nr_frags; f++) {
+ dma_addr_t dma;
+ u32 len;
+
+ if (!f) {
+ len = xdpf->len;
+ dma = dma_map_single(dev, xdpf->data, len,
+ DMA_TO_DEVICE);
+ } else {
+ const skb_frag_t *frag = &sinfo->frags[f - 1];
+
+ len = skb_frag_size(frag);
+ dma = skb_frag_dma_map(dev, frag);
+ }
+
+ if (dma_mapping_error(dev, dma))
+ goto unmap;
+
+ buffer_info = &tx_ring->buffer_info[i];
+ buffer_info->type = E1000_TX_BUF_XDP_XMIT;
+ buffer_info->xdpf = f ? NULL : xdpf;
+ buffer_info->dma = dma;
+ buffer_info->length = len;
+ buffer_info->mapped_as_page = !!f;
+ buffer_info->time_stamp = jiffies;
+ buffer_info->next_to_watch = i;
+ buffer_info->segs = 0;
+ buffer_info->bytecount = 0;
+
+ e1000_xdp_tx_desc(tx_ring, i, dma, len, f == nr_frags);
+
+ last = i;
+ if (unlikely(++i == tx_ring->count))
+ i = 0;
+ }
+
+ /* the frame is completed when its last descriptor is done */
+ tx_ring->buffer_info[first].next_to_watch = last;
+ tx_ring->buffer_info[last].segs = 1;
+ tx_ring->buffer_info[last].bytecount = xdp_get_frame_len(xdpf);
+
+ tx_ring->next_to_use = i;
+
+ return true;
+
+unmap:
+ /* the frame is freed by the caller */
+ tx_ring->buffer_info[first].xdpf = NULL;
+
+ while (i != first) {
+ if (i-- == 0)
+ i = tx_ring->count - 1;
+
+ e1000_put_txbuf(tx_ring, &tx_ring->buffer_info[i], false);
+ }
+
+ return false;
+}
+
+/**
+ * e1000_xdp_xmit - transmit XDP frames redirected from other devices
+ * @netdev: network interface device structure
+ * @n: number of frames to transmit
+ * @frames: frames to transmit
+ * @flags: XDP_XMIT_* flags
+ *
+ * Return: the number of frames placed on the Tx ring, negative on failure.
+ **/
+static int e1000_xdp_xmit(struct net_device *netdev, int n,
+ struct xdp_frame **frames, u32 flags)
+{
+ struct e1000_adapter *adapter = netdev_priv(netdev);
+ struct e1000_ring *tx_ring = adapter->tx_ring;
+ struct netdev_queue *nq;
+ int nxmit = 0;
+
+ if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
+ return -EINVAL;
+
+ nq = netdev_get_tx_queue(netdev, 0);
+ __netif_tx_lock(nq, smp_processor_id());
+
+ /* e1000e_down() takes the lock after setting the flag, so the Tx ring
+ * can't be cleaned while the frames are being placed on it
+ */
+ if (unlikely(test_bit(__E1000_DOWN, &adapter->state))) {
+ __netif_tx_unlock(nq);
+ return -ENETDOWN;
+ }
+
+ txq_trans_cond_update(nq);
+
+ while (nxmit < n && e1000_xdp_xmit_frame(tx_ring, frames[nxmit]))
+ nxmit++;
+
+ if (flags & XDP_XMIT_FLUSH)
+ e1000_xdp_ring_update_tail(tx_ring);
+
+ __netif_tx_unlock(nq);
+
+ return nxmit;
+}
+
static const struct net_device_ops e1000e_netdev_ops = {
.ndo_open = e1000e_open,
.ndo_stop = e1000e_close,
@@ -6894,6 +7035,7 @@ static const struct net_device_ops e1000e_netdev_ops = {
#endif
.ndo_set_features = e1000_set_features,
.ndo_bpf = e1000_xdp,
+ .ndo_xdp_xmit = e1000_xdp_xmit,
.ndo_fix_features = e1000_fix_features,
.ndo_features_check = passthru_features_check,
.ndo_hwtstamp_get = e1000e_hwtstamp_get,
@@ -7109,9 +7251,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
netdev->features |= NETIF_F_HIGHDMA;
netdev->vlan_features |= NETIF_F_HIGHDMA;
- xdp_set_features_flag(netdev, NETDEV_XDP_ACT_BASIC |
- NETDEV_XDP_ACT_REDIRECT |
- NETDEV_XDP_ACT_RX_SG);
+ libeth_xdp_set_features(netdev);
/* MTU range: 68 - max_hw_frame_size */
netdev->min_mtu = ETH_MIN_MTU;
--
2.56.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-04 20:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 20:43 [PATCH net-next v5 0/6] e1000e: add XDP support Matteo Croce
2026-12-04 20:43 ` [PATCH net-next v5 1/6] e1000e: clean the Tx ring from NAPI in MSI-X mode Matteo Croce
2026-12-04 20:43 ` [PATCH net-next v5 2/6] e1000e: disable NAPI when bringing the interface down Matteo Croce
2026-12-04 20:43 ` [PATCH net-next v5 3/6] e1000e: remove packet split Rx Matteo Croce
2026-12-04 20:43 ` [PATCH net-next v5 4/6] e1000e: use libeth for Rx buffer management Matteo Croce
2026-12-04 20:44 ` [PATCH net-next v5 6/6] e1000e: add .ndo_xdp_xmit support Matteo Croce
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox