Commit 56c10d5e authored by Haren Myneni's avatar Haren Myneni Committed by Michael Ellerman

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: default avatarHaren Myneni <haren@us.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent c97f8169
...@@ -358,6 +358,40 @@ static int wait_for_csb(struct nx842_workmem *wmem, ...@@ -358,6 +358,40 @@ static int wait_for_csb(struct nx842_workmem *wmem,
return 0; 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 * 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, ...@@ -397,7 +431,6 @@ static int nx842_exec_icswx(const unsigned char *in, unsigned int inlen,
struct coprocessor_status_block *csb; struct coprocessor_status_block *csb;
struct nx842_workmem *wmem; struct nx842_workmem *wmem;
int ret; int ret;
u64 csb_addr;
u32 ccw; u32 ccw;
unsigned int outlen = *outlenp; unsigned int outlen = *outlenp;
...@@ -411,33 +444,19 @@ static int nx842_exec_icswx(const unsigned char *in, unsigned int inlen, ...@@ -411,33 +444,19 @@ static int nx842_exec_icswx(const unsigned char *in, unsigned int inlen,
return -ENODEV; return -ENODEV;
} }
crb = &wmem->crb; ret = nx842_config_crb(in, inlen, out, outlen, wmem);
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) if (ret)
return ret; return ret;
crb = &wmem->crb;
csb = &crb->csb;
/* set up CCW */ /* set up CCW */
ccw = 0; ccw = 0;
ccw = SET_FIELD(CCW_CT, ccw, nx842_ct); 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_CI_842, ccw, 0); /* use 0 for hw auto-selection */
ccw = SET_FIELD(CCW_FC_842, ccw, fc); 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(); wmem->start = ktime_get();
/* do ICSWX */ /* do ICSWX */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment