On Fri, Jan 26, 2024 at 11:41:49AM +0100, Hrvoje Popovski wrote:
> I've manage to reproduce TSO em problem on anoter setup, unfortunatly
> production.
What helped debugging a similar issue with ixl(4) and TSO was to
remove all TSO specific code from the driver. Then only this part
remains from the original em(4) TSO diff.
error = bus_dmamap_create(sc->sc_dmat, EM_TSO_SIZE,
EM_MAX_SCATTER / (sc->pcix_82544 ? 2 : 1),
EM_TSO_SEG_SIZE, 0, BUS_DMA_NOWAIT, &pkt->pkt_map);
The parameters that changed when adding TSO are:
bus_size_t size: MAX_JUMBO_FRAME_SIZE 16128 -> EM_TSO_SIZE 65535
bus_size_t maxsegsz: MAX_JUMBO_FRAME_SIZE 16128 -> EM_TSO_SEG_SIZE 4096
I suspect that this is the cause for the regression as disabling
TSO did not help. Would it be possible to run the diff below? I
expect that the problem will still be there. But then we know it
must be the change of one of the bus_dmamap_create() arguments.
bluhm
Index: dev/pci/if_em.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_em.c,v
diff -u -p -r1.370 if_em.c
--- dev/pci/if_em.c 31 Dec 2023 08:42:33 -0000 1.370
+++ dev/pci/if_em.c 26 Jan 2024 21:32:08 -0000
@@ -291,8 +291,6 @@ void em_receive_checksum(struct em_softc
struct mbuf *);
u_int em_transmit_checksum_setup(struct em_queue *, struct mbuf *, u_int,
u_int32_t *, u_int32_t *);
-u_int em_tso_setup(struct em_queue *, struct mbuf *, u_int, u_int32_t *,
- u_int32_t *);
u_int em_tx_ctx_setup(struct em_queue *, struct mbuf *, u_int, u_int32_t *,
u_int32_t *);
void em_iff(struct em_softc *);
@@ -1238,15 +1236,7 @@ em_encap(struct em_queue *que, struct mb
}
if (sc->hw.mac_type >= em_82575 && sc->hw.mac_type <= em_i210) {
- if (ISSET(m->m_pkthdr.csum_flags, M_TCP_TSO)) {
- used += em_tso_setup(que, m, head, &txd_upper,
- &txd_lower);
- if (!used)
- return (used);
- } else {
- used += em_tx_ctx_setup(que, m, head, &txd_upper,
- &txd_lower);
- }
+ used += em_tx_ctx_setup(que, m, head, &txd_upper, &txd_lower);
} else if (sc->hw.mac_type >= em_82543) {
used += em_transmit_checksum_setup(que, m, head,
&txd_upper, &txd_lower);
@@ -1579,21 +1569,6 @@ em_update_link_status(struct em_softc *s
ifp->if_link_state = link_state;
if_link_state_change(ifp);
}
-
- /* Disable TSO for 10/100 speeds to avoid some hardware issues */
- switch (sc->link_speed) {
- case SPEED_10:
- case SPEED_100:
- if (sc->hw.mac_type >= em_82575 && sc->hw.mac_type <= em_i210) {
- ifp->if_capabilities &= ~IFCAP_TSOv4;
- ifp->if_capabilities &= ~IFCAP_TSOv6;
- }
- break;
- case SPEED_1000:
- if (sc->hw.mac_type >= em_82575 && sc->hw.mac_type <= em_i210)
- ifp->if_capabilities |= IFCAP_TSOv4 | IFCAP_TSOv6;
- break;
- }
}
/*********************************************************************
@@ -2013,7 +1988,6 @@ em_setup_interface(struct em_softc *sc)
if (sc->hw.mac_type >= em_82575 && sc->hw.mac_type <= em_i210) {
ifp->if_capabilities |= IFCAP_CSUM_IPv4;
ifp->if_capabilities |= IFCAP_CSUM_TCPv6 | IFCAP_CSUM_UDPv6;
- ifp->if_capabilities |= IFCAP_TSOv4 | IFCAP_TSOv6;
}
/*
@@ -2429,81 +2403,6 @@ em_free_transmit_structures(struct em_so
0, que->tx.sc_tx_dma.dma_map->dm_mapsize,
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
}
-}
-
-u_int
-em_tso_setup(struct em_queue *que, struct mbuf *mp, u_int head,
- u_int32_t *olinfo_status, u_int32_t *cmd_type_len)
-{
- struct ether_extracted ext;
- struct e1000_adv_tx_context_desc *TD;
- uint32_t vlan_macip_lens = 0, type_tucmd_mlhl = 0, mss_l4len_idx = 0;
- uint32_t paylen = 0;
- uint8_t iphlen = 0;
-
- *olinfo_status = 0;
- *cmd_type_len = 0;
- TD = (struct e1000_adv_tx_context_desc *)&que->tx.sc_tx_desc_ring[head];
-
-#if NVLAN > 0
- if (ISSET(mp->m_flags, M_VLANTAG)) {
- uint32_t vtag = mp->m_pkthdr.ether_vtag;
- vlan_macip_lens |= vtag << E1000_ADVTXD_VLAN_SHIFT;
- *cmd_type_len |= E1000_ADVTXD_DCMD_VLE;
- }
-#endif
-
- ether_extract_headers(mp, &ext);
- if (ext.tcp == NULL)
- goto out;
-
- vlan_macip_lens |= (sizeof(*ext.eh) << E1000_ADVTXD_MACLEN_SHIFT);
-
- if (ext.ip4) {
- iphlen = ext.ip4->ip_hl << 2;
-
- type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_IPV4;
- *olinfo_status |= E1000_TXD_POPTS_IXSM << 8;
-#ifdef INET6
- } else if (ext.ip6) {
- iphlen = sizeof(*ext.ip6);
-
- type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_IPV6;
-#endif
- } else {
- goto out;
- }
-
- *cmd_type_len |= E1000_ADVTXD_DTYP_DATA | E1000_ADVTXD_DCMD_IFCS;
- *cmd_type_len |= E1000_ADVTXD_DCMD_DEXT | E1000_ADVTXD_DCMD_TSE;
- paylen = mp->m_pkthdr.len - sizeof(*ext.eh) - iphlen -
- (ext.tcp->th_off << 2);
- *olinfo_status |= paylen << E1000_ADVTXD_PAYLEN_SHIFT;
- vlan_macip_lens |= iphlen;
- type_tucmd_mlhl |= E1000_ADVTXD_DCMD_DEXT | E1000_ADVTXD_DTYP_CTXT;
-
- type_tucmd_mlhl |= E1000_ADVTXD_TUCMD_L4T_TCP;
- *olinfo_status |= E1000_TXD_POPTS_TXSM << 8;
-
- mss_l4len_idx |= mp->m_pkthdr.ph_mss << E1000_ADVTXD_MSS_SHIFT;
- mss_l4len_idx |= (ext.tcp->th_off << 2) << E1000_ADVTXD_L4LEN_SHIFT;
- /* 82575 needs the queue index added */
- if (que->sc->hw.mac_type == em_82575)
- mss_l4len_idx |= (que->me & 0xff) << 4;
-
- htolem32(&TD->vlan_macip_lens, vlan_macip_lens);
- htolem32(&TD->type_tucmd_mlhl, type_tucmd_mlhl);
- htolem32(&TD->u.seqnum_seed, 0);
- htolem32(&TD->mss_l4len_idx, mss_l4len_idx);
-
- tcpstat_add(tcps_outpkttso, (paylen + mp->m_pkthdr.ph_mss - 1) /
- mp->m_pkthdr.ph_mss);
-
- return 1;
-
-out:
- tcpstat_inc(tcps_outbadtso);
- return 0;
}
u_int