xmos / lib_ethernet

Ethernet MAC library
Other
3 stars 12 forks source link

RGMII buffering should not drop LP packets unless HP queue used #17

Closed pthedinger closed 6 years ago

pthedinger commented 7 years ago

From http://www.xcore.com/viewtopic.php?f=26&t=5798&p=29414#p29414:

In rgmii_buffering.xc there is the code

    if (buffers_free_available(free_buffers) <= RGMII_RX_BUFFERS_THRESHOLD) {
      drop_lp_packets(client_state_lp, n_rx_lp, used_buffers_rx_lp, free_buffers);
    }

This means that if there is back-pressure in the RGMII buffering layer then packets that have already been committed to a client will be dropped. It would be better to allow the client to collect these packets and drop new incoming packets in this case, otherwise there is the possibility of no packets being delivered.

The solution in this case would be to only run this code if the high priority queue is enabled:

  if (!isnull(c_rx_hp)) {
      if (buffers_free_available(free_buffers) <= RGMII_RX_BUFFERS_THRESHOLD) {
        drop_lp_packets(client_state_lp, n_rx_lp, used_buffers_rx_lp, free_buffers);
      }
  }

Need to add a test case to demonstrate that data is still received by the client regardless of the level of back pressure.