All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yacin Belmihoub-Martel" <yacin.belmihoub-martel@silabs.com>
To: "Damien Riégel" <damien.riegel@silabs.com>,
	greybus-dev@lists.linaro.org, "Johan Hovold" <johan@kernel.org>,
	"Alex Elder" <elder@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org
Cc: "Silicon Labs Kernel Team" <linux-devel@silabs.com>
Subject: Re: [RFC PATCH v2 11/12] greybus: cpc: honour remote's RX window
Date: Fri, 14 Nov 2025 15:28:38 -0500	[thread overview]
Message-ID: <DE8P9HDNEZJH.33TRDMVZI1L55@silabs.com> (raw)
In-Reply-To: <20251114150738.32426-12-damien.riegel@silabs.com>

On Fri Nov 14, 2025 at 10:07 AM EST, Damien Riégel wrote:
> +/**
> + * cpc_header_get_frames_acked_count() - Get frames to be acknowledged.
> + * @seq: Current sequence number of the endpoint.
> + * @ack: Acknowledge number of the received frame.
> + *
> + * Return: Frames to be acknowledged.
> + */
> +u8 cpc_header_get_frames_acked_count(u8 seq, u8 ack)
> +{
> +	u8 frames_acked_count;
> +
> +	/* Find number of frames acknowledged with ACK number. */
> +	if (ack > seq) {
> +		frames_acked_count = ack - seq;
> +	} else {
> +		frames_acked_count = 256 - seq;
> +		frames_acked_count += ack;
> +	}
> +
> +	return frames_acked_count;
> +}

There is no need to check whether `ack > seq` since the return value in
downcasted to a `u8`. For example, if `ack=0` and `seq=254`, we can
simply do `(u8)(0-254)=2`.

> +static void __cpc_protocol_receive_ack(struct cpc_cport *cport, u8 recv_wnd, u8 ack)
> +{
> +	struct gb_host_device *gb_hd = cport->cpc_hd->gb_hd;
> +	struct sk_buff *skb;
> +	u8 acked_frames;
> +
> +	cport->tcb.send_wnd = recv_wnd;

Little bit of a nitpick, but handling the RX window update in
`__cpc_protocol_receive_ack` seems a bit misleading to me, in the sense
that the ACK itself is not directly related to the window. 

I would either rename the function to indicate that we are handling all 
the CPort's metadata received from the CPC header, or I would move the 
RX window update to the caller.

Thanks,
-- 
Yacin Belmihoub-Martel
Silicon Laboratories


  reply	other threads:[~2025-11-14 20:29 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-14 15:07 [RFC PATCH v2 00/12] greybus: introduce CPC as transport layer Damien Riégel
2025-11-14 15:07 ` [RFC PATCH v2 01/12] greybus: cpc: add minimal CPC Host Device infrastructure Damien Riégel
2025-11-14 16:44   ` Yacin Belmihoub-Martel
2025-11-14 16:51   ` Yacin Belmihoub-Martel
2025-11-14 16:55   ` Yacin Belmihoub-Martel
2025-11-14 15:07 ` [RFC PATCH v2 02/12] greybus: cpc: introduce CPC cport structure Damien Riégel
2025-11-14 15:07 ` [RFC PATCH v2 03/12] greybus: cpc: use socket buffers instead of gb_message in TX path Damien Riégel
2025-11-14 15:07 ` [RFC PATCH v2 04/12] greybus: cpc: pack cport ID in Greybus header Damien Riégel
2025-11-14 15:07 ` [RFC PATCH v2 05/12] greybus: cpc: switch RX path to socket buffers Damien Riégel
2025-11-14 15:07 ` [RFC PATCH v2 06/12] greybus: cpc: introduce CPC header structure Damien Riégel
2025-11-14 15:07 ` [RFC PATCH v2 07/12] greybus: cpc: account for CPC header size in RX and TX path Damien Riégel
2025-11-14 15:07 ` [RFC PATCH v2 08/12] greybus: cpc: add and validate sequence numbers Damien Riégel
2025-11-14 15:07 ` [RFC PATCH v2 09/12] greybus: cpc: acknowledge all incoming messages Damien Riégel
2025-11-14 15:07 ` [RFC PATCH v2 10/12] greybus: cpc: use holding queue instead of sending out immediately Damien Riégel
2025-11-14 19:53   ` Yacin Belmihoub-Martel
2025-11-14 15:07 ` [RFC PATCH v2 11/12] greybus: cpc: honour remote's RX window Damien Riégel
2025-11-14 20:28   ` Yacin Belmihoub-Martel [this message]
2025-11-14 15:07 ` [RFC PATCH v2 12/12] greybus: cpc: let host device drivers dequeue TX frames Damien Riégel
2025-11-25 15:26 ` [RFC PATCH v2 00/12] greybus: introduce CPC as transport layer Damien Riégel
2025-11-26 12:33   ` Greg Kroah-Hartman
2025-12-01 15:39     ` Damien Riégel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DE8P9HDNEZJH.33TRDMVZI1L55@silabs.com \
    --to=yacin.belmihoub-martel@silabs.com \
    --cc=damien.riegel@silabs.com \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-devel@silabs.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.