[PATCH net 0/2] mlx5 driver fixes for 4.5-rc1

STALE3876d

5 messages, 3 authors, 2016-01-29 · open the first message on its own page

[PATCH net 0/2] mlx5 driver fixes for 4.5-rc1

From: Or Gerlitz <hidden>
Date: 2016-01-27 15:02:56

Hi Dave,

Amir fixed a case where we could attempt to set destination for 
a non-forwarding (e.g drop) steering rule. Saeed fixed the case 
where VFs probed to the host shared the PF ndo_set_vf_yyy NDOs
which is wrong.

Or.

Amir Vadai (1):
  net/mlx5_core: Set flow steering dest only for forward rules

Saeed Mahameed (1):
  net/mlx5e: Use a private copy of netdev ops

 drivers/net/ethernet/mellanox/mlx5/core/en.h      |  2 +
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 52 ++++++++++++-----------
 drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c  | 33 +++++++-------
 3 files changed, 48 insertions(+), 39 deletions(-)

-- 
2.3.7

[PATCH net 1/2] net/mlx5_core: Set flow steering dest only for forward rules

From: Or Gerlitz <hidden>
Date: 2016-01-27 15:02:56

From: Amir Vadai <redacted>

We need to handle flow table entry destinations only if the action
associated with the rule is
forwarding (MLX5_FLOW_CONTEXT_ACTION_FWD_DEST).

Fixes: 26a8145390b3 ('net/mlx5_core: Introduce flow steering firmware commands')
Signed-off-by: Amir Vadai <redacted>
Signed-off-by: Maor Gottlieb <redacted>
Signed-off-by: Or Gerlitz <redacted>
---
 drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 33 +++++++++++++-----------
 1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
index a9894d2..0302f44 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
@@ -212,25 +212,28 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
 	MLX5_SET(flow_context, in_flow_context, group_id, group_id);
 	MLX5_SET(flow_context, in_flow_context, flow_tag, fte->flow_tag);
 	MLX5_SET(flow_context, in_flow_context, action, fte->action);
-	MLX5_SET(flow_context, in_flow_context, destination_list_size,
-		 fte->dests_size);
 	in_match_value = MLX5_ADDR_OF(flow_context, in_flow_context,
 				      match_value);
 	memcpy(in_match_value, &fte->val, MLX5_ST_SZ_BYTES(fte_match_param));
 
