git: 201c4b7c29da - main - e1000: Some fixes for em(4) TSO setup

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Fri, 21 Jul 2023 03:44:40 UTC
The branch main has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=201c4b7c29da44500ccb9e47b854dc1207df8b0a

commit 201c4b7c29da44500ccb9e47b854dc1207df8b0a
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2023-07-21 01:51:02 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2023-07-21 01:52:53 +0000

    e1000: Some fixes for em(4) TSO setup
    
    Always set TXD_CMD_IP for 82544
    Otherwise set TXD_CMD_IP for IPv4, not IPv6
    
    Reviewed by:    markj (previous version)
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D30072
---
 sys/dev/e1000/em_txrx.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/sys/dev/e1000/em_txrx.c b/sys/dev/e1000/em_txrx.c
index 255aea6347d2..47f9b187aa14 100644
--- a/sys/dev/e1000/em_txrx.c
+++ b/sys/dev/e1000/em_txrx.c
@@ -141,8 +141,10 @@ em_tso_setup(struct e1000_softc *sc, if_pkt_info_t pi, uint32_t *txd_upper,
 	if_softc_ctx_t scctx = sc->shared;
 	struct em_tx_queue *que = &sc->tx_queues[pi->ipi_qsidx];
 	struct tx_ring *txr = &que->txr;
+	struct e1000_hw *hw = &sc->hw;
 	struct e1000_context_desc *TXD;
 	int cur, hdr_len;
+	uint32_t cmd_type_len;
 
 	hdr_len = pi->ipi_ehdrlen + pi->ipi_ip_hlen + pi->ipi_tcp_hlen;
 	*txd_lower = (E1000_TXD_CMD_DEXT |	/* Extended descr type */
@@ -183,12 +185,23 @@ em_tso_setup(struct e1000_softc *sc, if_pkt_info_t pi, uint32_t *txd_upper,
 	TXD->tcp_seg_setup.fields.mss = htole16(pi->ipi_tso_segsz);
 	TXD->tcp_seg_setup.fields.hdr_len = hdr_len;
 
-	TXD->cmd_and_length = htole32(sc->txd_cmd |
-				E1000_TXD_CMD_DEXT |	/* Extended descr */
-				E1000_TXD_CMD_TSE |	/* TSE context */
-				E1000_TXD_CMD_IP |	/* Do IP csum */
-				E1000_TXD_CMD_TCP |	/* Do TCP checksum */
-				      (pi->ipi_len - hdr_len)); /* Total len */
+	/*
+	 * 8254x SDM4.0 page 45, and PCIe GbE SDM2.5 page 63
+	 * - Set up basic TUCMDs
+	 * - Enable IP bit on 82544
+	 * - For others IP bit on indicates IPv4, while off indicates IPv6
+	*/
+	cmd_type_len = sc->txd_cmd |
+	    E1000_TXD_CMD_DEXT | /* Extended descr */
+	    E1000_TXD_CMD_TSE |  /* TSE context */
+	    E1000_TXD_CMD_TCP;   /* Do TCP checksum */
+	if (hw->mac.type == e1000_82544)
+		cmd_type_len |= E1000_TXD_CMD_IP;
+	else if (pi->ipi_etype == ETHERTYPE_IP)
+		cmd_type_len |= E1000_TXD_CMD_IP;
+	TXD->cmd_and_length = htole32(cmd_type_len |
+	    (pi->ipi_len - hdr_len)); /* Total len */
+
 	txr->tx_tso = true;
 
 	if (++cur == scctx->isc_ntxd[0]) {