/** * sg_assign_page - Assign a given page to an SG entry * @sg: SG entry * @page: The page * * Description: * Assign page to sg entry. Also see sg_set_page(), the most commonly used * variant. *
**/ staticinlinevoid sg_assign_page(struct scatterlist *sg, struct page *page)
{ unsignedlong page_link = sg->page_link & 0x3;
/* * In order for the low bit stealing approach to work, pages * must be aligned at a 32-bit boundary as a minimum.
*/
BUG_ON((unsignedlong) page & 0x03); #ifdef CONFIG_DEBUG_SG
BUG_ON(sg_is_chain(sg)); #endif
sg->page_link = page_link | (unsignedlong) page;
}
/** * sg_set_page - Set sg entry to point at given page * @sg: SG entry * @page: The page * @len: Length of data * @offset: Offset into page * * Description: * Use this function to set an sg entry pointing at a page, never assign * the page directly. We encode sg table information in the lower bits * of the page pointer. See sg_page() for looking up the page belonging * to an sg entry. *
**/ staticinlinevoid sg_set_page(struct scatterlist *sg, struct page *page, unsignedint len, unsignedint offset)
{
sg_assign_page(sg, page);
sg->offset = offset;
sg->length = len;
}
/* * Loop over each sg element, following the pointer to a new list if necessary
*/ #define for_each_sg(sglist, sg, nr, __i) \ for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))
/** * sg_chain - Chain two sglists together * @prv: First scatterlist * @prv_nents: Number of entries in prv * @sgl: Second scatterlist * * Description: * Links @prv@ and @sgl@ together, to form a longer scatterlist. *
**/ staticinlinevoid sg_chain(struct scatterlist *prv, unsignedint prv_nents, struct scatterlist *sgl)
{ /* * offset and length are unused for chain entry. Clear them.
*/
prv[prv_nents - 1].offset = 0;
prv[prv_nents - 1].length = 0;
/* * Set lowest bit to indicate a link pointer, and make sure to clear * the termination bit if it happens to be set.
*/
prv[prv_nents - 1].page_link = ((unsignedlong) sgl | 0x01) & ~0x02;
}
/** * sg_mark_end - Mark the end of the scatterlist * @sg: SG entryScatterlist * * Description: * Marks the passed in sg entry as the termination point for the sg * table. A call to sg_next() on this entry will return NULL. *
**/ staticinlinevoid sg_mark_end(struct scatterlist *sg)
{ /* * Set termination bit, clear potential chain bit
*/
sg->page_link |= 0x02;
sg->page_link &= ~0x01;
}
/** * sg_unmark_end - Undo setting the end of the scatterlist * @sg: SG entryScatterlist * * Description: * Removes the termination marker from the given entry of the scatterlist. *
**/ staticinlinevoid sg_unmark_end(struct scatterlist *sg)
{
sg->page_link &= ~0x02;
}
staticinlinestruct scatterlist *sg_next(struct scatterlist *sg)
{ if (sg_is_last(sg)) return NULL;
sg++; if (unlikely(sg_is_chain(sg)))
sg = sg_chain_ptr(sg);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.