@@ -630,32 +630,61 @@ bool ice_is_tunnel_supported(struct net_device *dev)
630
630
return ice_tc_tun_get_type (dev ) != TNL_LAST ;
631
631
}
632
632
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 )
636
641
{
637
642
struct ice_repr * repr ;
638
643
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
+
639
679
switch (act -> id ) {
640
680
case FLOW_ACTION_DROP :
641
681
fltr -> action .fltr_act = ICE_DROP_PACKET ;
642
682
break ;
643
683
644
684
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 ;
659
688
660
689
break ;
661
690
@@ -696,10 +725,6 @@ ice_eswitch_add_tc_fltr(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr)
696
725
goto exit ;
697
726
}
698
727
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
-
703
728
rule_info .sw_act .fltr_act = fltr -> action .fltr_act ;
704
729
if (fltr -> action .fltr_act != ICE_DROP_PACKET )
705
730
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)
713
738
rule_info .flags_info .act_valid = true;
714
739
715
740
if (fltr -> direction == ICE_ESWITCH_FLTR_INGRESS ) {
741
+ /* Uplink to VF */
716
742
rule_info .sw_act .flag |= ICE_FLTR_RX ;
717
743
rule_info .sw_act .src = hw -> pf_id ;
718
744
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 */
720
748
rule_info .sw_act .flag |= ICE_FLTR_TX ;
721
749
rule_info .sw_act .src = vsi -> idx ;
722
750
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 ;
723
756
}
724
757
725
758
/* 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,
1745
1778
1746
1779
/**
1747
1780
* ice_parse_tc_flower_actions - Parse the actions for a TC filter
1781
+ * @filter_dev: Pointer to device on which filter is being added
1748
1782
* @vsi: Pointer to VSI
1749
1783
* @cls_flower: Pointer to TC flower offload structure
1750
1784
* @fltr: Pointer to TC flower filter structure
1751
1785
*
1752
1786
* Parse the actions for a TC filter
1753
1787
*/
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 )
1758
1792
{
1759
1793
struct flow_rule * rule = flow_cls_offload_flow_rule (cls_flower );
1760
1794
struct flow_action * flow_action = & rule -> action ;
@@ -1769,7 +1803,7 @@ ice_parse_tc_flower_actions(struct ice_vsi *vsi,
1769
1803
1770
1804
flow_action_for_each (i , act , flow_action ) {
1771
1805
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 );
1773
1807
else
1774
1808
err = ice_tc_parse_action (vsi , fltr , act );
1775
1809
if (err )
@@ -1856,7 +1890,7 @@ ice_add_tc_fltr(struct net_device *netdev, struct ice_vsi *vsi,
1856
1890
if (err < 0 )
1857
1891
goto err ;
1858
1892
1859
- err = ice_parse_tc_flower_actions (vsi , f , fltr );
1893
+ err = ice_parse_tc_flower_actions (netdev , vsi , f , fltr );
1860
1894
if (err < 0 )
1861
1895
goto err ;
1862
1896
0 commit comments