Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by "Daniel Zahka"
Tue, 17 Nov 2026 20:57
Re: [PATCH iwl-next 08/15] idpf: psp: add support for psp rx key allocation
Author: "Daniel Zahka"
Date: Tue, 17 Nov 2026 20:57
Date: Tue, 17 Nov 2026 20:57
86 lines
14536 bytes
14536 bytes
On Tue Nov 17, 2026 at 9:55 AM EST, Stan Iliev wrote:
> Add support for allocating PSP RX keys on demand:
> - Introduce VIRTCHNL2_OP_PSP_ALLOCATE_KEYS (560),
> enum virtchnl2_psp_allocate_response_flags,
> struct virtchnl2_psp_allocate_keys_request/_response and
> struct virtchnl2_allocate_psp_key_v0/_v1.
> - Implement idpf_send_allocate_psp_key(), which allocates one V0 RX
> key with a synchronous request, validates the reply (key type,
> keys_size_bytes, length, and an SPI with a key ID, which the PSP core
> requires) and wipes the key from the mailbox buffer. The key, its SPI
> and its master key generation are returned in struct idpf_psp_rx_key.
> - Implement the rx_spi_alloc PSP device op. It gets the adapter from
> the netdev of the PSP device, as the vports can be freed while the
> PSP device is registered.
> - Keep a copy of the vport ID in adapter->psp.vport_id, for the same
> reason.
> - Wipe the RX keys of late replies, which libie passes to
> idpf_recv_event_msg() after the request timed out.
>
> Signed-off-by: Stan Iliev <stani@google.com>
> ---
[...]
> +int idpf_send_allocate_psp_key(struct idpf_adapter *adapter,
> + struct idpf_psp_rx_key *key)
> +{
> + struct libie_ctlq_xn_send_params xn_params = {
> + .chnl_opcode = VIRTCHNL2_OP_PSP_ALLOCATE_KEYS,
> + .timeout_ms = IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC,
> + };
> + const struct virtchnl2_psp_allocate_keys_response *vc_reply;
> + struct virtchnl2_psp_allocate_keys_request key_req = { };
> + const struct virtchnl2_allocate_psp_key_v0 *v0_key;
> + size_t reply_sz;
> + u32 spi;
> + int err;
> +
> + BUILD_BUG_ON(sizeof(key->key) != sizeof(v0_key->v0_key));
> +
> + key_req.vport_id = cpu_to_le32(READ_ONCE(adapter->psp.vport_id));
> + key_req.num_keys = cpu_to_le32(1);
> + key_req.key_type = VIRTCHNL2_PSP_KEY_TYPE_V0;
> + /* key_req.domain stays zeroed: VIRTCHNL2_PSP_DOMAIN_NONE */
> +
> + err = idpf_send_mb_msg_stack(adapter, &xn_params, &key_req);
> + if (err)
> + return err;
> +
> + reply_sz = xn_params.recv_mem.iov_len;
> + vc_reply = xn_params.recv_mem.iov_base;
> + if (reply_sz < sizeof(*vc_reply) + sizeof(*v0_key) ||
> + vc_reply->key_type != VIRTCHNL2_PSP_KEY_TYPE_V0 ||
> + le32_to_cpu(vc_reply->keys_size_bytes) != sizeof(*v0_key)) {
> + net_warn_ratelimited("%s: invalid reply of %zu bytes\n",
> + __func__, reply_sz);
> + err = -EIO;
> + goto release_rx;
> + }
> +
> + v0_key = (const struct virtchnl2_allocate_psp_key_v0 *)vc_reply->keys;
> + spi = le32_to_cpu(v0_key->spi);
> + if (!(spi & PSP_SPI_KEY_ID)) {
> + net_warn_ratelimited("%s: invalid SPI %#x\n", __func__, spi);
> + err = -EIO;
nit: seems a bit defensive not to trust the fw to provide a valid SPI.
No issues with keeping it around though.
> + goto release_rx;
> + }
> +
> + key->spi = cpu_to_be32(spi);
> + key->generation = le32_to_cpu(vc_reply->master_key_generation);
> + memcpy(key->key, v0_key->v0_key, sizeof(key->key));
> + atomic_inc(&adapter->psp.keys_allocated);
> +
> +release_rx:
> + /* Don't leave the RX key in the recycled mailbox buffer */
> + memzero_explicit(xn_params.recv_mem.iov_base, reply_sz);
> + libie_ctlq_release_rx_buf(&xn_params.recv_mem);
> + return err;
> +}
> +
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads