}
static int sgl_read_to_frags(struct scatterlist *sg, unsigned int sgoffset,
- unsigned int dlen, skb_frag_t *frags,
+ unsigned int dlen, struct page_frag *frags,
int frag_max)
{
unsigned int datalen = dlen;
copy = min(datalen, sglen);
if (i && page == frags[i - 1].page &&
sgoffset + sg->offset ==
- frags[i - 1].page_offset + skb_frag_size(&frags[i - 1])) {
- skb_frag_size_add(&frags[i - 1], copy);
+ frags[i - 1].offset + frags[i - 1].size) {
+ frags[i - 1].size += copy;
} else {
if (i >= frag_max) {
pr_warn("too many pages %u, dlen %u.\n",
}
frags[i].page = page;
- frags[i].page_offset = sg->offset + sgoffset;
- skb_frag_size_set(&frags[i], copy);
+ frags[i].offset = sg->offset + sgoffset;
+ frags[i].size = copy;
i++;
}
datalen -= copy;
if (tdata->nr_frags > MAX_SKB_FRAGS ||
(padlen && tdata->nr_frags == MAX_SKB_FRAGS)) {
char *dst = skb->data + task->hdr_len;
- skb_frag_t *frag = tdata->frags;
+ struct page_frag *frag = tdata->frags;
/* data fits in the skb's headroom */
for (i = 0; i < tdata->nr_frags; i++, frag++) {
char *src = kmap_atomic(frag->page,
KM_SOFTIRQ0);
- memcpy(dst, src+frag->page_offset, skb_frag_size(frag));
- dst += skb_frag_size(frag);
+ memcpy(dst, src+frag->offset, frag->size);
+ dst += frag->size;
kunmap_atomic(src, KM_SOFTIRQ0);
}
if (padlen) {
skb_put(skb, count + padlen);
} else {
/* data fit into frag_list */
- for (i = 0; i < tdata->nr_frags; i++)
- get_page(tdata->frags[i].page);
-
- memcpy(skb_shinfo(skb)->frags, tdata->frags,
- sizeof(skb_frag_t) * tdata->nr_frags);
+ for (i = 0; i < tdata->nr_frags; i++) {
+ __skb_fill_page_desc(skb, i,
+ tdata->frags[i].page,
+ tdata->frags[i].offset,
+ tdata->frags[i].size);
+ skb_frag_ref(skb, i);
+ }
skb_shinfo(skb)->nr_frags = tdata->nr_frags;
skb->len += count;
skb->data_len += count;