]> git.dujemihanovic.xyz Git - linux.git/commitdiff
mlx4: replace mlx4_mac_to_u64() with ether_addr_to_u64()
authorJakub Kicinski <kuba@kernel.org>
Mon, 4 Oct 2021 19:14:43 +0000 (12:14 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 5 Oct 2021 12:15:35 +0000 (13:15 +0100)
mlx4_mac_to_u64() predates and opencodes ether_addr_to_u64().
It doesn't make the argument constant so it'll be problematic
when dev->dev_addr becomes a const. Convert to the generic helper.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/infiniband/hw/mlx4/main.c
drivers/infiniband/hw/mlx4/qp.c
drivers/net/ethernet/mellanox/mlx4/cmd.c
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
drivers/net/ethernet/mellanox/mlx4/fw.c
include/linux/mlx4/driver.h

index f367f4a4abffc1e1ff996866770b2c81575703a7..f3fa2fe6a88a0002770e36aad26c5cf5ad60d7cf 100644 (file)
@@ -2275,7 +2275,7 @@ static void mlx4_ib_update_qps(struct mlx4_ib_dev *ibdev,
        u64 release_mac = MLX4_IB_INVALID_MAC;
        struct mlx4_ib_qp *qp;
 
-       new_smac = mlx4_mac_to_u64(dev->dev_addr);
+       new_smac = ether_addr_to_u64(dev->dev_addr);
        atomic64_set(&ibdev->iboe.mac[port - 1], new_smac);
 
        /* no need for update QP1 and mac registration in non-SRIOV */
index 8662f462e2a5faab9d3bedf168867b4cf62680b4..aea4182f33a48c90601c69881b74082b771d0584 100644 (file)
@@ -1853,7 +1853,7 @@ static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_qp_attr *qp,
                         u16 vlan_id, u8 *smac)
 {
        return _mlx4_set_path(dev, &qp->ah_attr,
-                             mlx4_mac_to_u64(smac),
+                             ether_addr_to_u64(smac),
                              vlan_id,
                              path, &mqp->pri, port);
 }
index 8d751383530b431096263520c489ff8fff9dd314..9fadedfca41c42613fd55b8e6c881bf38382e157 100644 (file)
@@ -3009,7 +3009,7 @@ int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u8 *mac)
                return -EPERM;
        }
 
-       s_info->mac = mlx4_mac_to_u64(mac);
+       s_info->mac = ether_addr_to_u64(mac);
        mlx4_info(dev, "default mac on vf %d port %d to %llX will take effect only after vf restart\n",
                  vf, port, s_info->mac);
        return 0;
index ac480dc79bc1889bfef4ba6915315288b9a3e30e..76c8fe8e0125518f120c7cd329c3d778dfce57c6 100644 (file)
@@ -644,7 +644,7 @@ static int mlx4_en_get_qp(struct mlx4_en_priv *priv)
        int index = 0;
        int err = 0;
        int *qpn = &priv->base_qpn;
-       u64 mac = mlx4_mac_to_u64(priv->dev->dev_addr);
+       u64 mac = ether_addr_to_u64(priv->dev->dev_addr);
 
        en_dbg(DRV, priv, "Registering MAC: %pM for adding\n",
               priv->dev->dev_addr);
