From: Simon Horman <horms@kernel.org>
To: Satish Kharat <satishkh@cisco.com>
Cc: Christian Benvenuti <benve@cisco.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Nelson Escobar <neescoba@cisco.com>,
John Daley <johndale@cisco.com>
Subject: Re: [PATCH net-next v3 4/8] enic: enable rq extended cq support
Date: Fri, 7 Mar 2025 18:00:06 +0000 [thread overview]
Message-ID: <20250307180006.GK3666230@kernel.org> (raw)
In-Reply-To: <20250306-enic_cleanup_and_ext_cq-v3-4-92bc165344cf@cisco.com>
On Thu, Mar 06, 2025 at 07:15:25PM -0500, Satish Kharat via B4 Relay wrote:
> From: Satish Kharat <satishkh@cisco.com>
>
> Enables getting from hw all the supported rq cq sizes and
> uses the highest supported cq size.
>
> Co-developed-by: Nelson Escobar <neescoba@cisco.com>
> Signed-off-by: Nelson Escobar <neescoba@cisco.com>
> Co-developed-by: John Daley <johndale@cisco.com>
> Signed-off-by: John Daley <johndale@cisco.com>
> Signed-off-by: Satish Kharat <satishkh@cisco.com>
...
> diff --git a/drivers/net/ethernet/cisco/enic/enic_rq.c b/drivers/net/ethernet/cisco/enic/enic_rq.c
> index 842b273c2e2a59e81a7c1423449b023d646f5e81..ccbf5c9a21d0ffe33c7c74042d5425497ea0f9dc 100644
> --- a/drivers/net/ethernet/cisco/enic/enic_rq.c
> +++ b/drivers/net/ethernet/cisco/enic/enic_rq.c
> @@ -21,24 +21,76 @@ static void enic_intr_update_pkt_size(struct vnic_rx_bytes_counter *pkt_size,
> pkt_size->small_pkt_bytes_cnt += pkt_len;
> }
>
> -static void enic_rq_cq_desc_dec(struct cq_enet_rq_desc *desc, u8 *type,
> +static void enic_rq_cq_desc_dec(void *cq_desc, u8 cq_desc_size, u8 *type,
> u8 *color, u16 *q_number, u16 *completed_index)
> {
> /* type_color is the last field for all cq structs */
> - u8 type_color = desc->type_color;
> + u8 type_color;
> +
> + switch (cq_desc_size) {
> + case VNIC_RQ_CQ_ENTRY_SIZE_16: {
> + struct cq_enet_rq_desc *desc =
> + (struct cq_enet_rq_desc *)cq_desc;
> + type_color = desc->type_color;
> +
> + /* Make sure color bit is read from desc *before* other fields
> + * are read from desc. Hardware guarantees color bit is last
> + * bit (byte) written. Adding the rmb() prevents the compiler
> + * and/or CPU from reordering the reads which would potentially
> + * result in reading stale values.
> + */
> + rmb();
>
> - /* Make sure color bit is read from desc *before* other fields
> - * are read from desc. Hardware guarantees color bit is last
> - * bit (byte) written. Adding the rmb() prevents the compiler
> - * and/or CPU from reordering the reads which would potentially
> - * result in reading stale values.
> - */
> - rmb();
> + *q_number = le16_to_cpu(desc->q_number_rss_type_flags) &
> + CQ_DESC_Q_NUM_MASK;
> + *completed_index = le16_to_cpu(desc->completed_index_flags) &
> + CQ_DESC_COMP_NDX_MASK;
> + break;
> + }
> + case VNIC_RQ_CQ_ENTRY_SIZE_32: {
> + struct cq_enet_rq_desc_32 *desc =
> + (struct cq_enet_rq_desc_32 *)cq_desc;
> + type_color = desc->type_color;
> +
> + /* Make sure color bit is read from desc *before* other fields
> + * are read from desc. Hardware guarantees color bit is last
> + * bit (byte) written. Adding the rmb() prevents the compiler
> + * and/or CPU from reordering the reads which would potentially
> + * result in reading stale values.
> + */
> + rmb();
> +
> + *q_number = le16_to_cpu(desc->q_number_rss_type_flags) &
> + CQ_DESC_Q_NUM_MASK;
> + *completed_index = le16_to_cpu(desc->completed_index_flags) &
> + CQ_DESC_COMP_NDX_MASK;
> + *completed_index |= (desc->fetch_index_flags & CQ_DESC_32_FI_MASK) <<
> + CQ_DESC_COMP_NDX_BITS;
> + break;
> + }
> + case VNIC_RQ_CQ_ENTRY_SIZE_64: {
> + struct cq_enet_rq_desc_64 *desc =
> + (struct cq_enet_rq_desc_64 *)cq_desc;
> + type_color = desc->type_color;
> +
> + /* Make sure color bit is read from desc *before* other fields
> + * are read from desc. Hardware guarantees color bit is last
> + * bit (byte) written. Adding the rmb() prevents the compiler
> + * and/or CPU from reordering the reads which would potentially
> + * result in reading stale values.
> + */
> + rmb();
> +
> + *q_number = le16_to_cpu(desc->q_number_rss_type_flags) &
> + CQ_DESC_Q_NUM_MASK;
> + *completed_index = le16_to_cpu(desc->completed_index_flags) &
> + CQ_DESC_COMP_NDX_MASK;
> + *completed_index |= (desc->fetch_index_flags & CQ_DESC_64_FI_MASK) <<
> + CQ_DESC_COMP_NDX_BITS;
> + break;
> + }
> + }
>
> - *q_number = le16_to_cpu(desc->q_number_rss_type_flags) &
> - CQ_DESC_Q_NUM_MASK;
> - *completed_index = le16_to_cpu(desc->completed_index_flags) &
> - CQ_DESC_COMP_NDX_MASK;
> *color = (type_color >> CQ_DESC_COLOR_SHIFT) & CQ_DESC_COLOR_MASK;
> *type = type_color & CQ_DESC_TYPE_MASK;
Hi Satish, all,
I'm unsure if this can occur in practice, but it seems that if
none of the cases above are met then type_color will be used
uninitialised here.
Flagged by Smatch.
> }
...
next prev parent reply other threads:[~2025-03-07 18:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 0:15 [PATCH net-next v3 0/8] enic: enable 32, 64 byte cqes and get max rx/tx ring size from hw Satish Kharat
2025-03-07 0:15 ` Satish Kharat via B4 Relay
2025-03-07 0:15 ` [PATCH net-next v3 1/8] enic: Move function from header file to c file Satish Kharat
2025-03-07 0:15 ` Satish Kharat via B4 Relay
2025-03-07 0:15 ` [PATCH net-next v3 2/8] enic: enic rq code reorg Satish Kharat
2025-03-07 0:15 ` Satish Kharat via B4 Relay
2025-03-07 0:15 ` [PATCH net-next v3 3/8] enic: enic rq extended cq defines Satish Kharat
2025-03-07 0:15 ` Satish Kharat via B4 Relay
2025-03-07 0:15 ` [PATCH net-next v3 4/8] enic: enable rq extended cq support Satish Kharat
2025-03-07 0:15 ` Satish Kharat via B4 Relay
2025-03-07 18:00 ` Simon Horman [this message]
2025-03-07 0:15 ` [PATCH net-next v3 5/8] enic: remove unused function cq_enet_wq_desc_dec Satish Kharat
2025-03-07 0:15 ` Satish Kharat via B4 Relay
2025-03-07 0:15 ` [PATCH net-next v3 6/8] enic: added enic_wq.c and enic_wq.h Satish Kharat
2025-03-07 0:15 ` Satish Kharat via B4 Relay
2025-03-07 0:15 ` [PATCH net-next v3 7/8] enic: cleanup of enic wq request completion path Satish Kharat
2025-03-07 0:15 ` Satish Kharat via B4 Relay
2025-03-07 0:15 ` [PATCH net-next v3 8/8] enic: get max rq & wq entries supported by hw, 16K queues Satish Kharat
2025-03-07 0:15 ` Satish Kharat via B4 Relay
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=20250307180006.GK3666230@kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=benve@cisco.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=johndale@cisco.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neescoba@cisco.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=satishkh@cisco.com \
/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.