/** * DOC: cxl features * * CXL Features: * A CXL device that includes a mailbox supports commands that allows * listing, getting, and setting of optionally defined features such * as memory sparing or post package sparing. Vendors may define custom * features for the device.
*/
/* All the features below are exclusive to the kernel */ staticconst uuid_t cxl_exclusive_feats[] = {
CXL_FEAT_PATROL_SCRUB_UUID,
CXL_FEAT_ECS_UUID,
CXL_FEAT_SPPR_UUID,
CXL_FEAT_HPPR_UUID,
CXL_FEAT_CACHELINE_SPARING_UUID,
CXL_FEAT_ROW_SPARING_UUID,
CXL_FEAT_BANK_SPARING_UUID,
CXL_FEAT_RANK_SPARING_UUID,
};
staticbool is_cxl_feature_exclusive_by_uuid(const uuid_t *uuid)
{ for (int i = 0; i < ARRAY_SIZE(cxl_exclusive_feats); i++) { if (uuid_equal(uuid, &cxl_exclusive_feats[i])) returntrue;
}
/* * Make sure retrieved out buffer is multiple of feature * entries.
*/
retrieved = mbox_cmd.size_out - hdr_size; if (retrieved % feat_size) return NULL;
num_entries = le16_to_cpu(mbox_out->num_entries); /* * If the reported output entries * defined entry size != * retrieved output bytes, then the output package is incorrect.
*/ if (num_entries * feat_size != retrieved) return NULL;
memcpy(entry, mbox_out->ents, retrieved); for (int i = 0; i < num_entries; i++) { if (!is_cxl_feature_exclusive(entry + i))
user_feats++;
}
entry += num_entries; /* * If the number of output entries is less than expected, add the * remaining entries to the next batch.
*/
remain_feats += copy_feats - num_entries;
start += num_entries;
} while (remain_feats);
if (return_code)
*return_code = CXL_MBOX_CMD_RC_SUCCESS;
return data_rcvd_size;
}
/* * FEAT_DATA_MIN_PAYLOAD_SIZE - min extra number of bytes should be * available in the mailbox for storing the actual feature data so that * the feature data transfer would work as expected.
*/ #define FEAT_DATA_MIN_PAYLOAD_SIZE 10 int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, u8 feat_version, constvoid *feat_data, size_t feat_data_size,
u32 feat_flag, u16 offset, u16 *return_code)
{
size_t data_in_size, data_sent_size = 0; struct cxl_mbox_cmd mbox_cmd;
size_t hdr_size;
if (return_code)
*return_code = CXL_MBOX_CMD_RC_INPUT;
/* * Make sure that the total requested number of entries is not greater * than the total number of supported features allowed for userspace.
*/ if (start >= cxlfs->entries->num_features) return ERR_PTR(-EINVAL);
for (i = start, pos = &feat_out->ents[0];
i < cxlfs->entries->num_features; i++, pos++) { if (i - start == requested) break;
memcpy(pos, &cxlfs->entries->ent[i], sizeof(*pos)); /* * If the feature is exclusive, set the set_feat_size to 0 to * indicate that the feature is not changeable.
*/ if (is_cxl_feature_exclusive(pos)) {
u32 flags;
if (rpc_in->op_size < sizeof(uuid_t)) returnfalse;
feat = cxl_feature_info(cxlfs, &rpc_in->set_feat_in.uuid); if (IS_ERR(feat)) returnfalse;
/* Ensure that the attribute is changeable */
flags = le32_to_cpu(feat->flags); if (!(flags & CXL_FEATURE_F_CHANGEABLE)) returnfalse;
effects = le16_to_cpu(feat->effects);
/* * Reserved bits are set, rejecting since the effects is not * comprehended by the driver.
*/ if (effects & CXL_CMD_EFFECTS_RESERVED) {
dev_warn_once(cxlfs->cxlds->dev, "Reserved bits set in the Feature effects field!\n"); returnfalse;
}
/* Currently no user background command support */ if (effects & CXL_CMD_BACKGROUND) returnfalse;
/* Effects cause immediate change, highest security scope is needed */
imm_mask = CXL_CMD_CONFIG_CHANGE_IMMEDIATE |
CXL_CMD_DATA_CHANGE_IMMEDIATE |
CXL_CMD_POLICY_CHANGE_IMMEDIATE |
CXL_CMD_LOG_CHANGE_IMMEDIATE;
/* If no immediate or reset effect set, The hardware has a bug */ if (!(effects & imm_mask) && !(effects & reset_mask)) returnfalse;
/* * If the Feature setting causes immediate configuration change * then we need the full write permission policy.
*/ if (effects & imm_mask && scope >= FWCTL_RPC_DEBUG_WRITE_FULL) returntrue;
/* * If the Feature setting only causes configuration change * after a reset, then the lesser level of write permission * policy is ok.
*/ if (!(effects & imm_mask) && scope >= FWCTL_RPC_DEBUG_WRITE) returntrue;
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.6Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.