Skip to content

Commit 5a7b0b6

Browse files
halfboy93anguy11
authored andcommitted
ice: refactor ice_fdir_create_dflt_rules() function
The Flow Director function ice_fdir_create_dflt_rules() calls few times function ice_create_init_fdir_rule() each time with different enum ice_fltr_ptype parameter. Next step is to return error code if error occurred. Change the code to store all necessary default rules in constant array and call ice_create_init_fdir_rule() in the loop. It makes it easy to extend the list of default rules in the future, without the need of duplicate code more and more. Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent f003075 commit 5a7b0b6

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,22 +1605,19 @@ void ice_fdir_replay_fltrs(struct ice_pf *pf)
16051605
*/
16061606
int ice_fdir_create_dflt_rules(struct ice_pf *pf)
16071607
{
1608+
const enum ice_fltr_ptype dflt_rules[] = {
1609+
ICE_FLTR_PTYPE_NONF_IPV4_TCP, ICE_FLTR_PTYPE_NONF_IPV4_UDP,
1610+
ICE_FLTR_PTYPE_NONF_IPV6_TCP, ICE_FLTR_PTYPE_NONF_IPV6_UDP,
1611+
};
16081612
int err;
16091613

16101614
/* Create perfect TCP and UDP rules in hardware. */
1611-
err = ice_create_init_fdir_rule(pf, ICE_FLTR_PTYPE_NONF_IPV4_TCP);
1612-
if (err)
1613-
return err;
1614-
1615-
err = ice_create_init_fdir_rule(pf, ICE_FLTR_PTYPE_NONF_IPV4_UDP);
1616-
if (err)
1617-
return err;
1615+
for (int i = 0; i < ARRAY_SIZE(dflt_rules); i++) {
1616+
err = ice_create_init_fdir_rule(pf, dflt_rules[i]);
16181617

1619-
err = ice_create_init_fdir_rule(pf, ICE_FLTR_PTYPE_NONF_IPV6_TCP);
1620-
if (err)
1621-
return err;
1622-
1623-
err = ice_create_init_fdir_rule(pf, ICE_FLTR_PTYPE_NONF_IPV6_UDP);
1618+
if (err)
1619+
break;
1620+
}
16241621

16251622
return err;
16261623
}

0 commit comments

Comments
 (0)