Lines Matching refs:sg

15 #define sg_is_chain(sg)		((sg)->page_link & 0x01)
16 #define sg_is_last(sg) ((sg)->page_link & 0x02)
17 #define sg_chain_ptr(sg) \
18 ((struct scatterlist *) ((sg)->page_link & ~0x03))
22 * @sg: SG entry
26 * Assign page to sg entry. Also see sg_set_page(), the most commonly used
30 static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
32 unsigned long page_link = sg->page_link & 0x3;
40 BUG_ON(sg_is_chain(sg));
42 sg->page_link = page_link | (unsigned long) page;
46 * sg_set_page - Set sg entry to point at given page
47 * @sg: SG entry
53 * Use this function to set an sg entry pointing at a page, never assign
54 * the page directly. We encode sg table information in the lower bits
56 * to an sg entry.
59 static inline void sg_set_page(struct scatterlist *sg, struct page *page,
62 sg_assign_page(sg, page);
63 sg->offset = offset;
64 sg->length = len;
67 static inline struct page *sg_page(struct scatterlist *sg)
70 BUG_ON(sg_is_chain(sg));
72 return (struct page *)((sg)->page_link & ~0x3);
76 * Loop over each sg element, following the pointer to a new list if necessary
78 #define for_each_sg(sglist, sg, nr, __i) \
79 for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))
109 * @sg: SG entryScatterlist
112 * Marks the passed in sg entry as the termination point for the sg
116 static inline void sg_mark_end(struct scatterlist *sg)
121 sg->page_link |= 0x02;
122 sg->page_link &= ~0x01;
127 * @sg: SG entryScatterlist
133 static inline void sg_unmark_end(struct scatterlist *sg)
135 sg->page_link &= ~0x02;
138 static inline struct scatterlist *sg_next(struct scatterlist *sg)
140 if (sg_is_last(sg))
143 sg++;
144 if (unlikely(sg_is_chain(sg)))
145 sg = sg_chain_ptr(sg);
147 return sg;
156 static inline dma_addr_t sg_phys(struct scatterlist *sg)
158 return page_to_phys(sg_page(sg)) + sg->offset;
161 static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
164 sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
167 static inline void sg_init_one(struct scatterlist *sg,
170 sg_init_table(sg, 1);
171 sg_set_buf(sg, buf, buflen);