Knocking before entering

Every guy I’ve been with has always knocked his dick on me before entering me.

Like is this a rule? Like being polite knocking on the door instead of just walking straight in??