#include <linux/semaphore.h>
 #include <rdma/ib_smi.h>
 #include <linux/delay.h>
+#include <linux/etherdevice.h>
 
 #include <asm/io.h>
 
        return false;
 }
 
-int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u64 mac)
+int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u8 *mac)
 {
        struct mlx4_priv *priv = mlx4_priv(dev);
        struct mlx4_vport_state *s_info;
        if (!mlx4_is_master(dev))
                return -EPROTONOSUPPORT;
 
+       if (is_multicast_ether_addr(mac))
+               return -EINVAL;
+
        slave = mlx4_get_slave_indx(dev, vf);
        if (slave < 0)
                return -EINVAL;
 
        port = mlx4_slaves_closest_port(dev, slave, port);
        s_info = &priv->mfunc.master.vf_admin[slave].vport[port];
-       s_info->mac = mac;
+
+       if (s_info->spoofchk && is_zero_ether_addr(mac)) {
+               mlx4_info(dev, "MAC invalidation is not allowed when spoofchk is on\n");
+               return -EPERM;
+       }
+
+       s_info->mac = mlx4_mac_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;
        struct mlx4_priv *priv = mlx4_priv(dev);
        struct mlx4_vport_state *s_info;
        int slave;
+       u8 mac[ETH_ALEN];
 
        if ((!mlx4_is_master(dev)) ||
            !(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_FSM))
 
        port = mlx4_slaves_closest_port(dev, slave, port);
        s_info = &priv->mfunc.master.vf_admin[slave].vport[port];
+
+       mlx4_u64_to_mac(mac, s_info->mac);
+       if (setting && !is_valid_ether_addr(mac)) {
+               mlx4_info(dev, "Illegal MAC with spoofchk\n");
+               return -EPERM;
+       }
+
        s_info->spoofchk = setting;
 
        return 0;
 
 {
        struct mlx4_en_priv *en_priv = netdev_priv(dev);
        struct mlx4_en_dev *mdev = en_priv->mdev;
-       u64 mac_u64 = mlx4_mac_to_u64(mac);
 
-       if (is_multicast_ether_addr(mac))
-               return -EINVAL;
-
-       return mlx4_set_vf_mac(mdev->dev, en_priv->port, queue, mac_u64);
+       return mlx4_set_vf_mac(mdev->dev, en_priv->port, queue, mac);
 }
 
 static int mlx4_en_set_vf_vlan(struct net_device *dev, int vf, u16 vlan, u8 qos,
 
 int mlx4_get_vf_stats(struct mlx4_dev *dev, int port, int vf_idx,
                      struct ifla_vf_stats *vf_stats);
 u32 mlx4_comm_get_version(void);
-int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u64 mac);
+int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u8 *mac);
 int mlx4_set_vf_vlan(struct mlx4_dev *dev, int port, int vf, u16 vlan,
                     u8 qos, __be16 proto);
 int mlx4_set_vf_rate(struct mlx4_dev *dev, int port, int vf, int min_tx_rate,