crypto/nx: Create nx842_configure_crb function
Configure CRB is moved to nx842_configure_crb() so that it can be used for icswx and VAS exec functions. VAS function will be added later with P9 support. Signed-off-by: Haren Myneni <haren@us.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
parent
c97f8169fb
commit
56c10d5ea6
|
@ -358,6 +358,40 @@ static int wait_for_csb(struct nx842_workmem *wmem,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int nx842_config_crb(const unsigned char *in, unsigned int inlen,
|
||||
unsigned char *out, unsigned int outlen,
|
||||
struct nx842_workmem *wmem)
|
||||
{
|
||||
struct coprocessor_request_block *crb;
|
||||
struct coprocessor_status_block *csb;
|
||||
u64 csb_addr;
|
||||
int ret;
|
||||
|
||||
crb = &wmem->crb;
|
||||
csb = &crb->csb;
|
||||
|
||||
/* Clear any previous values */
|
||||
memset(crb, 0, sizeof(*crb));
|
||||
|
||||
/* set up DDLs */
|
||||
ret = setup_ddl(&crb->source, wmem->ddl_in,
|
||||
(unsigned char *)in, inlen, true);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = setup_ddl(&crb->target, wmem->ddl_out,
|
||||
out, outlen, false);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* set up CRB's CSB addr */
|
||||
csb_addr = nx842_get_pa(csb) & CRB_CSB_ADDRESS;
|
||||
csb_addr |= CRB_CSB_AT; /* Addrs are phys */
|
||||
crb->csb_addr = cpu_to_be64(csb_addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* nx842_exec_icswx - compress/decompress data using the 842 algorithm
|
||||
*
|
||||
|
@ -397,7 +431,6 @@ static int nx842_exec_icswx(const unsigned char *in, unsigned int inlen,
|
|||
struct coprocessor_status_block *csb;
|
||||
struct nx842_workmem *wmem;
|
||||
int ret;
|
||||
u64 csb_addr;
|
||||
u32 ccw;
|
||||
unsigned int outlen = *outlenp;
|
||||
|
||||
|
@ -411,33 +444,19 @@ static int nx842_exec_icswx(const unsigned char *in, unsigned int inlen,
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = nx842_config_crb(in, inlen, out, outlen, wmem);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
crb = &wmem->crb;
|
||||
csb = &crb->csb;
|
||||
|
||||
/* Clear any previous values */
|
||||
memset(crb, 0, sizeof(*crb));
|
||||
|
||||
/* set up DDLs */
|
||||
ret = setup_ddl(&crb->source, wmem->ddl_in,
|
||||
(unsigned char *)in, inlen, true);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = setup_ddl(&crb->target, wmem->ddl_out,
|
||||
out, outlen, false);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* set up CCW */
|
||||
ccw = 0;
|
||||
ccw = SET_FIELD(CCW_CT, ccw, nx842_ct);
|
||||
ccw = SET_FIELD(CCW_CI_842, ccw, 0); /* use 0 for hw auto-selection */
|
||||
ccw = SET_FIELD(CCW_FC_842, ccw, fc);
|
||||
|
||||
/* set up CRB's CSB addr */
|
||||
csb_addr = nx842_get_pa(csb) & CRB_CSB_ADDRESS;
|
||||
csb_addr |= CRB_CSB_AT; /* Addrs are phys */
|
||||
crb->csb_addr = cpu_to_be64(csb_addr);
|
||||
|
||||
wmem->start = ktime_get();
|
||||
|
||||
/* do ICSWX */
|
||||
|
|
Loading…
Reference in New Issue