[PATCH v9 04/17] net/nbl: add Channel layer definitions and implementation
Stephen Hemminger
stephen at networkplumber.org
Thu Sep 18 18:33:17 CEST 2025
On Wed, 17 Sep 2025 01:08:30 -0700
Dimon Zhao <dimon.zhao at nebula-matrix.com> wrote:
> +static void nbl_chan_recv_ack_msg(void *priv, uint16_t srcid, uint16_t msgid,
> + void *data, uint32_t data_len)
> +{
> + struct nbl_channel_mgt *chan_mgt = (struct nbl_channel_mgt *)priv;
> + union nbl_chan_info *chan_info = NULL;
> + struct nbl_chan_waitqueue_head *wait_head;
> + uint32_t *payload = (uint32_t *)data;
> + uint32_t ack_msgid;
> + uint32_t ack_msgtype;
> + uint32_t copy_len;
> +
> + chan_info = NBL_CHAN_MGT_TO_CHAN_INFO(chan_mgt);
> + ack_msgtype = *payload;
> + ack_msgid = *(payload + 1);
> + wait_head = &chan_info->mailbox.wait[ack_msgid];
> + wait_head->ack_err = *(payload + 2);
> +
> + if (wait_head->ack_err >= 0 && (data_len > 3 * sizeof(uint32_t))) {
> + if (data_len - 3 * sizeof(uint32_t) != wait_head->ack_data_len)
> + NBL_LOG(ERR, "payload_len do not match ack_len!,"
> + " srcid:%u, msgtype:%u, msgid:%u, ack_msgid %u,"
> + " data_len:%u, ack_data_len:%u",
> + srcid, ack_msgtype, msgid,
> + ack_msgid, data_len, wait_head->ack_data_len);
> + copy_len = RTE_MIN((u32)wait_head->ack_data_len,
> + (u32)data_len - 3 * sizeof(uint32_t));
> + memcpy(wait_head->ack_data, payload + 3, copy_len);
> + }
> +
> + /* wmb */
> + rte_wmb();
> + wait_head->acked = 1;
> +}
The C11 atomic (rte_atomic) model is preferred over using memory barriers.
In this case you want to ensure the wati_head is updated before the
store to acked. That would rte_memory_order_release or rte_memory_order_seq_cst.
More information about the dev
mailing list