mirror of
https://github.com/raspberrypi/linux.git
synced 2026-01-02 15:53:42 +00:00
ice: Deduplicate tc action setup
ice_tc_setup_redirect_action() and ice_tc_setup_mirror_action() are almost identical, except for setting filter action. Reduce them to one function with an extra param, which handles both cases. Reviewed-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com> Signed-off-by: Marcin Szycik <marcin.szycik@linux.intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Tested-by: Sujai Buvaneswaran <sujai.buvaneswaran@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
This commit is contained in:
committed by
Tony Nguyen
parent
a8e682f037
commit
c5e6bd977d
@@ -669,13 +669,19 @@ static bool ice_tc_is_dev_uplink(struct net_device *dev)
|
||||
return netif_is_ice(dev) || ice_is_tunnel_supported(dev);
|
||||
}
|
||||
|
||||
static int ice_tc_setup_redirect_action(struct net_device *filter_dev,
|
||||
struct ice_tc_flower_fltr *fltr,
|
||||
struct net_device *target_dev)
|
||||
static int ice_tc_setup_action(struct net_device *filter_dev,
|
||||
struct ice_tc_flower_fltr *fltr,
|
||||
struct net_device *target_dev,
|
||||
enum ice_sw_fwd_act_type action)
|
||||
{
|
||||
struct ice_repr *repr;
|
||||
|
||||
fltr->action.fltr_act = ICE_FWD_TO_VSI;
|
||||
if (action != ICE_FWD_TO_VSI && action != ICE_MIRROR_PACKET) {
|
||||
NL_SET_ERR_MSG_MOD(fltr->extack, "Unsupported action to setup provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
fltr->action.fltr_act = action;
|
||||
|
||||
if (ice_is_port_repr_netdev(filter_dev) &&
|
||||
ice_is_port_repr_netdev(target_dev)) {
|
||||
@@ -723,41 +729,6 @@ ice_tc_setup_drop_action(struct net_device *filter_dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ice_tc_setup_mirror_action(struct net_device *filter_dev,
|
||||
struct ice_tc_flower_fltr *fltr,
|
||||
struct net_device *target_dev)
|
||||
{
|
||||
struct ice_repr *repr;
|
||||
|
||||
fltr->action.fltr_act = ICE_MIRROR_PACKET;
|
||||
|
||||
if (ice_is_port_repr_netdev(filter_dev) &&
|
||||
ice_is_port_repr_netdev(target_dev)) {
|
||||
repr = ice_netdev_to_repr(target_dev);
|
||||
|
||||
fltr->dest_vsi = repr->src_vsi;
|
||||
fltr->direction = ICE_ESWITCH_FLTR_EGRESS;
|
||||
} else if (ice_is_port_repr_netdev(filter_dev) &&
|
||||
ice_tc_is_dev_uplink(target_dev)) {
|
||||
repr = ice_netdev_to_repr(filter_dev);
|
||||
|
||||
fltr->dest_vsi = repr->src_vsi->back->eswitch.uplink_vsi;
|
||||
fltr->direction = ICE_ESWITCH_FLTR_EGRESS;
|
||||
} else if (ice_tc_is_dev_uplink(filter_dev) &&
|
||||
ice_is_port_repr_netdev(target_dev)) {
|
||||
repr = ice_netdev_to_repr(target_dev);
|
||||
|
||||
fltr->dest_vsi = repr->src_vsi;
|
||||
fltr->direction = ICE_ESWITCH_FLTR_INGRESS;
|
||||
} else {
|
||||
NL_SET_ERR_MSG_MOD(fltr->extack,
|
||||
"Unsupported netdevice in switchdev mode");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ice_eswitch_tc_parse_action(struct net_device *filter_dev,
|
||||
struct ice_tc_flower_fltr *fltr,
|
||||
struct flow_action_entry *act)
|
||||
@@ -773,16 +744,19 @@ static int ice_eswitch_tc_parse_action(struct net_device *filter_dev,
|
||||
break;
|
||||
|
||||
case FLOW_ACTION_REDIRECT:
|
||||
err = ice_tc_setup_redirect_action(filter_dev, fltr, act->dev);
|
||||
err = ice_tc_setup_action(filter_dev, fltr,
|
||||
act->dev, ICE_FWD_TO_VSI);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
break;
|
||||
|
||||
case FLOW_ACTION_MIRRED:
|
||||
err = ice_tc_setup_mirror_action(filter_dev, fltr, act->dev);
|
||||
err = ice_tc_setup_action(filter_dev, fltr,
|
||||
act->dev, ICE_MIRROR_PACKET);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user