// SPDX-License-Identifier: GPL-2.0-only /* * xor offload engine api * * Copyright © 2006, Intel Corporation. * * Dan Williams <[email protected]> * * with architecture considerations by: * Neil Brown <[email protected]> * Jeff Garzik <[email protected]> */ #include <linux/kernel.h> #include <linux/interrupt.h> #include <linux/module.h> #include <linux/mm.h> #include <linux/dma-mapping.h> #include <linux/raid/xor.h> #include <linux/async_tx.h> /* do_async_xor - dma map the pages and perform the xor with an engine */ static __async_inline struct dma_async_tx_descriptor * do_async_xor(struct dma_chan *chan, struct dmaengine_unmap_data *unmap, struct async_submit_ctl *submit) { … } static void do_sync_xor_offs(struct page *dest, unsigned int offset, struct page **src_list, unsigned int *src_offs, int src_cnt, size_t len, struct async_submit_ctl *submit) { … } static inline bool dma_xor_aligned_offsets(struct dma_device *device, unsigned int offset, unsigned int *src_offs, int src_cnt, int len) { … } /** * async_xor_offs - attempt to xor a set of blocks with a dma engine. * @dest: destination page * @offset: dst offset to start transaction * @src_list: array of source pages * @src_offs: array of source pages offset, NULL means common src/dst offset * @src_cnt: number of source pages * @len: length in bytes * @submit: submission / completion modifiers * * honored flags: ASYNC_TX_ACK, ASYNC_TX_XOR_ZERO_DST, ASYNC_TX_XOR_DROP_DST * * xor_blocks always uses the dest as a source so the * ASYNC_TX_XOR_ZERO_DST flag must be set to not include dest data in * the calculation. The assumption with dma engines is that they only * use the destination buffer as a source when it is explicitly specified * in the source list. * * src_list note: if the dest is also a source it must be at index zero. * The contents of this array will be overwritten if a scribble region * is not specified. */ struct dma_async_tx_descriptor * async_xor_offs(struct page *dest, unsigned int offset, struct page **src_list, unsigned int *src_offs, int src_cnt, size_t len, struct async_submit_ctl *submit) { … } EXPORT_SYMBOL_GPL(…); /** * async_xor - attempt to xor a set of blocks with a dma engine. * @dest: destination page * @src_list: array of source pages * @offset: common src/dst offset to start transaction * @src_cnt: number of source pages * @len: length in bytes * @submit: submission / completion modifiers * * honored flags: ASYNC_TX_ACK, ASYNC_TX_XOR_ZERO_DST, ASYNC_TX_XOR_DROP_DST * * xor_blocks always uses the dest as a source so the * ASYNC_TX_XOR_ZERO_DST flag must be set to not include dest data in * the calculation. The assumption with dma engines is that they only * use the destination buffer as a source when it is explicitly specified * in the source list. * * src_list note: if the dest is also a source it must be at index zero. * The contents of this array will be overwritten if a scribble region * is not specified. */ struct dma_async_tx_descriptor * async_xor(struct page *dest, struct page **src_list, unsigned int offset, int src_cnt, size_t len, struct async_submit_ctl *submit) { … } EXPORT_SYMBOL_GPL(…); static int page_is_zero(struct page *p, unsigned int offset, size_t len) { … } static inline struct dma_chan * xor_val_chan(struct async_submit_ctl *submit, struct page *dest, struct page **src_list, int src_cnt, size_t len) { … } /** * async_xor_val_offs - attempt a xor parity check with a dma engine. * @dest: destination page used if the xor is performed synchronously * @offset: des offset in pages to start transaction * @src_list: array of source pages * @src_offs: array of source pages offset, NULL means common src/det offset * @src_cnt: number of source pages * @len: length in bytes * @result: 0 if sum == 0 else non-zero * @submit: submission / completion modifiers * * honored flags: ASYNC_TX_ACK * * src_list note: if the dest is also a source it must be at index zero. * The contents of this array will be overwritten if a scribble region * is not specified. */ struct dma_async_tx_descriptor * async_xor_val_offs(struct page *dest, unsigned int offset, struct page **src_list, unsigned int *src_offs, int src_cnt, size_t len, enum sum_check_flags *result, struct async_submit_ctl *submit) { … } EXPORT_SYMBOL_GPL(…); /** * async_xor_val - attempt a xor parity check with a dma engine. * @dest: destination page used if the xor is performed synchronously * @src_list: array of source pages * @offset: offset in pages to start transaction * @src_cnt: number of source pages * @len: length in bytes * @result: 0 if sum == 0 else non-zero * @submit: submission / completion modifiers * * honored flags: ASYNC_TX_ACK * * src_list note: if the dest is also a source it must be at index zero. * The contents of this array will be overwritten if a scribble region * is not specified. */ struct dma_async_tx_descriptor * async_xor_val(struct page *dest, struct page **src_list, unsigned int offset, int src_cnt, size_t len, enum sum_check_flags *result, struct async_submit_ctl *submit) { … } EXPORT_SYMBOL_GPL(…); MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;