@@ -630,32 +630,83 @@ 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
674
+ ice_tc_setup_drop_action (struct net_device * filter_dev ,
675
+ struct ice_tc_flower_fltr * fltr )
676
+ {
677
+ fltr -> action .fltr_act = ICE_DROP_PACKET ;
678
+
679
+ if (ice_is_port_repr_netdev (filter_dev )) {
680
+ fltr -> direction = ICE_ESWITCH_FLTR_EGRESS ;
681
+ } else if (ice_tc_is_dev_uplink (filter_dev )) {
682
+ fltr -> direction = ICE_ESWITCH_FLTR_INGRESS ;
683
+ } else {
684
+ NL_SET_ERR_MSG_MOD (fltr -> extack ,
685
+ "Unsupported netdevice in switchdev mode" );
686
+ return - EINVAL ;
687
+ }
688
+
689
+ return 0 ;
690
+ }
691
+
692
+ static int ice_eswitch_tc_parse_action (struct net_device * filter_dev ,
693
+ struct ice_tc_flower_fltr * fltr ,
694
+ struct flow_action_entry * act )
695
+ {
696
+ int err ;
697
+
639
698
switch (act -> id ) {
640
699
case FLOW_ACTION_DROP :
641
- fltr -> action .fltr_act = ICE_DROP_PACKET ;
700
+ err = ice_tc_setup_drop_action (filter_dev , fltr );
701
+ if (err )
702
+ return err ;
703
+
642
704
break ;
643
705
644
706
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
- }
707
+ err = ice_tc_setup_redirect_action (filter_dev , fltr , act -> dev );
708
+ if (err )
709
+ return err ;
659
710
660
711
break ;
661
712
@@ -696,10 +747,6 @@ ice_eswitch_add_tc_fltr(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr)
696
747
goto exit ;
697
748
}
698
749
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
750
rule_info .sw_act .fltr_act = fltr -> action .fltr_act ;
704
751
if (fltr -> action .fltr_act != ICE_DROP_PACKET )
705
752
rule_info .sw_act .vsi_handle = fltr -> dest_vsi -> idx ;
@@ -713,13 +760,21 @@ ice_eswitch_add_tc_fltr(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr)
713
760
rule_info .flags_info .act_valid = true;
714
761
715
762
if (fltr -> direction == ICE_ESWITCH_FLTR_INGRESS ) {
763
+ /* Uplink to VF */
716
764
rule_info .sw_act .flag |= ICE_FLTR_RX ;
717
765
rule_info .sw_act .src = hw -> pf_id ;
718
766
rule_info .flags_info .act = ICE_SINGLE_ACT_LB_ENABLE ;
719
- } else {
767
+ } else if (fltr -> direction == ICE_ESWITCH_FLTR_EGRESS &&
768
+ fltr -> dest_vsi == vsi -> back -> switchdev .uplink_vsi ) {
769
+ /* VF to Uplink */
720
770
rule_info .sw_act .flag |= ICE_FLTR_TX ;
721
771
rule_info .sw_act .src = vsi -> idx ;
722
772
rule_info .flags_info .act = ICE_SINGLE_ACT_LAN_ENABLE ;
773
+ } else {
774
+ /* VF to VF */
775
+ rule_info .sw_act .flag |= ICE_FLTR_TX ;
776
+ rule_info .sw_act .src = vsi -> idx ;
777
+ rule_info .flags_info .act = ICE_SINGLE_ACT_LB_ENABLE ;
723
778
}
724
779
725
780
/* specify the cookie as filter_rule_id */
@@ -1745,16 +1800,17 @@ ice_tc_parse_action(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr,
1745
1800
1746
1801
/**
1747
1802
* ice_parse_tc_flower_actions - Parse the actions for a TC filter
1803
+ * @filter_dev: Pointer to device on which filter is being added
1748
1804
* @vsi: Pointer to VSI
1749
1805
* @cls_flower: Pointer to TC flower offload structure
1750
1806
* @fltr: Pointer to TC flower filter structure
1751
1807
*
1752
1808
* Parse the actions for a TC filter
1753
1809
*/
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 )
1810
+ static int ice_parse_tc_flower_actions ( struct net_device * filter_dev ,
1811
+ struct ice_vsi * vsi ,
1812
+ struct flow_cls_offload * cls_flower ,
1813
+ struct ice_tc_flower_fltr * fltr )
1758
1814
{
1759
1815
struct flow_rule * rule = flow_cls_offload_flow_rule (cls_flower );
1760
1816
struct flow_action * flow_action = & rule -> action ;
@@ -1769,7 +1825,7 @@ ice_parse_tc_flower_actions(struct ice_vsi *vsi,
1769
1825
1770
1826
flow_action_for_each (i , act , flow_action ) {
1771
1827
if (ice_is_eswitch_mode_switchdev (vsi -> back ))
1772
- err = ice_eswitch_tc_parse_action (fltr , act );
1828
+ err = ice_eswitch_tc_parse_action (filter_dev , fltr , act );
1773
1829
else
1774
1830
err = ice_tc_parse_action (vsi , fltr , act );
1775
1831
if (err )
@@ -1856,7 +1912,7 @@ ice_add_tc_fltr(struct net_device *netdev, struct ice_vsi *vsi,
1856
1912
if (err < 0 )
1857
1913
goto err ;
1858
1914
1859
- err = ice_parse_tc_flower_actions (vsi , f , fltr );
1915
+ err = ice_parse_tc_flower_actions (netdev , vsi , f , fltr );
1860
1916
if (err < 0 )
1861
1917
goto err ;
1862
1918
0 commit comments