netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Ahmed Zaki <ahmed.zaki@intel.com>
Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	jacob.e.keller@intel.com, anthony.l.nguyen@intel.com,
	Junfeng Guo <junfeng.guo@intel.com>,
	Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
	Wojciech Drewek <wojciech.drewek@intel.com>,
	Marcin Szycik <marcin.szycik@linux.intel.com>
Subject: Re: [PATCH iwl-next v2 04/13] ice: add parser internal helper functions
Date: Fri, 31 May 2024 14:15:42 +0100	[thread overview]
Message-ID: <20240531131542.GF123401@kernel.org> (raw)
In-Reply-To: <20240527185810.3077299-5-ahmed.zaki@intel.com>

On Mon, May 27, 2024 at 12:58:01PM -0600, Ahmed Zaki wrote:
> From: Junfeng Guo <junfeng.guo@intel.com>
> 
> Add the following internal helper functions:
> 
> - ice_bst_tcam_match():
>   to perform ternary match on boost TCAM.
> 
> - ice_pg_cam_match():
>   to perform parse graph key match in cam table.
> 
> - ice_pg_nm_cam_match():
>   to perform parse graph key no match in cam table.
> 
> - ice_ptype_mk_tcam_match():
>   to perform ptype markers match in tcam table.
> 
> - ice_flg_redirect():
>   to redirect parser flags to packet flags.
> 
> - ice_xlt_kb_flag_get():
>   to aggregate 64 bit packet flag into 16 bit key builder flags.
> 
> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
> Reviewed-by: Marcin Szycik <marcin.szycik@linux.intel.com>
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> Signed-off-by: Junfeng Guo <junfeng.guo@intel.com>
> Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_parser.c | 196 ++++++++++++++++++++
>  drivers/net/ethernet/intel/ice/ice_parser.h |  52 ++++--
>  2 files changed, 233 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_parser.c b/drivers/net/ethernet/intel/ice/ice_parser.c
> index 19dd7472b5ba..91dbe70d7fe5 100644
> --- a/drivers/net/ethernet/intel/ice/ice_parser.c
> +++ b/drivers/net/ethernet/intel/ice/ice_parser.c
> @@ -957,6 +957,105 @@ static struct ice_pg_nm_cam_item *ice_pg_nm_sp_cam_table_get(struct ice_hw *hw)
>  					ice_pg_nm_sp_cam_parse_item, false);
>  }
>  
> +static bool __ice_pg_cam_match(struct ice_pg_cam_item *item,
> +			       struct ice_pg_cam_key *key)
> +{
> +	return (item->key.valid &&
> +		!memcmp(&item->key.val, &key->val, sizeof(key->val)));
> +}
> +
> +static bool __ice_pg_nm_cam_match(struct ice_pg_nm_cam_item *item,
> +				  struct ice_pg_cam_key *key)
> +{
> +	return (item->key.valid &&
> +		!memcmp(&item->key.val, &key->val, sizeof(key->val)));
> +}

Hi,

The size of &item->key.val is 9 bytes, while the size of key->val is 13 bytes.
So this will compare data beyond the end of &item->key.val.

I think this is caused by the presence of the next_proto field
in the val struct_group of struct ice_pg_cam_key.

I do also wonder if there could be some consolidation in
the definitions of struct ice_pg_cam_key and struct ice_pg_nm_cam_key.
The main difference seems to be the presence of next_proto at
the end of the latter.

Flagged by Smatch.

...

> +/**
> + * ice_xlt_kb_flag_get - aggregate 64 bits packet flag into 16 bits xlt flag
> + * @kb: xlt key build
> + * @pkt_flag: 64 bits packet flag
> + */
> +u16 ice_xlt_kb_flag_get(struct ice_xlt_kb *kb, u64 pkt_flag)
> +{
> +	struct ice_xlt_kb_entry *entry = &kb->entries[0];
> +	u16 flag = 0;
> +	int i;
> +
> +	/* check flag 15 */
> +	if (kb->flag15 & pkt_flag)
> +		flag = (u16)BIT(ICE_XLT_KB_FLAG0_14_CNT);

nit: It's not clear to me that this cast is necessary.
     Likewise twice more in this function, and elsewhere in this patchset.

> +
> +	/* check flag 0 - 14 */
> +	for (i = 0; i < ICE_XLT_KB_FLAG0_14_CNT; i++) {
> +		/* only check first entry */
> +		u16 idx = (u16)(entry->flg0_14_sel[i] & ICE_XLT_KB_MASK);
> +
> +		if (pkt_flag & BIT(idx))
> +			flag |= (u16)BIT(i);
> +	}
> +
> +	return flag;
> +}

