[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/50] e1000x: Take CRC into consideration for size check
|
From: |
Jason Wang |
|
Subject: |
[PULL 17/50] e1000x: Take CRC into consideration for size check |
|
Date: |
Tue, 23 May 2023 15:32:05 +0800 |
From: Akihiko Odaki <akihiko.odaki@daynix.com>
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>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/net/e1000x_common.c | 10 +++++-----
include/net/eth.h | 2 ++
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c
index 6cc2313..212873f 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);
diff --git a/include/net/eth.h b/include/net/eth.h
index e8af574..05f5693 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 */
--
2.7.4
- [PULL 07/50] igb: Clear IMS bits when committing ICR access, (continued)
- [PULL 07/50] igb: Clear IMS bits when committing ICR access, Jason Wang, 2023/05/23
- [PULL 08/50] net/net_rx_pkt: Use iovec for net_rx_pkt_set_protocols(), Jason Wang, 2023/05/23
- [PULL 09/50] e1000e: Always copy ethernet header, Jason Wang, 2023/05/23
- [PULL 10/50] igb: Always copy ethernet header, Jason Wang, 2023/05/23
- [PULL 11/50] Fix references to igb Avocado test, Jason Wang, 2023/05/23
- [PULL 12/50] tests/avocado: Remove unused imports, Jason Wang, 2023/05/23
- [PULL 13/50] tests/avocado: Remove test_igb_nomsi_kvm, Jason Wang, 2023/05/23
- [PULL 14/50] hw/net/net_tx_pkt: Remove net_rx_pkt_get_l4_info, Jason Wang, 2023/05/23
- [PULL 15/50] net/eth: Rename eth_setup_vlan_headers_ex, Jason Wang, 2023/05/23
- [PULL 16/50] e1000x: Share more Rx filtering logic, Jason Wang, 2023/05/23
- [PULL 17/50] e1000x: Take CRC into consideration for size check,
Jason Wang <=
- [PULL 18/50] e1000x: Rename TcpIpv6 into TcpIpv6Ex, Jason Wang, 2023/05/23
- [PULL 19/50] e1000e: Always log status after building rx metadata, Jason Wang, 2023/05/23
- [PULL 20/50] igb: Always log status after building rx metadata, Jason Wang, 2023/05/23
- [PULL 21/50] igb: Remove goto, Jason Wang, 2023/05/23
- [PULL 22/50] igb: Read DCMD.VLE of the first Tx descriptor, Jason Wang, 2023/05/23
- [PULL 23/50] e1000e: Reset packet state after emptying Tx queue, Jason Wang, 2023/05/23
- [PULL 24/50] vmxnet3: Reset packet state after emptying Tx queue, Jason Wang, 2023/05/23
- [PULL 25/50] igb: Add more definitions for Tx descriptor, Jason Wang, 2023/05/23
- [PULL 26/50] igb: Share common VF constants, Jason Wang, 2023/05/23
- [PULL 27/50] igb: Fix igb_mac_reg_init coding style alignment, Jason Wang, 2023/05/23