This may not be the most useful piece of knowledge, but if you ever get to see an elephant doing this you would at least know what he is up to. Urban Dictionary calls it trunking. Don’t try to do it at home – you will break your back.
On a side note, you should know that mammals, particularly primates – such as monkeys and apes – masturbate quite often. Even dolphins do it. They rub themselves against the seabed.