/*
 * if_alg: User-space algorithm interface
 *
 * Copyright (c) 2010 Herbert Xu <herbert@gondor.apana.org.au>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 */

#ifndef _CRYPTO_IF_ALG_H
#define _CRYPTO_IF_ALG_H

#include <linux/compiler.h>
#include <linux/completion.h>
#include <linux/if_alg.h>
#include <linux/scatterlist.h>
#include <linux/types.h>
#include <net/sock.h>

#define ALG_MAX_PAGES			16

struct crypto_async_request;

struct alg_sock {
	/* struct sock must be the first member of struct alg_sock */
	struct sock sk;

	struct sock *parent;

	unsigned int refcnt;
	unsigned int nokey_refcnt;

	const struct af_alg_type *type;
	void *private;
};

struct af_alg_completion {
	struct completion completion;
	int err;
};

struct af_alg_control {
	struct af_alg_iv *iv;
	int op;
	unsigned int aead_assoclen;
};

struct af_alg_type {
	void *(*bind)(const char *name, u32 type, u32 mask);
	void (*release)(void *private);
	int (*setkey)(void *private, const u8 *key, unsigned int keylen);
	int (*accept)(void *private, struct sock *sk);
	int (*accept_nokey)(void *private, struct sock *sk);
	int (*setauthsize)(void *private, unsigned int authsize);

	struct proto_ops *ops;
	struct proto_ops *ops_nokey;
	struct module *owner;
	char name[14];
};

struct af_alg_sgl {
	struct scatterlist sg[ALG_MAX_PAGES + 1];
	struct page *pages[ALG_MAX_PAGES];
	unsigned int npages;
};

int af_alg_register_type(const struct af_alg_type *type);
int af_alg_unregister_type(const struct af_alg_type *type);

int af_alg_release(struct socket *sock);
void af_alg_release_parent(struct sock *sk);
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);
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_wait_for_completion(int err, struct af_alg_completion *completion);
void af_alg_complete(struct crypto_async_request *req, int err);

static inline struct alg_sock *alg_sk(struct sock *sk)
{
	return (struct alg_sock *)sk;
}

static inline void af_alg_init_completion(struct af_alg_completion *completion)
{
	init_completion(&completion->completion);
}

#endif	/* _CRYPTO_IF_ALG_H */
put type='hidden' name='id' value='2fb78e89405f4321b86274a0c24b30896dd50529'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/commit/?h=nds-private-remove&amp;id=2fb78e89405f4321b86274a0c24b30896dd50529'>root</a>/<a href='/cgit.cgi/linux/net-next.git/commit/tools?h=nds-private-remove&amp;id=2fb78e89405f4321b86274a0c24b30896dd50529'>tools</a>/<a href='/cgit.cgi/linux/net-next.git/commit/tools/laptop?h=nds-private-remove&amp;id=2fb78e89405f4321b86274a0c24b30896dd50529'>laptop</a>/<a href='/cgit.cgi/linux/net-next.git/commit/tools/laptop/dslm?h=nds-private-remove&amp;id=2fb78e89405f4321b86274a0c24b30896dd50529'>dslm</a>/<a href='/cgit.cgi/linux/net-next.git/commit/tools/laptop/dslm/dslm.c?h=nds-private-remove&amp;id=2fb78e89405f4321b86274a0c24b30896dd50529'>dslm.c</a></div><div class='content'><div class='cgit-panel'><b>diff options</b><form method='get'><input type='hidden' name='h' value='nds-private-remove'/><input type='hidden' name='id' value='2fb78e89405f4321b86274a0c24b30896dd50529'/><table><tr><td colspan='2'/></tr><tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><table summary='commit info' class='commit-info'>
<tr><th>author</th><td>Linus Torvalds &lt;torvalds@linux-foundation.org&gt;</td><td class='right'>2017-01-27 12:36:39 -0800</td></tr>
<tr><th>committer</th><td>Linus Torvalds &lt;torvalds@linux-foundation.org&gt;</td><td class='right'>2017-01-27 12:36:39 -0800</td></tr>
<tr><th>commit</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/tools/laptop/dslm/dslm.c?h=nds-private-remove&amp;id=2fb78e89405f4321b86274a0c24b30896dd50529'>2fb78e89405f4321b86274a0c24b30896dd50529</a> (<a href='/cgit.cgi/linux/net-next.git/patch/tools/laptop/dslm/dslm.c?id=2fb78e89405f4321b86274a0c24b30896dd50529'>patch</a>)</td></tr>
<tr><th>tree</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/tree/?h=nds-private-remove&amp;id=2fb78e89405f4321b86274a0c24b30896dd50529'>4de241e242441b80bd3f0022fc546bb07374571f</a> /<a href='/cgit.cgi/linux/net-next.git/tree/tools/laptop/dslm/dslm.c?h=nds-private-remove&amp;id=2fb78e89405f4321b86274a0c24b30896dd50529'>tools/laptop/dslm/dslm.c</a></td></tr>
<tr><th>parent</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/tools/laptop/dslm/dslm.c?h=nds-private-remove&amp;id=dd3b9f25c867cb2507a45e436d6ede8eb08e7b05'>dd3b9f25c867cb2507a45e436d6ede8eb08e7b05</a> (<a href='/cgit.cgi/linux/net-next.git/diff/tools/laptop/dslm/dslm.c?h=nds-private-remove&amp;id=2fb78e89405f4321b86274a0c24b30896dd50529&amp;id2=dd3b9f25c867cb2507a45e436d6ede8eb08e7b05'>diff</a>)</td></tr><tr><th>parent</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/tools/laptop/dslm/dslm.c?h=nds-private-remove&amp;id=c14024dbb156c8392908aaa822097d27c6af8ec8'>c14024dbb156c8392908aaa822097d27c6af8ec8</a> (<a href='/cgit.cgi/linux/net-next.git/diff/tools/laptop/dslm/dslm.c?h=nds-private-remove&amp;id=2fb78e89405f4321b86274a0c24b30896dd50529&amp;id2=c14024dbb156c8392908aaa822097d27c6af8ec8'>diff</a>)</td></tr></table>
<div class='commit-subject'>Merge branch 'for-linus' of git://git.kernel.dk/linux-block</div><div class='commit-msg'>Pull block fixes from Jens Axboe:
 "A set of fixes for this series. This contains:

   - Set of fixes for the nvme target code

   - A revert of patch from this merge window, causing a regression with
     WRITE_SAME on iSCSI targets at least.

   - A fix for a use-after-free in the new O_DIRECT bdev code.

   - Two fixes for the xen-blkfront driver"

* 'for-linus' of git://git.kernel.dk/linux-block:
  Revert "sd: remove __data_len hack for WRITE SAME"
  nvme-fc: use blk_rq_nr_phys_segments
  nvmet-rdma: Fix missing dma sync to nvme data structures
  nvmet: Call fatal_error from keep-alive timout expiration
  nvmet: cancel fatal error and flush async work before free controller
  nvmet: delete controllers deletion upon subsystem release
  nvmet_fc: correct logic in disconnect queue LS handling
  block: fix use after free in __blkdev_direct_IO
  xen-blkfront: correct maximum segment accounting
  xen-blkfront: feature flags handling adjustments
</div><div class='diffstat-header'><a href='/cgit.cgi/linux/net-next.git/diff/?h=nds-private-remove&amp;id=2fb78e89405f4321b86274a0c24b30896dd50529'>Diffstat</a> (limited to 'tools/laptop/dslm/dslm.c')</div><table summary='diffstat' class='diffstat'>