wifi: rtw89: pci: add new RX ring design to determine full RX ring efficiently
authorPing-Ke Shih <pkshih@realtek.com>
Thu, 26 Oct 2023 12:00:48 +0000 (20:00 +0800)
committerKalle Valo <kvalo@kernel.org>
Mon, 30 Oct 2023 17:23:01 +0000 (19:23 +0200)
commit0dc9324206d3856a657cb076d78c8cc015fb57c8
tree07de266eea9288310e01c099c5b1eccec8abe164
parent0b79c540b13506b727fcd2b689fec99dc4fc51c6
wifi: rtw89: pci: add new RX ring design to determine full RX ring efficiently

To make hardware efficient to determine if RX ring is full, introduce new
design that checks if reading and writing indices are equal. Comparing
to old design, initial indices of both reading and writing indices are 0
that means empty, and hardware checks full by "writing index + 1 ==
reading index". The "+1" has extra cost for hardware, so new design is
to avoid this.

Take ring size is 256 as an example, the initial reading and writing
indices are 255 and 0 respectively; the initial values mean empty. If two
indices are the same, for example 5 and 5, it means ring is full.

   wp       rp       used_cnt        state
   255      0        0               initial (ring is empty)
   255      1        1               receive 1st packet
   255      2        2               receive 2nd packet
   0        2        1               driver read 1st packet
   1        2        0               driver read 2nd packet (ring is empty)
            :
   5        5        255             ring is full

Note: 'rp' is hardware writing index

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20231026120049.9187-4-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/pci.c
drivers/net/wireless/realtek/rtw89/pci.h
drivers/net/wireless/realtek/rtw89/rtw8852ae.c
drivers/net/wireless/realtek/rtw89/rtw8852be.c
drivers/net/wireless/realtek/rtw89/rtw8852ce.c
drivers/net/wireless/realtek/rtw89/rtw8922ae.c