From nobody Fri Aug 04 01:23:40 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RH7Jr4NlQzZY5f; Fri, 4 Aug 2023 01:23:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RH7Jr34Vqz4Z15; Fri, 4 Aug 2023 01:23:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691112220; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4KK/eHNCU1A6aBWfqNtblmRY2U3DLpw00BnRg0Imx0U=; b=tmKOgMpyew5prnMmuegS3tiK+CvQPwf8QveyJiTgN/sQbwuDJsvOx27VKsuSZYRY1GH++e QeNHoS9euvgdhMn0pzNZrKNwU6jDDYsdAEie49sbxDTqK87XtqDWgJNEMyjlGF+7AJNUM1 n7Ics9LiRMq9L1Z/oxB3t/UmcmYOGlmoINUoxAvp3b/AyfwvJ2uY576XLDF83xowt3bk3R YHnYQCPGxE1nP9Nd7oGhFi+fbIA7HAEjSHz3gV2sAyuF1O1ICEgUTgzUznvPj1gz9FkrYV be3JxwdNjtFTvsZ98/x7h3C+87SOaCmu1cQt1QQ1gNZ1atR7geRLjz00LfTU2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691112220; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4KK/eHNCU1A6aBWfqNtblmRY2U3DLpw00BnRg0Imx0U=; b=CnGjg2FAEGRQ/ZyXMohrcxCTNcpMPHlF3DcV3S7q52CLwj73NiFf45vsOH5BhGY3qOPxX0 Fu+6bM1k6aUpOkEWKrXh2DhlWcFIxcCKya++cbpMdLacKDCfNP8r23Bhb5tODDsNl9op2Z Xuec5SMaaGAuMW44nwTun1BTX0CcjsufAOZB652NGZSB6Y5TqYNcgszmR1tMmKiCxTxxpc XksomiWEzxirXcHgJ0c9i0YTrNm3UD7uOsi1ta0dgvyke2Tnpa30/dVdEofmI2TslbVHLX wWBlVkbxTpLbn7vc2qQu9maap82iAa/VhWzw6U2QAtDh5UYcDAEtPqrhIfKptA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691112220; a=rsa-sha256; cv=none; b=SPUZs7IsGtdilTTD30IosihVxqFnMAOZr+kZ4lUkn9y1nij9u3mjtTHpYGt+S1+xrsWk6c opodu1iG9RdbyPw7KQ5dnp06GlzxEImWnKqv7yY/PqCh4xeRS95pf6dZz5vLQuBoBUhVC/ SmYIM9Pvwwnv4A4+8If2i6MszXdBZeyZ8Byguux4NINCFCThDMkAVnAsWgyY3uN6eZcdRR PexPkVz6hOXY8UakJWGkd9hTU4tZe8APcaaNQDnAnkwDzD9fgJB7L58gIB1jFOOOF9BW91 dgxFisKM0eDfwyAOw1VFZxfWjWNbMaWxDgWX1BZSjYqdw0i6dUFdlOVHUNBnWg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RH7Jr257zzkDL; Fri, 4 Aug 2023 01:23:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3741Ne3X021303; Fri, 4 Aug 2023 01:23:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3741Neup021302; Fri, 4 Aug 2023 01:23:40 GMT (envelope-from git) Date: Fri, 4 Aug 2023 01:23:40 GMT Message-Id: <202308040123.3741Neup021302@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: b71d11ba9476 - stable/13 - e1000: Corrections for lem(4)/em(4) txcsum offload List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b71d11ba9476cd1c4e001f465a519a94caeef4fa Auto-Submitted: auto-generated The branch stable/13 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=b71d11ba9476cd1c4e001f465a519a94caeef4fa commit b71d11ba9476cd1c4e001f465a519a94caeef4fa Author: Kevin Bowling AuthorDate: 2023-07-27 22:50:32 +0000 Commit: Kevin Bowling CommitDate: 2023-08-04 01:22:34 +0000 e1000: Corrections for lem(4)/em(4) txcsum offload Explicitly set ipcss/ipcse/ipcso for IPv6 per intel SDM as indicated in inline comments. Fix and consolidate 82543/82547 hwcsum exemption. While here rearrange and expand some commentary. (cherry picked from commit cbcab907f8ad1a4ac38dbc574c747ac2901faa54) --- sys/dev/e1000/em_txrx.c | 37 +++++++++++++++++++++++-------------- sys/dev/e1000/if_em.c | 11 ++++------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/sys/dev/e1000/em_txrx.c b/sys/dev/e1000/em_txrx.c index 8b1d2817490f..0e433f388ac5 100644 --- a/sys/dev/e1000/em_txrx.c +++ b/sys/dev/e1000/em_txrx.c @@ -186,7 +186,7 @@ em_tso_setup(struct e1000_softc *sc, if_pkt_info_t pi, uint32_t *txd_upper, TXD->tcp_seg_setup.fields.hdr_len = hdr_len; /* - * 8254x SDM4.0 page 45, and PCIe GbE SDM2.5 page 63 + * "PCI/PCI-X SDM 4.0" page 45, and "PCIe GbE SDM 2.5" page 63 * - Set up basic TUCMDs * - Enable IP bit on 82544 * - For others IP bit on indicates IPv4, while off indicates IPv6 @@ -212,10 +212,6 @@ em_tso_setup(struct e1000_softc *sc, if_pkt_info_t pi, uint32_t *txd_upper, return (cur); } -#define TSO_WORKAROUND 4 -#define DONT_FORCE_CTX 1 - - /********************************************************************* * The offload context is protocol specific (TCP/UDP) and thus * only needs to be set when the protocol changes. The occasion @@ -232,6 +228,7 @@ em_tso_setup(struct e1000_softc *sc, if_pkt_info_t pi, uint32_t *txd_upper, * in turn greatly slow down performance to send small sized * frames. **********************************************************************/ +#define DONT_FORCE_CTX 1 static int em_transmit_checksum_setup(struct e1000_softc *sc, if_pkt_info_t pi, @@ -271,20 +268,30 @@ em_transmit_checksum_setup(struct e1000_softc *sc, if_pkt_info_t pi, } TXD = (struct e1000_context_desc *)&txr->tx_base[cur]; + /* + * ipcss - Start offset for header checksum calculation. + * ipcse - End offset for header checksum calculation. + * ipcso - Offset of place to put the checksum. + * + * We set ipcsX values regardless of IP version to work around HW issues + * and ipcse must be 0 for IPv6 per "PCIe GbE SDM 2.5" page 61. + * IXSM controls whether it's inserted. + */ + TXD->lower_setup.ip_fields.ipcss = pi->ipi_ehdrlen; + TXD->lower_setup.ip_fields.ipcso = pi->ipi_ehdrlen + + offsetof(struct ip, ip_sum); if (csum_flags & CSUM_IP) { *txd_upper |= E1000_TXD_POPTS_IXSM << 8; - /* - * Start offset for header checksum calculation. - * End offset for header checksum calculation. - * Offset of place to put the checksum. - */ - TXD->lower_setup.ip_fields.ipcss = pi->ipi_ehdrlen; TXD->lower_setup.ip_fields.ipcse = htole16(hdr_len); - TXD->lower_setup.ip_fields.ipcso = pi->ipi_ehdrlen + - offsetof(struct ip, ip_sum); cmd |= E1000_TXD_CMD_IP; - } + } else if (csum_flags & (CSUM_IP6_TCP | CSUM_IP6_UDP)) + TXD->lower_setup.ip_fields.ipcse = htole16(0); + /* + * tucss - Start offset for payload checksum calculation. + * tucse - End offset for payload checksum calculation. + * tucso - Offset of place to put the checksum. + */ if (csum_flags & (CSUM_TCP | CSUM_UDP | CSUM_IP6_TCP | CSUM_IP6_UDP)) { uint8_t tucso; @@ -320,6 +327,8 @@ em_transmit_checksum_setup(struct e1000_softc *sc, if_pkt_info_t pi, return (cur); } +#define TSO_WORKAROUND 4 /* TSO sentinel descriptor */ + static int em_isc_txd_encap(void *arg, if_pkt_info_t pi) { diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 6e8970ccf6f6..6ceab6be2b8a 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -950,15 +950,13 @@ em_if_attach_pre(if_ctx_t ctx) scctx->isc_tx_csum_flags = CSUM_TCP | CSUM_UDP | CSUM_IP_TSO | CSUM_IP6_TCP | CSUM_IP6_UDP; - /* 8254x SDM4.0 page 33 - FDX requirement on these chips */ - if (hw->mac.type == e1000_82547 || hw->mac.type == e1000_82547_rev_2) + /* "PCI/PCI-X SDM 4.0" page 33 (b) - FDX requirement on these chips */ + if (hw->mac.type < e1000_82543 || hw->mac.type == e1000_82547 || + hw->mac.type == e1000_82547_rev_2) scctx->isc_capenable &= ~(IFCAP_HWCSUM|IFCAP_VLAN_HWCSUM); - - if (hw->mac.type < e1000_82543) - scctx->isc_capabilities &= ~(IFCAP_HWCSUM|IFCAP_VLAN_HWCSUM); /* 82541ER doesn't do HW tagging */ if (hw->device_id == E1000_DEV_ID_82541ER || hw->device_id == E1000_DEV_ID_82541ER_LOM) - scctx->isc_capabilities &= ~IFCAP_VLAN_HWTAGGING; + scctx->isc_capenable &= ~IFCAP_VLAN_HWTAGGING; /* INTx only */ scctx->isc_msix_bar = 0; } @@ -1354,7 +1352,6 @@ em_if_init(if_ctx_t ctx) E1000_RAR_ENTRIES - 1); } - /* Initialize the hardware */ em_reset(ctx); em_if_update_admin_status(ctx);