From patchwork Mon Mar 25 22:28:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13603109 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.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 2925C84D11 for ; Mon, 25 Mar 2024 22:29:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711405786; cv=none; b=gN+vzHvQlqImepAFakndtf0gbzdBIl5NlLoB8Lkg9rVj57Jg4JJ46+a34EIS0Qr6knTKKnMoAt9aKUqpR30HAjxhGnN0m9Hy6P3E1cOP/L4dGee1FwYkUqDOl/6cQZXfeVkEn85baszsIYaMZ0bA78Ap0h/IjrZtfvITiSzHCWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711405786; c=relaxed/simple; bh=IWM52G6xq0RUmHC7va8fk/WVU+4aNBxcy+vksytQoI8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=kOSHA2oL2r2VpRZXnOEvJgbtMZ+RBovpdNNX9wE0a5sHjZtM0PXYHFVL56owYglJm6hFcCZu7yShC0JqEhmDz3fH0eKNdsZezEb7avAGIKSzcPqQ+oW7lYJWDAsk6OI9dNjSHY/N5rJR7vfJJCfA1voaKZswt1dMDQTweK7ozNU= 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=HchITWeC; arc=none smtp.client-ip=209.85.167.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="HchITWeC" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3c3ca3c3bbaso1051380b6e.0 for ; Mon, 25 Mar 2024 15:29:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1711405784; x=1712010584; 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=ShLru4NopyvDBaZEQVzOxGy9sbawK6ttFuIDW0V7C80=; b=HchITWeCz6Eao8bsJdJ2tpGQo/oPdyHK6bpoybMhSUovOVxa6mv8wc196YALvaC4RR eop17VMKW6hKd5vAuKazYRNLRmf1JLykdhMTVRrNty8BHf8QEgvniNX0eHtXCcc3sS5t ynkIgWQabanmIISlf+thMQk5/xIyW7k2vZcqI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711405784; x=1712010584; 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=ShLru4NopyvDBaZEQVzOxGy9sbawK6ttFuIDW0V7C80=; b=cNKw+wQs1TTSPPu+zQWun/6Y5N7G5ThDzjeKDNRwVp+57H1q4htpow4MItECcOD/0B 2A0Rf9iKsyLdfRMCFhxhdImMtiCNsS34DYbGaGCxlh7F0L/v8cOEFl1mzp3164WDM3bR dqyJHSTJzdVsSo98/+Ia7Y2Rw4Ger5hzNXJOg9bHwypd3mMR0QXCk0UfrSseHTfBCO5u 7+UVoWWPzU4FyVpKQtpHqIogdZXFS+IhaE9w8TLUrelXHQWz8Pi0MaLfRTCbfqkV26n+ k8B3jklJGGNdRLjmpv9iaml2vkpxgo7m9UWuIxLp5MMwcjA+uFeXBrAKKYQtu8rRWLab ZcWg== X-Gm-Message-State: AOJu0YxUJz/6cNVTqoQ+kQIXDf7ptS25OwDbVu3TLVRbZ+R3WR4g0RE4 d4R4csJRwaKWtKWXYKeNaaZXPt/wBb8SeWQY2OXuMtO6dAu36x9LGES8vnOmlQ== X-Google-Smtp-Source: AGHT+IG+hN1SywKHMItu3vvDKX/KGgoZjoEgyZTLx27d5OtbMTl9ebFbDqC31PNNzWrHfnx5X7xesw== X-Received: by 2002:a05:6358:9386:b0:17f:5797:b0ee with SMTP id h6-20020a056358938600b0017f5797b0eemr11673287rwb.10.1711405783889; Mon, 25 Mar 2024 15:29:43 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id t10-20020a63dd0a000000b005e438fe702dsm6301610pgg.65.2024.03.25.15.29.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Mar 2024 15:29:42 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com Subject: [PATCH net-next 09/12] bnxt_en: Refactor bnxt_set_rxfh() Date: Mon, 25 Mar 2024 15:28:59 -0700 Message-Id: <20240325222902.220712-10-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240325222902.220712-1-michael.chan@broadcom.com> References: <20240325222902.220712-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 Add a new bnxt_modify_rss() function to modify the RSS key and RSS indirection table. The new function can modify the parameters for the default context or additional contexts. Signed-off-by: Michael Chan --- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 771833b1900d..7f57198f5834 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1778,6 +1778,32 @@ static int bnxt_get_rxfh(struct net_device *dev, return 0; } +static void bnxt_modify_rss(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx, + struct ethtool_rxfh_param *rxfh) +{ + if (rxfh->key) { + if (rss_ctx) { + memcpy(rss_ctx->vnic.rss_hash_key, rxfh->key, + HW_HASH_KEY_SIZE); + } else { + 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(bp->dev); + u16 *indir_tbl = bp->rss_indir_tbl; + + if (rss_ctx) + indir_tbl = rss_ctx->rss_indir_tbl; + for (i = 0; i < tbl_size; i++) + indir_tbl[i] = rxfh->indir[i]; + pad = bp->rss_indir_tbl_entries - tbl_size; + if (pad) + memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16)); + } +} + static int bnxt_set_rxfh(struct net_device *dev, struct ethtool_rxfh_param *rxfh, struct netlink_ext_ack *extack) @@ -1788,20 +1814,8 @@ static int bnxt_set_rxfh(struct net_device *dev, if (rxfh->hfunc && rxfh->hfunc != ETH_RSS_HASH_TOP) 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); + bnxt_modify_rss(bp, NULL, rxfh); - for (i = 0; i < tbl_size; i++) - bp->rss_indir_tbl[i] = rxfh->indir[i]; - pad = bp->rss_indir_tbl_entries - tbl_size; - if (pad) - memset(&bp->rss_indir_tbl[i], 0, pad * sizeof(u16)); - } bnxt_clear_usr_fltrs(bp, false); if (netif_running(bp->dev)) { bnxt_close_nic(bp, false, false);