Skip to content

Commit f9d23ea

Browse files
pkitszelgregkh
authored andcommitted
ice: fix ice_parser_rt::bst_key array size
[ Upstream commit 18625e2 ] Fix &ice_parser_rt::bst_key size. It was wrongly set to 10 instead of 20 in the initial impl commit (see Fixes tag). All usage code assumed it was of size 20. That was also the initial size present up to v2 of the intro series [2], but halved by v3 [3] refactor described as "Replace magic hardcoded values with macros." The introducing series was so big that some ugliness was unnoticed, same for bugs :/ ICE_BST_KEY_TCAM_SIZE and ICE_BST_TCAM_KEY_SIZE were differing by one. There was tmp variable @j in the scope of edited function, but was not used in all places. This ugliness is now gone. I'm moving ice_parser_rt::pg_prio a few positions up, to fill up one of the holes in order to compensate for the added 10 bytes to the ::bst_key, resulting in the same size of the whole as prior to the fix, and minimal changes in the offsets of the fields. Extend also the debug dump print of the key to cover all bytes. To not have string with 20 "%02x" and 20 params, switch to ice_debug_array_w_prefix(). This fix obsoletes Ahmed's attempt at [1]. [1] https://lore.kernel.org/intel-wired-lan/[email protected] [2] https://lore.kernel.org/intel-wired-lan/[email protected] [3] https://lore.kernel.org/intel-wired-lan/[email protected] Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/intel-wired-lan/[email protected] Fixes: 9a4c07a ("ice: add parser execution main loop") CC: Ahmed Zaki <[email protected]> Reviewed-by: Larysa Zaremba <[email protected]> Signed-off-by: Przemek Kitszel <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 868202e commit f9d23ea

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

drivers/net/ethernet/intel/ice/ice_parser.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ ice_pg_nm_cam_match(struct ice_pg_nm_cam_item *table, int size,
257257
/*** ICE_SID_RXPARSER_BOOST_TCAM and ICE_SID_LBL_RXPARSER_TMEM sections ***/
258258
#define ICE_BST_TCAM_TABLE_SIZE 256
259259
#define ICE_BST_TCAM_KEY_SIZE 20
260-
#define ICE_BST_KEY_TCAM_SIZE 19
261260

262261
/* Boost TCAM item */
263262
struct ice_bst_tcam_item {
@@ -401,7 +400,6 @@ u16 ice_xlt_kb_flag_get(struct ice_xlt_kb *kb, u64 pkt_flag);
401400
#define ICE_PARSER_GPR_NUM 128
402401
#define ICE_PARSER_FLG_NUM 64
403402
#define ICE_PARSER_ERR_NUM 16
404-
#define ICE_BST_KEY_SIZE 10
405403
#define ICE_MARKER_ID_SIZE 9
406404
#define ICE_MARKER_MAX_SIZE \
407405
(ICE_MARKER_ID_SIZE * BITS_PER_BYTE - 1)
@@ -431,13 +429,13 @@ struct ice_parser_rt {
431429
u8 pkt_buf[ICE_PARSER_MAX_PKT_LEN + ICE_PARSER_PKT_REV];
432430
u16 pkt_len;
433431
u16 po;
434-
u8 bst_key[ICE_BST_KEY_SIZE];
432+
u8 bst_key[ICE_BST_TCAM_KEY_SIZE];
435433
struct ice_pg_cam_key pg_key;
434+
u8 pg_prio;
436435
struct ice_alu *alu0;
437436
struct ice_alu *alu1;
438437
struct ice_alu *alu2;
439438
struct ice_pg_cam_action *action;
440-
u8 pg_prio;
441439
struct ice_gpr_pu pu;
442440
u8 markers[ICE_MARKER_ID_SIZE];
443441
bool protocols[ICE_PO_PAIR_SIZE];

drivers/net/ethernet/intel/ice/ice_parser_rt.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,20 @@ static void ice_bst_key_init(struct ice_parser_rt *rt,
125125
else
126126
key[idd] = imem->b_kb.prio;
127127

128-
idd = ICE_BST_KEY_TCAM_SIZE - 1;
128+
idd = ICE_BST_TCAM_KEY_SIZE - 2;
129129
for (i = idd; i >= 0; i--) {
130130
int j;
131131

132132
j = ho + idd - i;
133133
if (j < ICE_PARSER_MAX_PKT_LEN)
134-
key[i] = rt->pkt_buf[ho + idd - i];
134+
key[i] = rt->pkt_buf[j];
135135
else
136136
key[i] = 0;
137137
}
138138

139-
ice_debug(rt->psr->hw, ICE_DBG_PARSER, "Generated Boost TCAM Key:\n");
140-
ice_debug(rt->psr->hw, ICE_DBG_PARSER, "%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
141-
key[0], key[1], key[2], key[3], key[4],
142-
key[5], key[6], key[7], key[8], key[9]);
143-
ice_debug(rt->psr->hw, ICE_DBG_PARSER, "\n");
139+
ice_debug_array_w_prefix(rt->psr->hw, ICE_DBG_PARSER,
140+
KBUILD_MODNAME ": Generated Boost TCAM Key",
141+
key, ICE_BST_TCAM_KEY_SIZE);
144142
}
145143

146144
static u16 ice_bit_rev_u16(u16 v, int len)

0 commit comments

Comments
 (0)