Skip to content

Commit 1f8176f

Browse files
Shaker Daibesdavem330
authored andcommitted
net/mlx4_en: Check the enabling pptx/pprx flags in SET_PORT wrapper flow
Make sure pptx/pprx mask flag is set using new fields upon set port request. In addition, move this code into a helper function for better code readability. Signed-off-by: Shaker Daibes <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bf1f939 commit 1f8176f

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

drivers/net/ethernet/mellanox/mlx4/en_port.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#define _MLX4_EN_PORT_H_
3636

3737

38-
#define SET_PORT_GEN_ALL_VALID 0x7
3938
#define SET_PORT_PROMISC_SHIFT 31
4039
#define SET_PORT_MC_PROMISC_SHIFT 30
4140

drivers/net/ethernet/mellanox/mlx4/mlx4.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,9 @@ struct mlx4_vlan_table {
776776
int max;
777777
};
778778

779-
#define SET_PORT_GEN_ALL_VALID 0x7
779+
#define SET_PORT_GEN_ALL_VALID (MLX4_FLAG_V_MTU_MASK | \
780+
MLX4_FLAG_V_PPRX_MASK | \
781+
MLX4_FLAG_V_PPTX_MASK)
780782
#define SET_PORT_PROMISC_SHIFT 31
781783
#define SET_PORT_MC_PROMISC_SHIFT 30
782784

drivers/net/ethernet/mellanox/mlx4/port.c

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
#define MLX4_FLAG2_V_IGNORE_FCS_MASK BIT(1)
5454
#define MLX4_FLAG2_V_USER_MTU_MASK BIT(5)
5555
#define MLX4_FLAG_V_MTU_MASK BIT(0)
56+
#define MLX4_FLAG_V_PPRX_MASK BIT(1)
57+
#define MLX4_FLAG_V_PPTX_MASK BIT(2)
5658
#define MLX4_IGNORE_FCS_MASK 0x1
5759
#define MLX4_TC_MAX_NUMBER 8
5860

@@ -1305,12 +1307,32 @@ mlx4_en_set_port_user_mtu(struct mlx4_dev *dev, int slave, int port,
13051307
gen_context->user_mtu = cpu_to_be16(master->max_user_mtu[port]);
13061308
}
13071309

1310+
static void
1311+
mlx4_en_set_port_global_pause(struct mlx4_dev *dev, int slave,
1312+
struct mlx4_set_port_general_context *gen_context)
1313+
{
1314+
struct mlx4_priv *priv = mlx4_priv(dev);
1315+
struct mlx4_mfunc_master_ctx *master = &priv->mfunc.master;
1316+
1317+
/* Slave cannot change Global Pause configuration */
1318+
if (slave != mlx4_master_func_num(dev) &&
1319+
(gen_context->pptx != master->pptx ||
1320+
gen_context->pprx != master->pprx)) {
1321+
gen_context->pptx = master->pptx;
1322+
gen_context->pprx = master->pprx;
1323+
mlx4_warn(dev, "denying Global Pause change for slave:%d\n",
1324+
slave);
1325+
} else {
1326+
master->pptx = gen_context->pptx;
1327+
master->pprx = gen_context->pprx;
1328+
}
1329+
}
1330+
13081331
static int mlx4_common_set_port(struct mlx4_dev *dev, int slave, u32 in_mod,
13091332
u8 op_mod, struct mlx4_cmd_mailbox *inbox)
13101333
{
13111334
struct mlx4_priv *priv = mlx4_priv(dev);
13121335
struct mlx4_port_info *port_info;
1313-
struct mlx4_mfunc_master_ctx *master = &priv->mfunc.master;
13141336
struct mlx4_set_port_rqp_calc_context *qpn_context;
13151337
struct mlx4_set_port_general_context *gen_context;
13161338
struct mlx4_roce_gid_entry *gid_entry_tbl, *gid_entry_mbox, *gid_entry_mb1;
@@ -1372,19 +1394,11 @@ static int mlx4_common_set_port(struct mlx4_dev *dev, int slave, u32 in_mod,
13721394
mlx4_en_set_port_user_mtu(dev, slave, port,
13731395
gen_context);
13741396

1375-
/* Slave cannot change Global Pause configuration */
1376-
if (slave != mlx4_master_func_num(dev) &&
1377-
((gen_context->pptx != master->pptx) ||
1378-
(gen_context->pprx != master->pprx))) {
1379-
gen_context->pptx = master->pptx;
1380-
gen_context->pprx = master->pprx;
1381-
mlx4_warn(dev,
1382-
"denying Global Pause change for slave:%d\n",
1383-
slave);
1384-
} else {
1385-
master->pptx = gen_context->pptx;
1386-
master->pprx = gen_context->pprx;
1387-
}
1397+
if (gen_context->flags &
1398+
(MLX4_FLAG_V_PPRX_MASK || MLX4_FLAG_V_PPTX_MASK))
1399+
mlx4_en_set_port_global_pause(dev, slave,
1400+
gen_context);
1401+
13881402
break;
13891403
case MLX4_SET_PORT_GID_TABLE:
13901404
/* change to MULTIPLE entries: number of guest's gids

0 commit comments

Comments
 (0)