@@ -630,32 +630,61 @@ bool ice_is_tunnel_supported(struct net_device *dev)
630630 return ice_tc_tun_get_type (dev ) != TNL_LAST ;
631631}
632632
633- static int
634- ice_eswitch_tc_parse_action (struct ice_tc_flower_fltr * fltr ,
635- struct flow_action_entry * act )
633+ static bool ice_tc_is_dev_uplink (struct net_device * dev )
634+ {
635+ return netif_is_ice (dev ) || ice_is_tunnel_supported (dev );
636+ }
637+
638+ static int ice_tc_setup_redirect_action (struct net_device * filter_dev ,
639+ struct ice_tc_flower_fltr * fltr ,
640+ struct net_device * target_dev )
636641{
637642 struct ice_repr * repr ;
638643
644+ fltr -> action .fltr_act = ICE_FWD_TO_VSI ;
645+
646+ if (ice_is_port_repr_netdev (filter_dev ) &&
647+ ice_is_port_repr_netdev (target_dev )) {
648+ repr = ice_netdev_to_repr (target_dev );
649+
650+ fltr -> dest_vsi = repr -> src_vsi ;
651+ fltr -> direction = ICE_ESWITCH_FLTR_EGRESS ;
652+ } else if (ice_is_port_repr_netdev (filter_dev ) &&
653+ ice_tc_is_dev_uplink (target_dev )) {
654+ repr = ice_netdev_to_repr (filter_dev );
655+
656+ fltr -> dest_vsi = repr -> src_vsi -> back -> switchdev .uplink_vsi ;
657+ fltr -> direction = ICE_ESWITCH_FLTR_EGRESS ;
658+ } else if (ice_tc_is_dev_uplink (filter_dev ) &&
659+ ice_is_port_repr_netdev (target_dev )) {
660+ repr = ice_netdev_to_repr (target_dev );
661+
662+ fltr -> dest_vsi = repr -> src_vsi ;
663+ fltr -> direction = ICE_ESWITCH_FLTR_INGRESS ;
664+ } else {
665+ NL_SET_ERR_MSG_MOD (fltr -> extack ,
666+ "Unsupported netdevice in switchdev mode" );
667+ return - EINVAL ;
668+ }
669+
670+ return 0 ;
671+ }
672+
673+ static int ice_eswitch_tc_parse_action (struct net_device * filter_dev ,
674+ struct ice_tc_flower_fltr * fltr ,
675+ struct flow_action_entry * act )
676+ {
677+ int err ;
678+
639679 switch (act -> id ) {
640680 case FLOW_ACTION_DROP :
641681 fltr -> action .fltr_act = ICE_DROP_PACKET ;
642682 break ;
643683
644684 case FLOW_ACTION_REDIRECT :
645- fltr -> action .fltr_act = ICE_FWD_TO_VSI ;
646-
647- if (ice_is_port_repr_netdev (act -> dev )) {
648- repr = ice_netdev_to_repr (act -> dev );
649-
650- fltr -> dest_vsi = repr -> src_vsi ;
651- fltr -> direction = ICE_ESWITCH_FLTR_INGRESS ;
652- } else if (netif_is_ice (act -> dev ) ||
653- ice_is_tunnel_supported (act -> dev )) {
654- fltr -> direction = ICE_ESWITCH_FLTR_EGRESS ;
655- } else {
656- NL_SET_ERR_MSG_MOD (fltr -> extack , "Unsupported netdevice in switchdev mode" );
657- return - EINVAL ;
658- }
685+ err = ice_tc_setup_redirect_action (filter_dev , fltr , act -> dev );
686+ if (err )
687+ return err ;
659688
660689 break ;
661690
@@ -696,10 +725,6 @@ ice_eswitch_add_tc_fltr(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr)
696725 goto exit ;
697726 }
698727
699- /* egress traffic is always redirect to uplink */
700- if (fltr -> direction == ICE_ESWITCH_FLTR_EGRESS )
701- fltr -> dest_vsi = vsi -> back -> switchdev .uplink_vsi ;
702-
703728 rule_info .sw_act .fltr_act = fltr -> action .fltr_act ;
704729 if (fltr -> action .fltr_act != ICE_DROP_PACKET )
705730 rule_info .sw_act .vsi_handle = fltr -> dest_vsi -> idx ;
@@ -713,13 +738,21 @@ ice_eswitch_add_tc_fltr(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr)
713738 rule_info .flags_info .act_valid = true;
714739
715740 if (fltr -> direction == ICE_ESWITCH_FLTR_INGRESS ) {
741+ /* Uplink to VF */
716742 rule_info .sw_act .flag |= ICE_FLTR_RX ;
717743 rule_info .sw_act .src = hw -> pf_id ;
718744 rule_info .flags_info .act = ICE_SINGLE_ACT_LB_ENABLE ;
719- } else {
745+ } else if (fltr -> direction == ICE_ESWITCH_FLTR_EGRESS &&
746+ fltr -> dest_vsi == vsi -> back -> switchdev .uplink_vsi ) {
747+ /* VF to Uplink */
720748 rule_info .sw_act .flag |= ICE_FLTR_TX ;
721749 rule_info .sw_act .src = vsi -> idx ;
722750 rule_info .flags_info .act = ICE_SINGLE_ACT_LAN_ENABLE ;
751+ } else {
752+ /* VF to VF */
753+ rule_info .sw_act .flag |= ICE_FLTR_TX ;
754+ rule_info .sw_act .src = vsi -> idx ;
755+ rule_info .flags_info .act = ICE_SINGLE_ACT_LB_ENABLE ;
723756 }
724757
725758 /* specify the cookie as filter_rule_id */
@@ -1745,16 +1778,17 @@ ice_tc_parse_action(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr,
17451778
17461779/**
17471780 * ice_parse_tc_flower_actions - Parse the actions for a TC filter
1781+ * @filter_dev: Pointer to device on which filter is being added
17481782 * @vsi: Pointer to VSI
17491783 * @cls_flower: Pointer to TC flower offload structure
17501784 * @fltr: Pointer to TC flower filter structure
17511785 *
17521786 * Parse the actions for a TC filter
17531787 */
1754- static int
1755- ice_parse_tc_flower_actions ( struct ice_vsi * vsi ,
1756- struct flow_cls_offload * cls_flower ,
1757- struct ice_tc_flower_fltr * fltr )
1788+ static int ice_parse_tc_flower_actions ( struct net_device * filter_dev ,
1789+ struct ice_vsi * vsi ,
1790+ struct flow_cls_offload * cls_flower ,
1791+ struct ice_tc_flower_fltr * fltr )
17581792{
17591793 struct flow_rule * rule = flow_cls_offload_flow_rule (cls_flower );
17601794 struct flow_action * flow_action = & rule -> action ;
@@ -1769,7 +1803,7 @@ ice_parse_tc_flower_actions(struct ice_vsi *vsi,
17691803
17701804 flow_action_for_each (i , act , flow_action ) {
17711805 if (ice_is_eswitch_mode_switchdev (vsi -> back ))
1772- err = ice_eswitch_tc_parse_action (fltr , act );
1806+ err = ice_eswitch_tc_parse_action (filter_dev , fltr , act );
17731807 else
17741808 err = ice_tc_parse_action (vsi , fltr , act );
17751809 if (err )
@@ -1856,7 +1890,7 @@ ice_add_tc_fltr(struct net_device *netdev, struct ice_vsi *vsi,
18561890 if (err < 0 )
18571891 goto err ;
18581892
1859- err = ice_parse_tc_flower_actions (vsi , f , fltr );
1893+ err = ice_parse_tc_flower_actions (netdev , vsi , f , fltr );
18601894 if (err < 0 )
18611895 goto err ;
18621896
0 commit comments