net/hns3: simplify Rx checksum
authorChengwen Feng <fengchengwen@huawei.com>
Thu, 15 Apr 2021 03:52:01 +0000 (11:52 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 19 Apr 2021 17:15:45 +0000 (19:15 +0200)
commitbd7399291a2b4b9fbc33395530dd26a8c900fec1
treeb7f51840c12ca273082a6ace38b1825d31df763e
parent70791213242ea01f75fb2706fcf75a1f52efa068
net/hns3: simplify Rx checksum

Currently, the L3L4P/L3E/L4E/OL3E/OL4E fields in Rx descriptor used to
indicate hardware checksum result:
1. L3L4P: indicates hardware has processed L3L4 checksum for this
   packet, if this bit is 1 then L3E/L4E/OL3E/OL4E is trustable.
2. L3E: L3 checksum error indication, 1 means with error.
3. L4E: L4 checksum error indication, 1 means with error.
4. OL3E: outer L3 checksum error indication, 1 means with error.
5. OL4E: outer L4 checksum error indication, 1 means with error.

Driver will set the good checksum flag through packet type and
L3E/L4E/OL3E/OL4E when L3L4P is 1, it runs as follows:
1. If packet type indicates it's tunnel packet:
1.1. If packet type indicates it has inner L3 and L3E is zero, then
mark the IP checksum good.
1.2. If packet type indicates it has inner L4 and L4E is zero, then
mark the L4 checksum good.
1.3. If packet type indicates it has outer L4 and OL4E is zero, then
mark the outer L4 checksum good.
2. If packet type indicates it's not tunnel packet:
2.1. If packet type indicates it has L3 and L3E is zero, then mark the
IP checksum good.
2.2. If packet type indicates it has L4 and L4E is zero, then mark the
L4 checksum good.

As described above, the good checksum calculation is time consuming,
it impacts the Rx performance.

By balancing performance and functionality, driver uses the following
scheme to set good checksum flag when L3L4P is 1:
1. If L3E is zero, then mark the IP checksum good.
2. If L4E is zero, then mark the L4 checksum good.

The performance gains are 3% in small packet iofwd scenarios.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
drivers/net/hns3/hns3_rxtx.c
drivers/net/hns3/hns3_rxtx.h
drivers/net/hns3/hns3_rxtx_vec_neon.h
drivers/net/hns3/hns3_rxtx_vec_sve.c