Thats bad news im afraid. Sounds like the emergency engine management kicked in, due to an engine problem. And if it is indeed a swirlflap failure, the prospect isnt great.
I use to own a 320d touring, and after a few nightmare stories from other owners I had my swirl flaps replaced with blanking plates.
The swirl flaps basically sit at the entrance to the manifold, and rotate back and forth,(not sure of there exact purpose, but believe they are there to help fuel management when idleing. There was no negative impact in the total removal of mine.
Anyhow the flaps have a tendancy on e46 models and earlier, to corrode, break loose, drop into the manifold, and at worst totally wreck your engine cylinders. Which, according to many angry owners reports, results in exactly what you experienced. Ie, no power etc.
Id get it down the dealers/decent independant straight away if you can. It will be easy to see if theres been a swirl flap failure. Literally a 5min job to check.
Good luck!
The garage that removed mine said they had another 4 bmws booked in that week for the same removal process.