block: sed-opal: unify cmd start
Every step starts with resetting the cmd buffer as well as the comid and constructs the appropriate OPAL_CALL command. Consequently, those actions may be combined into one generic function. On should take care that the opening and closing tokens for the argument list are already emitted by cmd_start and cmd_finalize respectively and thus must not be additionally added. Co-authored-by: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de> Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz> Signed-off-by: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de> Reviewed-by: Scott Bauer <sbauer@plzdonthack.me> Reviewed-by: Christoph Hellwig <hch@lst.de> Acked-by: Jon Derrick <jonathan.derrick@intel.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Родитель
78d584ca31
Коммит
e8b2922459
228
block/sed-opal.c
228
block/sed-opal.c
|
@ -655,7 +655,7 @@ static int cmd_finalize(struct opal_dev *cmd, u32 hsn, u32 tsn)
|
||||||
struct opal_header *hdr;
|
struct opal_header *hdr;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
/* close parameter list */
|
/* close the parameter list opened from cmd_start */
|
||||||
add_token_u8(&err, cmd, OPAL_ENDLIST);
|
add_token_u8(&err, cmd, OPAL_ENDLIST);
|
||||||
|
|
||||||
add_token_u8(&err, cmd, OPAL_ENDOFDATA);
|
add_token_u8(&err, cmd, OPAL_ENDOFDATA);
|
||||||
|
@ -1000,6 +1000,27 @@ static void clear_opal_cmd(struct opal_dev *dev)
|
||||||
memset(dev->cmd, 0, IO_BUFFER_LENGTH);
|
memset(dev->cmd, 0, IO_BUFFER_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cmd_start(struct opal_dev *dev, const u8 *uid, const u8 *method)
|
||||||
|
{
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
clear_opal_cmd(dev);
|
||||||
|
set_comid(dev, dev->comid);
|
||||||
|
|
||||||
|
add_token_u8(&err, dev, OPAL_CALL);
|
||||||
|
add_token_bytestring(&err, dev, uid, OPAL_UID_LENGTH);
|
||||||
|
add_token_bytestring(&err, dev, method, OPAL_METHOD_LENGTH);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Every method call is followed by its parameters enclosed within
|
||||||
|
* OPAL_STARTLIST and OPAL_ENDLIST tokens. We automatically open the
|
||||||
|
* parameter list here and close it later in cmd_finalize.
|
||||||
|
*/
|
||||||
|
add_token_u8(&err, dev, OPAL_STARTLIST);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
static int start_opal_session_cont(struct opal_dev *dev)
|
static int start_opal_session_cont(struct opal_dev *dev)
|
||||||
{
|
{
|
||||||
u32 hsn, tsn;
|
u32 hsn, tsn;
|
||||||
|
@ -1062,20 +1083,13 @@ static int finalize_and_send(struct opal_dev *dev, cont_fn cont)
|
||||||
static int gen_key(struct opal_dev *dev, void *data)
|
static int gen_key(struct opal_dev *dev, void *data)
|
||||||
{
|
{
|
||||||
u8 uid[OPAL_UID_LENGTH];
|
u8 uid[OPAL_UID_LENGTH];
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
|
||||||
set_comid(dev, dev->comid);
|
|
||||||
|
|
||||||
memcpy(uid, dev->prev_data, min(sizeof(uid), dev->prev_d_len));
|
memcpy(uid, dev->prev_data, min(sizeof(uid), dev->prev_d_len));
|
||||||
kfree(dev->prev_data);
|
kfree(dev->prev_data);
|
||||||
dev->prev_data = NULL;
|
dev->prev_data = NULL;
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
err = cmd_start(dev, uid, opalmethod[OPAL_GENKEY]);
|
||||||
add_token_bytestring(&err, dev, uid, OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_GENKEY],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
pr_debug("Error building gen key command\n");
|
pr_debug("Error building gen key command\n");
|
||||||
|
@ -1113,21 +1127,14 @@ static int get_active_key_cont(struct opal_dev *dev)
|
||||||
static int get_active_key(struct opal_dev *dev, void *data)
|
static int get_active_key(struct opal_dev *dev, void *data)
|
||||||
{
|
{
|
||||||
u8 uid[OPAL_UID_LENGTH];
|
u8 uid[OPAL_UID_LENGTH];
|
||||||
int err = 0;
|
int err;
|
||||||
u8 *lr = data;
|
u8 *lr = data;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
|
||||||
set_comid(dev, dev->comid);
|
|
||||||
|
|
||||||
err = build_locking_range(uid, sizeof(uid), *lr);
|
err = build_locking_range(uid, sizeof(uid), *lr);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
err = 0;
|
err = cmd_start(dev, uid, opalmethod[OPAL_GET]);
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
|
||||||
add_token_bytestring(&err, dev, uid, OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_GET], OPAL_UID_LENGTH);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
add_token_u8(&err, dev, OPAL_STARTLIST);
|
||||||
add_token_u8(&err, dev, OPAL_STARTNAME);
|
add_token_u8(&err, dev, OPAL_STARTNAME);
|
||||||
add_token_u8(&err, dev, 3); /* startCloumn */
|
add_token_u8(&err, dev, 3); /* startCloumn */
|
||||||
|
@ -1150,13 +1157,10 @@ static int generic_lr_enable_disable(struct opal_dev *dev,
|
||||||
u8 *uid, bool rle, bool wle,
|
u8 *uid, bool rle, bool wle,
|
||||||
bool rl, bool wl)
|
bool rl, bool wl)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
err = cmd_start(dev, uid, opalmethod[OPAL_SET]);
|
||||||
add_token_bytestring(&err, dev, uid, OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_SET], OPAL_UID_LENGTH);
|
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTNAME);
|
add_token_u8(&err, dev, OPAL_STARTNAME);
|
||||||
add_token_u8(&err, dev, OPAL_VALUES);
|
add_token_u8(&err, dev, OPAL_VALUES);
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
add_token_u8(&err, dev, OPAL_STARTLIST);
|
||||||
|
@ -1203,10 +1207,7 @@ static int setup_locking_range(struct opal_dev *dev, void *data)
|
||||||
u8 uid[OPAL_UID_LENGTH];
|
u8 uid[OPAL_UID_LENGTH];
|
||||||
struct opal_user_lr_setup *setup = data;
|
struct opal_user_lr_setup *setup = data;
|
||||||
u8 lr;
|
u8 lr;
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
|
||||||
set_comid(dev, dev->comid);
|
|
||||||
|
|
||||||
lr = setup->session.opal_key.lr;
|
lr = setup->session.opal_key.lr;
|
||||||
err = build_locking_range(uid, sizeof(uid), lr);
|
err = build_locking_range(uid, sizeof(uid), lr);
|
||||||
|
@ -1216,12 +1217,8 @@ static int setup_locking_range(struct opal_dev *dev, void *data)
|
||||||
if (lr == 0)
|
if (lr == 0)
|
||||||
err = enable_global_lr(dev, uid, setup);
|
err = enable_global_lr(dev, uid, setup);
|
||||||
else {
|
else {
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
err = cmd_start(dev, uid, opalmethod[OPAL_SET]);
|
||||||
add_token_bytestring(&err, dev, uid, OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_SET],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTNAME);
|
add_token_u8(&err, dev, OPAL_STARTNAME);
|
||||||
add_token_u8(&err, dev, OPAL_VALUES);
|
add_token_u8(&err, dev, OPAL_VALUES);
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
add_token_u8(&err, dev, OPAL_STARTLIST);
|
||||||
|
@ -1265,22 +1262,15 @@ static int start_generic_opal_session(struct opal_dev *dev,
|
||||||
u8 key_len)
|
u8 key_len)
|
||||||
{
|
{
|
||||||
u32 hsn;
|
u32 hsn;
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
if (key == NULL && auth != OPAL_ANYBODY_UID)
|
if (key == NULL && auth != OPAL_ANYBODY_UID)
|
||||||
return OPAL_INVAL_PARAM;
|
return OPAL_INVAL_PARAM;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
|
||||||
|
|
||||||
set_comid(dev, dev->comid);
|
|
||||||
hsn = GENERIC_HOST_SESSION_NUM;
|
hsn = GENERIC_HOST_SESSION_NUM;
|
||||||
|
err = cmd_start(dev, opaluid[OPAL_SMUID_UID],
|
||||||
|
opalmethod[OPAL_STARTSESSION]);
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
|
||||||
add_token_bytestring(&err, dev, opaluid[OPAL_SMUID_UID],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_STARTSESSION],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
add_token_u64(&err, dev, hsn);
|
add_token_u64(&err, dev, hsn);
|
||||||
add_token_bytestring(&err, dev, opaluid[sp_type], OPAL_UID_LENGTH);
|
add_token_bytestring(&err, dev, opaluid[sp_type], OPAL_UID_LENGTH);
|
||||||
add_token_u8(&err, dev, 1);
|
add_token_u8(&err, dev, 1);
|
||||||
|
@ -1360,30 +1350,21 @@ static int start_auth_opal_session(struct opal_dev *dev, void *data)
|
||||||
u8 *key = session->opal_key.key;
|
u8 *key = session->opal_key.key;
|
||||||
u32 hsn = GENERIC_HOST_SESSION_NUM;
|
u32 hsn = GENERIC_HOST_SESSION_NUM;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
if (session->sum)
|
||||||
set_comid(dev, dev->comid);
|
|
||||||
|
|
||||||
if (session->sum) {
|
|
||||||
err = build_locking_user(lk_ul_user, sizeof(lk_ul_user),
|
err = build_locking_user(lk_ul_user, sizeof(lk_ul_user),
|
||||||
session->opal_key.lr);
|
session->opal_key.lr);
|
||||||
if (err)
|
else if (session->who != OPAL_ADMIN1 && !session->sum)
|
||||||
return err;
|
|
||||||
|
|
||||||
} else if (session->who != OPAL_ADMIN1 && !session->sum) {
|
|
||||||
err = build_locking_user(lk_ul_user, sizeof(lk_ul_user),
|
err = build_locking_user(lk_ul_user, sizeof(lk_ul_user),
|
||||||
session->who - 1);
|
session->who - 1);
|
||||||
if (err)
|
else
|
||||||
return err;
|
|
||||||
} else
|
|
||||||
memcpy(lk_ul_user, opaluid[OPAL_ADMIN1_UID], OPAL_UID_LENGTH);
|
memcpy(lk_ul_user, opaluid[OPAL_ADMIN1_UID], OPAL_UID_LENGTH);
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
if (err)
|
||||||
add_token_bytestring(&err, dev, opaluid[OPAL_SMUID_UID],
|
return err;
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_STARTSESSION],
|
err = cmd_start(dev, opaluid[OPAL_SMUID_UID],
|
||||||
OPAL_UID_LENGTH);
|
opalmethod[OPAL_STARTSESSION]);
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
add_token_u64(&err, dev, hsn);
|
add_token_u64(&err, dev, hsn);
|
||||||
add_token_bytestring(&err, dev, opaluid[OPAL_LOCKINGSP_UID],
|
add_token_bytestring(&err, dev, opaluid[OPAL_LOCKINGSP_UID],
|
||||||
OPAL_UID_LENGTH);
|
OPAL_UID_LENGTH);
|
||||||
|
@ -1407,17 +1388,10 @@ static int start_auth_opal_session(struct opal_dev *dev, void *data)
|
||||||
|
|
||||||
static int revert_tper(struct opal_dev *dev, void *data)
|
static int revert_tper(struct opal_dev *dev, void *data)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
err = cmd_start(dev, opaluid[OPAL_ADMINSP_UID],
|
||||||
set_comid(dev, dev->comid);
|
opalmethod[OPAL_REVERT]);
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
|
||||||
add_token_bytestring(&err, dev, opaluid[OPAL_ADMINSP_UID],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_REVERT],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
pr_debug("Error building REVERT TPER command.\n");
|
pr_debug("Error building REVERT TPER command.\n");
|
||||||
return err;
|
return err;
|
||||||
|
@ -1430,18 +1404,12 @@ static int internal_activate_user(struct opal_dev *dev, void *data)
|
||||||
{
|
{
|
||||||
struct opal_session_info *session = data;
|
struct opal_session_info *session = data;
|
||||||
u8 uid[OPAL_UID_LENGTH];
|
u8 uid[OPAL_UID_LENGTH];
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
|
||||||
set_comid(dev, dev->comid);
|
|
||||||
|
|
||||||
memcpy(uid, opaluid[OPAL_USER1_UID], OPAL_UID_LENGTH);
|
memcpy(uid, opaluid[OPAL_USER1_UID], OPAL_UID_LENGTH);
|
||||||
uid[7] = session->who;
|
uid[7] = session->who;
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
err = cmd_start(dev, uid, opalmethod[OPAL_SET]);
|
||||||
add_token_bytestring(&err, dev, uid, OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_SET], OPAL_UID_LENGTH);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTNAME);
|
add_token_u8(&err, dev, OPAL_STARTNAME);
|
||||||
add_token_u8(&err, dev, OPAL_VALUES);
|
add_token_u8(&err, dev, OPAL_VALUES);
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
add_token_u8(&err, dev, OPAL_STARTLIST);
|
||||||
|
@ -1464,19 +1432,12 @@ static int erase_locking_range(struct opal_dev *dev, void *data)
|
||||||
{
|
{
|
||||||
struct opal_session_info *session = data;
|
struct opal_session_info *session = data;
|
||||||
u8 uid[OPAL_UID_LENGTH];
|
u8 uid[OPAL_UID_LENGTH];
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
|
||||||
set_comid(dev, dev->comid);
|
|
||||||
|
|
||||||
if (build_locking_range(uid, sizeof(uid), session->opal_key.lr) < 0)
|
if (build_locking_range(uid, sizeof(uid), session->opal_key.lr) < 0)
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
err = cmd_start(dev, uid, opalmethod[OPAL_ERASE]);
|
||||||
add_token_bytestring(&err, dev, uid, OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_ERASE],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
pr_debug("Error building Erase Locking Range Command.\n");
|
pr_debug("Error building Erase Locking Range Command.\n");
|
||||||
|
@ -1488,16 +1449,11 @@ static int erase_locking_range(struct opal_dev *dev, void *data)
|
||||||
static int set_mbr_done(struct opal_dev *dev, void *data)
|
static int set_mbr_done(struct opal_dev *dev, void *data)
|
||||||
{
|
{
|
||||||
u8 *mbr_done_tf = data;
|
u8 *mbr_done_tf = data;
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
err = cmd_start(dev, opaluid[OPAL_MBRCONTROL],
|
||||||
set_comid(dev, dev->comid);
|
opalmethod[OPAL_SET]);
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
|
||||||
add_token_bytestring(&err, dev, opaluid[OPAL_MBRCONTROL],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_SET], OPAL_UID_LENGTH);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTNAME);
|
add_token_u8(&err, dev, OPAL_STARTNAME);
|
||||||
add_token_u8(&err, dev, OPAL_VALUES);
|
add_token_u8(&err, dev, OPAL_VALUES);
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
add_token_u8(&err, dev, OPAL_STARTLIST);
|
||||||
|
@ -1519,16 +1475,11 @@ static int set_mbr_done(struct opal_dev *dev, void *data)
|
||||||
static int set_mbr_enable_disable(struct opal_dev *dev, void *data)
|
static int set_mbr_enable_disable(struct opal_dev *dev, void *data)
|
||||||
{
|
{
|
||||||
u8 *mbr_en_dis = data;
|
u8 *mbr_en_dis = data;
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
err = cmd_start(dev, opaluid[OPAL_MBRCONTROL],
|
||||||
set_comid(dev, dev->comid);
|
opalmethod[OPAL_SET]);
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
|
||||||
add_token_bytestring(&err, dev, opaluid[OPAL_MBRCONTROL],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_SET], OPAL_UID_LENGTH);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTNAME);
|
add_token_u8(&err, dev, OPAL_STARTNAME);
|
||||||
add_token_u8(&err, dev, OPAL_VALUES);
|
add_token_u8(&err, dev, OPAL_VALUES);
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
add_token_u8(&err, dev, OPAL_STARTLIST);
|
||||||
|
@ -1550,16 +1501,10 @@ static int set_mbr_enable_disable(struct opal_dev *dev, void *data)
|
||||||
static int generic_pw_cmd(u8 *key, size_t key_len, u8 *cpin_uid,
|
static int generic_pw_cmd(u8 *key, size_t key_len, u8 *cpin_uid,
|
||||||
struct opal_dev *dev)
|
struct opal_dev *dev)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
err = cmd_start(dev, cpin_uid, opalmethod[OPAL_SET]);
|
||||||
set_comid(dev, dev->comid);
|
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
|
||||||
add_token_bytestring(&err, dev, cpin_uid, OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_SET],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTNAME);
|
add_token_u8(&err, dev, OPAL_STARTNAME);
|
||||||
add_token_u8(&err, dev, OPAL_VALUES);
|
add_token_u8(&err, dev, OPAL_VALUES);
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
add_token_u8(&err, dev, OPAL_STARTLIST);
|
||||||
|
@ -1616,10 +1561,7 @@ static int add_user_to_lr(struct opal_dev *dev, void *data)
|
||||||
u8 lr_buffer[OPAL_UID_LENGTH];
|
u8 lr_buffer[OPAL_UID_LENGTH];
|
||||||
u8 user_uid[OPAL_UID_LENGTH];
|
u8 user_uid[OPAL_UID_LENGTH];
|
||||||
struct opal_lock_unlock *lkul = data;
|
struct opal_lock_unlock *lkul = data;
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
|
||||||
set_comid(dev, dev->comid);
|
|
||||||
|
|
||||||
memcpy(lr_buffer, opaluid[OPAL_LOCKINGRANGE_ACE_RDLOCKED],
|
memcpy(lr_buffer, opaluid[OPAL_LOCKINGRANGE_ACE_RDLOCKED],
|
||||||
OPAL_UID_LENGTH);
|
OPAL_UID_LENGTH);
|
||||||
|
@ -1634,12 +1576,8 @@ static int add_user_to_lr(struct opal_dev *dev, void *data)
|
||||||
|
|
||||||
user_uid[7] = lkul->session.who;
|
user_uid[7] = lkul->session.who;
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
err = cmd_start(dev, lr_buffer, opalmethod[OPAL_SET]);
|
||||||
add_token_bytestring(&err, dev, lr_buffer, OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_SET],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTNAME);
|
add_token_u8(&err, dev, OPAL_STARTNAME);
|
||||||
add_token_u8(&err, dev, OPAL_VALUES);
|
add_token_u8(&err, dev, OPAL_VALUES);
|
||||||
|
|
||||||
|
@ -1693,9 +1631,6 @@ static int lock_unlock_locking_range(struct opal_dev *dev, void *data)
|
||||||
u8 read_locked = 1, write_locked = 1;
|
u8 read_locked = 1, write_locked = 1;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
|
||||||
set_comid(dev, dev->comid);
|
|
||||||
|
|
||||||
if (build_locking_range(lr_buffer, sizeof(lr_buffer),
|
if (build_locking_range(lr_buffer, sizeof(lr_buffer),
|
||||||
lkul->session.opal_key.lr) < 0)
|
lkul->session.opal_key.lr) < 0)
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
|
@ -1717,10 +1652,8 @@ static int lock_unlock_locking_range(struct opal_dev *dev, void *data)
|
||||||
return OPAL_INVAL_PARAM;
|
return OPAL_INVAL_PARAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
err = cmd_start(dev, lr_buffer, opalmethod[OPAL_SET]);
|
||||||
add_token_bytestring(&err, dev, lr_buffer, OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_SET], OPAL_UID_LENGTH);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTNAME);
|
add_token_u8(&err, dev, OPAL_STARTNAME);
|
||||||
add_token_u8(&err, dev, OPAL_VALUES);
|
add_token_u8(&err, dev, OPAL_VALUES);
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
add_token_u8(&err, dev, OPAL_STARTLIST);
|
||||||
|
@ -1791,17 +1724,10 @@ static int activate_lsp(struct opal_dev *dev, void *data)
|
||||||
struct opal_lr_act *opal_act = data;
|
struct opal_lr_act *opal_act = data;
|
||||||
u8 user_lr[OPAL_UID_LENGTH];
|
u8 user_lr[OPAL_UID_LENGTH];
|
||||||
u8 uint_3 = 0x83;
|
u8 uint_3 = 0x83;
|
||||||
int err = 0, i;
|
int err, i;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
|
||||||
set_comid(dev, dev->comid);
|
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
|
||||||
add_token_bytestring(&err, dev, opaluid[OPAL_LOCKINGSP_UID],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_ACTIVATE],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
|
|
||||||
|
err = cmd_start(dev, opaluid[OPAL_LOCKINGSP_UID],
|
||||||
|
opalmethod[OPAL_ACTIVATE]);
|
||||||
|
|
||||||
if (opal_act->sum) {
|
if (opal_act->sum) {
|
||||||
err = build_locking_range(user_lr, sizeof(user_lr),
|
err = build_locking_range(user_lr, sizeof(user_lr),
|
||||||
|
@ -1809,7 +1735,6 @@ static int activate_lsp(struct opal_dev *dev, void *data)
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTNAME);
|
add_token_u8(&err, dev, OPAL_STARTNAME);
|
||||||
add_token_u8(&err, dev, uint_3);
|
add_token_u8(&err, dev, uint_3);
|
||||||
add_token_u8(&err, dev, 6);
|
add_token_u8(&err, dev, 6);
|
||||||
|
@ -1824,8 +1749,6 @@ static int activate_lsp(struct opal_dev *dev, void *data)
|
||||||
}
|
}
|
||||||
add_token_u8(&err, dev, OPAL_ENDLIST);
|
add_token_u8(&err, dev, OPAL_ENDLIST);
|
||||||
add_token_u8(&err, dev, OPAL_ENDNAME);
|
add_token_u8(&err, dev, OPAL_ENDNAME);
|
||||||
} else {
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -1859,17 +1782,11 @@ static int get_lsp_lifecycle_cont(struct opal_dev *dev)
|
||||||
/* Determine if we're in the Manufactured Inactive or Active state */
|
/* Determine if we're in the Manufactured Inactive or Active state */
|
||||||
static int get_lsp_lifecycle(struct opal_dev *dev, void *data)
|
static int get_lsp_lifecycle(struct opal_dev *dev, void *data)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
err = cmd_start(dev, opaluid[OPAL_LOCKINGSP_UID],
|
||||||
set_comid(dev, dev->comid);
|
opalmethod[OPAL_GET]);
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
|
||||||
add_token_bytestring(&err, dev, opaluid[OPAL_LOCKINGSP_UID],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_GET], OPAL_UID_LENGTH);
|
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
add_token_u8(&err, dev, OPAL_STARTLIST);
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTNAME);
|
add_token_u8(&err, dev, OPAL_STARTNAME);
|
||||||
|
@ -1919,19 +1836,12 @@ static int get_msid_cpin_pin_cont(struct opal_dev *dev)
|
||||||
|
|
||||||
static int get_msid_cpin_pin(struct opal_dev *dev, void *data)
|
static int get_msid_cpin_pin(struct opal_dev *dev, void *data)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err;
|
||||||
|
|
||||||
clear_opal_cmd(dev);
|
err = cmd_start(dev, opaluid[OPAL_C_PIN_MSID],
|
||||||
set_comid(dev, dev->comid);
|
opalmethod[OPAL_GET]);
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_CALL);
|
|
||||||
add_token_bytestring(&err, dev, opaluid[OPAL_C_PIN_MSID],
|
|
||||||
OPAL_UID_LENGTH);
|
|
||||||
add_token_bytestring(&err, dev, opalmethod[OPAL_GET], OPAL_UID_LENGTH);
|
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
add_token_u8(&err, dev, OPAL_STARTLIST);
|
||||||
add_token_u8(&err, dev, OPAL_STARTLIST);
|
|
||||||
|
|
||||||
add_token_u8(&err, dev, OPAL_STARTNAME);
|
add_token_u8(&err, dev, OPAL_STARTNAME);
|
||||||
add_token_u8(&err, dev, 3); /* Start Column */
|
add_token_u8(&err, dev, 3); /* Start Column */
|
||||||
add_token_u8(&err, dev, 3); /* PIN */
|
add_token_u8(&err, dev, 3); /* PIN */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче