Re: [Intel-wired-lan] [PATCH RFC net-next v4 1/9] net: intel: introduce Intel Ethernet common library

From: Przemek Kitszel
Date: Fri Jul 14 2023 - 10:19:33 EST


On 7/5/23 17:55, Alexander Lobakin wrote:
Not a secret there's a ton of code duplication between two and more Intel
ethernet modules.
Before introducing new changes, which would need to be copied over again,
start decoupling the already existing duplicate functionality into a new
module, which will be shared between several Intel Ethernet drivers.
Add the lookup table which converts 8/10-bit hardware packet type into
a parsed bitfield structure for easy checking packet format parameters,
such as payload level, IP version, etc. This is currently used by i40e,
ice and iavf and it's all the same in all three drivers.
The only difference introduced in this implementation is that instead of
defining a 256 (or 1024 in case of ice) element array, add unlikely()
condition to limit the input to 154 (current maximum non-reserved packet
type). There's no reason to waste 600 (or even 3600) bytes only to not
hurt very unlikely exception packets.
The hash computation function now takes payload level directly as a
pkt_hash_type. There's a couple cases when non-IP ptypes are marked as
L3 payload and in the previous versions their hash level would be 2, not
3. But skb_set_hash() only sees difference between L4 and non-L4, thus
this won't change anything at all.
The module is behind the hidden Kconfig symbol, which the drivers will
select when needed. The exports are behind 'LIBIE' namespace to limit
the scope of the functions.

Signed-off-by: Alexander Lobakin <aleksander.lobakin@xxxxxxxxx>
---
MAINTAINERS | 3 +-
drivers/net/ethernet/intel/Kconfig | 10 +
drivers/net/ethernet/intel/Makefile | 1 +
drivers/net/ethernet/intel/i40e/i40e_common.c | 253 --------------
drivers/net/ethernet/intel/i40e/i40e_main.c | 1 +
.../net/ethernet/intel/i40e/i40e_prototype.h | 7 -
drivers/net/ethernet/intel/i40e/i40e_txrx.c | 74 +---
drivers/net/ethernet/intel/i40e/i40e_type.h | 88 -----
drivers/net/ethernet/intel/iavf/iavf_common.c | 253 --------------
drivers/net/ethernet/intel/iavf/iavf_main.c | 1 +
.../net/ethernet/intel/iavf/iavf_prototype.h | 7 -
drivers/net/ethernet/intel/iavf/iavf_txrx.c | 70 +---
drivers/net/ethernet/intel/iavf/iavf_type.h | 88 -----
.../net/ethernet/intel/ice/ice_lan_tx_rx.h | 316 ------------------
drivers/net/ethernet/intel/ice/ice_main.c | 1 +
drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 74 +---
drivers/net/ethernet/intel/libie/Makefile | 6 +
drivers/net/ethernet/intel/libie/rx.c | 110 ++++++
include/linux/net/intel/libie/rx.h | 128 +++++++
19 files changed, 312 insertions(+), 1179 deletions(-)
create mode 100644 drivers/net/ethernet/intel/libie/Makefile
create mode 100644 drivers/net/ethernet/intel/libie/rx.c
create mode 100644 include/linux/net/intel/libie/rx.h


Thanks a lot for whole effort on this series, it's refreshing to see a move in that direction.

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@xxxxxxxxx>