@@ -1665,11 +1665,9 @@ bool mlx5e_tc_is_vf_tunnel(struct net_device *out_dev, struct net_device *route_
16651665int mlx5e_tc_query_route_vport (struct net_device * out_dev , struct net_device * route_dev , u16 * vport )
16661666{
16671667 struct mlx5e_priv * out_priv , * route_priv ;
1668- struct mlx5_devcom * devcom = NULL ;
16691668 struct mlx5_core_dev * route_mdev ;
16701669 struct mlx5_eswitch * esw ;
16711670 u16 vhca_id ;
1672- int err ;
16731671
16741672 out_priv = netdev_priv (out_dev );
16751673 esw = out_priv -> mdev -> priv .eswitch ;
@@ -1678,6 +1676,9 @@ int mlx5e_tc_query_route_vport(struct net_device *out_dev, struct net_device *ro
16781676
16791677 vhca_id = MLX5_CAP_GEN (route_mdev , vhca_id );
16801678 if (mlx5_lag_is_active (out_priv -> mdev )) {
1679+ struct mlx5_devcom * devcom ;
1680+ int err ;
1681+
16811682 /* In lag case we may get devices from different eswitch instances.
16821683 * If we failed to get vport num, it means, mostly, that we on the wrong
16831684 * eswitch.
@@ -1686,16 +1687,16 @@ int mlx5e_tc_query_route_vport(struct net_device *out_dev, struct net_device *ro
16861687 if (err != - ENOENT )
16871688 return err ;
16881689
1690+ rcu_read_lock ();
16891691 devcom = out_priv -> mdev -> priv .devcom ;
1690- esw = mlx5_devcom_get_peer_data (devcom , MLX5_DEVCOM_ESW_OFFLOADS );
1691- if (!esw )
1692- return - ENODEV ;
1692+ esw = mlx5_devcom_get_peer_data_rcu (devcom , MLX5_DEVCOM_ESW_OFFLOADS );
1693+ err = esw ? mlx5_eswitch_vhca_id_to_vport (esw , vhca_id , vport ) : - ENODEV ;
1694+ rcu_read_unlock ();
1695+
1696+ return err ;
16931697 }
16941698
1695- err = mlx5_eswitch_vhca_id_to_vport (esw , vhca_id , vport );
1696- if (devcom )
1697- mlx5_devcom_release_peer_data (devcom , MLX5_DEVCOM_ESW_OFFLOADS );
1698- return err ;
1699+ return mlx5_eswitch_vhca_id_to_vport (esw , vhca_id , vport );
16991700}
17001701
17011702static int
@@ -5301,6 +5302,8 @@ int mlx5e_tc_esw_init(struct mlx5_rep_uplink_priv *uplink_priv)
53015302 goto err_action_counter ;
53025303 }
53035304
5305+ mlx5_esw_offloads_devcom_init (esw );
5306+
53045307 return 0 ;
53055308
53065309err_action_counter :
@@ -5329,7 +5332,7 @@ void mlx5e_tc_esw_cleanup(struct mlx5_rep_uplink_priv *uplink_priv)
53295332 priv = netdev_priv (rpriv -> netdev );
53305333 esw = priv -> mdev -> priv .eswitch ;
53315334
5332- mlx5e_tc_clean_fdb_peer_flows (esw );
5335+ mlx5_esw_offloads_devcom_cleanup (esw );
53335336
53345337 mlx5e_tc_tun_cleanup (uplink_priv -> encap );
53355338
@@ -5643,22 +5646,43 @@ bool mlx5e_tc_update_skb_nic(struct mlx5_cqe64 *cqe, struct sk_buff *skb)
56435646 0 , NULL );
56445647}
56455648
5649+ static struct mapping_ctx *
5650+ mlx5e_get_priv_obj_mapping (struct mlx5e_priv * priv )
5651+ {
5652+ struct mlx5e_tc_table * tc ;
5653+ struct mlx5_eswitch * esw ;
5654+ struct mapping_ctx * ctx ;
5655+
5656+ if (is_mdev_switchdev_mode (priv -> mdev )) {
5657+ esw = priv -> mdev -> priv .eswitch ;
5658+ ctx = esw -> offloads .reg_c0_obj_pool ;
5659+ } else {
5660+ tc = mlx5e_fs_get_tc (priv -> fs );
5661+ ctx = tc -> mapping ;
5662+ }
5663+
5664+ return ctx ;
5665+ }
5666+
56465667int mlx5e_tc_action_miss_mapping_get (struct mlx5e_priv * priv , struct mlx5_flow_attr * attr ,
56475668 u64 act_miss_cookie , u32 * act_miss_mapping )
56485669{
5649- struct mlx5_eswitch * esw = priv -> mdev -> priv .eswitch ;
56505670 struct mlx5_mapped_obj mapped_obj = {};
5671+ struct mlx5_eswitch * esw ;
56515672 struct mapping_ctx * ctx ;
56525673 int err ;
56535674
5654- ctx = esw -> offloads .reg_c0_obj_pool ;
5655-
5675+ ctx = mlx5e_get_priv_obj_mapping (priv );
56565676 mapped_obj .type = MLX5_MAPPED_OBJ_ACT_MISS ;
56575677 mapped_obj .act_miss_cookie = act_miss_cookie ;
56585678 err = mapping_add (ctx , & mapped_obj , act_miss_mapping );
56595679 if (err )
56605680 return err ;
56615681
5682+ if (!is_mdev_switchdev_mode (priv -> mdev ))
5683+ return 0 ;
5684+
5685+ esw = priv -> mdev -> priv .eswitch ;
56625686 attr -> act_id_restore_rule = esw_add_restore_rule (esw , * act_miss_mapping );
56635687 if (IS_ERR (attr -> act_id_restore_rule ))
56645688 goto err_rule ;
@@ -5673,10 +5697,9 @@ int mlx5e_tc_action_miss_mapping_get(struct mlx5e_priv *priv, struct mlx5_flow_a
56735697void mlx5e_tc_action_miss_mapping_put (struct mlx5e_priv * priv , struct mlx5_flow_attr * attr ,
56745698 u32 act_miss_mapping )
56755699{
5676- struct mlx5_eswitch * esw = priv -> mdev -> priv .eswitch ;
5677- struct mapping_ctx * ctx ;
5700+ struct mapping_ctx * ctx = mlx5e_get_priv_obj_mapping (priv );
56785701
5679- ctx = esw -> offloads . reg_c0_obj_pool ;
5680- mlx5_del_flow_rules (attr -> act_id_restore_rule );
5702+ if ( is_mdev_switchdev_mode ( priv -> mdev ))
5703+ mlx5_del_flow_rules (attr -> act_id_restore_rule );
56815704 mapping_remove (ctx , act_miss_mapping );
56825705}
0 commit comments