mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-04-01 03:44:08 +00:00
crypto: af_alg - Allow to link sgl
Allow to link af_alg sgls. Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
0345f93138
commit
66db37391d
2 changed files with 16 additions and 6 deletions
|
@ -358,8 +358,8 @@ int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len)
|
||||||
npages = (off + n + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
npages = (off + n + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
||||||
if (WARN_ON(npages == 0))
|
if (WARN_ON(npages == 0))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
/* Add one extra for linking */
|
||||||
sg_init_table(sgl->sg, npages);
|
sg_init_table(sgl->sg, npages + 1);
|
||||||
|
|
||||||
for (i = 0, len = n; i < npages; i++) {
|
for (i = 0, len = n; i < npages; i++) {
|
||||||
int plen = min_t(int, len, PAGE_SIZE - off);
|
int plen = min_t(int, len, PAGE_SIZE - off);
|
||||||
|
@ -369,18 +369,26 @@ int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len)
|
||||||
off = 0;
|
off = 0;
|
||||||
len -= plen;
|
len -= plen;
|
||||||
}
|
}
|
||||||
|
sg_mark_end(sgl->sg + npages - 1);
|
||||||
|
sgl->npages = npages;
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(af_alg_make_sg);
|
EXPORT_SYMBOL_GPL(af_alg_make_sg);
|
||||||
|
|
||||||
|
void af_alg_link_sg(struct af_alg_sgl *sgl_prev, struct af_alg_sgl *sgl_new)
|
||||||
|
{
|
||||||
|
sg_unmark_end(sgl_prev->sg + sgl_prev->npages - 1);
|
||||||
|
sg_chain(sgl_prev->sg, sgl_prev->npages + 1, sgl_new->sg);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(af_alg_link_sg);
|
||||||
|
|
||||||
void af_alg_free_sg(struct af_alg_sgl *sgl)
|
void af_alg_free_sg(struct af_alg_sgl *sgl)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = 0;
|
for (i = 0; i < sgl->npages; i++)
|
||||||
do {
|
|
||||||
put_page(sgl->pages[i]);
|
put_page(sgl->pages[i]);
|
||||||
} while (!sg_is_last(sgl->sg + (i++)));
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(af_alg_free_sg);
|
EXPORT_SYMBOL_GPL(af_alg_free_sg);
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,9 @@ struct af_alg_type {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct af_alg_sgl {
|
struct af_alg_sgl {
|
||||||
struct scatterlist sg[ALG_MAX_PAGES];
|
struct scatterlist sg[ALG_MAX_PAGES + 1];
|
||||||
struct page *pages[ALG_MAX_PAGES];
|
struct page *pages[ALG_MAX_PAGES];
|
||||||
|
unsigned int npages;
|
||||||
};
|
};
|
||||||
|
|
||||||
int af_alg_register_type(const struct af_alg_type *type);
|
int af_alg_register_type(const struct af_alg_type *type);
|
||||||
|
@ -70,6 +71,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock);
|
||||||
|
|
||||||
int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len);
|
int af_alg_make_sg(struct af_alg_sgl *sgl, struct iov_iter *iter, int len);
|
||||||
void af_alg_free_sg(struct af_alg_sgl *sgl);
|
void af_alg_free_sg(struct af_alg_sgl *sgl);
|
||||||
|
void af_alg_link_sg(struct af_alg_sgl *sgl_prev, struct af_alg_sgl *sgl_new);
|
||||||
|
|
||||||
int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con);
|
int af_alg_cmsg_send(struct msghdr *msg, struct af_alg_control *con);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue