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>
This commit is contained in:
parent
1dbd0d373a
commit
dbe413e3bb
|
@ -3387,6 +3387,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
|
|||
queue_work(priv->wq, &priv->set_rx_mode_work);
|
||||
|
||||
if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
|
||||
mlx5_query_nic_vport_mac_address(mdev, 0, rep.hw_id);
|
||||
rep.load = mlx5e_nic_rep_load;
|
||||
rep.unload = mlx5e_nic_rep_unload;
|
||||
rep.vport = 0;
|
||||
|
@ -3505,16 +3506,20 @@ static void mlx5e_register_vport_rep(struct mlx5_core_dev *mdev)
|
|||
struct mlx5_eswitch *esw = mdev->priv.eswitch;
|
||||
int total_vfs = MLX5_TOTAL_VPORTS(mdev);
|
||||
int vport;
|
||||
u8 mac[ETH_ALEN];
|
||||
|
||||
if (!MLX5_CAP_GEN(mdev, vport_group_manager))
|
||||
return;
|
||||
|
||||
mlx5_query_nic_vport_mac_address(mdev, 0, mac);
|
||||
|
||||
for (vport = 1; vport < total_vfs; vport++) {
|
||||
struct mlx5_eswitch_rep rep;
|
||||
|
||||
rep.load = mlx5e_vport_rep_load;
|
||||
rep.unload = mlx5e_vport_rep_unload;
|
||||
rep.vport = vport;
|
||||
ether_addr_copy(rep.hw_id, mac);
|
||||
mlx5_eswitch_register_vport_rep(esw, &rep);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,17 +135,16 @@ static const struct ethtool_ops mlx5e_rep_ethtool_ops = {
|
|||
int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr)
|
||||
{
|
||||
struct mlx5e_priv *priv = netdev_priv(dev);
|
||||
struct mlx5_eswitch_rep *rep = priv->ppriv;
|
||||
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
|
||||
u8 mac[ETH_ALEN];
|
||||
|
||||
if (esw->mode == SRIOV_NONE)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
switch (attr->id) {
|
||||
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
|
||||
mlx5_query_nic_vport_mac_address(priv->mdev, 0, mac);
|
||||
attr->u.ppid.id_len = ETH_ALEN;
|
||||
memcpy(&attr->u.ppid.id, &mac, ETH_ALEN);
|
||||
ether_addr_copy(attr->u.ppid.id, rep->hw_id);
|
||||
break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
|
|
|
@ -174,6 +174,7 @@ struct mlx5_eswitch_rep {
|
|||
void *priv_data;
|
||||
struct list_head vport_sqs_list;
|
||||
bool valid;
|
||||
u8 hw_id[ETH_ALEN];
|
||||
};
|
||||
|
||||
struct mlx5_esw_offload {
|
||||
|
|
Loading…
Reference in New Issue