Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'mlx4-const-dev_addr'

Jakub Kicinski says:

====================
mlx4: prep for constant dev->dev_addr

This patch converts mlx4 for dev->dev_addr being const. It converts
to use of common helpers but also removes some seemingly unnecessary
idiosyncrasies.

Please review.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+26 -48
+1 -1
drivers/infiniband/hw/mlx4/main.c
··· 2275 2275 u64 release_mac = MLX4_IB_INVALID_MAC; 2276 2276 struct mlx4_ib_qp *qp; 2277 2277 2278 - new_smac = mlx4_mac_to_u64(dev->dev_addr); 2278 + new_smac = ether_addr_to_u64(dev->dev_addr); 2279 2279 atomic64_set(&ibdev->iboe.mac[port - 1], new_smac); 2280 2280 2281 2281 /* no need for update QP1 and mac registration in non-SRIOV */
+1 -1
drivers/infiniband/hw/mlx4/qp.c
··· 1853 1853 u16 vlan_id, u8 *smac) 1854 1854 { 1855 1855 return _mlx4_set_path(dev, &qp->ah_attr, 1856 - mlx4_mac_to_u64(smac), 1856 + ether_addr_to_u64(smac), 1857 1857 vlan_id, 1858 1858 path, &mqp->pri, port); 1859 1859 }
+2 -2
drivers/net/ethernet/mellanox/mlx4/cmd.c
··· 3009 3009 return -EPERM; 3010 3010 } 3011 3011 3012 - s_info->mac = mlx4_mac_to_u64(mac); 3012 + s_info->mac = ether_addr_to_u64(mac); 3013 3013 mlx4_info(dev, "default mac on vf %d port %d to %llX will take effect only after vf restart\n", 3014 3014 vf, port, s_info->mac); 3015 3015 return 0; ··· 3195 3195 port = mlx4_slaves_closest_port(dev, slave, port); 3196 3196 s_info = &priv->mfunc.master.vf_admin[slave].vport[port]; 3197 3197 3198 - mlx4_u64_to_mac(mac, s_info->mac); 3198 + u64_to_ether_addr(s_info->mac, mac); 3199 3199 if (setting && !is_valid_ether_addr(mac)) { 3200 3200 mlx4_info(dev, "Illegal MAC with spoofchk\n"); 3201 3201 return -EPERM;
+19 -19
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
··· 527 527 return err; 528 528 } 529 529 530 - static void mlx4_en_u64_to_mac(unsigned char dst_mac[ETH_ALEN + 2], u64 src_mac) 530 + static void mlx4_en_u64_to_mac(struct net_device *dev, u64 src_mac) 531 531 { 532 - int i; 533 - for (i = ETH_ALEN - 1; i >= 0; --i) { 534 - dst_mac[i] = src_mac & 0xff; 535 - src_mac >>= 8; 536 - } 537 - memset(&dst_mac[ETH_ALEN], 0, 2); 532 + u8 addr[ETH_ALEN]; 533 + 534 + u64_to_ether_addr(src_mac, addr); 535 + eth_hw_addr_set(dev, addr); 538 536 } 539 537 540 538 541 - static int mlx4_en_tunnel_steer_add(struct mlx4_en_priv *priv, unsigned char *addr, 539 + static int mlx4_en_tunnel_steer_add(struct mlx4_en_priv *priv, 540 + const unsigned char *addr, 542 541 int qpn, u64 *reg_id) 543 542 { 544 543 int err; ··· 558 559 559 560 560 561 static int mlx4_en_uc_steer_add(struct mlx4_en_priv *priv, 561 - unsigned char *mac, int *qpn, u64 *reg_id) 562 + const unsigned char *mac, int *qpn, u64 *reg_id) 562 563 { 563 564 struct mlx4_en_dev *mdev = priv->mdev; 564 565 struct mlx4_dev *dev = mdev->dev; ··· 610 611 } 611 612 612 613 static void mlx4_en_uc_steer_release(struct mlx4_en_priv *priv, 613 - unsigned char *mac, int qpn, u64 reg_id) 614 + const unsigned char *mac, 615 + int qpn, u64 reg_id) 614 616 { 615 617 struct mlx4_en_dev *mdev = priv->mdev; 616 618 struct mlx4_dev *dev = mdev->dev; ··· 644 644 int index = 0; 645 645 int err = 0; 646 646 int *qpn = &priv->base_qpn; 647 - u64 mac = mlx4_mac_to_u64(priv->dev->dev_addr); 647 + u64 mac = ether_addr_to_u64(priv->dev->dev_addr); 648 648 649 649 en_dbg(DRV, priv, "Registering MAC: %pM for adding\n", 650 650 priv->dev->dev_addr); ··· 683 683 int qpn = priv->base_qpn; 684 684 685 685 if (dev->caps.steering_mode == MLX4_STEERING_MODE_A0) { 686 - u64 mac = mlx4_mac_to_u64(priv->dev->dev_addr); 686 + u64 mac = ether_addr_to_u64(priv->dev->dev_addr); 687 687 en_dbg(DRV, priv, "Registering MAC: %pM for deleting\n", 688 688 priv->dev->dev_addr); 689 689 mlx4_unregister_mac(dev, priv->port, mac); ··· 701 701 struct mlx4_en_dev *mdev = priv->mdev; 702 702 struct mlx4_dev *dev = mdev->dev; 703 703 int err = 0; 704 - u64 new_mac_u64 = mlx4_mac_to_u64(new_mac); 704 + u64 new_mac_u64 = ether_addr_to_u64(new_mac); 705 705 706 706 if (dev->caps.steering_mode != MLX4_STEERING_MODE_A0) { 707 707 struct hlist_head *bucket; 708 708 unsigned int mac_hash; 709 709 struct mlx4_mac_entry *entry; 710 710 struct hlist_node *tmp; 711 - u64 prev_mac_u64 = mlx4_mac_to_u64(prev_mac); 711 + u64 prev_mac_u64 = ether_addr_to_u64(prev_mac); 712 712 713 713 bucket = &priv->mac_hash[prev_mac[MLX4_EN_MAC_HASH_IDX]]; 714 714 hlist_for_each_entry_safe(entry, tmp, bucket, hlist) { ··· 1076 1076 mlx4_en_cache_mclist(dev); 1077 1077 netif_addr_unlock_bh(dev); 1078 1078 list_for_each_entry(mclist, &priv->mc_list, list) { 1079 - mcast_addr = mlx4_mac_to_u64(mclist->addr); 1079 + mcast_addr = ether_addr_to_u64(mclist->addr); 1080 1080 mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 1081 1081 mcast_addr, 0, MLX4_MCAST_CONFIG); 1082 1082 } ··· 1169 1169 found = true; 1170 1170 1171 1171 if (!found) { 1172 - mac = mlx4_mac_to_u64(entry->mac); 1172 + mac = ether_addr_to_u64(entry->mac); 1173 1173 mlx4_en_uc_steer_release(priv, entry->mac, 1174 1174 priv->base_qpn, 1175 1175 entry->reg_id); ··· 1212 1212 priv->flags |= MLX4_EN_FLAG_FORCE_PROMISC; 1213 1213 break; 1214 1214 } 1215 - mac = mlx4_mac_to_u64(ha->addr); 1215 + mac = ether_addr_to_u64(ha->addr); 1216 1216 memcpy(entry->mac, ha->addr, ETH_ALEN); 1217 1217 err = mlx4_register_mac(mdev->dev, priv->port, mac); 1218 1218 if (err < 0) { ··· 1348 1348 for (i = 0; i < MLX4_EN_MAC_HASH_SIZE; ++i) { 1349 1349 bucket = &priv->mac_hash[i]; 1350 1350 hlist_for_each_entry_safe(entry, tmp, bucket, hlist) { 1351 - mac = mlx4_mac_to_u64(entry->mac); 1351 + mac = ether_addr_to_u64(entry->mac); 1352 1352 en_dbg(DRV, priv, "Registering MAC:%pM for deleting\n", 1353 1353 entry->mac); 1354 1354 mlx4_en_uc_steer_release(priv, entry->mac, ··· 3267 3267 3268 3268 /* Set default MAC */ 3269 3269 dev->addr_len = ETH_ALEN; 3270 - mlx4_en_u64_to_mac(dev->dev_addr, mdev->dev->caps.def_mac[priv->port]); 3270 + mlx4_en_u64_to_mac(dev, mdev->dev->caps.def_mac[priv->port]); 3271 3271 if (!is_valid_ether_addr(dev->dev_addr)) { 3272 3272 en_err(priv, "Port: %d, invalid mac burned: %pM, quitting\n", 3273 3273 priv->port, dev->dev_addr);
+1 -1
drivers/net/ethernet/mellanox/mlx4/fw.c
··· 3105 3105 dev->caps.port_type[i] == MLX4_PORT_TYPE_ETH) { 3106 3106 eth_random_addr(mac_addr); 3107 3107 dev->port_random_macs |= 1 << i; 3108 - dev->caps.def_mac[i] = mlx4_mac_to_u64(mac_addr); 3108 + dev->caps.def_mac[i] = ether_addr_to_u64(mac_addr); 3109 3109 } 3110 3110 } 3111 3111 EXPORT_SYMBOL_GPL(mlx4_replace_zero_macs);
+1 -1
drivers/net/ethernet/mellanox/mlx4/mcg.c
··· 1046 1046 } 1047 1047 EXPORT_SYMBOL_GPL(mlx4_flow_detach); 1048 1048 1049 - int mlx4_tunnel_steer_add(struct mlx4_dev *dev, unsigned char *addr, 1049 + int mlx4_tunnel_steer_add(struct mlx4_dev *dev, const unsigned char *addr, 1050 1050 int port, int qpn, u16 prio, u64 *reg_id) 1051 1051 { 1052 1052 int err;
+1 -1
include/linux/mlx4/device.h
··· 1436 1436 enum mlx4_net_trans_rule_id id); 1437 1437 int mlx4_hw_rule_sz(struct mlx4_dev *dev, enum mlx4_net_trans_rule_id id); 1438 1438 1439 - int mlx4_tunnel_steer_add(struct mlx4_dev *dev, unsigned char *addr, 1439 + int mlx4_tunnel_steer_add(struct mlx4_dev *dev, const unsigned char *addr, 1440 1440 int port, int qpn, u16 prio, u64 *reg_id); 1441 1441 1442 1442 void mlx4_sync_pkey_table(struct mlx4_dev *dev, int slave, int port,
-22
include/linux/mlx4/driver.h
··· 92 92 93 93 struct devlink_port *mlx4_get_devlink_port(struct mlx4_dev *dev, int port); 94 94 95 - static inline u64 mlx4_mac_to_u64(u8 *addr) 96 - { 97 - u64 mac = 0; 98 - int i; 99 - 100 - for (i = 0; i < ETH_ALEN; i++) { 101 - mac <<= 8; 102 - mac |= addr[i]; 103 - } 104 - return mac; 105 - } 106 - 107 - static inline void mlx4_u64_to_mac(u8 *addr, u64 mac) 108 - { 109 - int i; 110 - 111 - for (i = ETH_ALEN; i > 0; i--) { 112 - addr[i - 1] = mac & 0xFF; 113 - mac >>= 8; 114 - } 115 - } 116 - 117 95 #endif /* MLX4_DRIVER_H */