[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 15/41] e1000x: Take CRC into consideration for size check
From: |
Akihiko Odaki |
Subject: |
[PATCH v2 15/41] e1000x: Take CRC into consideration for size check |
Date: |
Thu, 20 Apr 2023 14:46:31 +0900 |
Section 13.7.15 Receive Length Error Count says:
> Packets over 1522 bytes are oversized if LongPacketEnable is 0b
> (RCTL.LPE). If LongPacketEnable (LPE) is 1b, then an incoming packet
> is considered oversized if it exceeds 16384 bytes.
> These lengths are based on bytes in the received packet from
> <Destination Address> through <CRC>, inclusively.
As QEMU processes packets without CRC, the number of bytes for CRC
need to be subtracted. This change adds some size definitions to be used
to derive the new size thresholds to eth.h.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
include/net/eth.h | 2 ++
hw/net/e1000x_common.c | 10 +++++-----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/include/net/eth.h b/include/net/eth.h
index e8af5742be..05f56931e7 100644
--- a/include/net/eth.h
+++ b/include/net/eth.h
@@ -32,6 +32,8 @@
#define ETH_ALEN 6
#define ETH_HLEN 14
#define ETH_ZLEN 60 /* Min. octets in frame without FCS */
+#define ETH_FCS_LEN 4
+#define ETH_MTU 1500
struct eth_header {
uint8_t h_dest[ETH_ALEN]; /* destination eth addr */
diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c
index 6cc23138a8..212873fd77 100644
--- a/hw/net/e1000x_common.c
+++ b/hw/net/e1000x_common.c
@@ -140,16 +140,16 @@ bool e1000x_hw_rx_enabled(uint32_t *mac)
bool e1000x_is_oversized(uint32_t *mac, size_t size)
{
+ size_t header_size = sizeof(struct eth_header) + sizeof(struct
vlan_header);
/* this is the size past which hardware will
drop packets when setting LPE=0 */
- static const int maximum_ethernet_vlan_size = 1522;
+ size_t maximum_short_size = header_size + ETH_MTU;
/* this is the size past which hardware will
drop packets when setting LPE=1 */
- static const int maximum_ethernet_lpe_size = 16 * KiB;
+ size_t maximum_large_size = 16 * KiB - ETH_FCS_LEN;
- if ((size > maximum_ethernet_lpe_size ||
- (size > maximum_ethernet_vlan_size
- && !(mac[RCTL] & E1000_RCTL_LPE)))
+ if ((size > maximum_large_size ||
+ (size > maximum_short_size && !(mac[RCTL] & E1000_RCTL_LPE)))
&& !(mac[RCTL] & E1000_RCTL_SBP)) {
e1000x_inc_reg_if_not_full(mac, ROC);
trace_e1000x_rx_oversized(size);
--
2.40.0
- [PATCH v2 06/41] net/net_rx_pkt: Use iovec for net_rx_pkt_set_protocols(), (continued)
- [PATCH v2 06/41] net/net_rx_pkt: Use iovec for net_rx_pkt_set_protocols(), Akihiko Odaki, 2023/04/20
- [PATCH v2 07/41] e1000e: Always copy ethernet header, Akihiko Odaki, 2023/04/20
- [PATCH v2 08/41] igb: Always copy ethernet header, Akihiko Odaki, 2023/04/20
- [PATCH v2 09/41] Fix references to igb Avocado test, Akihiko Odaki, 2023/04/20
- [PATCH v2 10/41] tests/avocado: Remove unused imports, Akihiko Odaki, 2023/04/20
- [PATCH v2 11/41] tests/avocado: Remove test_igb_nomsi_kvm, Akihiko Odaki, 2023/04/20
- [PATCH v2 12/41] hw/net/net_tx_pkt: Remove net_rx_pkt_get_l4_info, Akihiko Odaki, 2023/04/20
- [PATCH v2 14/41] e1000x: Share more Rx filtering logic, Akihiko Odaki, 2023/04/20
- [PATCH v2 15/41] e1000x: Take CRC into consideration for size check,
Akihiko Odaki <=
- [PATCH v2 16/41] e1000x: Rename TcpIpv6 into TcpIpv6Ex, Akihiko Odaki, 2023/04/20
- [PATCH v2 17/41] e1000e: Always log status after building rx metadata, Akihiko Odaki, 2023/04/20
- [PATCH v2 13/41] net/eth: Rename eth_setup_vlan_headers_ex, Akihiko Odaki, 2023/04/20
- [PATCH v2 18/41] igb: Always log status after building rx metadata, Akihiko Odaki, 2023/04/20
- [PATCH v2 19/41] igb: Remove goto, Akihiko Odaki, 2023/04/20
- [PATCH v2 20/41] igb: Read DCMD.VLE of the first Tx descriptor, Akihiko Odaki, 2023/04/20
- [PATCH v2 21/41] e1000e: Reset packet state after emptying Tx queue, Akihiko Odaki, 2023/04/20