ice: xsk: ZC changes
Subsystems (4)
Tony Nguyen
maintainerMaciej Fijalkowski says:
This set consists of two fixes to issues that were either pointed out on indirectly (John was reviewing AF_XDP selftests that were testing ice's ZC support) mailing list or were directly reported by customers.
First patch allows user space to see done descriptor in CQ even after a single frame being transmitted and second patch removes the need for having HW rings sized to power of 2 number of descriptors when used against AF_XDP.
I also forgot to mention that due to the current Tx cleaning algorithm, 4k HW ring was broken and these two patches bring it back to life, so we kill two birds with one stone.
The following are changes since commit 797666cd5af041ffb66642fff62f7389f08566a2:
net: usb: qmi_wwan: Add new usb-id for Dell branded EM7455
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 100GbE
Maciej Fijalkowski (2):
ice: xsk: change batched Tx descriptor cleaning
ice: xsk: drop power of 2 ring size restriction for AF_XDP
drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- drivers/net/ethernet/intel/ice/ice_xsk.c | 163 +++++++++------------- drivers/net/ethernet/intel/ice/ice_xsk.h | 7 +- 3 files changed, 71 insertions(+), 101 deletions(-)
Signature · 1 line
2.35.1
Tony Nguyen
maintainerPATCH 1/2 ice: xsk: change batched Tx descriptor cleaning
From: Maciej Fijalkowski <[email protected]>
AF_XDP Tx descriptor cleaning in ice driver currently works in a "lazy" way - descriptors are not cleaned immediately after send. We rather hold on with cleaning until we see that free space in ring drops below particular threshold. This was supposed to reduce the amount of unnecessary work related to cleaning and instead of keeping the ring empty, ring was rather saturated.
In AF_XDP realm cleaning Tx descriptors implies producing them to CQ. This is a way of letting know user space that particular descriptor has been sent, as John points out in [0].
We tried to implement serial descriptor cleaning which would be used in conjunction with batched cleaning but it made code base more convoluted and probably harder to maintain in future. Therefore we step away from batched cleaning in a current form in favor of an approach where we set RS bit on every last descriptor from a batch and clean always at the beginning of ice_xmit_zc().
This means that we give up a bit of Tx performance, but this doesn't hurt l2fwd scenario which is way more meaningful than txonly as this can be treaten as AF_XDP based packet generator. l2fwd is not hurt due to the fact that Tx side is much faster than Rx and Rx is the one that has to catch Tx up.
FWIW Tx descriptors are still produced in a batched way.
[0]: https://lore.kernel.org/bpf/[email protected]/
--- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- drivers/net/ethernet/intel/ice/ice_xsk.c | 143 +++++++++------------- drivers/net/ethernet/intel/ice/ice_xsk.h | 7 +- 3 files changed, 64 insertions(+), 88 deletions(-)
drivers/net/ethernet/intel/ice/ice_txrx.c +1 -1
@@ -1467,7 +1467,7 @@ int ice_napi_poll(struct napi_struct *napi, int budget)bool wd;if (tx_ring->xsk_pool) - wd =ice_xmit_zc (tx_ring,ICE_DESC_UNUSED (tx_ring), budget); + wd =ice_xmit_zc (tx_ring);else if (ice_ring_is_xdp (tx_ring)) wd = true;else
drivers/net/ethernet/intel/ice/ice_xsk.c +61 -82
211 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_xsk.h +2 -5
@@ -26,13 +26,10 @@ bool ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count);bool ice_xsk_any_rx_ring_ena (struct ice_vsi *vsi);void ice_xsk_clean_rx_ring (struct ice_rx_ring *rx_ring);void ice_xsk_clean_xdp_ring (struct ice_tx_ring *xdp_ring); -bool ice_xmit_zc (struct ice_tx_ring *xdp_ring,u32 budget,int napi_budget); +bool ice_xmit_zc (struct ice_tx_ring *xdp_ring);int ice_realloc_zc_buf (struct ice_vsi *vsi,bool zc);#else -static inline bool -ice_xmit_zc (struct ice_tx_ring __always_unused *xdp_ring, -u32 __always_unused budget, -int __always_unused napi_budget) +static inline bool ice_xmit_zc (struct ice_tx_ring __always_unused *xdp_ring) {return false; }
Signature · 1 line
2.35.1
Tony Nguyen
maintainerPATCH 2/2 ice: xsk: drop power of 2 ring size restriction for AF_XDP
In reply to Tony NguyenFrom: Maciej Fijalkowski <[email protected]>
We had multiple customers in the past months that reported commit 296f13ff3854 ("ice: xsk: Force rings to be sized to power of 2") makes them unable to use ring size of 8160 in conjunction with AF_XDP. Remove this restriction.
--- drivers/net/ethernet/intel/ice/ice_xsk.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ice/ice_xsk.c +7 -13
@@ -392,13 +392,6 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid) goto failure; } -if (!is_power_of_2 (vsi->rx_rings[qid]->count) || - !is_power_of_2 (vsi->tx_rings[qid]->count)) { -netdev_err (vsi->netdev,"Please align ring sizes to power of 2\n" ); - pool_failure = -EINVAL ; - goto failure; - } - if_running =netif_running (vsi->netdev) &&ice_is_xdp_ena_vsi (vsi);if (if_running) {
@@ -534,11 +527,10 @@ static bool __ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count)bool ice_alloc_rx_bufs_zc (struct ice_rx_ring *rx_ring,u16 count) {u16 rx_thresh =ICE_RING_QUARTER (rx_ring); -u16 batched, leftover, i, tail_bumps; +u16 leftover, i, tail_bumps; - batched =ALIGN_DOWN (count, rx_thresh); - tail_bumps = batched / rx_thresh; - leftover = count & (rx_thresh -1 ); + tail_bumps = count / rx_thresh; + leftover = count - (tail_bumps * rx_thresh);for (i =0 ; i < tail_bumps; i++)if (!__ice_alloc_rx_bufs_zc (rx_ring, rx_thresh))
@@ -1037,14 +1029,16 @@ bool ice_xsk_any_rx_ring_ena(struct ice_vsi *vsi)*/ void ice_xsk_clean_rx_ring (struct ice_rx_ring *rx_ring) { -u16 count_mask = rx_ring->count -1 ;u16 ntc = rx_ring->next_to_clean;u16 ntu = rx_ring->next_to_use; -for ( ; ntc != ntu; ntc = (ntc +1 ) & count_mask) { +while (ntc != ntu) {struct xdp_buff *xdp = *ice_xdp_buf (rx_ring, ntc);xsk_buff_free (xdp); + ntc++; +if (ntc >= rx_ring->count) + ntc =0 ; } }
Signature · 1 line
2.35.1
This series was applied to netdev/net.git (master) by Tony Nguyen <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by Tony Nguyen <[email protected]>:
Quoted 6 lines · On Tue, 27 Sep 2022 09:41:10 -0700 you wrote:
Maciej Fijalkowski says:
This set consists of two fixes to issues that were either pointed out on indirectly (John was reviewing
AF_XDPselftests that were testing ice's ZC support) mailing list or were directly reported by customers.
Quoted 6 lines
First patch allows user space to see done descriptor in CQ even after a single frame being transmitted and second patch removes the need for having HW rings sized to power of 2 number of descriptors when used against
AF_XDP.[...]
Here is the summary with links:
- [net,1/2] ice: xsk: change batched Tx descriptor cleaning
https://git.kernel.org/netdev/net/c/29322791bc8b - [net,2/2] ice: xsk: drop power of 2 ring size restriction for AF_XDP https://git.kernel.org/netdev/net/c/b3056ae2b578
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html