If his tail is toward the bottom, it is likely a spinal injury from either jumping and hitting the top or darting quickly and hitting the glass or rock. Sometimes they recover, sometimes they don't. It just depends on the severity.
If the tail is toward the surface, then it would be a swim bladder infection. Venting with a sterilized pin can solve that.