From owner-svn-src-stable@freebsd.org Thu Jul 30 13:55:06 2020 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1C9593A61AA; Thu, 30 Jul 2020 13:55:06 +0000 (UTC) (envelope-from avg@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BHX3Y6Vtvz4PCv; Thu, 30 Jul 2020 13:55:05 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C279611EAD; Thu, 30 Jul 2020 13:55:05 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 06UDt5TH031160; Thu, 30 Jul 2020 13:55:05 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06UDt50o031158; Thu, 30 Jul 2020 13:55:05 GMT (envelope-from avg@FreeBSD.org) Message-Id: <202007301355.06UDt50o031158@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 30 Jul 2020 13:55:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r363694 - in stable/12/sys: dev/ena modules/ena X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12/sys: dev/ena modules/ena X-SVN-Commit-Revision: 363694 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jul 2020 13:55:06 -0000 Author: avg Date: Thu Jul 30 13:55:05 2020 New Revision: 363694 URL: https://svnweb.freebsd.org/changeset/base/363694 Log: MFC r362530: teach ena driver about RSS kernel option Networking is broken if the driver configures its (virtual) hardware to use a hash algorithm (or a key) different from the one that the network stack (software RSS) uses. This can be seen with connections initiated from the host. The PCB will be placed into the hash table based on the hash value calculated by the software. The hardware-calculated hash value in reponse packets will be different, so the PCB won't be found. Tested with a kernel compiled with 'options RSS' on an instance with ena driver. Modified: stable/12/sys/dev/ena/ena.c stable/12/sys/modules/ena/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ena/ena.c ============================================================================== --- stable/12/sys/dev/ena/ena.c Thu Jul 30 13:36:24 2020 (r363693) +++ stable/12/sys/dev/ena/ena.c Thu Jul 30 13:55:05 2020 (r363694) @@ -30,6 +30,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_rss.h" + #include #include #include @@ -62,6 +64,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef RSS +#include +#endif #include #include @@ -1424,6 +1429,19 @@ ena_rx_hash_mbuf(struct ena_ring *rx_ring, struct ena_ if (likely(adapter->rss_support)) { mbuf->m_pkthdr.flowid = ena_rx_ctx->hash; +#ifdef RSS + /* + * Hardware and software RSS are in agreement only when both are + * configured to Toeplitz algorithm. This driver configures + * that algorithm only when software RSS is enabled and uses it. + */ + if (adapter->ena_dev->rss.hash_func != ENA_ADMIN_TOEPLITZ && + ena_rx_ctx->l3_proto != ENA_ETH_IO_L3_PROTO_UNKNOWN) { + M_HASHTYPE_SET(mbuf, M_HASHTYPE_OPAQUE_HASH); + return; + } +#endif + if (ena_rx_ctx->frag && (ena_rx_ctx->l3_proto != ENA_ETH_IO_L3_PROTO_UNKNOWN)) { M_HASHTYPE_SET(mbuf, M_HASHTYPE_OPAQUE_HASH); @@ -3106,6 +3124,16 @@ ena_rss_init_default(struct ena_adapter *adapter) } } +#ifdef RSS + uint8_t rss_algo = rss_gethashalgo(); + if (rss_algo == RSS_HASH_TOEPLITZ) { + uint8_t hash_key[RSS_KEYSIZE]; + + rss_getkey(hash_key); + rc = ena_com_fill_hash_function(ena_dev, ENA_ADMIN_TOEPLITZ, + hash_key, RSS_KEYSIZE, 0xFFFFFFFF); + } else +#endif rc = ena_com_fill_hash_function(ena_dev, ENA_ADMIN_CRC32, NULL, ENA_HASH_KEY_SIZE, 0xFFFFFFFF); if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) { Modified: stable/12/sys/modules/ena/Makefile ============================================================================== --- stable/12/sys/modules/ena/Makefile Thu Jul 30 13:36:24 2020 (r363693) +++ stable/12/sys/modules/ena/Makefile Thu Jul 30 13:55:05 2020 (r363694) @@ -36,6 +36,7 @@ KMOD = if_ena SRCS = ena.c ena_com.c ena_eth_com.c ena_sysctl.c SRCS += device_if.h bus_if.h pci_if.h +SRCS += opt_rss.h CFLAGS += -I${SRCTOP}/sys/contrib .include