Commit b6f72f96 authored by Julian Wiedmann's avatar Julian Wiedmann Committed by David S. Miller

s390/qeth: clean up page frag creation

Replace the open-coded skb_add_rx_frag(), and use a fall-through
to remove some duplicated code.
Signed-off-by: default avatarJulian Wiedmann <jwi@linux.vnet.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9400c53f
...@@ -5172,10 +5172,11 @@ EXPORT_SYMBOL_GPL(qeth_core_hardsetup_card); ...@@ -5172,10 +5172,11 @@ EXPORT_SYMBOL_GPL(qeth_core_hardsetup_card);
static int qeth_create_skb_frag(struct qeth_qdio_buffer *qethbuffer, static int qeth_create_skb_frag(struct qeth_qdio_buffer *qethbuffer,
struct qdio_buffer_element *element, struct qdio_buffer_element *element,
struct sk_buff **pskb, int offset, int *pfrag, struct sk_buff **pskb, int offset, int data_len)
int data_len)
{ {
struct page *page = virt_to_page(element->addr); struct page *page = virt_to_page(element->addr);
unsigned int next_frag;
if (*pskb == NULL) { if (*pskb == NULL) {
if (qethbuffer->rx_skb) { if (qethbuffer->rx_skb) {
/* only if qeth_card.options.cq == QETH_CQ_ENABLED */ /* only if qeth_card.options.cq == QETH_CQ_ENABLED */
...@@ -5190,28 +5191,19 @@ static int qeth_create_skb_frag(struct qeth_qdio_buffer *qethbuffer, ...@@ -5190,28 +5191,19 @@ static int qeth_create_skb_frag(struct qeth_qdio_buffer *qethbuffer,
skb_reserve(*pskb, ETH_HLEN); skb_reserve(*pskb, ETH_HLEN);
if (data_len <= QETH_RX_PULL_LEN) { if (data_len <= QETH_RX_PULL_LEN) {
skb_put_data(*pskb, element->addr + offset, data_len); skb_put_data(*pskb, element->addr + offset, data_len);
return 0;
} else { } else {
get_page(page);
skb_put_data(*pskb, element->addr + offset, skb_put_data(*pskb, element->addr + offset,
QETH_RX_PULL_LEN); QETH_RX_PULL_LEN);
skb_fill_page_desc(*pskb, *pfrag, page, data_len -= QETH_RX_PULL_LEN;
offset + QETH_RX_PULL_LEN, offset += QETH_RX_PULL_LEN;
data_len - QETH_RX_PULL_LEN); /* fall through to add page frag for remaining data */
(*pskb)->data_len += data_len - QETH_RX_PULL_LEN;
(*pskb)->len += data_len - QETH_RX_PULL_LEN;
(*pskb)->truesize += data_len - QETH_RX_PULL_LEN;
(*pfrag)++;
} }
} else {
get_page(page);
skb_fill_page_desc(*pskb, *pfrag, page, offset, data_len);
(*pskb)->data_len += data_len;
(*pskb)->len += data_len;
(*pskb)->truesize += data_len;
(*pfrag)++;
} }
next_frag = skb_shinfo(*pskb)->nr_frags;
get_page(page);
skb_add_rx_frag(*pskb, next_frag, page, offset, data_len, data_len);
return 0; return 0;
} }
...@@ -5234,7 +5226,6 @@ struct sk_buff *qeth_core_get_next_skb(struct qeth_card *card, ...@@ -5234,7 +5226,6 @@ struct sk_buff *qeth_core_get_next_skb(struct qeth_card *card,
int data_len; int data_len;
int headroom = 0; int headroom = 0;
int use_rx_sg = 0; int use_rx_sg = 0;
int frag = 0;
/* qeth_hdr must not cross element boundaries */ /* qeth_hdr must not cross element boundaries */
if (element->length < offset + sizeof(struct qeth_hdr)) { if (element->length < offset + sizeof(struct qeth_hdr)) {
...@@ -5286,7 +5277,7 @@ struct sk_buff *qeth_core_get_next_skb(struct qeth_card *card, ...@@ -5286,7 +5277,7 @@ struct sk_buff *qeth_core_get_next_skb(struct qeth_card *card,
if (data_len) { if (data_len) {
if (use_rx_sg) { if (use_rx_sg) {
if (qeth_create_skb_frag(qethbuffer, element, if (qeth_create_skb_frag(qethbuffer, element,
&skb, offset, &frag, data_len)) &skb, offset, data_len))
goto no_mem; goto no_mem;
} else { } else {
skb_put_data(skb, data_ptr, data_len); skb_put_data(skb, data_ptr, data_len);
......
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