Why did Ma Chao attack Tongguan?
It was because Cao Cao introduced Ma Chao's father, Ma Teng, and his younger brother to Chang 'an and designed to kill them. A younger brother, Ma Dai, fled back. Afterwards, Ma Chao avenged his father and brother and joined forces with Han Sui to attack Cao.
Cao Jun fought against Ma Chao, who was brave and defeated three generals of Cao Ying in succession. Cao Jun quickly retreated. Ma Chao shouted, "Cao Cao is wearing a red robe." Hearing this, Cao Cao quickly took off his red robe. When Ma Chao knew it, he shouted, "That's Cao Cao with a beard." Cao Cao hurriedly cut off his long beard, and Ma Chao shouted, "The one with short beard is Cao Cao." Cao Cao could only pull a banner and run away around his neck.
In the novel Romance of the Three Kingdoms, chapter 58 "Ma Mengqi fought for revenge, Cao Aman cut his beard and abandoned his robe" and chapter 59 "Chu Xu hit Ma Chao naked, and Cao Cao wiped Han Sui between books" all describe this battle.