From: Dave Ertman <david.m.ertman@intel.com>
To: intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org, Jacob Keller <jacob.e.keller@intel.com>
Subject: [PATCH net v2 01/10] ice: Correctly initialize queue context values
Date: Mon, 5 Jun 2023 11:22:49 -0700 [thread overview]
Message-ID: <20230605182258.557933-2-david.m.ertman@intel.com> (raw)
In-Reply-To: <20230605182258.557933-1-david.m.ertman@intel.com>
From: Jacob Keller <jacob.e.keller@intel.com>
The ice_alloc_lan_q_ctx function allocates the queue context array for a
given traffic class. This function uses devm_kcalloc which will
zero-allocate the structure. Thus, prior to any queue being setup by
ice_ena_vsi_txq, the q_ctx structure will have a q_handle of 0 and a q_teid
of 0. These are potentially valid values.
Modify the ice_alloc_lan_q_ctx function to initialize every member of the
q_ctx array to have invalid values. Modify ice_dis_vsi_txq to ensure that
it assigns q_teid to an invalid value when it assigns q_handle to the
invalid value as well.
This will allow other code to check whether the queue context is currently
valid before operating on it.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Dave Ertman <david.m.ertman@intel.com>
---
drivers/net/ethernet/intel/ice/ice_common.c | 1 +
drivers/net/ethernet/intel/ice/ice_sched.c | 23 ++++++++++++++++-----
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index a9f2e6bff806..23a9f169bc71 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -4708,6 +4708,7 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
break;
ice_free_sched_node(pi, node);
q_ctx->q_handle = ICE_INVAL_Q_HANDLE;
+ q_ctx->q_teid = ICE_INVAL_TEID;
}
mutex_unlock(&pi->sched_lock);
kfree(qg_list);
diff --git a/drivers/net/ethernet/intel/ice/ice_sched.c b/drivers/net/ethernet/intel/ice/ice_sched.c
index 824bac5ce003..0db9eb8fd402 100644
--- a/drivers/net/ethernet/intel/ice/ice_sched.c
+++ b/drivers/net/ethernet/intel/ice/ice_sched.c
@@ -572,18 +572,24 @@ ice_alloc_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 new_numqs)
{
struct ice_vsi_ctx *vsi_ctx;
struct ice_q_ctx *q_ctx;
+ u16 idx;
vsi_ctx = ice_get_vsi_ctx(hw, vsi_handle);
if (!vsi_ctx)
return -EINVAL;
/* allocate LAN queue contexts */
if (!vsi_ctx->lan_q_ctx[tc]) {
- vsi_ctx->lan_q_ctx[tc] = devm_kcalloc(ice_hw_to_dev(hw),
- new_numqs,
- sizeof(*q_ctx),
- GFP_KERNEL);
- if (!vsi_ctx->lan_q_ctx[tc])
+ q_ctx = devm_kcalloc(ice_hw_to_dev(hw), new_numqs,
+ sizeof(*q_ctx), GFP_KERNEL);
+ if (!q_ctx)
return -ENOMEM;
+
+ for (idx = 0; idx < new_numqs; idx++) {
+ q_ctx[idx].q_handle = ICE_INVAL_Q_HANDLE;
+ q_ctx[idx].q_teid = ICE_INVAL_TEID;
+ }
+
+ vsi_ctx->lan_q_ctx[tc] = q_ctx;
vsi_ctx->num_lan_q_entries[tc] = new_numqs;
return 0;
}
@@ -595,9 +601,16 @@ ice_alloc_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 new_numqs)
sizeof(*q_ctx), GFP_KERNEL);
if (!q_ctx)
return -ENOMEM;
+
memcpy(q_ctx, vsi_ctx->lan_q_ctx[tc],
prev_num * sizeof(*q_ctx));
devm_kfree(ice_hw_to_dev(hw), vsi_ctx->lan_q_ctx[tc]);
+
+ for (idx = prev_num; idx < new_numqs; idx++) {
+ q_ctx[idx].q_handle = ICE_INVAL_Q_HANDLE;
+ q_ctx[idx].q_teid = ICE_INVAL_TEID;
+ }
+
vsi_ctx->lan_q_ctx[tc] = q_ctx;
vsi_ctx->num_lan_q_entries[tc] = new_numqs;
}
--
2.40.1
next prev parent reply other threads:[~2023-06-05 18:21 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-05 18:22 [PATCH net v2 00/10] Implement support for SRIOV + LAG Dave Ertman
2023-06-05 18:22 ` Dave Ertman [this message]
2023-06-06 9:03 ` [PATCH net v2 01/10] ice: Correctly initialize queue context values Daniel Machon
2023-06-06 16:31 ` Ertman, David M
2023-06-05 18:22 ` [PATCH net v2 02/10] ice: Add driver support for firmware changes for LAG Dave Ertman
2023-06-06 9:16 ` Daniel Machon
2023-06-06 16:59 ` Ertman, David M
2023-06-05 18:22 ` [PATCH net v2 03/10] ice: changes to the interface with the HW and FW for SRIOV_VF+LAG Dave Ertman
2023-06-06 9:36 ` Daniel Machon
2023-06-06 18:11 ` Ertman, David M
2023-06-05 18:22 ` [PATCH net v2 04/10] ice: implement lag netdev event handler Dave Ertman
2023-06-06 9:56 ` Daniel Machon
2023-06-06 18:23 ` Ertman, David M
2023-06-07 7:22 ` Daniel Machon
2023-06-05 18:22 ` [PATCH net v2 05/10] ice: process events created by " Dave Ertman
2023-06-06 10:54 ` Daniel Machon
2023-06-06 18:26 ` Ertman, David M
2023-06-05 18:22 ` [PATCH net v2 06/10] ice: Flesh out implementation of support for SRIOV on bonded interface Dave Ertman
2023-06-07 8:42 ` Daniel Machon
2023-06-08 1:08 ` Ertman, David M
2023-06-05 18:22 ` [PATCH net v2 07/10] ice: support non-standard teardown of bond interface Dave Ertman
2023-06-07 8:48 ` Daniel Machon
2023-06-05 18:22 ` [PATCH net v2 08/10] ice: enforce interface eligibility and add messaging for SRIOV LAG Dave Ertman
2023-06-07 8:54 ` Daniel Machon
2023-06-05 18:22 ` [PATCH net v2 09/10] ice: enforce no DCB config changing when in bond Dave Ertman
2023-06-07 9:01 ` Daniel Machon
2023-06-05 18:22 ` [PATCH net v2 10/10] ice: update reset path for SRIOV LAG support Dave Ertman
2023-06-07 10:08 ` Daniel Machon
2023-06-08 17:24 ` Ertman, David M
2023-06-05 19:12 ` [PATCH net v2 00/10] Implement support for SRIOV + LAG Ertman, David M
2023-06-05 20:27 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230605182258.557933-2-david.m.ertman@intel.com \
--to=david.m.ertman@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jacob.e.keller@intel.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).