diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index 3e993d5a199419f8857e8d557173a1b36b440e71..f523f0204f1f6da3ed8efa6579924823b9c1335f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -711,6 +711,7 @@ static int mlx4_en_ethtool_add_mac_rule_by_ipv4(struct mlx4_en_priv *priv,
 						struct mlx4_spec_list *spec_l2,
 						__be32 ipv4_dst)
 {
+#ifdef CONFIG_INET
 	__be64 be_mac = 0;
 	unsigned char mac[ETH_ALEN];
 
@@ -726,6 +727,9 @@ static int mlx4_en_ethtool_add_mac_rule_by_ipv4(struct mlx4_en_priv *priv,
 	}
 
 	return mlx4_en_ethtool_add_mac_rule(cmd, rule_list_h, spec_l2, &mac[0]);
+#else
+	return -EINVAL;
+#endif
 }
 
 static int add_ip_rule(struct mlx4_en_priv *priv,