From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8C483A0547 for ; Thu, 27 May 2021 08:43:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7CC40410F0; Thu, 27 May 2021 08:43:29 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 8DFF740143; Thu, 27 May 2021 08:43:26 +0200 (CEST) IronPort-SDR: TGnCgyGIVQ3wPIJKtXDO6hz5SO6BJGu9oNtafWdAGaJKEK+aghCKqvbYjrvd9a25UIIw1H2Gcn Znqno/URPdhw== X-IronPort-AV: E=McAfee;i="6200,9189,9996"; a="263866994" X-IronPort-AV: E=Sophos;i="5.82,334,1613462400"; d="scan'208";a="263866994" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 23:43:25 -0700 IronPort-SDR: lzRE+tKUC3ACV5VBMr9C4UMSHveOyIs2jbqftCKzqxa6cfNJH7I82miUYYVcptGslG6y5MTha4 +KTUOYxOBrFA== X-IronPort-AV: E=Sophos;i="5.82,334,1613462400"; d="scan'208";a="477351353" Received: from unknown (HELO localhost.localdomain) ([10.240.183.93]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 23:43:22 -0700 From: dapengx.yu@intel.com To: Qiming Yang , Qi Zhang Cc: dev@dpdk.org, ferruh.yigit@intel.com, Dapeng Yu , stable@dpdk.org Date: Thu, 27 May 2021 14:42:51 +0800 Message-Id: <20210527064251.242076-1-dapengx.yu@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH] net/ice: fix default RSS key generation X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Dapeng Yu In original implementation, device reconfiguration will generate a new default RSS key if there is no one from user, it is unexpected when updating a completely unrelated configuration. This patch makes default RSS key unchanged, during the lifetime of the DPDK application even if there are multiple reconfigurations. Fixes: 50370662b727 ("net/ice: support device and queue ops") Cc: stable@dpdk.org Signed-off-by: Dapeng Yu --- drivers/net/ice/ice_ethdev.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 5fd5f99b6f..ad20f6baff 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -2990,6 +2990,31 @@ ice_rss_hash_set(struct ice_pf *pf, uint64_t rss_hf) pf->rss_hf = rss_hf & ICE_RSS_HF_ALL; } +static void +ice_get_default_rss_key(uint8_t *rss_key, uint32_t rss_key_size) +{ + static struct ice_aqc_get_set_rss_keys default_key; + static bool default_key_done; + uint8_t *key = (uint8_t *)&default_key; + size_t i; + + if (rss_key_size > sizeof(default_key)) { + PMD_DRV_LOG(WARNING, + "requested size %u is larger than default %zu, " + "only %zu bytes are gotten for key\n", + rss_key_size, sizeof(default_key), + sizeof(default_key)); + } + + if (!default_key_done) { + /* Calculate the default hash key */ + for (i = 0; i < sizeof(default_key); i++) + key[i] = (uint8_t)rte_rand(); + default_key_done = true; + } + rte_memcpy(rss_key, key, RTE_MIN(rss_key_size, sizeof(default_key))); +} + static int ice_init_rss(struct ice_pf *pf) { struct ice_hw *hw = ICE_PF_TO_HW(pf); @@ -3038,15 +3063,13 @@ static int ice_init_rss(struct ice_pf *pf) } } /* configure RSS key */ - if (!rss_conf->rss_key) { - /* Calculate the default hash key */ - for (i = 0; i < vsi->rss_key_size; i++) - vsi->rss_key[i] = (uint8_t)rte_rand(); - } else { + if (!rss_conf->rss_key) + ice_get_default_rss_key(vsi->rss_key, vsi->rss_key_size); + else rte_memcpy(vsi->rss_key, rss_conf->rss_key, RTE_MIN(rss_conf->rss_key_len, vsi->rss_key_size)); - } + rte_memcpy(key.standard_rss_key, vsi->rss_key, vsi->rss_key_size); ret = ice_aq_set_rss_key(hw, vsi->idx, &key); if (ret) -- 2.27.0