Message ID | 20210407045421.148987-13-saeed@kernel.org (mailing list archive) |
---|---|
State | Accepted |
Commit | be9dc0047450f7d8c0462a6ef3f7c26bced16911 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next,01/13] net/mlx5: E-switch, Move vport table functions to a new file | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Pull request |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 9 maintainers not CCed: pablo@netfilter.org wenxu@ucloud.cn jianbol@mellanox.com roid@nvidia.com paulb@mellanox.com vladbu@nvidia.com lariel@mellanox.com linux-rdma@vger.kernel.org leon@kernel.org |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 5 this patch: 5 |
netdev/kdoc | success | Errors and warnings before: 1 this patch: 1 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | WARNING: line length of 81 exceeds 80 columns WARNING: line length of 82 exceeds 80 columns |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 5 this patch: 5 |
netdev/header_inline | success | Link |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c index a25ec309d298..6cdc52d50a48 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c @@ -17,6 +17,7 @@ #include "en/mapping.h" #include "en/tc_tun.h" #include "lib/port_tun.h" +#include "esw/sample.h" struct mlx5e_rep_indr_block_priv { struct net_device *netdev; @@ -675,13 +676,20 @@ bool mlx5e_rep_tc_update_skb(struct mlx5_cqe64 *cqe, } #if IS_ENABLED(CONFIG_NET_TC_SKB_EXT) - if (mapped_obj.type == MLX5_MAPPED_OBJ_CHAIN) { + if (mapped_obj.type == MLX5_MAPPED_OBJ_CHAIN) return mlx5e_restore_skb(skb, mapped_obj.chain, reg_c1, tc_priv); - } else { +#endif /* CONFIG_NET_TC_SKB_EXT */ +#if IS_ENABLED(CONFIG_MLX5_TC_SAMPLE) + if (mapped_obj.type == MLX5_MAPPED_OBJ_SAMPLE) { + mlx5_esw_sample_skb(skb, &mapped_obj); + return false; + } +#endif /* CONFIG_MLX5_TC_SAMPLE */ + if (mapped_obj.type != MLX5_MAPPED_OBJ_SAMPLE && + mapped_obj.type != MLX5_MAPPED_OBJ_CHAIN) { netdev_dbg(priv->netdev, "Invalid mapped object type: %d\n", mapped_obj.type); return false; } -#endif /* CONFIG_NET_TC_SKB_EXT */ return true; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.c index 79a0e49b2799..629a0a28a7ba 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.c @@ -298,6 +298,21 @@ sample_restore_put(struct mlx5_esw_psample *esw_psample, struct mlx5_sample_rest } } +void mlx5_esw_sample_skb(struct sk_buff *skb, struct mlx5_mapped_obj *mapped_obj) +{ + u32 trunc_size = mapped_obj->sample.trunc_size; + struct psample_group psample_group = {}; + struct psample_metadata md = {}; + + md.trunc_size = trunc_size ? min(trunc_size, skb->len) : skb->len; + md.in_ifindex = skb->dev->ifindex; + psample_group.group_num = mapped_obj->sample.group_id; + psample_group.net = &init_net; + skb_push(skb, skb->mac_len); + + psample_sample_packet(&psample_group, skb, mapped_obj->sample.rate, &md); +} + struct mlx5_esw_psample * mlx5_esw_sample_init(struct mlx5e_priv *priv) { diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.h b/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.h index e42e3cb01c8c..82bff97bd9b7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/sample.h @@ -5,6 +5,7 @@ #define __MLX5_EN_TC_SAMPLE_H__ #include "en.h" +#include "eswitch.h" struct mlx5_sample_attr { u32 group_num; @@ -12,6 +13,8 @@ struct mlx5_sample_attr { u32 trunc_size; }; +void mlx5_esw_sample_skb(struct sk_buff *skb, struct mlx5_mapped_obj *mapped_obj); + struct mlx5_esw_psample * mlx5_esw_sample_init(struct mlx5e_priv *priv); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h index 9b26bd67e2b8..ed4d7f8f798f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h @@ -50,12 +50,18 @@ enum mlx5_mapped_obj_type { MLX5_MAPPED_OBJ_CHAIN, + MLX5_MAPPED_OBJ_SAMPLE, }; struct mlx5_mapped_obj { enum mlx5_mapped_obj_type type; union { u32 chain; + struct { + u32 group_id; + u32 rate; + u32 trunc_size; + } sample; }; };