aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHadar Hen Zion <hadarh@mellanox.com>2016-08-18 14:09:08 -0400
committerDavid S. Miller <davem@davemloft.net>2016-08-19 19:09:56 -0400
commitdbe413e3bb93e0634f6d8d00b01cda6f141e0acd (patch)
treeadf7eed7c74e2e56bf5ae3c55382b3c085edf8fb
parent1dbd0d373ac338903d27fab5204b13122cc5accd (diff)
net/mlx5e: Retrieve the switchdev id from the firmware only once
Avoid firmware command execution each time the switchdev HW ID attr get call is made. We do that by reading the ID (PF NIC MAC) only once at load time and store it on the representor structure. Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_rep.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eswitch.h1
3 files changed, 8 insertions, 3 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 65258b259579..03d944c0077e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3387,6 +3387,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
3387 queue_work(priv->wq, &priv->set_rx_mode_work); 3387 queue_work(priv->wq, &priv->set_rx_mode_work);
3388 3388
3389 if (MLX5_CAP_GEN(mdev, vport_group_manager)) { 3389 if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
3390 mlx5_query_nic_vport_mac_address(mdev, 0, rep.hw_id);
3390 rep.load = mlx5e_nic_rep_load; 3391 rep.load = mlx5e_nic_rep_load;
3391 rep.unload = mlx5e_nic_rep_unload; 3392 rep.unload = mlx5e_nic_rep_unload;
3392 rep.vport = 0; 3393 rep.vport = 0;
@@ -3505,16 +3506,20 @@ static void mlx5e_register_vport_rep(struct mlx5_core_dev *mdev)
3505 struct mlx5_eswitch *esw = mdev->priv.eswitch; 3506 struct mlx5_eswitch *esw = mdev->priv.eswitch;
3506 int total_vfs = MLX5_TOTAL_VPORTS(mdev); 3507 int total_vfs = MLX5_TOTAL_VPORTS(mdev);
3507 int vport; 3508 int vport;
3509 u8 mac[ETH_ALEN];
3508 3510
3509 if (!MLX5_CAP_GEN(mdev, vport_group_manager)) 3511 if (!MLX5_CAP_GEN(mdev, vport_group_manager))
3510 return; 3512 return;
3511 3513
3514 mlx5_query_nic_vport_mac_address(mdev, 0, mac);
3515
3512 for (vport = 1; vport < total_vfs; vport++) { 3516 for (vport = 1; vport < total_vfs; vport++) {
3513 struct mlx5_eswitch_rep rep; 3517 struct mlx5_eswitch_rep rep;
3514 3518
3515 rep.load = mlx5e_vport_rep_load; 3519 rep.load = mlx5e_vport_rep_load;
3516 rep.unload = mlx5e_vport_rep_unload; 3520 rep.unload = mlx5e_vport_rep_unload;
3517 rep.vport = vport; 3521 rep.vport = vport;
3522 ether_addr_copy(rep.hw_id, mac);
3518 mlx5_eswitch_register_vport_rep(esw, &rep); 3523 mlx5_eswitch_register_vport_rep(esw, &rep);
3519 } 3524 }
3520} 3525}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 1c7d8b8314bf..134de4a11f1d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -135,17 +135,16 @@ static const struct ethtool_ops mlx5e_rep_ethtool_ops = {
135int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr) 135int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr)
136{ 136{
137 struct mlx5e_priv *priv = netdev_priv(dev); 137 struct mlx5e_priv *priv = netdev_priv(dev);
138 struct mlx5_eswitch_rep *rep = priv->ppriv;
138 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; 139 struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
139 u8 mac[ETH_ALEN];
140 140
141 if (esw->mode == SRIOV_NONE) 141 if (esw->mode == SRIOV_NONE)
142 return -EOPNOTSUPP; 142 return -EOPNOTSUPP;
143 143
144 switch (attr->id) { 144 switch (attr->id) {
145 case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: 145 case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
146 mlx5_query_nic_vport_mac_address(priv->mdev, 0, mac);
147 attr->u.ppid.id_len = ETH_ALEN; 146 attr->u.ppid.id_len = ETH_ALEN;
148 memcpy(&attr->u.ppid.id, &mac, ETH_ALEN); 147 ether_addr_copy(attr->u.ppid.id, rep->hw_id);
149 break; 148 break;
150 default: 149 default:
151 return -EOPNOTSUPP; 150 return -EOPNOTSUPP;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index c0b05603fc31..a96140971d77 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -174,6 +174,7 @@ struct mlx5_eswitch_rep {
174 void *priv_data; 174 void *priv_data;
175 struct list_head vport_sqs_list; 175 struct list_head vport_sqs_list;
176 bool valid; 176 bool valid;
177 u8 hw_id[ETH_ALEN];
177}; 178};
178 179
179struct mlx5_esw_offload { 180struct mlx5_esw_offload {