...

  reply	other threads:[~2024-05-31 13:15 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27 18:57 [PATCH iwl-next v2 00/13] ice: iavf: add support for TC U32 filters on VFs Ahmed Zaki
2024-05-27 18:57 ` [PATCH iwl-next v2 01/13] ice: add parser create and destroy skeleton Ahmed Zaki
2024-05-31 13:11   ` Simon Horman
2024-07-23  7:53     ` [Intel-wired-lan] " Romanowski, Rafal
2024-05-27 18:57 ` [PATCH iwl-next v2 02/13] ice: parse and init various DDP parser sections Ahmed Zaki
2024-05-31 13:14   ` Simon Horman
2024-07-23  7:54     ` [Intel-wired-lan] " Romanowski, Rafal
2024-05-27 18:58 ` [PATCH iwl-next v2 03/13] ice: add debugging functions for the " Ahmed Zaki
2024-07-23  7:55   ` [Intel-wired-lan] " Romanowski, Rafal
2024-05-27 18:58 ` [PATCH iwl-next v2 04/13] ice: add parser internal helper functions Ahmed Zaki
2024-05-31 13:15   ` Simon Horman [this message]
2024-07-23  8:07     ` [Intel-wired-lan] " Romanowski, Rafal
2024-05-27 18:58 ` [PATCH iwl-next v2 05/13] ice: add parser execution main loop Ahmed Zaki
2024-07-23  7:58   ` [Intel-wired-lan] " Romanowski, Rafal
2024-05-27 18:58 ` [PATCH iwl-next v2 06/13] ice: support turning on/off the parser's double vlan mode Ahmed Zaki
2024-07-23  7:59   ` [Intel-wired-lan] " Romanowski, Rafal
2024-05-27 18:58 ` [PATCH iwl-next v2 07/13] ice: add UDP tunnels support to the parser Ahmed Zaki
2024-07-23  8:01   ` [Intel-wired-lan] " Romanowski, Rafal
2024-05-27 18:58 ` [PATCH iwl-next v2 08/13] ice: add API for parser profile initialization Ahmed Zaki
2024-07-23  8:02   ` [Intel-wired-lan] " Romanowski, Rafal
2024-05-27 18:58 ` [PATCH iwl-next v2 09/13] virtchnl: support raw packet in protocol header Ahmed Zaki
2024-07-23  8:03   ` [Intel-wired-lan] " Romanowski, Rafal
2024-05-27 18:58 ` [PATCH iwl-next v2 10/13] ice: add method to disable FDIR SWAP option Ahmed Zaki
2024-07-23  8:04   ` [Intel-wired-lan] " Romanowski, Rafal
2024-05-27 18:58 ` [PATCH iwl-next v2 11/13] ice: enable FDIR filters from raw binary patterns for VFs Ahmed Zaki
2024-05-31 13:18   ` Simon Horman
2024-05-31 15:47     ` Ahmed Zaki
2024-05-31 18:11       ` Simon Horman
2024-07-23  8:05         ` [Intel-wired-lan] " Romanowski, Rafal
2024-06-01  0:24       ` Keller, Jacob E
2024-06-01 12:06         ` Simon Horman
2024-05-27 18:58 ` [PATCH iwl-next v2 12/13] iavf: refactor add/del FDIR filters Ahmed Zaki
2024-07-23  8:05   ` [Intel-wired-lan] " Romanowski, Rafal
2024-05-27 18:58 ` [PATCH iwl-next v2 13/13] iavf: add support for offloading tc U32 cls filters Ahmed Zaki
2024-07-23  8:06   ` [Intel-wired-lan] " Romanowski, Rafal
2024-07-23  8:00 ` [Intel-wired-lan] [PATCH iwl-next v2 00/13] ice: iavf: add support for TC U32 filters on VFs Romanowski, Rafal

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=20240531131542.GF123401@kernel.org \
    --to=horms@kernel.org \
    --cc=ahmed.zaki@intel.com \
    --cc=aleksandr.loktionov@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jacob.e.keller@intel.com \
    --cc=junfeng.guo@intel.com \
    --cc=marcin.szycik@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=wojciech.drewek@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).