[NET] move skb_can_coalesce to skbuff.h

This one also removes the duplicate can_coalesce in tcp.c and makes it
use skb_can_coalesce.
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@conectiva.com.br>
parent 56a6f4d0
......@@ -993,6 +993,18 @@ static inline int skb_add_data(struct sk_buff *skb,
return -EFAULT;
}
static inline int skb_can_coalesce(struct sk_buff *skb, int i,
struct page *page, int off)
{
if (i) {
struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1];
return page == frag->page &&
off == frag->page_offset + frag->size;
}
return 0;
}
/**
* skb_linearize - convert paged skb to linear one
* @skb: buffer to linarize
......
......@@ -702,17 +702,6 @@ ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk
return 0;
}
static inline int
skb_can_coalesce(struct sk_buff *skb, int i, struct page *page, int off)
{
if (i) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i-1];
return page == frag->page &&
off == frag->page_offset+frag->size;
}
return 0;
}
static inline unsigned int
csum_page(struct page *page, int offset, int copy)
{
......
......@@ -737,17 +737,6 @@ static int wait_for_tcp_memory(struct sock *sk, long *timeo)
goto out;
}
static inline int can_coalesce(struct sk_buff *skb, int i, struct page *page,
int off)
{
if (i) {
skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];
return page == frag->page &&
off == frag->page_offset + frag->size;
}
return 0;
}
static inline void fill_page_desc(struct sk_buff *skb, int i,
struct page *page, int off, int size)
{
......@@ -865,7 +854,7 @@ static ssize_t do_tcp_sendpages(struct sock *sk, struct page **pages, int poffse
copy = size;
i = skb_shinfo(skb)->nr_frags;
if (can_coalesce(skb, i, page, offset)) {
if (skb_can_coalesce(skb, i, page, offset)) {
skb_shinfo(skb)->frags[i - 1].size += copy;
} else if (i < MAX_SKB_FRAGS) {
get_page(page);
......@@ -1053,7 +1042,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
struct page *page = TCP_PAGE(sk);
int off = TCP_OFF(sk);
if (can_coalesce(skb, i, page, off) &&
if (skb_can_coalesce(skb, i, page, off) &&
off != PAGE_SIZE) {
/* We can extend the last page
* fragment. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment