net/mlx4_en: Check the enabling pptx/pprx flags in SET_PORT wrapper flow
authorShaker Daibes <shakerd@mellanox.com>
Sun, 29 Jan 2017 16:56:20 +0000 (18:56 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 30 Jan 2017 20:26:43 +0000 (15:26 -0500)
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 <shakerd@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/en_port.h
drivers/net/ethernet/mellanox/mlx4/mlx4.h
drivers/net/ethernet/mellanox/mlx4/port.c

index 040da4b16b1c65ee3448598550ee6b5726ccdb76..930f961fee42140cb7c03b1cf4a843911657b02d 100644 (file)
@@ -35,7 +35,6 @@
 #define _MLX4_EN_PORT_H_
 
 
-#define SET_PORT_GEN_ALL_VALID 0x7
 #define SET_PORT_PROMISC_SHIFT 31
 #define SET_PORT_MC_PROMISC_SHIFT      30
 
index 1132d76ddfdf954ea206893568662f5004e81531..7a495090b0bc1aa557e55613175fd1e03b7269ef 100644 (file)
@@ -776,7 +776,9 @@ struct mlx4_vlan_table {
        int                     max;
 };
 
-#define SET_PORT_GEN_ALL_VALID         0x7
+#define SET_PORT_GEN_ALL_VALID (MLX4_FLAG_V_MTU_MASK   | \
+                                MLX4_FLAG_V_PPRX_MASK  | \
+                                MLX4_FLAG_V_PPTX_MASK)
 #define SET_PORT_PROMISC_SHIFT         31
 #define SET_PORT_MC_PROMISC_SHIFT      30
 
index 57a10575a7aa8cc0c4625eea548b4d28d2b6d165..5053c949148f77545a5b917e8eb09d79f133b1df 100644 (file)
@@ -53,6 +53,8 @@
 #define MLX4_FLAG2_V_IGNORE_FCS_MASK           BIT(1)
 #define MLX4_FLAG2_V_USER_MTU_MASK             BIT(5)
 #define MLX4_FLAG_V_MTU_MASK                   BIT(0)
+#define MLX4_FLAG_V_PPRX_MASK                  BIT(1)
+#define MLX4_FLAG_V_PPTX_MASK                  BIT(2)
 #define MLX4_IGNORE_FCS_MASK                   0x1
 #define MLX4_TC_MAX_NUMBER                     8
 
@@ -1305,12 +1307,32 @@ mlx4_en_set_port_user_mtu(struct mlx4_dev *dev, int slave, int port,
        gen_context->user_mtu = cpu_to_be16(master->max_user_mtu[port]);
 }
 
+static void
+mlx4_en_set_port_global_pause(struct mlx4_dev *dev, int slave,
+                             struct mlx4_set_port_general_context *gen_context)
+{
+       struct mlx4_priv *priv = mlx4_priv(dev);
+       struct mlx4_mfunc_master_ctx *master = &priv->mfunc.master;
+
+       /* Slave cannot change Global Pause configuration */
+       if (slave != mlx4_master_func_num(dev) &&
+           (gen_context->pptx != master->pptx ||
+            gen_context->pprx != master->pprx)) {
+               gen_context->pptx = master->pptx;
+               gen_context->pprx = master->pprx;
+               mlx4_warn(dev, "denying Global Pause change for slave:%d\n",
+                         slave);
+       } else {
+               master->pptx = gen_context->pptx;
+               master->pprx = gen_context->pprx;
+       }
+}
+
 static int mlx4_common_set_port(struct mlx4_dev *dev, int slave, u32 in_mod,
                                u8 op_mod, struct mlx4_cmd_mailbox *inbox)
 {
        struct mlx4_priv *priv = mlx4_priv(dev);
        struct mlx4_port_info *port_info;
-       struct mlx4_mfunc_master_ctx *master = &priv->mfunc.master;
        struct mlx4_set_port_rqp_calc_context *qpn_context;
        struct mlx4_set_port_general_context *gen_context;
        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,
                                mlx4_en_set_port_user_mtu(dev, slave, port,
                                                          gen_context);
 
-                       /* Slave cannot change Global Pause configuration */
-                       if (slave != mlx4_master_func_num(dev) &&
-                           ((gen_context->pptx != master->pptx) ||
-                            (gen_context->pprx != master->pprx))) {
-                               gen_context->pptx = master->pptx;
-                               gen_context->pprx = master->pprx;
-                               mlx4_warn(dev,
-                                         "denying Global Pause change for slave:%d\n",
-                                         slave);
-                       } else {
-                               master->pptx = gen_context->pptx;
-                               master->pprx = gen_context->pprx;
-                       }
+                       if (gen_context->flags &
+                           (MLX4_FLAG_V_PPRX_MASK || MLX4_FLAG_V_PPTX_MASK))
+                               mlx4_en_set_port_global_pause(dev, slave,
+                                                             gen_context);
+
                        break;
                case MLX4_SET_PORT_GID_TABLE:
                        /* change to MULTIPLE entries: number of guest's gids