I do not think Bluetooth stack allows such functionality to count the number of advertisement packets. Advertisement is just a way of letting know the existence of the device.
Regarding p_tx_complete_cback, this is a way to notify about data packet & not the advertisement packet. So I am doubtful if your code will work as per your expected behavior.
It seems that the way I got from the API reference document is not feasible.
Is there any other way to get the number of tx adv. packet?
Unfortunately there is no way to count the number of adv packets.