From owner-svn-src-head@freebsd.org Mon Oct 2 12:11:44 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CAEBFE3E267; Mon, 2 Oct 2017 12:11:44 +0000 (UTC) (envelope-from hselasky@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 mx1.freebsd.org (Postfix) with ESMTPS id A5E5265FCC; Mon, 2 Oct 2017 12:11:44 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v92CBhiV018893; Mon, 2 Oct 2017 12:11:43 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v92CBhes018892; Mon, 2 Oct 2017 12:11:43 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201710021211.v92CBhes018892@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 2 Oct 2017 12:11:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324201 - head/sys/dev/mlx4/mlx4_en X-SVN-Group: head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: head/sys/dev/mlx4/mlx4_en X-SVN-Commit-Revision: 324201 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.23 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: Mon, 02 Oct 2017 12:11:44 -0000 Author: hselasky Date: Mon Oct 2 12:11:43 2017 New Revision: 324201 URL: https://svnweb.freebsd.org/changeset/base/324201 Log: Setup mbuf hash type properly when receiving IP packets in the mlx4en(4) driver. Submitted by: sephe@ Differential Revision: https://reviews.freebsd.org/D12229 MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c Modified: head/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c ============================================================================== --- head/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c Mon Oct 2 12:05:38 2017 (r324200) +++ head/sys/dev/mlx4/mlx4_en/mlx4_en_rx.c Mon Oct 2 12:11:43 2017 (r324201) @@ -555,6 +555,51 @@ mlx4_en_rx_mb(struct mlx4_en_priv *priv, struct mlx4_e return (mb); } +static __inline int +mlx4_en_rss_hash(__be16 status, int udp_rss) +{ + const __be16 status_all = cpu_to_be16( + MLX4_CQE_STATUS_IPV4 | + MLX4_CQE_STATUS_IPV4F | + MLX4_CQE_STATUS_IPV6 | + MLX4_CQE_STATUS_TCP | + MLX4_CQE_STATUS_UDP); + const __be16 status_ipv4_tcp = cpu_to_be16( + MLX4_CQE_STATUS_IPV4 | + MLX4_CQE_STATUS_TCP); + const __be16 status_ipv6_tcp = cpu_to_be16( + MLX4_CQE_STATUS_IPV6 | + MLX4_CQE_STATUS_TCP); + const __be16 status_ipv4_udp = cpu_to_be16( + MLX4_CQE_STATUS_IPV4 | + MLX4_CQE_STATUS_UDP); + const __be16 status_ipv6_udp = cpu_to_be16( + MLX4_CQE_STATUS_IPV6 | + MLX4_CQE_STATUS_UDP); + const __be16 status_ipv4 = cpu_to_be16(MLX4_CQE_STATUS_IPV4); + const __be16 status_ipv6 = cpu_to_be16(MLX4_CQE_STATUS_IPV6); + + status &= status_all; + switch (status) { + case status_ipv4_tcp: + return (M_HASHTYPE_RSS_TCP_IPV4); + case status_ipv6_tcp: + return (M_HASHTYPE_RSS_TCP_IPV6); + case status_ipv4_udp: + return (udp_rss ? M_HASHTYPE_RSS_UDP_IPV4 + : M_HASHTYPE_RSS_IPV4); + case status_ipv6_udp: + return (udp_rss ? M_HASHTYPE_RSS_UDP_IPV6 + : M_HASHTYPE_RSS_IPV6); + default: + if (status & status_ipv4) + return (M_HASHTYPE_RSS_IPV4); + if (status & status_ipv6) + return (M_HASHTYPE_RSS_IPV6); + return (M_HASHTYPE_OPAQUE_HASH); + } +} + /* For cpu arch with cache line of 64B the performance is better when cqe size==64B * To enlarge cqe size from 32B to 64B --> 32B of garbage (i.e. 0xccccccc) * was added in the beginning of each cqe (the real data is in the corresponding 32B). @@ -578,6 +623,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, stru u32 size_mask = ring->size_mask; int size = cq->size; int factor = priv->cqe_factor; + const int udp_rss = priv->mdev->profile.udp_rss; if (!priv->port_up) return 0; @@ -625,7 +671,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, stru /* forward Toeplitz compatible hash value */ mb->m_pkthdr.flowid = be32_to_cpu(cqe->immed_rss_invalid); - M_HASHTYPE_SET(mb, M_HASHTYPE_OPAQUE_HASH); + M_HASHTYPE_SET(mb, mlx4_en_rss_hash(cqe->status, udp_rss)); mb->m_pkthdr.rcvif = dev; if (be32_to_cpu(cqe->vlan_my_qpn) & MLX4_CQE_VLAN_PRESENT_MASK) {