@@ -66,18 +66,36 @@ static const struct counter_desc sw_rep_stats_desc[] = {
6666 { MLX5E_DECLARE_STAT (struct mlx5e_sw_stats , tx_bytes ) },
6767};
6868
69- #define NUM_VPORT_REP_COUNTERS ARRAY_SIZE(sw_rep_stats_desc)
69+ struct vport_stats {
70+ u64 vport_rx_packets ;
71+ u64 vport_tx_packets ;
72+ u64 vport_rx_bytes ;
73+ u64 vport_tx_bytes ;
74+ };
75+
76+ static const struct counter_desc vport_rep_stats_desc [] = {
77+ { MLX5E_DECLARE_STAT (struct vport_stats , vport_rx_packets ) },
78+ { MLX5E_DECLARE_STAT (struct vport_stats , vport_rx_bytes ) },
79+ { MLX5E_DECLARE_STAT (struct vport_stats , vport_tx_packets ) },
80+ { MLX5E_DECLARE_STAT (struct vport_stats , vport_tx_bytes ) },
81+ };
82+
83+ #define NUM_VPORT_REP_SW_COUNTERS ARRAY_SIZE(sw_rep_stats_desc)
84+ #define NUM_VPORT_REP_HW_COUNTERS ARRAY_SIZE(vport_rep_stats_desc)
7085
7186static void mlx5e_rep_get_strings (struct net_device * dev ,
7287 u32 stringset , uint8_t * data )
7388{
74- int i ;
89+ int i , j ;
7590
7691 switch (stringset ) {
7792 case ETH_SS_STATS :
78- for (i = 0 ; i < NUM_VPORT_REP_COUNTERS ; i ++ )
93+ for (i = 0 ; i < NUM_VPORT_REP_SW_COUNTERS ; i ++ )
7994 strcpy (data + (i * ETH_GSTRING_LEN ),
8095 sw_rep_stats_desc [i ].format );
96+ for (j = 0 ; j < NUM_VPORT_REP_HW_COUNTERS ; j ++ , i ++ )
97+ strcpy (data + (i * ETH_GSTRING_LEN ),
98+ vport_rep_stats_desc [j ].format );
8199 break ;
82100 }
83101}
@@ -140,26 +158,31 @@ static void mlx5e_rep_get_ethtool_stats(struct net_device *dev,
140158 struct ethtool_stats * stats , u64 * data )
141159{
142160 struct mlx5e_priv * priv = netdev_priv (dev );
143- int i ;
161+ int i , j ;
144162
145163 if (!data )
146164 return ;
147165
148166 mutex_lock (& priv -> state_lock );
149167 if (test_bit (MLX5E_STATE_OPENED , & priv -> state ))
150168 mlx5e_rep_update_sw_counters (priv );
169+ mlx5e_rep_update_hw_counters (priv );
151170 mutex_unlock (& priv -> state_lock );
152171
153- for (i = 0 ; i < NUM_VPORT_REP_COUNTERS ; i ++ )
172+ for (i = 0 ; i < NUM_VPORT_REP_SW_COUNTERS ; i ++ )
154173 data [i ] = MLX5E_READ_CTR64_CPU (& priv -> stats .sw ,
155174 sw_rep_stats_desc , i );
175+
176+ for (j = 0 ; j < NUM_VPORT_REP_HW_COUNTERS ; j ++ , i ++ )
177+ data [i ] = MLX5E_READ_CTR64_CPU (& priv -> stats .vf_vport ,
178+ vport_rep_stats_desc , j );
156179}
157180
158181static int mlx5e_rep_get_sset_count (struct net_device * dev , int sset )
159182{
160183 switch (sset ) {
161184 case ETH_SS_STATS :
162- return NUM_VPORT_REP_COUNTERS ;
185+ return NUM_VPORT_REP_SW_COUNTERS + NUM_VPORT_REP_HW_COUNTERS ;
163186 default :
164187 return - EOPNOTSUPP ;
165188 }
@@ -723,15 +746,31 @@ static int mlx5e_rep_get_phys_port_name(struct net_device *dev,
723746
724747static int
725748mlx5e_rep_setup_tc_cls_flower (struct mlx5e_priv * priv ,
726- struct tc_cls_flower_offload * cls_flower )
749+ struct tc_cls_flower_offload * cls_flower , int flags )
727750{
728751 switch (cls_flower -> command ) {
729752 case TC_CLSFLOWER_REPLACE :
730- return mlx5e_configure_flower (priv , cls_flower );
753+ return mlx5e_configure_flower (priv , cls_flower , flags );
731754 case TC_CLSFLOWER_DESTROY :
732- return mlx5e_delete_flower (priv , cls_flower );
755+ return mlx5e_delete_flower (priv , cls_flower , flags );
733756 case TC_CLSFLOWER_STATS :
734- return mlx5e_stats_flower (priv , cls_flower );
757+ return mlx5e_stats_flower (priv , cls_flower , flags );
758+ default :
759+ return - EOPNOTSUPP ;
760+ }
761+ }
762+
763+ static int mlx5e_rep_setup_tc_cb_egdev (enum tc_setup_type type , void * type_data ,
764+ void * cb_priv )
765+ {
766+ struct mlx5e_priv * priv = cb_priv ;
767+
768+ if (!tc_cls_can_offload_and_chain0 (priv -> netdev , type_data ))
769+ return - EOPNOTSUPP ;
770+
771+ switch (type ) {
772+ case TC_SETUP_CLSFLOWER :
773+ return mlx5e_rep_setup_tc_cls_flower (priv , type_data , MLX5E_TC_EGRESS );
735774 default :
736775 return - EOPNOTSUPP ;
737776 }
@@ -747,7 +786,7 @@ static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data,
747786
748787 switch (type ) {
749788 case TC_SETUP_CLSFLOWER :
750- return mlx5e_rep_setup_tc_cls_flower (priv , type_data );
789+ return mlx5e_rep_setup_tc_cls_flower (priv , type_data , MLX5E_TC_INGRESS );
751790 default :
752791 return - EOPNOTSUPP ;
753792 }
@@ -965,14 +1004,8 @@ static int mlx5e_init_rep_rx(struct mlx5e_priv *priv)
9651004 }
9661005 rpriv -> vport_rx_rule = flow_rule ;
9671006
968- err = mlx5e_tc_init (priv );
969- if (err )
970- goto err_del_flow_rule ;
971-
9721007 return 0 ;
9731008
974- err_del_flow_rule :
975- mlx5_del_flow_rules (rpriv -> vport_rx_rule );
9761009err_destroy_direct_tirs :
9771010 mlx5e_destroy_direct_tirs (priv );
9781011err_destroy_direct_rqts :
@@ -984,7 +1017,6 @@ static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)
9841017{
9851018 struct mlx5e_rep_priv * rpriv = priv -> ppriv ;
9861019
987- mlx5e_tc_cleanup (priv );
9881020 mlx5_del_flow_rules (rpriv -> vport_rx_rule );
9891021 mlx5e_destroy_direct_tirs (priv );
9901022 mlx5e_destroy_direct_rqts (priv );
@@ -1042,8 +1074,15 @@ mlx5e_nic_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
10421074 if (err )
10431075 goto err_remove_sqs ;
10441076
1077+ /* init shared tc flow table */
1078+ err = mlx5e_tc_esw_init (& rpriv -> tc_ht );
1079+ if (err )
1080+ goto err_neigh_cleanup ;
1081+
10451082 return 0 ;
10461083
1084+ err_neigh_cleanup :
1085+ mlx5e_rep_neigh_cleanup (rpriv );
10471086err_remove_sqs :
10481087 mlx5e_remove_sqs_fwd_rules (priv );
10491088 return err ;
@@ -1058,9 +1097,8 @@ mlx5e_nic_rep_unload(struct mlx5_eswitch_rep *rep)
10581097 if (test_bit (MLX5E_STATE_OPENED , & priv -> state ))
10591098 mlx5e_remove_sqs_fwd_rules (priv );
10601099
1061- /* clean (and re-init) existing uplink offloaded TC rules */
1062- mlx5e_tc_cleanup (priv );
1063- mlx5e_tc_init (priv );
1100+ /* clean uplink offloaded TC rules, delete shared tc flow table */
1101+ mlx5e_tc_esw_cleanup (& rpriv -> tc_ht );
10641102
10651103 mlx5e_rep_neigh_cleanup (rpriv );
10661104}
@@ -1107,7 +1145,7 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
11071145
11081146 uplink_rpriv = mlx5_eswitch_get_uplink_priv (dev -> priv .eswitch , REP_ETH );
11091147 upriv = netdev_priv (uplink_rpriv -> netdev );
1110- err = tc_setup_cb_egdev_register (netdev , mlx5e_setup_tc_block_cb ,
1148+ err = tc_setup_cb_egdev_register (netdev , mlx5e_rep_setup_tc_cb_egdev ,
11111149 upriv );
11121150 if (err )
11131151 goto err_neigh_cleanup ;
@@ -1122,7 +1160,7 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
11221160 return 0 ;
11231161
11241162err_egdev_cleanup :
1125- tc_setup_cb_egdev_unregister (netdev , mlx5e_setup_tc_block_cb ,
1163+ tc_setup_cb_egdev_unregister (netdev , mlx5e_rep_setup_tc_cb_egdev ,
11261164 upriv );
11271165
11281166err_neigh_cleanup :
@@ -1151,7 +1189,7 @@ mlx5e_vport_rep_unload(struct mlx5_eswitch_rep *rep)
11511189 uplink_rpriv = mlx5_eswitch_get_uplink_priv (priv -> mdev -> priv .eswitch ,
11521190 REP_ETH );
11531191 upriv = netdev_priv (uplink_rpriv -> netdev );
1154- tc_setup_cb_egdev_unregister (netdev , mlx5e_setup_tc_block_cb ,
1192+ tc_setup_cb_egdev_unregister (netdev , mlx5e_rep_setup_tc_cb_egdev ,
11551193 upriv );
11561194 mlx5e_rep_neigh_cleanup (rpriv );
11571195 mlx5e_detach_netdev (priv );
0 commit comments