Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dbe413e3 authored by Hadar Hen Zion's avatar Hadar Hen Zion Committed by David S. Miller
Browse files

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: default avatarHadar Hen Zion <hadarh@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1dbd0d37
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -3387,6 +3387,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
	queue_work(priv->wq, &priv->set_rx_mode_work);
	queue_work(priv->wq, &priv->set_rx_mode_work);


	if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
	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.load = mlx5e_nic_rep_load;
		rep.unload = mlx5e_nic_rep_unload;
		rep.unload = mlx5e_nic_rep_unload;
		rep.vport = 0;
		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;
	struct mlx5_eswitch *esw = mdev->priv.eswitch;
	int total_vfs = MLX5_TOTAL_VPORTS(mdev);
	int total_vfs = MLX5_TOTAL_VPORTS(mdev);
	int vport;
	int vport;
	u8 mac[ETH_ALEN];


	if (!MLX5_CAP_GEN(mdev, vport_group_manager))
	if (!MLX5_CAP_GEN(mdev, vport_group_manager))
		return;
		return;


	mlx5_query_nic_vport_mac_address(mdev, 0, mac);

	for (vport = 1; vport < total_vfs; vport++) {
	for (vport = 1; vport < total_vfs; vport++) {
		struct mlx5_eswitch_rep rep;
		struct mlx5_eswitch_rep rep;


		rep.load = mlx5e_vport_rep_load;
		rep.load = mlx5e_vport_rep_load;
		rep.unload = mlx5e_vport_rep_unload;
		rep.unload = mlx5e_vport_rep_unload;
		rep.vport = vport;
		rep.vport = vport;
		ether_addr_copy(rep.hw_id, mac);
		mlx5_eswitch_register_vport_rep(esw, &rep);
		mlx5_eswitch_register_vport_rep(esw, &rep);
	}
	}
}
}
+2 −3
Original line number Original line Diff line number Diff line
@@ -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)
int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr)
{
{
	struct mlx5e_priv *priv = netdev_priv(dev);
	struct mlx5e_priv *priv = netdev_priv(dev);
	struct mlx5_eswitch_rep *rep = priv->ppriv;
	struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
	struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
	u8 mac[ETH_ALEN];


	if (esw->mode == SRIOV_NONE)
	if (esw->mode == SRIOV_NONE)
		return -EOPNOTSUPP;
		return -EOPNOTSUPP;


	switch (attr->id) {
	switch (attr->id) {
	case SWITCHDEV_ATTR_ID_PORT_PARENT_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;
		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;
		break;
	default:
	default:
		return -EOPNOTSUPP;
		return -EOPNOTSUPP;
+1 −0
Original line number Original line Diff line number Diff line
@@ -174,6 +174,7 @@ struct mlx5_eswitch_rep {
	void		      *priv_data;
	void		      *priv_data;
	struct list_head       vport_sqs_list;
	struct list_head       vport_sqs_list;
	bool		       valid;
	bool		       valid;
	u8		       hw_id[ETH_ALEN];
};
};


struct mlx5_esw_offload {
struct mlx5_esw_offload {