Skip to content

Commit 226f2ca

Browse files
w1ldptrSaeed Mahameed
authored andcommitted
net/mlx5e: Change flow flags type to unsigned long
To remove dependency on rtnl lock and allow concurrent modification of 'flags' field of tc flow structure, change flow flag type to unsigned long and use atomic bit ops for reading and changing the flags. Implement auxiliary functions for setting, resetting and getting specific flag, and for checking most often used flag values. Always set flags with smp_mb__before_atomic() to ensure that all mlx5e_tc_flow are updated before concurrent readers can read new flags value. Rearrange all code paths to actually set flow->rule[] pointers before setting the OFFLOADED flag. On read side, use smp_mb__after_atomic() when accessing flags to ensure that offload-related flow fields are only read after the flags. Signed-off-by: Vlad Buslov <[email protected]> Reviewed-by: Jianbo Liu <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 5a7e5bc commit 226f2ca

File tree

4 files changed

+149
-97
lines changed

4 files changed

+149
-97
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3429,7 +3429,7 @@ static int mlx5e_setup_tc_mqprio(struct mlx5e_priv *priv,
34293429
#ifdef CONFIG_MLX5_ESWITCH
34303430
static int mlx5e_setup_tc_cls_flower(struct mlx5e_priv *priv,
34313431
struct flow_cls_offload *cls_flower,
3432-
int flags)
3432+
unsigned long flags)
34333433
{
34343434
switch (cls_flower->command) {
34353435
case FLOW_CLS_REPLACE:
@@ -3449,12 +3449,12 @@ static int mlx5e_setup_tc_cls_flower(struct mlx5e_priv *priv,
34493449
static int mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
34503450
void *cb_priv)
34513451
{
3452+
unsigned long flags = MLX5_TC_FLAG(INGRESS) | MLX5_TC_FLAG(NIC_OFFLOAD);
34523453
struct mlx5e_priv *priv = cb_priv;
34533454

34543455
switch (type) {
34553456
case TC_SETUP_CLSFLOWER:
3456-
return mlx5e_setup_tc_cls_flower(priv, type_data, MLX5E_TC_INGRESS |
3457-
MLX5E_TC_NIC_OFFLOAD);
3457+
return mlx5e_setup_tc_cls_flower(priv, type_data, flags);
34583458
default:
34593459
return -EOPNOTSUPP;
34603460
}
@@ -3647,7 +3647,7 @@ static int set_feature_tc_num_filters(struct net_device *netdev, bool enable)
36473647
{
36483648
struct mlx5e_priv *priv = netdev_priv(netdev);
36493649

3650-
if (!enable && mlx5e_tc_num_filters(priv, MLX5E_TC_NIC_OFFLOAD)) {
3650+
if (!enable && mlx5e_tc_num_filters(priv, MLX5_TC_FLAG(NIC_OFFLOAD))) {
36513651
netdev_err(netdev,
36523652
"Active offloaded tc filters, can't turn hw_tc_offload off\n");
36533653
return -EINVAL;

drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,8 @@ mlx5e_rep_indr_offload(struct net_device *netdev,
659659
struct flow_cls_offload *flower,
660660
struct mlx5e_rep_indr_block_priv *indr_priv)
661661
{
662+
unsigned long flags = MLX5_TC_FLAG(EGRESS) | MLX5_TC_FLAG(ESW_OFFLOAD);
662663
struct mlx5e_priv *priv = netdev_priv(indr_priv->rpriv->netdev);
663-
int flags = MLX5E_TC_EGRESS | MLX5E_TC_ESW_OFFLOAD;
664664
int err = 0;
665665

666666
switch (flower->command) {
@@ -1159,12 +1159,12 @@ mlx5e_rep_setup_tc_cls_flower(struct mlx5e_priv *priv,
11591159
static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data,
11601160
void *cb_priv)
11611161
{
1162+
unsigned long flags = MLX5_TC_FLAG(INGRESS) | MLX5_TC_FLAG(ESW_OFFLOAD);
11621163
struct mlx5e_priv *priv = cb_priv;
11631164

11641165
switch (type) {
11651166
case TC_SETUP_CLSFLOWER:
1166-
return mlx5e_rep_setup_tc_cls_flower(priv, type_data, MLX5E_TC_INGRESS |
1167-
MLX5E_TC_ESW_OFFLOAD);
1167+
return mlx5e_rep_setup_tc_cls_flower(priv, type_data, flags);
11681168
default:
11691169
return -EOPNOTSUPP;
11701170
}

0 commit comments

Comments
 (0)