-	in_dests = MLX5_ADDR_OF(flow_context, in_flow_context, destination);
-	list_for_each_entry(dst, &fte->node.children, node.list) {
-		unsigned int id;
-
-		MLX5_SET(dest_format_struct, in_dests, destination_type,
-			 dst->dest_attr.type);
-		if (dst->dest_attr.type ==
-		    MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE)
-			id = dst->dest_attr.ft->id;
-		else
-			id = dst->dest_attr.tir_num;
-		MLX5_SET(dest_format_struct, in_dests, destination_id, id);
-		in_dests += MLX5_ST_SZ_BYTES(dest_format_struct);
+	if (fte->action & MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) {
+		MLX5_SET(flow_context, in_flow_context, destination_list_size,
+			 fte->dests_size);
+		in_dests = MLX5_ADDR_OF(flow_context, in_flow_context, destination);
+		list_for_each_entry(dst, &fte->node.children, node.list) {
+			unsigned int id;
+
+			MLX5_SET(dest_format_struct, in_dests, destination_type,
+				 dst->dest_attr.type);
+			if (dst->dest_attr.type ==
+			    MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE) {
+				id = dst->dest_attr.ft->id;
+			} else {
+				id = dst->dest_attr.tir_num;
+			}
+			MLX5_SET(dest_format_struct, in_dests, destination_id, id);
+			in_dests += MLX5_ST_SZ_BYTES(dest_format_struct);
+		}
 	}
 	memset(out, 0, sizeof(out));
 	err = mlx5_cmd_exec_check_status(dev, in, inlen, out,
-- 
2.3.7

[PATCH net 2/2] net/mlx5e: Use a private copy of netdev ops

From: Or Gerlitz <hidden>
Date: 2016-01-27 15:02:58

From: Saeed Mahameed <redacted>

Currently our netdevice ops is a static global variable which
is referenced by all mlx5e netdevice instances. This can be
problematic when different driver instances do not share same
HW capabilities (e.g SRIOV PF and VFs probed to the host).

Remove the global variable and add a private net_device_ops
field in netdevice private data, which is initialized at
netdev construction.

Fixes: 66e49dedada6 ("net/mlx5e: Add support for SR-IOV ndos")
Signed-off-by: Saeed Mahameed <redacted>
Signed-off-by: Or Gerlitz <redacted>
---
 drivers/net/ethernet/mellanox/mlx5/core/en.h      |  2 +
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 52 ++++++++++++-----------
 2 files changed, 30 insertions(+), 24 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 9ea49a8..4e7d339 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -510,6 +510,8 @@ struct mlx5e_priv {
 	int channeltc_to_txq_map[MLX5E_MAX_NUM_CHANNELS][MLX5E_MAX_NUM_TC];
 	/* priv data path fields - end */
 
+	struct net_device_ops      netdev_ops;
+
 	unsigned long              state;
 	struct mutex               state_lock; /* Protects Interface state */
 	struct mlx5_uar            cq_uar;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index c56d91a..49fe2e6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2024,20 +2024,6 @@ static int mlx5e_get_vf_stats(struct net_device *dev,
 					    vf_stats);
 }
 
-static struct net_device_ops mlx5e_netdev_ops = {
-	.ndo_open                = mlx5e_open,
-	.ndo_stop                = mlx5e_close,
-	.ndo_start_xmit          = mlx5e_xmit,
-	.ndo_get_stats64         = mlx5e_get_stats,
-	.ndo_set_rx_mode         = mlx5e_set_rx_mode,
-	.ndo_set_mac_address     = mlx5e_set_mac,
-	.ndo_vlan_rx_add_vid	 = mlx5e_vlan_rx_add_vid,
-	.ndo_vlan_rx_kill_vid	 = mlx5e_vlan_rx_kill_vid,
-	.ndo_set_features        = mlx5e_set_features,
-	.ndo_change_mtu		 = mlx5e_change_mtu,
-	.ndo_do_ioctl		 = mlx5e_ioctl,
-};
-
 static int mlx5e_check_required_hca_cap(struct mlx5_core_dev *mdev)
 {
 	if (MLX5_CAP_GEN(mdev, port_type) != MLX5_CAP_PORT_TYPE_ETH)
@@ -2130,25 +2116,43 @@ static void mlx5e_set_netdev_dev_addr(struct net_device *netdev)
 	}
 }
 
-static void mlx5e_build_netdev(struct net_device *netdev)
+static void mlx5e_build_priv_netdev_ops(struct mlx5e_priv *priv)
 {
-	struct mlx5e_priv *priv = netdev_priv(netdev);
 	struct mlx5_core_dev *mdev = priv->mdev;
 
-	SET_NETDEV_DEV(netdev, &mdev->pdev->dev);
+	priv->netdev_ops.ndo_open                = mlx5e_open;
+	priv->netdev_ops.ndo_stop                = mlx5e_close;
+	priv->netdev_ops.ndo_start_xmit          = mlx5e_xmit;
+	priv->netdev_ops.ndo_get_stats64         = mlx5e_get_stats;
+	priv->netdev_ops.ndo_set_rx_mode         = mlx5e_set_rx_mode;
+	priv->netdev_ops.ndo_set_mac_address     = mlx5e_set_mac;
+	priv->netdev_ops.ndo_vlan_rx_add_vid     = mlx5e_vlan_rx_add_vid;
+	priv->netdev_ops.ndo_vlan_rx_kill_vid    = mlx5e_vlan_rx_kill_vid;
+	priv->netdev_ops.ndo_set_features        = mlx5e_set_features;
+	priv->netdev_ops.ndo_change_mtu          = mlx5e_change_mtu;
+	priv->netdev_ops.ndo_do_ioctl            = mlx5e_ioctl;
 
 	if (priv->params.num_tc > 1)
-		mlx5e_netdev_ops.ndo_select_queue = mlx5e_select_queue;
+		priv->netdev_ops.ndo_select_queue = mlx5e_select_queue;
 
 	if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
-		mlx5e_netdev_ops.ndo_set_vf_mac = mlx5e_set_vf_mac;
-		mlx5e_netdev_ops.ndo_set_vf_vlan = mlx5e_set_vf_vlan;
-		mlx5e_netdev_ops.ndo_get_vf_config = mlx5e_get_vf_config;
-		mlx5e_netdev_ops.ndo_set_vf_link_state = mlx5e_set_vf_link_state;
-		mlx5e_netdev_ops.ndo_get_vf_stats = mlx5e_get_vf_stats;
+		priv->netdev_ops.ndo_set_vf_mac = mlx5e_set_vf_mac;
+		priv->netdev_ops.ndo_set_vf_vlan = mlx5e_set_vf_vlan;
+		priv->netdev_ops.ndo_get_vf_config = mlx5e_get_vf_config;
+		priv->netdev_ops.ndo_set_vf_link_state = mlx5e_set_vf_link_state;
+		priv->netdev_ops.ndo_get_vf_stats = mlx5e_get_vf_stats;
 	}
+}
+
+static void mlx5e_build_netdev(struct net_device *netdev)
+{
+	struct mlx5e_priv *priv = netdev_priv(netdev);
+	struct mlx5_core_dev *mdev = priv->mdev;
+
+	SET_NETDEV_DEV(netdev, &mdev->pdev->dev);
 
-	netdev->netdev_ops        = &mlx5e_netdev_ops;
+	mlx5e_build_priv_netdev_ops(priv);
+	netdev->netdev_ops        = &priv->netdev_ops;
 	netdev->watchdog_timeo    = 15 * HZ;
 
 	netdev->ethtool_ops	  = &mlx5e_ethtool_ops;
-- 
2.3.7

Re: [PATCH net 2/2] net/mlx5e: Use a private copy of netdev ops

From: David Miller <davem@davemloft.net>
Date: 2016-01-29 04:00:42

From: Or Gerlitz <redacted>
Date: Wed, 27 Jan 2016 17:02:25 +0200
From: Saeed Mahameed <redacted>

Currently our netdevice ops is a static global variable which
is referenced by all mlx5e netdevice instances. This can be
problematic when different driver instances do not share same
HW capabilities (e.g SRIOV PF and VFs probed to the host).

Remove the global variable and add a private net_device_ops
field in netdevice private data, which is initialized at
netdev construction.

Fixes: 66e49dedada6 ("net/mlx5e: Add support for SR-IOV ndos")
Signed-off-by: Saeed Mahameed <redacted>
Signed-off-by: Or Gerlitz <redacted>
This is not the canonical way to fix this.  Please look at how
other drivers handle this situation before inventing your own
way of solving the problem.

The proper way is to have multiple netdevice ops instances, and simply
choose the one which is correct for the chip in question.

You should also mark the ops as const.  They should never _ever_ be
modified at runtime.

Re: [PATCH net 2/2] net/mlx5e: Use a private copy of netdev ops

From: Or Gerlitz <hidden>
Date: 2016-01-29 13:17:55

On Fri, Jan 29, 2016 at 6:00 AM, David Miller [off-list ref] wrote:
This is not the canonical way to fix this.  Please look at how
other drivers handle this situation before inventing your own
way of solving the problem.
Dave, I was aware that other drivers do that differently, but the
maintainer here preferred to go this way and I didn't see a deep
reason why not.
The proper way is to have multiple netdevice ops instances, and simply
choose the one which is correct for the chip in question.
yep, but - this can become little lengthy if you have N ndos shared
among (say) three different profiles with m1, m2, m3 distinct ndos -
so we thought it can be a bit more elegant to do selective assignment
within a function and not as three globals.
You should also mark the ops as const.  They should never _ever_ be
modified at runtime.
okay

Or.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help