mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-24 07:31:41 +00:00
net/mlx5e: TC, Handle sampled packets
Mark the sampled packets with a sample restore object. Send sampled packets using the psample api. Signed-off-by: Chris Mi <cmi@nvidia.com> Reviewed-by: Oz Shlomo <ozsh@nvidia.com> Reviewed-by: Mark Bloch <mbloch@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
This commit is contained in:
parent
7319a1cc3c
commit
be9dc00474
4 changed files with 35 additions and 3 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include "en/mapping.h"
|
#include "en/mapping.h"
|
||||||
#include "en/tc_tun.h"
|
#include "en/tc_tun.h"
|
||||||
#include "lib/port_tun.h"
|
#include "lib/port_tun.h"
|
||||||
|
#include "esw/sample.h"
|
||||||
|
|
||||||
struct mlx5e_rep_indr_block_priv {
|
struct mlx5e_rep_indr_block_priv {
|
||||||
struct net_device *netdev;
|
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 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);
|
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);
|
netdev_dbg(priv->netdev, "Invalid mapped object type: %d\n", mapped_obj.type);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_TC_SKB_EXT */
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 *
|
struct mlx5_esw_psample *
|
||||||
mlx5_esw_sample_init(struct mlx5e_priv *priv)
|
mlx5_esw_sample_init(struct mlx5e_priv *priv)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#define __MLX5_EN_TC_SAMPLE_H__
|
#define __MLX5_EN_TC_SAMPLE_H__
|
||||||
|
|
||||||
#include "en.h"
|
#include "en.h"
|
||||||
|
#include "eswitch.h"
|
||||||
|
|
||||||
struct mlx5_sample_attr {
|
struct mlx5_sample_attr {
|
||||||
u32 group_num;
|
u32 group_num;
|
||||||
|
@ -12,6 +13,8 @@ struct mlx5_sample_attr {
|
||||||
u32 trunc_size;
|
u32 trunc_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void mlx5_esw_sample_skb(struct sk_buff *skb, struct mlx5_mapped_obj *mapped_obj);
|
||||||
|
|
||||||
struct mlx5_esw_psample *
|
struct mlx5_esw_psample *
|
||||||
mlx5_esw_sample_init(struct mlx5e_priv *priv);
|
mlx5_esw_sample_init(struct mlx5e_priv *priv);
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,18 @@
|
||||||
|
|
||||||
enum mlx5_mapped_obj_type {
|
enum mlx5_mapped_obj_type {
|
||||||
MLX5_MAPPED_OBJ_CHAIN,
|
MLX5_MAPPED_OBJ_CHAIN,
|
||||||
|
MLX5_MAPPED_OBJ_SAMPLE,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mlx5_mapped_obj {
|
struct mlx5_mapped_obj {
|
||||||
enum mlx5_mapped_obj_type type;
|
enum mlx5_mapped_obj_type type;
|
||||||
union {
|
union {
|
||||||
u32 chain;
|
u32 chain;
|
||||||
|
struct {
|
||||||
|
u32 group_id;
|
||||||
|
u32 rate;
|
||||||
|
u32 trunc_size;
|
||||||
|
} sample;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue