Real Madrid defender Pepe is facing a lengthy spell on the sidelines after undergoing surgery on his right ankle on Wednesday.