zlp-send quirk should default to true (and perhaps be removed)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- go
- Área
- embedded-iot
Línea de trabajo
Comienza localizando la configuración de zlp-send y el manejo de transferencias masivas USB en el repositorio; después, revisa cómo se pasa esta configuración a la capa de transferencia subyacente. Determina si habilitarla de forma predeterminada o eliminar el quirk conserva el comportamiento existente, e identifica las pruebas relevantes o las comprobaciones a nivel de dispositivo antes de cambiar el valor predeterminado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The USB ZLP (Zero Length Packet) with Bulk Transfers seems to have been widely misunderstood. Especially because OSes need to offer low-level driver implementation APIs that have the ability to omit sending it. But the ZLP really needs to be generated in various conditions or things will break or have delays in randomly seeming manner.
USB 2.0 specification section 5.8.3 Bulk Transfer Packet Size Constraints says the following:
A bulk transfer is complete when the endpoint does one of the following:
•Has transferred exactly the amount of data expected
•Transfers a packet with a payload size less than wMaxPacketSize or transfers a zero-length packet
When a bulk transfer is complete, the Host Controller retires the current IRP and advances to the next IRP. If a data payload is received that is larger than expected, all pending bulk IRPs for that endpoint will be aborted/retired.
In addition to the above, the host controller offers an IRP level timeout after which the IRP times out. The application may then choose to consider the timeout as a success or an error (e.g. based on the data received).
On Bulk endpoints the transfer typically maps to a read or write operation - also typically on application level a full APDU (e.g. HTTP request) does not need to happen within a single transfer, but it can span multiple transfer. That is, you can write multiple times (do multiple transfers) and the other side then on application level determines based on content when the APDU/HTTP request is complete.
The significant thing is that if the final transfer is a multiple of the USB maximum packet size and the ZLP is not sent, the transfer is not considered complete. While some USB stacks might still handle it. The USB specification is clear that the IRP is not complete, and the application will not see it. And this is a host controller (not OS) related feature. (Think of transfer complete as "flush the buffers from host controller to OS/application".) Without ZLP when needed, the IRP will typically timeout at some point and then it is completely up to the device if it proceeds handling at as valid data, or generating a timeout error. I've seen some USB-IPP devices where this actually depends on what type of request was being made. Other side effects are that print jobs do not print immediately (if any of the IPP requests suffer for this, the timeout needs happen - typically several seconds).
The other problem is that when streaming large amounts of print data, we might end up sending huge transfer sizes. That is we send full USB packets continuously for a long time. The USB specification says that the data payload is larger than expected, all pending bulk IRPs will be aborted/retired. Now some printers handle this fine, but I've seen devices that crash (though this should really be fixed on the device to). USB-IPP does not state maximum transfer size, but the Appendix C there suggests that typically large requests are split to multiple transfers. There is not requirement on boundaries, alignment other matters. When reading IPP-USB the transfers just map to read/write.
I personally think that libusb should have inverted the flag. Most users typically want ZLPs to be automatically generated or things will break in strange ways randomly and depending on device. LIBUSB_TRANSFER_ADD_ZERO_PACKET should really be LIBUSB_TRANSFER_NO_ZERO_PACKET. And have ZLP generation on by default.
But given the following facts on not generating ZLPs:
- is against the "spirit" of USB 5.8.3 and IPP-USB
- will cause random timeouts which different devices handle differently (some work but with additional delay causing perf issues, some error out)
- may cause other compatibility issues during streaming of large print data
I strongly recommend to enable zlp-send by default, or even just removing the quirk.
Thank you for considering.
PS. Perhaps this will also explain more about the received ZLPs. Normally the OS will drain these from received data. But applications can observe them if a they issue bulk read, and the peripheral sends no data (ZLP) as a response. Typically this means the buffers are flushed from the peripheral and no data is pending. But depending on the internal implementation of a peripheral this might be just an implementation quirk. In other cases it can actually mean what it should: there is no more data going to be available. So its always safe to ignore ZLPs, and typically it should be used to indicate that the upper protocol layer should now look into what is happening.
- Lenguaje dominante
- Go
- Estrellas
- 210
- Forks
- 35
- Merge medio
- 5 h 47 min
- PR fusionados (30 d)
- 1
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de OpenPrinting/ipp-usb
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
OpenPrinting/ipp-usb#136 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 32/100
OpenPrinting/ipp-usb#123 · 10 comentarios ·
-
arm64 and arm v7 OCI buildsAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
OpenPrinting/ipp-usb#122 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
OpenPrinting/ipp-usb#116 · 2 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
OpenPrinting/ipp-usb#115 · 5 comentarios ·
Todos los issues de OpenPrinting/ipp-usb
Issues similares
-
effort:high model:sonnet phase:3 type:docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
OffchainLabs/nitro#4771 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
BurntSushi/toml#530 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 7 días