diff options
author | Ian Campbell <Ian.Campbell@citrix.com> | 2011-10-19 19:01:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-10-21 02:52:53 -0400 |
commit | 6a39a16a5ac07a156de91cfb9422bde574e59fa6 (patch) | |
tree | cccf1f292391f9af858837fab03a40632f3144fc /drivers/scsi/cxgbi | |
parent | a0006a86cb19543f126bb2ee3d37baef82080763 (diff) |
cxgbi: convert to SKB paged frag API.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Mike Christie <michaelc@cs.wisc.edu>
Cc: James Bottomley <James.Bottomley@suse.de>
Cc: Karen Xie <kxie@chelsio.com>
Cc: linux-scsi@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/scsi/cxgbi')
-rw-r--r-- | drivers/scsi/cxgbi/libcxgbi.c | 28 | ||||
-rw-r--r-- | drivers/scsi/cxgbi/libcxgbi.h | 2 |
2 files changed, 16 insertions, 14 deletions
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c index be69da38ccaa..1c1329bc77c7 100644 --- a/drivers/scsi/cxgbi/libcxgbi.c +++ b/drivers/scsi/cxgbi/libcxgbi.c | |||
@@ -1787,7 +1787,7 @@ static int sgl_seek_offset(struct scatterlist *sgl, unsigned int sgcnt, | |||
1787 | } | 1787 | } |
1788 | 1788 | ||
1789 | static int sgl_read_to_frags(struct scatterlist *sg, unsigned int sgoffset, | 1789 | static int sgl_read_to_frags(struct scatterlist *sg, unsigned int sgoffset, |
1790 | unsigned int dlen, skb_frag_t *frags, | 1790 | unsigned int dlen, struct page_frag *frags, |
1791 | int frag_max) | 1791 | int frag_max) |
1792 | { | 1792 | { |
1793 | unsigned int datalen = dlen; | 1793 | unsigned int datalen = dlen; |
@@ -1814,8 +1814,8 @@ static int sgl_read_to_frags(struct scatterlist *sg, unsigned int sgoffset, | |||
1814 | copy = min(datalen, sglen); | 1814 | copy = min(datalen, sglen); |
1815 | if (i && page == frags[i - 1].page && | 1815 | if (i && page == frags[i - 1].page && |
1816 | sgoffset + sg->offset == | 1816 | sgoffset + sg->offset == |
1817 | frags[i - 1].page_offset + skb_frag_size(&frags[i - 1])) { | 1817 | frags[i - 1].offset + frags[i - 1].size) { |
1818 | skb_frag_size_add(&frags[i - 1], copy); | 1818 | frags[i - 1].size += copy; |
1819 | } else { | 1819 | } else { |
1820 | if (i >= frag_max) { | 1820 | if (i >= frag_max) { |
1821 | pr_warn("too many pages %u, dlen %u.\n", | 1821 | pr_warn("too many pages %u, dlen %u.\n", |
@@ -1824,8 +1824,8 @@ static int sgl_read_to_frags(struct scatterlist *sg, unsigned int sgoffset, | |||
1824 | } | 1824 | } |
1825 | 1825 | ||
1826 | frags[i].page = page; | 1826 | frags[i].page = page; |
1827 | frags[i].page_offset = sg->offset + sgoffset; | 1827 | frags[i].offset = sg->offset + sgoffset; |
1828 | skb_frag_size_set(&frags[i], copy); | 1828 | frags[i].size = copy; |
1829 | i++; | 1829 | i++; |
1830 | } | 1830 | } |
1831 | datalen -= copy; | 1831 | datalen -= copy; |
@@ -1944,15 +1944,15 @@ int cxgbi_conn_init_pdu(struct iscsi_task *task, unsigned int offset, | |||
1944 | if (tdata->nr_frags > MAX_SKB_FRAGS || | 1944 | if (tdata->nr_frags > MAX_SKB_FRAGS || |
1945 | (padlen && tdata->nr_frags == MAX_SKB_FRAGS)) { | 1945 | (padlen && tdata->nr_frags == MAX_SKB_FRAGS)) { |
1946 | char *dst = skb->data + task->hdr_len; | 1946 | char *dst = skb->data + task->hdr_len; |
1947 | skb_frag_t *frag = tdata->frags; | 1947 | struct page_frag *frag = tdata->frags; |
1948 | 1948 | ||
1949 | /* data fits in the skb's headroom */ | 1949 | /* data fits in the skb's headroom */ |
1950 | for (i = 0; i < tdata->nr_frags; i++, frag++) { | 1950 | for (i = 0; i < tdata->nr_frags; i++, frag++) { |
1951 | char *src = kmap_atomic(frag->page, | 1951 | char *src = kmap_atomic(frag->page, |
1952 | KM_SOFTIRQ0); | 1952 | KM_SOFTIRQ0); |
1953 | 1953 | ||
1954 | memcpy(dst, src+frag->page_offset, skb_frag_size(frag)); | 1954 | memcpy(dst, src+frag->offset, frag->size); |
1955 | dst += skb_frag_size(frag); | 1955 | dst += frag->size; |
1956 | kunmap_atomic(src, KM_SOFTIRQ0); | 1956 | kunmap_atomic(src, KM_SOFTIRQ0); |
1957 | } | 1957 | } |
1958 | if (padlen) { | 1958 | if (padlen) { |
@@ -1962,11 +1962,13 @@ int cxgbi_conn_init_pdu(struct iscsi_task *task, unsigned int offset, | |||
1962 | skb_put(skb, count + padlen); | 1962 | skb_put(skb, count + padlen); |
1963 | } else { | 1963 | } else { |
1964 | /* data fit into frag_list */ | 1964 | /* data fit into frag_list */ |
1965 | for (i = 0; i < tdata->nr_frags; i++) | 1965 | for (i = 0; i < tdata->nr_frags; i++) { |
1966 | get_page(tdata->frags[i].page); | 1966 | __skb_fill_page_desc(skb, i, |
1967 | 1967 | tdata->frags[i].page, | |
1968 | memcpy(skb_shinfo(skb)->frags, tdata->frags, | 1968 | tdata->frags[i].offset, |
1969 | sizeof(skb_frag_t) * tdata->nr_frags); | 1969 | tdata->frags[i].size); |
1970 | skb_frag_ref(skb, i); | ||
1971 | } | ||
1970 | skb_shinfo(skb)->nr_frags = tdata->nr_frags; | 1972 | skb_shinfo(skb)->nr_frags = tdata->nr_frags; |
1971 | skb->len += count; | 1973 | skb->len += count; |
1972 | skb->data_len += count; | 1974 | skb->data_len += count; |
diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h index 9267844519c9..3a25b1187c10 100644 --- a/drivers/scsi/cxgbi/libcxgbi.h +++ b/drivers/scsi/cxgbi/libcxgbi.h | |||
@@ -574,7 +574,7 @@ struct cxgbi_endpoint { | |||
574 | #define MAX_PDU_FRAGS ((ULP2_MAX_PDU_PAYLOAD + 512 - 1) / 512) | 574 | #define MAX_PDU_FRAGS ((ULP2_MAX_PDU_PAYLOAD + 512 - 1) / 512) |
575 | struct cxgbi_task_data { | 575 | struct cxgbi_task_data { |
576 | unsigned short nr_frags; | 576 | unsigned short nr_frags; |
577 | skb_frag_t frags[MAX_PDU_FRAGS]; | 577 | struct page_frag frags[MAX_PDU_FRAGS]; |
578 | struct sk_buff *skb; | 578 | struct sk_buff *skb; |
579 | unsigned int offset; | 579 | unsigned int offset; |
580 | unsigned int count; | 580 | unsigned int count; |