diff options
author | Eugenia Emantayev <eugenia@mellanox.com> | 2014-03-02 03:25:01 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-03-02 20:04:01 -0500 |
commit | 9813337a4b16ea5b1701b1d00f7e410f5decdfa5 (patch) | |
tree | 5f30aea8b73c5b5e2348f6d2f42ec69e54a90f9b | |
parent | 15bffdffccb3204eb1e993f60eee65c439a03136 (diff) |
net/mlx4: Replace mlx4_en_mac_to_u64() with mlx4_mac_to_u64()
Currently, the EN driver uses a private static function
mlx4_en_mac_to_u64(). Move it to a common include file (driver.h)
for mlx4_en and mlx4_ib for further use.
Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 32 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 | ||||
-rw-r--r-- | include/linux/mlx4/driver.h | 12 |
3 files changed, 22 insertions, 23 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 2c0823bf3e05..3db594614fd3 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c | |||
@@ -603,7 +603,7 @@ static int mlx4_en_get_qp(struct mlx4_en_priv *priv) | |||
603 | int err = 0; | 603 | int err = 0; |
604 | u64 reg_id; | 604 | u64 reg_id; |
605 | int *qpn = &priv->base_qpn; | 605 | int *qpn = &priv->base_qpn; |
606 | u64 mac = mlx4_en_mac_to_u64(priv->dev->dev_addr); | 606 | u64 mac = mlx4_mac_to_u64(priv->dev->dev_addr); |
607 | 607 | ||
608 | en_dbg(DRV, priv, "Registering MAC: %pM for adding\n", | 608 | en_dbg(DRV, priv, "Registering MAC: %pM for adding\n", |
609 | priv->dev->dev_addr); | 609 | priv->dev->dev_addr); |
@@ -672,7 +672,7 @@ static void mlx4_en_put_qp(struct mlx4_en_priv *priv) | |||
672 | u64 mac; | 672 | u64 mac; |
673 | 673 | ||
674 | if (dev->caps.steering_mode == MLX4_STEERING_MODE_A0) { | 674 | if (dev->caps.steering_mode == MLX4_STEERING_MODE_A0) { |
675 | mac = mlx4_en_mac_to_u64(priv->dev->dev_addr); | 675 | mac = mlx4_mac_to_u64(priv->dev->dev_addr); |
676 | en_dbg(DRV, priv, "Registering MAC: %pM for deleting\n", | 676 | en_dbg(DRV, priv, "Registering MAC: %pM for deleting\n", |
677 | priv->dev->dev_addr); | 677 | priv->dev->dev_addr); |
678 | mlx4_unregister_mac(dev, priv->port, mac); | 678 | mlx4_unregister_mac(dev, priv->port, mac); |
@@ -685,7 +685,7 @@ static void mlx4_en_put_qp(struct mlx4_en_priv *priv) | |||
685 | for (i = 0; i < MLX4_EN_MAC_HASH_SIZE; ++i) { | 685 | for (i = 0; i < MLX4_EN_MAC_HASH_SIZE; ++i) { |
686 | bucket = &priv->mac_hash[i]; | 686 | bucket = &priv->mac_hash[i]; |
687 | hlist_for_each_entry_safe(entry, tmp, bucket, hlist) { | 687 | hlist_for_each_entry_safe(entry, tmp, bucket, hlist) { |
688 | mac = mlx4_en_mac_to_u64(entry->mac); | 688 | mac = mlx4_mac_to_u64(entry->mac); |
689 | en_dbg(DRV, priv, "Registering MAC: %pM for deleting\n", | 689 | en_dbg(DRV, priv, "Registering MAC: %pM for deleting\n", |
690 | entry->mac); | 690 | entry->mac); |
691 | mlx4_en_uc_steer_release(priv, entry->mac, | 691 | mlx4_en_uc_steer_release(priv, entry->mac, |
@@ -715,14 +715,14 @@ static int mlx4_en_replace_mac(struct mlx4_en_priv *priv, int qpn, | |||
715 | struct mlx4_en_dev *mdev = priv->mdev; | 715 | struct mlx4_en_dev *mdev = priv->mdev; |
716 | struct mlx4_dev *dev = mdev->dev; | 716 | struct mlx4_dev *dev = mdev->dev; |
717 | int err = 0; | 717 | int err = 0; |
718 | u64 new_mac_u64 = mlx4_en_mac_to_u64(new_mac); | 718 | u64 new_mac_u64 = mlx4_mac_to_u64(new_mac); |
719 | 719 | ||
720 | if (dev->caps.steering_mode != MLX4_STEERING_MODE_A0) { | 720 | if (dev->caps.steering_mode != MLX4_STEERING_MODE_A0) { |
721 | struct hlist_head *bucket; | 721 | struct hlist_head *bucket; |
722 | unsigned int mac_hash; | 722 | unsigned int mac_hash; |
723 | struct mlx4_mac_entry *entry; | 723 | struct mlx4_mac_entry *entry; |
724 | struct hlist_node *tmp; | 724 | struct hlist_node *tmp; |
725 | u64 prev_mac_u64 = mlx4_en_mac_to_u64(prev_mac); | 725 | u64 prev_mac_u64 = mlx4_mac_to_u64(prev_mac); |
726 | 726 | ||
727 | bucket = &priv->mac_hash[prev_mac[MLX4_EN_MAC_HASH_IDX]]; | 727 | bucket = &priv->mac_hash[prev_mac[MLX4_EN_MAC_HASH_IDX]]; |
728 | hlist_for_each_entry_safe(entry, tmp, bucket, hlist) { | 728 | hlist_for_each_entry_safe(entry, tmp, bucket, hlist) { |
@@ -751,18 +751,6 @@ static int mlx4_en_replace_mac(struct mlx4_en_priv *priv, int qpn, | |||
751 | return __mlx4_replace_mac(dev, priv->port, qpn, new_mac_u64); | 751 | return __mlx4_replace_mac(dev, priv->port, qpn, new_mac_u64); |
752 | } | 752 | } |
753 | 753 | ||
754 | u64 mlx4_en_mac_to_u64(u8 *addr) | ||
755 | { | ||
756 | u64 mac = 0; | ||
757 | int i; | ||
758 | |||
759 | for (i = 0; i < ETH_ALEN; i++) { | ||
760 | mac <<= 8; | ||
761 | mac |= addr[i]; | ||
762 | } | ||
763 | return mac; | ||
764 | } | ||
765 | |||
766 | static int mlx4_en_do_set_mac(struct mlx4_en_priv *priv) | 754 | static int mlx4_en_do_set_mac(struct mlx4_en_priv *priv) |
767 | { | 755 | { |
768 | int err = 0; | 756 | int err = 0; |
@@ -1081,7 +1069,7 @@ static void mlx4_en_do_multicast(struct mlx4_en_priv *priv, | |||
1081 | mlx4_en_cache_mclist(dev); | 1069 | mlx4_en_cache_mclist(dev); |
1082 | netif_addr_unlock_bh(dev); | 1070 | netif_addr_unlock_bh(dev); |
1083 | list_for_each_entry(mclist, &priv->mc_list, list) { | 1071 | list_for_each_entry(mclist, &priv->mc_list, list) { |
1084 | mcast_addr = mlx4_en_mac_to_u64(mclist->addr); | 1072 | mcast_addr = mlx4_mac_to_u64(mclist->addr); |
1085 | mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, | 1073 | mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, |
1086 | mcast_addr, 0, MLX4_MCAST_CONFIG); | 1074 | mcast_addr, 0, MLX4_MCAST_CONFIG); |
1087 | } | 1075 | } |
@@ -1173,7 +1161,7 @@ static void mlx4_en_do_uc_filter(struct mlx4_en_priv *priv, | |||
1173 | found = true; | 1161 | found = true; |
1174 | 1162 | ||
1175 | if (!found) { | 1163 | if (!found) { |
1176 | mac = mlx4_en_mac_to_u64(entry->mac); | 1164 | mac = mlx4_mac_to_u64(entry->mac); |
1177 | mlx4_en_uc_steer_release(priv, entry->mac, | 1165 | mlx4_en_uc_steer_release(priv, entry->mac, |
1178 | priv->base_qpn, | 1166 | priv->base_qpn, |
1179 | entry->reg_id); | 1167 | entry->reg_id); |
@@ -1216,7 +1204,7 @@ static void mlx4_en_do_uc_filter(struct mlx4_en_priv *priv, | |||
1216 | priv->flags |= MLX4_EN_FLAG_FORCE_PROMISC; | 1204 | priv->flags |= MLX4_EN_FLAG_FORCE_PROMISC; |
1217 | break; | 1205 | break; |
1218 | } | 1206 | } |
1219 | mac = mlx4_en_mac_to_u64(ha->addr); | 1207 | mac = mlx4_mac_to_u64(ha->addr); |
1220 | memcpy(entry->mac, ha->addr, ETH_ALEN); | 1208 | memcpy(entry->mac, ha->addr, ETH_ALEN); |
1221 | err = mlx4_register_mac(mdev->dev, priv->port, mac); | 1209 | err = mlx4_register_mac(mdev->dev, priv->port, mac); |
1222 | if (err < 0) { | 1210 | if (err < 0) { |
@@ -2206,7 +2194,7 @@ static int mlx4_en_set_vf_mac(struct net_device *dev, int queue, u8 *mac) | |||
2206 | { | 2194 | { |
2207 | struct mlx4_en_priv *en_priv = netdev_priv(dev); | 2195 | struct mlx4_en_priv *en_priv = netdev_priv(dev); |
2208 | struct mlx4_en_dev *mdev = en_priv->mdev; | 2196 | struct mlx4_en_dev *mdev = en_priv->mdev; |
2209 | u64 mac_u64 = mlx4_en_mac_to_u64(mac); | 2197 | u64 mac_u64 = mlx4_mac_to_u64(mac); |
2210 | 2198 | ||
2211 | if (!is_valid_ether_addr(mac)) | 2199 | if (!is_valid_ether_addr(mac)) |
2212 | return -EINVAL; | 2200 | return -EINVAL; |
@@ -2407,7 +2395,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, | |||
2407 | if (mlx4_is_slave(priv->mdev->dev)) { | 2395 | if (mlx4_is_slave(priv->mdev->dev)) { |
2408 | eth_hw_addr_random(dev); | 2396 | eth_hw_addr_random(dev); |
2409 | en_warn(priv, "Assigned random MAC address %pM\n", dev->dev_addr); | 2397 | en_warn(priv, "Assigned random MAC address %pM\n", dev->dev_addr); |
2410 | mac_u64 = mlx4_en_mac_to_u64(dev->dev_addr); | 2398 | mac_u64 = mlx4_mac_to_u64(dev->dev_addr); |
2411 | mdev->dev->caps.def_mac[priv->port] = mac_u64; | 2399 | mdev->dev->caps.def_mac[priv->port] = mac_u64; |
2412 | } else { | 2400 | } else { |
2413 | en_err(priv, "Port: %d, invalid mac burned: %pM, quiting\n", | 2401 | en_err(priv, "Port: %d, invalid mac burned: %pM, quiting\n", |
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index c59011d4e830..4ff7da83c4b3 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | |||
@@ -797,7 +797,6 @@ void mlx4_en_cleanup_filters(struct mlx4_en_priv *priv); | |||
797 | 797 | ||
798 | #define MLX4_EN_NUM_SELF_TEST 5 | 798 | #define MLX4_EN_NUM_SELF_TEST 5 |
799 | void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf); | 799 | void mlx4_en_ex_selftest(struct net_device *dev, u32 *flags, u64 *buf); |
800 | u64 mlx4_en_mac_to_u64(u8 *addr); | ||
801 | void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev); | 800 | void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev); |
802 | 801 | ||
803 | /* | 802 | /* |
diff --git a/include/linux/mlx4/driver.h b/include/linux/mlx4/driver.h index c257e1b211be..022055c8fb26 100644 --- a/include/linux/mlx4/driver.h +++ b/include/linux/mlx4/driver.h | |||
@@ -64,4 +64,16 @@ void mlx4_unregister_interface(struct mlx4_interface *intf); | |||
64 | 64 | ||
65 | void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int port); | 65 | void *mlx4_get_protocol_dev(struct mlx4_dev *dev, enum mlx4_protocol proto, int port); |
66 | 66 | ||
67 | static inline u64 mlx4_mac_to_u64(u8 *addr) | ||
68 | { | ||
69 | u64 mac = 0; | ||
70 | int i; | ||
71 | |||
72 | for (i = 0; i < ETH_ALEN; i++) { | ||
73 | mac <<= 8; | ||
74 | mac |= addr[i]; | ||
75 | } | ||
76 | return mac; | ||
77 | } | ||
78 | |||
67 | #endif /* MLX4_DRIVER_H */ | 79 | #endif /* MLX4_DRIVER_H */ |