Well I think your car is in "limp mode", which is designed to protect your engine and transmission during a fault. It very well could e your output speed sensor but this is a big fix. You have to remove the transmission pan and the valve body as the sensor is on top of the valve body. This is very easy to mess up so you should let a mechanic replace it of needed. Sadly it's a dealer only part.
Taken from E46 Fanatics:
Transmission Input and Output Speed Sensors:
The transmission speed sensors (turbine and output shaft) are analog inductive
sensors that produce an AC sine wave similar to an ABS/ASC wheel
speed sensor. The AC signal frequency is proportional to the rotation speed
of the monitored components .
• The turbine speed sensor scans a pulse wheel attached to the forward clutch housing.
• The output shaft speed sensor scans a pulse wheel attached to the rear ring gear.
The GS 20 monitors these signals along with the engine speed signal (CAN) to calculate
transmission slip ratio for plausibility and for the adaptive pressure control function.
The sensors are monitored for plausible signals, opens and shorts. Specific fault codes are
stored for defects with these sensors.
These links are part diagrams showing you where it is located.