mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-13 21:09:25 -04:00
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>
This commit is contained in:
committed by
Tony Nguyen
parent
f003075227
commit
5a7b0b6ff4
@@ -1605,22 +1605,19 @@ void ice_fdir_replay_fltrs(struct ice_pf *pf)
|
||||
*/
|
||||
int ice_fdir_create_dflt_rules(struct ice_pf *pf)
|
||||
{
|
||||
const enum ice_fltr_ptype dflt_rules[] = {
|
||||
ICE_FLTR_PTYPE_NONF_IPV4_TCP, ICE_FLTR_PTYPE_NONF_IPV4_UDP,
|
||||
ICE_FLTR_PTYPE_NONF_IPV6_TCP, ICE_FLTR_PTYPE_NONF_IPV6_UDP,
|
||||
};
|
||||
int err;
|
||||
|
||||
/* Create perfect TCP and UDP rules in hardware. */
|
||||
err = ice_create_init_fdir_rule(pf, ICE_FLTR_PTYPE_NONF_IPV4_TCP);
|
||||
if (err)
|
||||
return err;
|
||||
for (int i = 0; i < ARRAY_SIZE(dflt_rules); i++) {
|
||||
err = ice_create_init_fdir_rule(pf, dflt_rules[i]);
|
||||
|
||||
err = ice_create_init_fdir_rule(pf, ICE_FLTR_PTYPE_NONF_IPV4_UDP);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = ice_create_init_fdir_rule(pf, ICE_FLTR_PTYPE_NONF_IPV6_TCP);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = ice_create_init_fdir_rule(pf, ICE_FLTR_PTYPE_NONF_IPV6_UDP);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user