From owner-svn-src-head@freebsd.org Tue Jun 23 04:58:37 2020 Return-Path: Delivered-To: svn-src-head@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 DD508349293; Tue, 23 Jun 2020 04:58:37 +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 49rYvd5Zmjz40kf; Tue, 23 Jun 2020 04:58:37 +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 BAE9D1ACEF; Tue, 23 Jun 2020 04:58:37 +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 05N4wbtg025690; Tue, 23 Jun 2020 04:58:37 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05N4wb8B025688; Tue, 23 Jun 2020 04:58:37 GMT (envelope-from avg@FreeBSD.org) Message-Id: <202006230458.05N4wb8B025688@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 23 Jun 2020 04:58:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362530 - head/sys/dev/ena X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: head/sys/dev/ena X-SVN-Commit-Revision: 362530 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jun 2020 04:58:37 -0000 Author: avg Date: Tue Jun 23 04:58:36 2020 New Revision: 362530 URL: https://svnweb.freebsd.org/changeset/base/362530 Log: 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. Reviewed by: mw, adrian MFC after: 2 weeks Sponsored by: Panzura Differential Revision: https://reviews.freebsd.org/D24733 Modified: head/sys/dev/ena/ena.c head/sys/dev/ena/ena_datapath.c Modified: head/sys/dev/ena/ena.c ============================================================================== --- head/sys/dev/ena/ena.c Tue Jun 23 03:32:58 2020 (r362529) +++ head/sys/dev/ena/ena.c Tue Jun 23 04:58:36 2020 (r362530) @@ -30,6 +30,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_rss.h" + #include #include #include @@ -61,6 +63,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef RSS +#include +#endif #include #include @@ -2700,6 +2705,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: head/sys/dev/ena/ena_datapath.c ============================================================================== --- head/sys/dev/ena/ena_datapath.c Tue Jun 23 03:32:58 2020 (r362529) +++ head/sys/dev/ena/ena_datapath.c Tue Jun 23 04:58:36 2020 (r362530) @@ -30,6 +30,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_rss.h" #include "ena.h" #include "ena_datapath.h" #ifdef DEV_NETMAP @@ -335,6 +336,19 @@ ena_rx_hash_mbuf(struct ena_ring *rx_ring, struct ena_ if (likely(ENA_FLAG_ISSET(ENA_FLAG_RSS_ACTIVE, adapter))) { 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)) {