Don't know if you have figured out the solution. I believe the size information is in the "IOBufferMemoryDescriptor *ifmd". This seems to be a descriptor for interface and the interface seems to describe a ring buffer structure. If you look at "struct SerialPortInterface" defined in "SerialPortInterface.h", you will see the producer index and consumer index defined there. I think every time TxDataAvailable() is called, the txPI will be increased by the size of the new data.
I have a different problem and I want to see if anyone can help me. I'm trying to create a virtual serial port driver using DriverKit. I have a basic implementation that subclassess IOUserSerial. I've got as far as to be able to have the serial port shown as sth like /dev/tty.serial-100000B5A. When using picocom to write to this virtual serial port, I can see TxDataAvailable() gets called and the size information is updated correctly in the ifmd. However, upon checking the content of the TX buffer, it's all zeros. I don't know how to debug as I can't think of anything I did wrong. Really appreciate it if anyone can provide any suggestion! Thanks!