Re: [PATCH net v2] net: sparx5: flower: fix fragment flags handling

From: Daniel Machon
Date: Thu Apr 11 2024 - 03:04:59 EST


Hi Asbjørn,

I know I am nitpicking here, but could you please sneak in below
changes.

> static int
> sparx5_tc_flower_es0_tpid(struct vcap_tc_flower_parse_usage *st)
> {
> @@ -145,29 +166,27 @@ sparx5_tc_flower_handler_control_usage(struct vcap_tc_flower_parse_usage *st)
> flow_rule_match_control(st->frule, &mt);
>
> if (mt.mask->flags) {
> - if (mt.mask->flags & FLOW_DIS_FIRST_FRAG) {
> - if (mt.key->flags & FLOW_DIS_FIRST_FRAG) {
> - value = 1; /* initial fragment */
> - mask = 0x3;
> - } else {
> - if (mt.mask->flags & FLOW_DIS_IS_FRAGMENT) {
> - value = 3; /* follow up fragment */
> - mask = 0x3;
> - } else {
> - value = 0; /* no fragment */
> - mask = 0x3;
> - }
> - }
> - } else {
> - if (mt.mask->flags & FLOW_DIS_IS_FRAGMENT) {
> - value = 3; /* follow up fragment */
> - mask = 0x3;
> - } else {
> - value = 0; /* no fragment */
> - mask = 0x3;
> - }
> + u8 is_frag_key = !!(mt.key->flags & FLOW_DIS_IS_FRAGMENT);
> + u8 is_frag_mask = !!(mt.mask->flags & FLOW_DIS_IS_FRAGMENT);
> + u8 is_frag_idx = (is_frag_key << 1) | is_frag_mask;
> +
> + u8 first_frag_key = !!(mt.key->flags & FLOW_DIS_FIRST_FRAG);
> + u8 first_frag_mask = !!(mt.mask->flags & FLOW_DIS_FIRST_FRAG);
> + u8 first_frag_idx = (first_frag_key << 1) | first_frag_mask;
> +
> + /* lookup verdict based on the 2 + 2 input bits */
> + u8 vdt = sparx5_vcap_frag_map[is_frag_idx][first_frag_idx];
> +
> + if (vdt == FRAG_INVAL) {
> + NL_SET_ERR_MSG_MOD(st->fco->common.extack,
> + "match on invalid fragment flag combination");

Please start this NL msg with a capital letter. All (AFAICS) other
places in this file do this - nice to stay consistent. As a matter of
fact, also do this to the new comments introduced.

> + return -EINVAL;
> }
>
> + /* extract VCAP fragment key and mask from verdict */
> + value = (vdt >> 4) & 0x3;
> + mask = vdt & 0x3;
> +
> err = vcap_rule_add_key_u32(st->vrule,
> VCAP_KF_L3_FRAGMENT_TYPE,
> value, mask);
> --
> 2.43.0
>

Checkpatch is producing a warning about the placement of the version
information of the patch. Might as well fix this while at it.

Thanks,

/Daniel