This sentence comes from Caesar's De Bello Gallico (emphasis mine in the part I'm trying to understand):
Dum haec a Caesare geruntur, Treveri magnis coactis peditatus equitatusque copiis Labienum cum una legione, quae in eorum finibus hiemaverat, adoriri parabant, iamque ab eo non longius bidui via aberant, cum duas venisse legiones missu Caesaris cognoscunt.
In the expression cum duas venisse legiones, I find an accusative duas legiones and a perfect infinitive, venisse, so I suppose it's an accusativus cum infinitivo construction. My problem is that I've never encountered such structure used with cum. What's the role of cum in this case?