From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Marcin Szycik <marcin.szycik@linux.intel.com>
Cc: <intel-wired-lan@lists.osuosl.org>, <netdev@vger.kernel.org>,
<przemyslaw.kitszel@intel.com>,
<michal.swiatkowski@linux.intel.com>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next 3/6] ice: Simplify bitmap setting in adding recipe
Date: Wed, 19 Jun 2024 16:34:15 +0200 [thread overview]
Message-ID: <f98cf542-ca67-43e4-8a26-a809294cd1d8@intel.com> (raw)
In-Reply-To: <20240618141157.1881093-4-marcin.szycik@linux.intel.com>
From: Marcin Szycik <marcin.szycik@linux.intel.com>
Date: Tue, 18 Jun 2024 16:11:54 +0200
> From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
>
> Remove unnecessary size checks when copying bitmaps in ice_add_sw_recipe()
> and replace them with compile time assert. Check if the bitmaps are equal
> size, as they are copied both ways.
>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> Co-developed-by: Marcin Szycik <marcin.szycik@linux.intel.com>
> Signed-off-by: Marcin Szycik <marcin.szycik@linux.intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_switch.c | 24 ++++++++-------------
> 1 file changed, 9 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
> index da065512889d..2f67fbb73fd1 100644
> --- a/drivers/net/ethernet/intel/ice/ice_switch.c
> +++ b/drivers/net/ethernet/intel/ice/ice_switch.c
> @@ -5067,6 +5067,10 @@ ice_find_free_recp_res_idx(struct ice_hw *hw, const unsigned long *profiles,
> return (u16)bitmap_weight(free_idx, ICE_MAX_FV_WORDS);
> }
>
> +/* For memcpy in ice_add_sw_recipe. */
> +static_assert(sizeof(((struct ice_aqc_recipe_data_elem *)0)->recipe_bitmap) ==
> + sizeof(((struct ice_sw_recipe *)0)->r_bitmap));
sizeof_field(struct ice_aqc_recipe_data_elem, recipe_bitmap) etc.
> +
> /**
> * ice_add_sw_recipe - function to call AQ calls to create switch recipe
> * @hw: pointer to hardware structure
> @@ -5187,13 +5191,9 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
> rm->root_rid = buf[0].recipe_indx;
> set_bit(buf[0].recipe_indx, rm->r_bitmap);
> buf[0].content.rid = rm->root_rid | ICE_AQ_RECIPE_ID_IS_ROOT;
> - if (sizeof(buf[0].recipe_bitmap) >= sizeof(rm->r_bitmap)) {
> - memcpy(buf[0].recipe_bitmap, rm->r_bitmap,
> - sizeof(buf[0].recipe_bitmap));
> - } else {
> - status = -EINVAL;
> - goto err_unroll;
> - }
> + memcpy(buf[0].recipe_bitmap, rm->r_bitmap,
> + sizeof(buf[0].recipe_bitmap));
> +
> /* Applicable only for ROOT_RECIPE, set the fwd_priority for
> * the recipe which is getting created if specified
> * by user. Usually any advanced switch filter, which results
> @@ -5256,14 +5256,8 @@ ice_add_sw_recipe(struct ice_hw *hw, struct ice_sw_recipe *rm,
> set_bit(entry->rid, rm->r_bitmap);
> }
> list_add(&last_chain_entry->l_entry, &rm->rg_list);
> - if (sizeof(buf[recps].recipe_bitmap) >=
> - sizeof(rm->r_bitmap)) {
> - memcpy(buf[recps].recipe_bitmap, rm->r_bitmap,
> - sizeof(buf[recps].recipe_bitmap));
> - } else {
> - status = -EINVAL;
> - goto err_unroll;
> - }
> + memcpy(buf[recps].recipe_bitmap, rm->r_bitmap,
> + sizeof(buf[recps].recipe_bitmap));
> content->act_ctrl_fwd_priority = rm->priority;
>
> recps++;
Thanks,
Olek
next prev parent reply other threads:[~2024-06-19 14:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-18 14:11 [PATCH iwl-next 0/6] Switch API optimizations Marcin Szycik
2024-06-18 14:11 ` [PATCH iwl-next 1/6] ice: Remove unused struct ice_prot_lkup_ext members Marcin Szycik
2024-06-28 12:40 ` Simon Horman
2024-06-18 14:11 ` [PATCH iwl-next 2/6] ice: Remove reading all recipes before adding a new one Marcin Szycik
2024-06-28 12:41 ` Simon Horman
2024-06-18 14:11 ` [PATCH iwl-next 3/6] ice: Simplify bitmap setting in adding recipe Marcin Szycik
2024-06-19 14:34 ` Alexander Lobakin [this message]
2024-06-18 14:11 ` [PATCH iwl-next 4/6] ice: remove unused recipe bookkeeping data Marcin Szycik
2024-06-28 12:41 ` Simon Horman
2024-06-18 14:11 ` [PATCH iwl-next 5/6] ice: Optimize switch recipe creation Marcin Szycik
2024-06-28 12:44 ` Simon Horman
2024-06-28 13:39 ` [Intel-wired-lan] " Marcin Szycik
2024-06-28 18:22 ` Simon Horman
2024-06-28 13:56 ` Przemek Kitszel
2024-06-28 18:25 ` Simon Horman
2024-06-18 14:11 ` [PATCH iwl-next 6/6] ice: Remove unused members from switch API Marcin Szycik
2024-06-28 12:44 ` Simon Horman
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=f98cf542-ca67-43e4-8a26-a809294cd1d8@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=marcin.szycik@linux.intel.com \
--cc=michal.swiatkowski@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=przemyslaw.kitszel@intel.com \
/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).