Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/350338/?format=api
{ "id": 350338, "url": "http://patchwork.ozlabs.org/api/patches/350338/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/1400518800-6111-6-git-send-email-ezequiel.garcia@free-electrons.com/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "name": "Linux network development", "link_name": "netdev", "list_id": "netdev.vger.kernel.org", "list_email": "netdev@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1400518800-6111-6-git-send-email-ezequiel.garcia@free-electrons.com>", "list_archive_url": null, "date": "2014-05-19T16:59:56", "name": "[5/9] net: mv643xx_eth: Factorize initial checksum and command preparation", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "28a160f03ec3e3b9870c69128cefe472d887ae63", "submitter": { "id": 20433, "url": "http://patchwork.ozlabs.org/api/people/20433/?format=api", "name": "Ezequiel Garcia", "email": "ezequiel.garcia@free-electrons.com" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/1400518800-6111-6-git-send-email-ezequiel.garcia@free-electrons.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/350338/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/350338/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 7A3A7140082\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 20 May 2014 03:01:19 +1000 (EST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S932244AbaESRBL (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 19 May 2014 13:01:11 -0400", "from top.free-electrons.com ([176.31.233.9]:53608 \"EHLO\n\tmail.free-electrons.com\" rhost-flags-OK-OK-OK-FAIL) by\n\tvger.kernel.org with ESMTP id S1751596AbaESRBK (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 19 May 2014 13:01:10 -0400", "by mail.free-electrons.com (Postfix, from userid 106)\n\tid 66649912; Mon, 19 May 2014 19:01:13 +0200 (CEST)", "from localhost.localdomain (unknown [190.2.108.30])\n\tby mail.free-electrons.com (Postfix) with ESMTPSA id 13B627A9;\n\tMon, 19 May 2014 19:01:09 +0200 (CEST)" ], "X-Spam-Checker-Version": "SpamAssassin 3.3.2 (2011-06-06) on\n\tmail.free-electrons.com", "X-Spam-Level": "", "X-Spam-Status": "No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT\n\tshortcircuit=ham autolearn=disabled version=3.3.2", "From": "Ezequiel Garcia <ezequiel.garcia@free-electrons.com>", "To": "<netdev@vger.kernel.org>, David Miller <davem@davemloft.net>,\n\tEric Dumazet <eric.dumazet@gmail.com>", "Cc": "Willy Tarreau <w@1wt.eu>,\n\tThomas Petazzoni <thomas.petazzoni@free-electrons.com>,\n\tGregory Clement <gregory.clement@free-electrons.com>,\n\tSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,\n\tTawfik Bayouk <tawfik@marvell.com>, Lior Amsalem <alior@marvell.com>,\n\tEzequiel Garcia <ezequiel.garcia@free-electrons.com>", "Subject": "[PATCH 5/9] net: mv643xx_eth: Factorize initial checksum and\n\tcommand preparation", "Date": "Mon, 19 May 2014 13:59:56 -0300", "Message-Id": "<1400518800-6111-6-git-send-email-ezequiel.garcia@free-electrons.com>", "X-Mailer": "git-send-email 1.9.1", "In-Reply-To": "<1400518800-6111-1-git-send-email-ezequiel.garcia@free-electrons.com>", "References": "<1400518800-6111-1-git-send-email-ezequiel.garcia@free-electrons.com>", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "Make the code more readable by moving the initial checksum setup\nand the command/status preparation to its own function.\n\nSigned-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>\n---\n drivers/net/ethernet/marvell/mv643xx_eth.c | 113 +++++++++++++++++------------\n 1 file changed, 65 insertions(+), 48 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c\nindex df1d1b9..14a0dbb 100644\n--- a/drivers/net/ethernet/marvell/mv643xx_eth.c\n+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c\n@@ -661,6 +661,64 @@ static inline unsigned int has_tiny_unaligned_frags(struct sk_buff *skb)\n \treturn 0;\n }\n \n+static inline __be16 sum16_as_be(__sum16 sum)\n+{\n+\treturn (__force __be16)sum;\n+}\n+\n+static int skb_tx_csum(struct mv643xx_eth_private *mp, struct sk_buff *skb,\n+\t\t u16 *l4i_chk, u32 *command, int length)\n+{\n+\tint ret;\n+\tu32 cmd = 0;\n+\n+\tif (skb->ip_summed == CHECKSUM_PARTIAL) {\n+\t\tint hdr_len;\n+\t\tint tag_bytes;\n+\n+\t\tBUG_ON(skb->protocol != htons(ETH_P_IP) &&\n+\t\t skb->protocol != htons(ETH_P_8021Q));\n+\n+\t\thdr_len = (void *)ip_hdr(skb) - (void *)skb->data;\n+\t\ttag_bytes = hdr_len - ETH_HLEN;\n+\n+\t\tif (length - hdr_len > mp->shared->tx_csum_limit ||\n+\t\t unlikely(tag_bytes & ~12)) {\n+\t\t\tret = skb_checksum_help(skb);\n+\t\t\tif (!ret)\n+\t\t\t\tgoto no_csum;\n+\t\t\treturn ret;\n+\t\t}\n+\n+\t\tif (tag_bytes & 4)\n+\t\t\tcmd |= MAC_HDR_EXTRA_4_BYTES;\n+\t\tif (tag_bytes & 8)\n+\t\t\tcmd |= MAC_HDR_EXTRA_8_BYTES;\n+\n+\t\tcmd |= GEN_TCP_UDP_CHECKSUM |\n+\t\t\t GEN_IP_V4_CHECKSUM |\n+\t\t\t ip_hdr(skb)->ihl << TX_IHL_SHIFT;\n+\n+\t\tswitch (ip_hdr(skb)->protocol) {\n+\t\tcase IPPROTO_UDP:\n+\t\t\tcmd |= UDP_FRAME;\n+\t\t\t*l4i_chk = ntohs(sum16_as_be(udp_hdr(skb)->check));\n+\t\t\tbreak;\n+\t\tcase IPPROTO_TCP:\n+\t\t\t*l4i_chk = ntohs(sum16_as_be(tcp_hdr(skb)->check));\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tWARN(1, \"protocol not supported\");\n+\t\t}\n+\t} else {\n+no_csum:\n+\t\t/* Errata BTS #50, IHL must be 5 if no HW checksum */\n+\t\tcmd |= 5 << TX_IHL_SHIFT;\n+\t}\n+\t*command = cmd;\n+\treturn 0;\n+}\n+\n static void txq_submit_frag_skb(struct tx_queue *txq, struct sk_buff *skb)\n {\n \tstruct mv643xx_eth_private *mp = txq_to_mp(txq);\n@@ -699,11 +757,6 @@ static void txq_submit_frag_skb(struct tx_queue *txq, struct sk_buff *skb)\n \t}\n }\n \n-static inline __be16 sum16_as_be(__sum16 sum)\n-{\n-\treturn (__force __be16)sum;\n-}\n-\n static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb)\n {\n \tstruct mv643xx_eth_private *mp = txq_to_mp(txq);\n@@ -712,53 +765,17 @@ static int txq_submit_skb(struct tx_queue *txq, struct sk_buff *skb)\n \tstruct tx_desc *desc;\n \tu32 cmd_sts;\n \tu16 l4i_chk;\n-\tint length;\n+\tint length, ret;\n \n-\tcmd_sts = TX_FIRST_DESC | GEN_CRC | BUFFER_OWNED_BY_DMA;\n+\tcmd_sts = 0;\n \tl4i_chk = 0;\n \n-\tif (skb->ip_summed == CHECKSUM_PARTIAL) {\n-\t\tint hdr_len;\n-\t\tint tag_bytes;\n-\n-\t\tBUG_ON(skb->protocol != htons(ETH_P_IP) &&\n-\t\t skb->protocol != htons(ETH_P_8021Q));\n-\n-\t\thdr_len = (void *)ip_hdr(skb) - (void *)skb->data;\n-\t\ttag_bytes = hdr_len - ETH_HLEN;\n-\t\tif (skb->len - hdr_len > mp->shared->tx_csum_limit ||\n-\t\t unlikely(tag_bytes & ~12)) {\n-\t\t\tif (skb_checksum_help(skb) == 0)\n-\t\t\t\tgoto no_csum;\n-\t\t\tdev_kfree_skb_any(skb);\n-\t\t\treturn 1;\n-\t\t}\n-\n-\t\tif (tag_bytes & 4)\n-\t\t\tcmd_sts |= MAC_HDR_EXTRA_4_BYTES;\n-\t\tif (tag_bytes & 8)\n-\t\t\tcmd_sts |= MAC_HDR_EXTRA_8_BYTES;\n-\n-\t\tcmd_sts |= GEN_TCP_UDP_CHECKSUM |\n-\t\t\t GEN_IP_V4_CHECKSUM |\n-\t\t\t ip_hdr(skb)->ihl << TX_IHL_SHIFT;\n-\n-\t\tswitch (ip_hdr(skb)->protocol) {\n-\t\tcase IPPROTO_UDP:\n-\t\t\tcmd_sts |= UDP_FRAME;\n-\t\t\tl4i_chk = ntohs(sum16_as_be(udp_hdr(skb)->check));\n-\t\t\tbreak;\n-\t\tcase IPPROTO_TCP:\n-\t\t\tl4i_chk = ntohs(sum16_as_be(tcp_hdr(skb)->check));\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\tBUG();\n-\t\t}\n-\t} else {\n-no_csum:\n-\t\t/* Errata BTS #50, IHL must be 5 if no HW checksum */\n-\t\tcmd_sts |= 5 << TX_IHL_SHIFT;\n+\tret = skb_tx_csum(mp, skb, &l4i_chk, &cmd_sts, skb->len);\n+\tif (ret) {\n+\t\tdev_kfree_skb_any(skb);\n+\t\treturn ret;\n \t}\n+\tcmd_sts |= TX_FIRST_DESC | GEN_CRC | BUFFER_OWNED_BY_DMA;\n \n \ttx_index = txq->tx_curr_desc++;\n \tif (txq->tx_curr_desc == txq->tx_ring_size)\n", "prefixes": [ "5/9" ] }