From patchwork Mon Feb 5 22:32:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546353 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C1D11DA58 for ; Mon, 5 Feb 2024 22:32:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172355; cv=none; b=eXHZySTTvhS+7d0ivBXQDIAFF+h0Mt0W/RVdkmlNh/CvrIb0HxmeZPooBXFEy7wZrAnHdSNeH73YoFgei+C15IJ3+2JS2d/pQALdbgzYKc53BKeynfd/h/83uWfgFVTRM7Q7O6E+SCv2Le95xnY9+fnPoBIut6efKVj4sYgDmyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172355; c=relaxed/simple; bh=MAXuPCl2sFn1NUP0oXPJ8AAyQ7T0v1qHVHSFmGeCBPk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=sZiY1WAKd6+T67yn8FAAo4fRZ0dNdXsLQ0g65laCKCcjAlSR1g1Mp3JEkjtgLuLri5q23VgCxeUaydo7PVIr99HRSbwg+E0G9QvnrmiOYmds5zJfY80hNUeZYUS9KEK5JR0CSyO+CQjKiZgB7eqhuC9dQqPDoVUbyaLeLUXraXU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=QqJ0GTQb; arc=none smtp.client-ip=209.85.160.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="QqJ0GTQb" Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-42a9c21f9ecso29327811cf.0 for ; Mon, 05 Feb 2024 14:32:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172353; x=1707777153; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=d72hnexSFBoKXOTEfV0exTKLLP0xzu0ruuF+i1GK1W0=; b=QqJ0GTQbVzocoQX031hPVOMvhMjcpMPbkI5qcBhderuWmRw/5HPSlMSBvTBDlMjtfn hvjnhohm2cLYFqmG/9P/M+72sYb5MEFF97XNMv6m4hrlFRjyB0wspdcHFlh6O4anR/Js NS1XfYaCtSxd/umlpd85s+06c9Ye4GSDDja2s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172353; x=1707777153; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=d72hnexSFBoKXOTEfV0exTKLLP0xzu0ruuF+i1GK1W0=; b=Due+x0PR9HHQdmUbRJJ31eqGys1LovYKcWFRbeFOYLxTCnoCo/H3TNkSLcfbvg8jdU xxQ8lpOMGUtri6zHPG1+CcLECcVyeqtNsJPzLDh3AsUrO4BntEcAn0LsHdK6Dx8UCOcA jnhiY21bsP+5YzYWeJvwT9Rg0IwQdRzSsQozVN+mn65zI0KNdYMHMdAIuK/42U0OQbYM k+amO9V5wpwBlZ0E91wSxypzaUTYfETK1Rt/Qh8dzsOzno0FMs78GE2w/dX7DI+b/QuH TtP8ToewOKBq1aO9ShzbTyL3mw6P/E9827ruBkRiF77i6Z1WGDdaZoMtKmmYrIG8fRQx Jjnw== X-Gm-Message-State: AOJu0YyOqanBLatvErltRODTx9caVj5D3GIVSnBijr0zT4iWnPJBUjjl ImrGirSKj1JJ2i3a4zZVt5Jl/RsM33PZX9aTIvCzUwx26CGzNvmFHTZLGJSv0w== X-Google-Smtp-Source: AGHT+IFO8Lu0MA9f6cAnJHMx+TNgd/6YuXfQY45FHsJg73LK+9RNVNKOo1wbPcy61Hfzq3lkhFIFdQ== X-Received: by 2002:ac8:59cf:0:b0:42b:fd4a:e13d with SMTP id f15-20020ac859cf000000b0042bfd4ae13dmr649576qtf.55.1707172352837; Mon, 05 Feb 2024 14:32:32 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVQURLqNjfVDGaK6LO40iXhl6ki1L2N+5dbjxhnCBs2ZbUm+k+XCISduegLOvXQGY2Sm/XvET9vGoe+iSvqwkug9Gh1hSzAS4WxLkPo5rvl8uTyk0QduYliQrAoVosrDDrES1z0p/fy1E7FUIjlXKNFFAgWxBqJrfTOffXdkxO3fKV8gxDlryqANEBZ6K1qCNY05z+AW1KxPhRMmzo+BDh7bcI= Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:32 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com Subject: [PATCH net-next 11/13] bnxt_en: Add support for user configured RSS key Date: Mon, 5 Feb 2024 14:32:00 -0800 Message-Id: <20240205223202.25341-12-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Pavan Chebbi Store the user configured or generated Toeplitz key in bp->rss_hash_key. The key stays constant across ifdown/ifup unless updated by the user. Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 18 ++++++++++++++++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 4 ++++ .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 6 ++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index a6e2b65c45ce..27941ade894a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4246,9 +4246,23 @@ static void bnxt_init_vnics(struct bnxt *bp) u8 *key = (void *)vnic->rss_hash_key; int k; + if (!bp->rss_hash_key_valid && + !bp->rss_hash_key_updated) { + get_random_bytes(bp->rss_hash_key, + HW_HASH_KEY_SIZE); + bp->rss_hash_key_updated = true; + } + + memcpy(vnic->rss_hash_key, bp->rss_hash_key, + HW_HASH_KEY_SIZE); + + if (!bp->rss_hash_key_updated) + continue; + + bp->rss_hash_key_updated = false; + bp->rss_hash_key_valid = true; + bp->toeplitz_prefix = 0; - get_random_bytes(vnic->rss_hash_key, - HW_HASH_KEY_SIZE); for (k = 0; k < 8; k++) { bp->toeplitz_prefix <<= 8; bp->toeplitz_prefix |= key[k]; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index a6b6db1546cc..28091889615b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2222,6 +2222,10 @@ struct bnxt { #define BNXT_RSS_CAP_NEW_RSS_CAP BIT(2) #define BNXT_RSS_CAP_RSS_TCAM BIT(3) + u8 rss_hash_key[HW_HASH_KEY_SIZE]; + u8 rss_hash_key_valid:1; + u8 rss_hash_key_updated:1; + u16 max_mtu; u8 max_tc; u8 max_lltc; /* lossless TCs */ diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 6721c4a88453..9b5382412db3 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1755,8 +1755,10 @@ static int bnxt_set_rxfh(struct net_device *dev, if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP) return -EOPNOTSUPP; - if (rxfh->key) - return -EOPNOTSUPP; + if (rxfh->key) { + memcpy(bp->rss_hash_key, rxfh->key, HW_HASH_KEY_SIZE); + bp->rss_hash_key_updated = true; + } if (rxfh->indir) { u32 i, pad, tbl_size = bnxt_get_rxfh_indir_size(dev);