+static void hdlc_handle_rx_frame(struct gb_beagleplay *bg)
+{
+ u8 address = bg->rx_buffer[0];
+ char *buffer = &bg->rx_buffer[2];
+ size_t buffer_len = bg->rx_buffer_len - 4;
+
+ switch (address) {
+ case ADDRESS_DBG:
+ hdlc_handle_dbg_frame(bg, buffer, buffer_len);
+ break;
+ case ADDRESS_GREYBUS:
+ hdlc_handle_greybus_frame(bg, buffer, buffer_len);
+ break;
+ default:
+ dev_warn(&bg->serdev->dev, "Got Unknown Frame %u", address);
ratelimit
Probably as well in several places with possible flooding.
I don't think `hdlc_handle_rx_frame` is the correct place since it only
processes a single completed HDLC frame. The more appropriate place
would be `hdlc_rx` if we want to limit based on the number of HDLC
frames or `gb_beagleplay_tty_receive` to limit based on the number of bytes.
I would like to ask, though, why is rate limiting required here? Won't
`serdev_device_ops->receive_buf` already rate limit the number of bytes
somewhat? Or is it related to blocking in the
`serdev_device_ops->receive_buf` callback? In the case of latter, it
would probably make sense to ratelimit based on number of frames, I think.
Ayush Singh