@@ -683,7 +683,7 @@ static void mlx4_en_put_qp(struct mlx4_en_priv *priv)
        int qpn = priv->base_qpn;
 
        if (dev->caps.steering_mode == MLX4_STEERING_MODE_A0) {
-               u64 mac = mlx4_mac_to_u64(priv->dev->dev_addr);
+               u64 mac = ether_addr_to_u64(priv->dev->dev_addr);
                en_dbg(DRV, priv, "Registering MAC: %pM for deleting\n",
                       priv->dev->dev_addr);
                mlx4_unregister_mac(dev, priv->port, mac);
@@ -701,14 +701,14 @@ static int mlx4_en_replace_mac(struct mlx4_en_priv *priv, int qpn,
        struct mlx4_en_dev *mdev = priv->mdev;
        struct mlx4_dev *dev = mdev->dev;
        int err = 0;
-       u64 new_mac_u64 = mlx4_mac_to_u64(new_mac);
+       u64 new_mac_u64 = ether_addr_to_u64(new_mac);
 
        if (dev->caps.steering_mode != MLX4_STEERING_MODE_A0) {
                struct hlist_head *bucket;
                unsigned int mac_hash;
                struct mlx4_mac_entry *entry;
                struct hlist_node *tmp;
-               u64 prev_mac_u64 = mlx4_mac_to_u64(prev_mac);
+               u64 prev_mac_u64 = ether_addr_to_u64(prev_mac);
 
                bucket = &priv->mac_hash[prev_mac[MLX4_EN_MAC_HASH_IDX]];
                hlist_for_each_entry_safe(entry, tmp, bucket, hlist) {
@@ -1076,7 +1076,7 @@ static void mlx4_en_do_multicast(struct mlx4_en_priv *priv,
                mlx4_en_cache_mclist(dev);
                netif_addr_unlock_bh(dev);
                list_for_each_entry(mclist, &priv->mc_list, list) {
-                       mcast_addr = mlx4_mac_to_u64(mclist->addr);
+                       mcast_addr = ether_addr_to_u64(mclist->addr);
                        mlx4_SET_MCAST_FLTR(mdev->dev, priv->port,
                                            mcast_addr, 0, MLX4_MCAST_CONFIG);
                }
@@ -1169,7 +1169,7 @@ static void mlx4_en_do_uc_filter(struct mlx4_en_priv *priv,
                                found = true;
 
                        if (!found) {
-                               mac = mlx4_mac_to_u64(entry->mac);
+                               mac = ether_addr_to_u64(entry->mac);
                                mlx4_en_uc_steer_release(priv, entry->mac,
                                                         priv->base_qpn,
                                                         entry->reg_id);
@@ -1212,7 +1212,7 @@ static void mlx4_en_do_uc_filter(struct mlx4_en_priv *priv,
                                priv->flags |= MLX4_EN_FLAG_FORCE_PROMISC;
                                break;
                        }
-                       mac = mlx4_mac_to_u64(ha->addr);
+                       mac = ether_addr_to_u64(ha->addr);
                        memcpy(entry->mac, ha->addr, ETH_ALEN);
                        err = mlx4_register_mac(mdev->dev, priv->port, mac);
                        if (err < 0) {
@@ -1348,7 +1348,7 @@ static void mlx4_en_delete_rss_steer_rules(struct mlx4_en_priv *priv)
        for (i = 0; i < MLX4_EN_MAC_HASH_SIZE; ++i) {
                bucket = &priv->mac_hash[i];
                hlist_for_each_entry_safe(entry, tmp, bucket, hlist) {
-                       mac = mlx4_mac_to_u64(entry->mac);
+                       mac = ether_addr_to_u64(entry->mac);
                        en_dbg(DRV, priv, "Registering MAC:%pM for deleting\n",
                               entry->mac);
                        mlx4_en_uc_steer_release(priv, entry->mac,
index dc4ac1a2b6b67625edf665363f6bf60337a81146..42c96c9d7fb16d1432afde6b3cefad765331d4c4 100644 (file)
@@ -3105,7 +3105,7 @@ void mlx4_replace_zero_macs(struct mlx4_dev *dev)
                    dev->caps.port_type[i] == MLX4_PORT_TYPE_ETH) {
                        eth_random_addr(mac_addr);
                        dev->port_random_macs |= 1 << i;
-                       dev->caps.def_mac[i] = mlx4_mac_to_u64(mac_addr);
+                       dev->caps.def_mac[i] = ether_addr_to_u64(mac_addr);
                }
 }
 EXPORT_SYMBOL_GPL(mlx4_replace_zero_macs);
index a858bcb6220b5d090c2ca828527b38e6d7c0380e..b26b71f62fb41473133347f1010af8d118dc36cf 100644 (file)
@@ -92,18 +92,6 @@ void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int
 
 struct devlink_port *mlx4_get_devlink_port(struct mlx4_dev *dev, int port);
 
-static inline u64 mlx4_mac_to_u64(u8 *addr)
-{
-       u64 mac = 0;
-       int i;
-
-       for (i = 0; i < ETH_ALEN; i++) {
-               mac <<= 8;
-               mac |= addr[i];
-       }
-       return mac;
-}
-
 static inline void mlx4_u64_to_mac(u8 *addr, u64 mac)
 {
        int i;