Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cxl: Add support to handle user feature commands for get feature

Add helper function to parse the user data from fwctl RPC ioctl and
send the parsed input parameters to cxl_get_feature() call.

Link: https://patch.msgid.link/r/20250307205648.1021626-5-dave.jiang@intel.com
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Li Ming <ming.li@zohomail.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Dave Jiang and committed by
Jason Gunthorpe
5908f3ed 4d1c09ce

+54 -2
+44
drivers/cxl/core/features.c
··· 427 427 return no_free_ptr(rpc_out); 428 428 } 429 429 430 + static void *cxlctl_get_feature(struct cxl_features_state *cxlfs, 431 + const struct fwctl_rpc_cxl *rpc_in, 432 + size_t *out_len) 433 + { 434 + struct cxl_mailbox *cxl_mbox = &cxlfs->cxlds->cxl_mbox; 435 + const struct cxl_mbox_get_feat_in *feat_in; 436 + u16 offset, count, return_code; 437 + size_t out_size = *out_len; 438 + 439 + if (rpc_in->op_size != sizeof(*feat_in)) 440 + return ERR_PTR(-EINVAL); 441 + 442 + feat_in = &rpc_in->get_feat_in; 443 + offset = le16_to_cpu(feat_in->offset); 444 + count = le16_to_cpu(feat_in->count); 445 + 446 + if (!count) 447 + return ERR_PTR(-EINVAL); 448 + 449 + struct fwctl_rpc_cxl_out *rpc_out __free(kvfree) = 450 + kvzalloc(out_size, GFP_KERNEL); 451 + if (!rpc_out) 452 + return ERR_PTR(-ENOMEM); 453 + 454 + out_size = cxl_get_feature(cxl_mbox, &feat_in->uuid, 455 + feat_in->selection, rpc_out->payload, 456 + count, offset, &return_code); 457 + *out_len = sizeof(struct fwctl_rpc_cxl_out); 458 + if (!out_size) { 459 + rpc_out->size = 0; 460 + rpc_out->retval = return_code; 461 + return no_free_ptr(rpc_out); 462 + } 463 + 464 + rpc_out->size = out_size; 465 + rpc_out->retval = CXL_MBOX_CMD_RC_SUCCESS; 466 + *out_len += out_size; 467 + 468 + return no_free_ptr(rpc_out); 469 + } 470 + 430 471 static bool cxlctl_validate_hw_command(struct cxl_features_state *cxlfs, 431 472 const struct fwctl_rpc_cxl *rpc_in, 432 473 enum fwctl_rpc_scope scope, ··· 477 436 478 437 switch (opcode) { 479 438 case CXL_MBOX_OP_GET_SUPPORTED_FEATURES: 439 + case CXL_MBOX_OP_GET_FEATURE: 480 440 if (cxl_mbox->feat_cap < CXL_FEATURES_RO) 481 441 return false; 482 442 if (scope >= FWCTL_RPC_CONFIGURATION) ··· 495 453 switch (opcode) { 496 454 case CXL_MBOX_OP_GET_SUPPORTED_FEATURES: 497 455 return cxlctl_get_supported_features(cxlfs, rpc_in, out_len); 456 + case CXL_MBOX_OP_GET_FEATURE: 457 + return cxlctl_get_feature(cxlfs, rpc_in, out_len); 498 458 default: 499 459 return ERR_PTR(-EOPNOTSUPP); 500 460 }
+10 -2
include/uapi/fwctl/cxl.h
··· 18 18 * @op_size: Size of input payload. 19 19 * @reserved1: Reserved. Must be 0s. 20 20 * @get_sup_feats_in: Get Supported Features input 21 + * @get_feat_in: Get Feature input 21 22 */ 22 23 struct fwctl_rpc_cxl { 23 24 __struct_group(fwctl_rpc_cxl_hdr, hdr, /* no attrs */, ··· 27 26 __u32 op_size; 28 27 __u32 reserved1; 29 28 ); 30 - struct cxl_mbox_get_sup_feats_in get_sup_feats_in; 29 + union { 30 + struct cxl_mbox_get_sup_feats_in get_sup_feats_in; 31 + struct cxl_mbox_get_feat_in get_feat_in; 32 + }; 31 33 }; 32 34 33 35 /** ··· 38 34 * @size: Size of the output payload 39 35 * @retval: Return value from device 40 36 * @get_sup_feats_out: Get Supported Features output 37 + * @payload: raw byte stream of payload 41 38 */ 42 39 struct fwctl_rpc_cxl_out { 43 40 __struct_group(fwctl_rpc_cxl_out_hdr, hdr, /* no attrs */, 44 41 __u32 size; 45 42 __u32 retval; 46 43 ); 47 - struct cxl_mbox_get_sup_feats_out get_sup_feats_out; 44 + union { 45 + struct cxl_mbox_get_sup_feats_out get_sup_feats_out; 46 + __DECLARE_FLEX_ARRAY(__u8, payload); 47 + }; 48 48 }; 49 49 50 50 #endif