When reading a rule back from hardware, decoding has to identify which actionset the rule was written as. The existing logic was only aware of the actionset subword length, which cannot distinguish actionsets that share a subword length but differ in their type_id field. The LPM VCAP added in a following patch introduces this case: ARP_PTR, L3MC_PTR and ARP_ENTRY all occupy one subword and differ only by type_id. A helper is introduced to extract the type_id bits directly from stream[0]. This is valid by construction: the VCAP model places the type_id field (when present) immediately after the typegroup bits in the first subword. Reviewed-by: Daniel Machon Reviewed-by: Steen Hegelund Signed-off-by: Jens Emil Schulz Østergaard --- drivers/net/ethernet/microchip/vcap/vcap_api.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c index 6946fd738458..30700648672f 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c @@ -216,6 +216,13 @@ static void vcap_decode_field(u32 *stream, struct vcap_stream_iter *itr, } } +/* The type_id field is always right after the typegroup bits, if it exists */ +static u8 vcap_find_stream_type_id(u32 *stream, u16 tg_width, + u16 typefld_width) +{ + return (stream[0] >> tg_width) & GENMASK(typefld_width - 1, 0); +} + /* Verify that the type id in the stream matches the type id of the keyset */ static bool vcap_verify_keystream_keyset(struct vcap_control *vctrl, enum vcap_type vt, @@ -1331,8 +1338,10 @@ vcap_verify_actionstream_actionset(struct vcap_control *vctrl, enum vcap_actionfield_set actionset) { const struct vcap_typegroup *tgt; + const struct vcap_field *typefld; const struct vcap_field *fields; const struct vcap_set *info; + u8 value = 0; if (vcap_actionfield_count(vctrl, vt, actionset) == 0) return false; @@ -1355,8 +1364,11 @@ vcap_verify_actionstream_actionset(struct vcap_control *vctrl, if (!fields) return false; - /* Later this will be expanded with a check of the type id */ - return true; + typefld = &fields[VCAP_AF_TYPE]; + value = vcap_find_stream_type_id(actionstream, + tgt->width, typefld->width); + + return value == info->type_id; } /* Find the subword width of the action typegroup that matches the stream data -- 2.52.0