aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-10-24 05:20:47 -0400
committerJens Axboe <jens.axboe@oracle.com>2007-10-24 05:20:47 -0400
commit642f149031d70415d9318b919d50b71e4724adbd (patch)
treee792ad29dedffc6756d55e9d63e18ada35515b4b /net
parentbd6dee6f30a0f6943df190b387b5f8fe98a848f3 (diff)
SG: Change sg_set_page() to take length and offset argument
Most drivers need to set length and offset as well, so may as well fold those three lines into one. Add sg_assign_page() for those two locations that only needed to set the page, where the offset/length is set outside of the function context. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'net')
-rw-r--r--net/core/skbuff.c9
-rw-r--r--net/ieee80211/ieee80211_crypt_tkip.c9
-rw-r--r--net/sctp/auth.c4
-rw-r--r--net/sctp/sm_make_chunk.c8
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c14
-rw-r--r--net/sunrpc/xdr.c4
-rw-r--r--net/xfrm/xfrm_algo.c9
7 files changed, 18 insertions, 39 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 4e2c84fcf276..7b7c6c44c2da 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2045,9 +2045,7 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2045 if (copy > 0) { 2045 if (copy > 0) {
2046 if (copy > len) 2046 if (copy > len)
2047 copy = len; 2047 copy = len;
2048 sg_set_page(&sg[elt], virt_to_page(skb->data + offset)); 2048 sg_set_buf(sg, skb->data + offset, copy);
2049 sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
2050 sg[elt].length = copy;
2051 elt++; 2049 elt++;
2052 if ((len -= copy) == 0) 2050 if ((len -= copy) == 0)
2053 return elt; 2051 return elt;
@@ -2065,9 +2063,8 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2065 2063
2066 if (copy > len) 2064 if (copy > len)
2067 copy = len; 2065 copy = len;
2068 sg_set_page(&sg[elt], frag->page); 2066 sg_set_page(&sg[elt], frag->page, copy,
2069 sg[elt].offset = frag->page_offset+offset-start; 2067 frag->page_offset+offset-start);
2070 sg[elt].length = copy;
2071 elt++; 2068 elt++;
2072 if (!(len -= copy)) 2069 if (!(len -= copy))
2073 return elt; 2070 return elt;
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c
index 74d017520a23..4cce3534e408 100644
--- a/net/ieee80211/ieee80211_crypt_tkip.c
+++ b/net/ieee80211/ieee80211_crypt_tkip.c
@@ -537,13 +537,8 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
537 return -1; 537 return -1;
538 } 538 }
539 sg_init_table(sg, 2); 539 sg_init_table(sg, 2);
540 sg_set_page(&sg[0], virt_to_page(hdr)); 540 sg_set_buf(&sg[0], hdr, 16);
541 sg[0].offset = offset_in_page(hdr); 541 sg_set_buf(&sg[1], data, data_len);
542 sg[0].length = 16;
543
544 sg_set_page(&sg[1], virt_to_page(data));
545 sg[1].offset = offset_in_page(data);
546 sg[1].length = data_len;
547 542
548 if (crypto_hash_setkey(tfm_michael, key, 8)) 543 if (crypto_hash_setkey(tfm_michael, key, 8))
549 return -1; 544 return -1;
diff --git a/net/sctp/auth.c b/net/sctp/auth.c
index cbd64b216cce..621113a109b2 100644
--- a/net/sctp/auth.c
+++ b/net/sctp/auth.c
@@ -727,9 +727,7 @@ void sctp_auth_calculate_hmac(const struct sctp_association *asoc,
727 /* set up scatter list */ 727 /* set up scatter list */
728 end = skb_tail_pointer(skb); 728 end = skb_tail_pointer(skb);
729 sg_init_table(&sg, 1); 729 sg_init_table(&sg, 1);
730 sg_set_page(&sg, virt_to_page(auth)); 730 sg_set_buf(&sg, auth, end - (unsigned char *)auth);
731 sg.offset = (unsigned long)(auth) % PAGE_SIZE;
732 sg.length = end - (unsigned char *)auth;
733 731
734 desc.tfm = asoc->ep->auth_hmacs[hmac_id]; 732 desc.tfm = asoc->ep->auth_hmacs[hmac_id];
735 desc.flags = 0; 733 desc.flags = 0;
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 658476c4d587..c055212875f6 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1514,9 +1514,7 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
1514 1514
1515 /* Sign the message. */ 1515 /* Sign the message. */
1516 sg_init_table(&sg, 1); 1516 sg_init_table(&sg, 1);
1517 sg_set_page(&sg, virt_to_page(&cookie->c)); 1517 sg_set_buf(&sg, &cookie->c, bodysize);
1518 sg.offset = (unsigned long)(&cookie->c) % PAGE_SIZE;
1519 sg.length = bodysize;
1520 keylen = SCTP_SECRET_SIZE; 1518 keylen = SCTP_SECRET_SIZE;
1521 key = (char *)ep->secret_key[ep->current_key]; 1519 key = (char *)ep->secret_key[ep->current_key];
1522 desc.tfm = sctp_sk(ep->base.sk)->hmac; 1520 desc.tfm = sctp_sk(ep->base.sk)->hmac;
@@ -1587,9 +1585,7 @@ struct sctp_association *sctp_unpack_cookie(
1587 /* Check the signature. */ 1585 /* Check the signature. */
1588 keylen = SCTP_SECRET_SIZE; 1586 keylen = SCTP_SECRET_SIZE;
1589 sg_init_table(&sg, 1); 1587 sg_init_table(&sg, 1);
1590 sg_set_page(&sg, virt_to_page(bear_cookie)); 1588 sg_set_buf(&sg, bear_cookie, bodysize);
1591 sg.offset = (unsigned long)(bear_cookie) % PAGE_SIZE;
1592 sg.length = bodysize;
1593 key = (char *)ep->secret_key[ep->current_key]; 1589 key = (char *)ep->secret_key[ep->current_key];
1594 desc.tfm = sctp_sk(ep->base.sk)->hmac; 1590 desc.tfm = sctp_sk(ep->base.sk)->hmac;
1595 desc.flags = 0; 1591 desc.flags = 0;
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index 32be431affcf..24711be4b2dc 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -199,7 +199,7 @@ encryptor(struct scatterlist *sg, void *data)
199 } else { 199 } else {
200 in_page = sg_page(sg); 200 in_page = sg_page(sg);
201 } 201 }
202 sg_set_page(&desc->infrags[desc->fragno], in_page); 202 sg_assign_page(&desc->infrags[desc->fragno], in_page);
203 desc->fragno++; 203 desc->fragno++;
204 desc->fraglen += sg->length; 204 desc->fraglen += sg->length;
205 desc->pos += sg->length; 205 desc->pos += sg->length;
@@ -215,11 +215,10 @@ encryptor(struct scatterlist *sg, void *data)
215 if (ret) 215 if (ret)
216 return ret; 216 return ret;
217 if (fraglen) { 217 if (fraglen) {
218 sg_set_page(&desc->outfrags[0], sg_page(sg)); 218 sg_set_page(&desc->outfrags[0], sg_page(sg), fraglen,
219 desc->outfrags[0].offset = sg->offset + sg->length - fraglen; 219 sg->offset + sg->length - fraglen);
220 desc->outfrags[0].length = fraglen;
221 desc->infrags[0] = desc->outfrags[0]; 220 desc->infrags[0] = desc->outfrags[0];
222 sg_set_page(&desc->infrags[0], in_page); 221 sg_assign_page(&desc->infrags[0], in_page);
223 desc->fragno = 1; 222 desc->fragno = 1;
224 desc->fraglen = fraglen; 223 desc->fraglen = fraglen;
225 } else { 224 } else {
@@ -287,9 +286,8 @@ decryptor(struct scatterlist *sg, void *data)
287 if (ret) 286 if (ret)
288 return ret; 287 return ret;
289 if (fraglen) { 288 if (fraglen) {
290 sg_set_page(&desc->frags[0], sg_page(sg)); 289 sg_set_page(&desc->frags[0], sg_page(sg), fraglen,
291 desc->frags[0].offset = sg->offset + sg->length - fraglen; 290 sg->offset + sg->length - fraglen);
292 desc->frags[0].length = fraglen;
293 desc->fragno = 1; 291 desc->fragno = 1;
294 desc->fraglen = fraglen; 292 desc->fraglen = fraglen;
295 } else { 293 } else {
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 3d1f7cdf9dd0..f38dac30481b 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -1059,9 +1059,7 @@ xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len,
1059 do { 1059 do {
1060 if (thislen > page_len) 1060 if (thislen > page_len)
1061 thislen = page_len; 1061 thislen = page_len;
1062 sg_set_page(sg, buf->pages[i]); 1062 sg_set_page(sg, buf->pages[i], thislen, page_offset);
1063 sg->offset = page_offset;
1064 sg->length = thislen;
1065 ret = actor(sg, data); 1063 ret = actor(sg, data);
1066 if (ret) 1064 if (ret)
1067 goto out; 1065 goto out;
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c
index 313d4bed3aa9..fa45989a716a 100644
--- a/net/xfrm/xfrm_algo.c
+++ b/net/xfrm/xfrm_algo.c
@@ -553,9 +553,7 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
553 if (copy > len) 553 if (copy > len)
554 copy = len; 554 copy = len;
555 555
556 sg_set_page(&sg, virt_to_page(skb->data + offset)); 556 sg_set_buf(&sg, skb->data + offset, copy);
557 sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
558 sg.length = copy;
559 557
560 err = icv_update(desc, &sg, copy); 558 err = icv_update(desc, &sg, copy);
561 if (unlikely(err)) 559 if (unlikely(err))
@@ -578,9 +576,8 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
578 if (copy > len) 576 if (copy > len)
579 copy = len; 577 copy = len;
580 578
581 sg_set_page(&sg, frag->page); 579 sg_set_page(&sg, frag->page, copy,
582 sg.offset = frag->page_offset + offset-start; 580 frag->page_offset + offset-start);
583 sg.length = copy;
584 581
585 err = icv_update(desc, &sg, copy); 582 err = icv_update(desc, &sg, copy);
586 if (unlikely(err)) 583 if (unlikely(err))