brintos

brintos / linux-shallow public Read only

0
0
Text · 2.3 KiB · 150ef7e Raw
90 lines · c
1/* SPDX-License-Identifier: GPL-2.0 OR MIT */2 3/*4 * Xen frontend/backend page directory based shared buffer5 * helper module.6 *7 * Copyright (C) 2018 EPAM Systems Inc.8 *9 * Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>10 */11 12#ifndef __XEN_FRONT_PGDIR_SHBUF_H_13#define __XEN_FRONT_PGDIR_SHBUF_H_14 15#include <linux/kernel.h>16 17#include <xen/grant_table.h>18 19struct xen_front_pgdir_shbuf_ops;20 21struct xen_front_pgdir_shbuf {22	/*23	 * Number of references granted for the backend use:24	 *25	 *  - for frontend allocated/imported buffers this holds the number26	 *    of grant references for the page directory and the pages27	 *    of the buffer28	 *29	 *  - for the buffer provided by the backend this only holds the number30	 *    of grant references for the page directory itself as grant31	 *    references for the buffer will be provided by the backend.32	 */33	int num_grefs;34	grant_ref_t *grefs;35	/* Page directory backing storage. */36	u8 *directory;37 38	/*39	 * Number of pages for the shared buffer itself (excluding the page40	 * directory).41	 */42	int num_pages;43	/*44	 * Backing storage of the shared buffer: these are the pages being45	 * shared.46	 */47	struct page **pages;48 49	struct xenbus_device *xb_dev;50 51	/* These are the ops used internally depending on be_alloc mode. */52	const struct xen_front_pgdir_shbuf_ops *ops;53 54	/* Xen map handles for the buffer allocated by the backend. */55	grant_handle_t *backend_map_handles;56};57 58struct xen_front_pgdir_shbuf_cfg {59	struct xenbus_device *xb_dev;60 61	/* Number of pages of the buffer backing storage. */62	int num_pages;63	/* Pages of the buffer to be shared. */64	struct page **pages;65 66	/*67	 * This is allocated outside because there are use-cases when68	 * the buffer structure is allocated as a part of a bigger one.69	 */70	struct xen_front_pgdir_shbuf *pgdir;71	/*72	 * Mode of grant reference sharing: if set then backend will share73	 * grant references to the buffer with the frontend.74	 */75	int be_alloc;76};77 78int xen_front_pgdir_shbuf_alloc(struct xen_front_pgdir_shbuf_cfg *cfg);79 80grant_ref_t81xen_front_pgdir_shbuf_get_dir_start(struct xen_front_pgdir_shbuf *buf);82 83int xen_front_pgdir_shbuf_map(struct xen_front_pgdir_shbuf *buf);84 85int xen_front_pgdir_shbuf_unmap(struct xen_front_pgdir_shbuf *buf);86 87void xen_front_pgdir_shbuf_free(struct xen_front_pgdir_shbuf *buf);88 89#endif /* __XEN_FRONT_PGDIR_SHBUF_H_ */90