[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 40/48] igb: Implement igb-specific oversize check
From: |
Akihiko Odaki |
Subject: |
[PATCH v4 40/48] igb: Implement igb-specific oversize check |
Date: |
Wed, 26 Apr 2023 19:37:08 +0900 |
igb has a configurable size limit for LPE, and uses different limits
depending on whether the packet is treated as a VLAN packet.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Sriram Yagnaraman <sriram.yagnaraman@est.tech>
---
hw/net/igb_core.c | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c
index 5345f57031..c04ec01117 100644
--- a/hw/net/igb_core.c
+++ b/hw/net/igb_core.c
@@ -980,16 +980,13 @@ igb_rx_l4_cso_enabled(IGBCore *core)
return !!(core->mac[RXCSUM] & E1000_RXCSUM_TUOFLD);
}
-static bool
-igb_rx_is_oversized(IGBCore *core, uint16_t qn, size_t size)
+static bool igb_rx_is_oversized(IGBCore *core, const struct eth_header *ehdr,
+ size_t size, size_t vlan_num,
+ bool lpe, uint16_t rlpml)
{
- uint16_t pool = qn % IGB_NUM_VM_POOLS;
- bool lpe = !!(core->mac[VMOLR0 + pool] & E1000_VMOLR_LPE);
- int max_ethernet_lpe_size =
- core->mac[VMOLR0 + pool] & E1000_VMOLR_RLPML_MASK;
- int max_ethernet_vlan_size = 1522;
-
- return size > (lpe ? max_ethernet_lpe_size : max_ethernet_vlan_size);
+ size_t vlan_header_size = sizeof(struct vlan_header) * vlan_num;
+ size_t header_size = sizeof(struct eth_header) + vlan_header_size;
+ return lpe ? size + ETH_FCS_LEN > rlpml : size > header_size + ETH_MTU;
}
static uint16_t igb_receive_assign(IGBCore *core, const L2Header *l2_header,
@@ -1002,6 +999,8 @@ static uint16_t igb_receive_assign(IGBCore *core, const
L2Header *l2_header,
uint16_t queues = 0;
uint16_t oversized = 0;
size_t vlan_num = 0;
+ bool lpe;
+ uint16_t rlpml;
int i;
memset(rss_info, 0, sizeof(E1000E_RSSInfo));
@@ -1021,6 +1020,14 @@ static uint16_t igb_receive_assign(IGBCore *core, const
L2Header *l2_header,
}
}
+ lpe = !!(core->mac[RCTL] & E1000_RCTL_LPE);
+ rlpml = core->mac[RLPML];
+ if (!(core->mac[RCTL] & E1000_RCTL_SBP) &&
+ igb_rx_is_oversized(core, ehdr, size, vlan_num, lpe, rlpml)) {
+ trace_e1000x_rx_oversized(size);
+ return queues;
+ }
+
if (vlan_num &&
!e1000x_rx_vlan_filter(core->mac, l2_header->vlan + vlan_num - 1)) {
return queues;
@@ -1106,7 +1113,11 @@ static uint16_t igb_receive_assign(IGBCore *core, const
L2Header *l2_header,
queues &= core->mac[VFRE];
if (queues) {
for (i = 0; i < IGB_NUM_VM_POOLS; i++) {
- if ((queues & BIT(i)) && igb_rx_is_oversized(core, i, size)) {
+ lpe = !!(core->mac[VMOLR0 + i] & E1000_VMOLR_LPE);
+ rlpml = core->mac[VMOLR0 + i] & E1000_VMOLR_RLPML_MASK;
+ if ((queues & BIT(i)) &&
+ igb_rx_is_oversized(core, ehdr, size, vlan_num,
+ lpe, rlpml)) {
oversized |= BIT(i);
}
}
@@ -1662,11 +1673,6 @@ igb_receive_internal(IGBCore *core, const struct iovec
*iov, int iovcnt,
iov_to_buf(iov, iovcnt, iov_ofs, &buf, sizeof(buf.l2_header));
}
- /* Discard oversized packets if !LPE and !SBP. */
- if (e1000x_is_oversized(core->mac, size)) {
- return orig_size;
- }
-
net_rx_pkt_set_packet_type(core->rx_pkt,
get_eth_packet_type(&buf.l2_header.eth));
net_rx_pkt_set_protocols(core->rx_pkt, iov, iovcnt, iov_ofs);
--
2.40.0
- [PATCH v4 30/48] net/eth: Use void pointers, (continued)
- [PATCH v4 30/48] net/eth: Use void pointers, Akihiko Odaki, 2023/04/26
- [PATCH v4 31/48] net/eth: Always add VLAN tag, Akihiko Odaki, 2023/04/26
- [PATCH v4 32/48] hw/net/net_rx_pkt: Enforce alignment for eth_header, Akihiko Odaki, 2023/04/26
- [PATCH v4 33/48] tests/qtest/libqos/igb: Set GPIE.Multiple_MSIX, Akihiko Odaki, 2023/04/26
- [PATCH v4 34/48] igb: Implement MSI-X single vector mode, Akihiko Odaki, 2023/04/26
- [PATCH v4 35/48] igb: Use UDP for RSS hash, Akihiko Odaki, 2023/04/26
- [PATCH v4 36/48] igb: Implement Rx SCTP CSO, Akihiko Odaki, 2023/04/26
- [PATCH v4 37/48] igb: Implement Tx SCTP CSO, Akihiko Odaki, 2023/04/26
- [PATCH v4 38/48] igb: Strip the second VLAN tag for extended VLAN, Akihiko Odaki, 2023/04/26
- [PATCH v4 39/48] igb: Filter with the second VLAN tag for extended VLAN, Akihiko Odaki, 2023/04/26
- [PATCH v4 40/48] igb: Implement igb-specific oversize check,
Akihiko Odaki <=
- [PATCH v4 41/48] igb: Implement Rx PTP2 timestamp, Akihiko Odaki, 2023/04/26
- [PATCH v4 42/48] igb: Implement Tx timestamp, Akihiko Odaki, 2023/04/26
- [PATCH v4 43/48] e1000e: Notify only new interrupts, Akihiko Odaki, 2023/04/26
- [PATCH v4 44/48] igb: Notify only new interrupts, Akihiko Odaki, 2023/04/26
- [PATCH v4 45/48] igb: Clear-on-read ICR when ICR.INTA is set, Akihiko Odaki, 2023/04/26
- [PATCH v4 46/48] vmxnet3: Do not depend on PC, Akihiko Odaki, 2023/04/26
- [PATCH v4 47/48] MAINTAINERS: Add a reviewer for network packet abstractions, Akihiko Odaki, 2023/04/26
- [PATCH v4 48/48] docs/system/devices/igb: Note igb is tested for DPDK, Akihiko Odaki, 2023/04/26