Vagina pain

Last night while me and my boyfriend were having sex. It started to really hurt all of the sudden. And when he was finished he has blood all over himself. And it kept on hurting for a while. It wasn't our first time. But it was the first time in like 3 weeks. Does anyone know what happened?