Skip to content

RX/TX Ensō Pipe

RX/TX Ensō Pipes are designed for applications that modify received data in place and then send it back to the NIC without the need to impose copy overhead. They can be seen as a combination of an RX and TX Ensō Pipes, containing a subset of their functionality.

RX/TX Ensō Pipes can receive data from the NIC in the same way as RX Ensō Pipes. Therefore, applications can use analogous functions to receive data. Refer to the RX Ensō Pipe documentation for more information about each of those functions:

Different from RX Ensō Pipes, however, RX/TX Ensō Pipes do not support freeing the data received from the NIC. Instead, all received data is automatically freed after transmission.

To send data back to the NIC, applications should call RxTxPipe::SendAndFree(). Note that only data that was previously received can be sent back to the NIC, RX/TX Ensō Pipes do not support extending the buffer as in a TX Ensō Pipe.

The following example shows how to use RX/TX Ensō Pipes to echo received packets back to the NIC after incrementing their payload:

RxTxPipe* pipe = dev->AllocateRxTxPipe(); // (1)!
assert(pipe != nullptr);

while (keep_running) {
  auto batch = pipe->RecvPkts();
  if (unlikely(batch.available_bytes() == 0)) {
    continue;
  }
  for (auto pkt : batch) {
    ++pkt[59];  // Increment payload.
  }
  pipe->SendAndFree(batch.processed_bytes());
}
  1. ℹ Note that you should use a Device instance to allocate an RX/TX Ensō Pipe.

In this example we poll the RX/TX Ensō Pipe for new packets. If there are no packets available, we skip the current iteration of the loop. Otherwise, we increment the payload of each packet and send them back to the NIC.

Examples

The following examples use RX/TX Ensō Pipes: