Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/477521/?format=api
{ "id": 477521, "url": "http://patchwork.ozlabs.org/api/patches/477521/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/1432863742-18427-5-git-send-email-mathieu@codeaurora.org/", "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": "<1432863742-18427-5-git-send-email-mathieu@codeaurora.org>", "list_archive_url": null, "date": "2015-05-29T01:42:19", "name": "[4/7] net: dsa: add QCA tag support", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "b8868bbeb40f83d6d4211f119ec6be8084c25135", "submitter": { "id": 65737, "url": "http://patchwork.ozlabs.org/api/people/65737/?format=api", "name": "Mathieu Olivari", "email": "mathieu@codeaurora.org" }, "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/1432863742-18427-5-git-send-email-mathieu@codeaurora.org/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/477521/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/477521/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 D8757140E1A\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 29 May 2015 11:43:30 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1755164AbbE2Bm4 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 28 May 2015 21:42:56 -0400", "from smtp.codeaurora.org ([198.145.29.96]:37455 \"EHLO\n\tsmtp.codeaurora.org\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1754567AbbE2Bme (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Thu, 28 May 2015 21:42:34 -0400", "from smtp.codeaurora.org (localhost [127.0.0.1])\n\tby smtp.codeaurora.org (Postfix) with ESMTP id 4DBC4140DB6;\n\tFri, 29 May 2015 01:42:33 +0000 (UTC)", "by smtp.codeaurora.org (Postfix, from userid 486)\n\tid 3AEEB140DBC; Fri, 29 May 2015 01:42:33 +0000 (UTC)", "from mathieu-linux.qualcomm.com (qf-scl1nat.qualcomm.com\n\t[207.114.132.30])\n\t(using TLSv1.2 with cipher AES128-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\t(Authenticated sender: mathieu@smtp.codeaurora.org)\n\tby smtp.codeaurora.org (Postfix) with ESMTPSA id 1D200140DB6;\n\tFri, 29 May 2015 01:42:32 +0000 (UTC)" ], "X-Spam-Checker-Version": "SpamAssassin 3.3.1 (2010-03-16) on\n\tpdx-caf-smtp.dmz.codeaurora.org", "X-Spam-Level": "", "X-Spam-Status": "No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00\n\tautolearn=ham version=3.3.1", "From": "Mathieu Olivari <mathieu@codeaurora.org>", "To": "robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com,\n\tijc+devicetree@hellion.org.uk, galak@codeaurora.org,\n\tdavem@davemloft.net, mathieu@codeaurora.org, andrew@lunn.ch,\n\tf.fainelli@gmail.com, linux@roeck-us.net, gang.chen.5i5j@gmail.com,\n\tjiri@resnulli.us, leitec@staticky.com, fabf@skynet.be,\n\talexander.h.duyck@intel.com, pavel.nakonechny@skitlab.ru,\n\tjoe@perches.com, sfeldma@gmail.com, nbd@openwrt.org, juhosg@openwrt.org", "Cc": "devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,\n\tnetdev@vger.kernel.org", "Subject": "[PATCH 4/7] net: dsa: add QCA tag support", "Date": "Thu, 28 May 2015 18:42:19 -0700", "Message-Id": "<1432863742-18427-5-git-send-email-mathieu@codeaurora.org>", "X-Mailer": "git-send-email 2.1.4", "In-Reply-To": "<1432863742-18427-1-git-send-email-mathieu@codeaurora.org>", "References": "<1432863742-18427-1-git-send-email-mathieu@codeaurora.org>", "X-Virus-Scanned": "ClamAV using ClamSMTP", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "QCA tags are used on QCA ar8xxx switch family. This change adds support\nfor encap/decap using 2 bytes header mode.\n\nSigned-off-by: Mathieu Olivari <mathieu@codeaurora.org>\n---\n include/net/dsa.h | 1 +\n net/dsa/Kconfig | 3 +\n net/dsa/Makefile | 1 +\n net/dsa/dsa.c | 5 ++\n net/dsa/dsa_priv.h | 2 +\n net/dsa/slave.c | 5 ++\n net/dsa/tag_qca.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n 7 files changed, 175 insertions(+)\n create mode 100644 net/dsa/tag_qca.c", "diff": "diff --git a/include/net/dsa.h b/include/net/dsa.h\nindex fbca63b..64ddf6f 100644\n--- a/include/net/dsa.h\n+++ b/include/net/dsa.h\n@@ -26,6 +26,7 @@ enum dsa_tag_protocol {\n \tDSA_TAG_PROTO_TRAILER,\n \tDSA_TAG_PROTO_EDSA,\n \tDSA_TAG_PROTO_BRCM,\n+\tDSA_TAG_PROTO_QCA,\n };\n \n #define DSA_MAX_SWITCHES\t4\ndiff --git a/net/dsa/Kconfig b/net/dsa/Kconfig\nindex ff7736f..4f3cce1 100644\n--- a/net/dsa/Kconfig\n+++ b/net/dsa/Kconfig\n@@ -26,6 +26,9 @@ config NET_DSA_HWMON\n \t via the hwmon sysfs interface and exposes the onboard sensors.\n \n # tagging formats\n+config NET_DSA_TAG_QCA\n+\tbool\n+\n config NET_DSA_TAG_BRCM\n \tbool\n \ndiff --git a/net/dsa/Makefile b/net/dsa/Makefile\nindex da06ed1..9feb86c 100644\n--- a/net/dsa/Makefile\n+++ b/net/dsa/Makefile\n@@ -3,6 +3,7 @@ obj-$(CONFIG_NET_DSA) += dsa_core.o\n dsa_core-y += dsa.o slave.o\n \n # tagging formats\n+dsa_core-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o\n dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o\n dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o\n dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o\ndiff --git a/net/dsa/dsa.c b/net/dsa/dsa.c\nindex fffb9aa..6010a7d 100644\n--- a/net/dsa/dsa.c\n+++ b/net/dsa/dsa.c\n@@ -249,6 +249,11 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)\n \t\t\tdst->rcv = brcm_netdev_ops.rcv;\n \t\t\tbreak;\n #endif\n+#ifdef CONFIG_NET_DSA_TAG_QCA\n+\t\tcase DSA_TAG_PROTO_QCA:\n+\t\t\tdst->rcv = qca_netdev_ops.rcv;\n+\t\t\tbreak;\n+#endif\n \t\tcase DSA_TAG_PROTO_NONE:\n \t\t\tbreak;\n \t\tdefault:\ndiff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h\nindex d5f1f9b..350c94b 100644\n--- a/net/dsa/dsa_priv.h\n+++ b/net/dsa/dsa_priv.h\n@@ -74,5 +74,7 @@ extern const struct dsa_device_ops trailer_netdev_ops;\n /* tag_brcm.c */\n extern const struct dsa_device_ops brcm_netdev_ops;\n \n+/* tag_qca.c */\n+extern const struct dsa_device_ops qca_netdev_ops;\n \n #endif\ndiff --git a/net/dsa/slave.c b/net/dsa/slave.c\nindex 04ffad3..cd8f552 100644\n--- a/net/dsa/slave.c\n+++ b/net/dsa/slave.c\n@@ -925,6 +925,11 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,\n \t\tp->xmit = brcm_netdev_ops.xmit;\n \t\tbreak;\n #endif\n+#ifdef CONFIG_NET_DSA_TAG_QCA\n+\tcase DSA_TAG_PROTO_QCA:\n+\t\tp->xmit = qca_netdev_ops.xmit;\n+\t\tbreak;\n+#endif\n \tdefault:\n \t\tp->xmit\t= dsa_slave_notag_xmit;\n \t\tbreak;\ndiff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c\nnew file mode 100644\nindex 0000000..8f02196\n--- /dev/null\n+++ b/net/dsa/tag_qca.c\n@@ -0,0 +1,158 @@\n+/*\n+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License version 2 and\n+ * only version 2 as published by the Free Software Foundation.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n+ * GNU General Public License for more details.\n+ */\n+\n+#include <linux/etherdevice.h>\n+#include \"dsa_priv.h\"\n+\n+#define QCA_HDR_LEN\t2\n+#define QCA_HDR_VERSION\t0x2\n+\n+#define QCA_HDR_RECV_VERSION_MASK\tGENMASK(15, 14)\n+#define QCA_HDR_RECV_VERSION_S\t\t14\n+#define QCA_HDR_RECV_PRIORITY_MASK\tGENMASK(13, 11)\n+#define QCA_HDR_RECV_PRIORITY_S\t\t11\n+#define QCA_HDR_RECV_TYPE_MASK\t\tGENMASK(10, 6)\n+#define QCA_HDR_RECV_TYPE_S\t\t6\n+#define QCA_HDR_RECV_FRAME_IS_TAGGED\tBIT(3)\n+#define QCA_HDR_RECV_SOURCE_PORT_MASK\tGENMASK(2, 0)\n+\n+#define QCA_HDR_XMIT_VERSION_MASK\tGENMASK(15, 14)\n+#define QCA_HDR_XMIT_VERSION_S\t\t14\n+#define QCA_HDR_XMIT_PRIORITY_MASK\tGENMASK(13, 11)\n+#define QCA_HDR_XMIT_PRIORITY_S\t\t11\n+#define QCA_HDR_XMIT_CONTROL_MASK\tGENMASK(10, 8)\n+#define QCA_HDR_XMIT_CONTROL_S\t\t8\n+#define QCA_HDR_XMIT_FROM_CPU\t\tBIT(7)\n+#define QCA_HDR_XMIT_DP_BIT_MASK\tGENMASK(6, 0)\n+\n+static inline int reg_to_port(int reg)\n+{\n+\tif (reg < 5)\n+\t\treturn reg + 1;\n+\n+\treturn -1;\n+}\n+\n+static inline int port_to_reg(int port)\n+{\n+\tif (port >= 1 && port <= 6)\n+\t\treturn port - 1;\n+\n+\treturn -1;\n+}\n+\n+static netdev_tx_t qca_tag_xmit(struct sk_buff *skb, struct net_device *dev)\n+{\n+\tstruct dsa_slave_priv *p = netdev_priv(dev);\n+\tu16 *phdr, hdr;\n+\n+\tdev->stats.tx_packets++;\n+\tdev->stats.tx_bytes += skb->len;\n+\n+\tif (skb_cow_head(skb, 0) < 0)\n+\t\tgoto out_free;\n+\n+\tskb_push(skb, QCA_HDR_LEN);\n+\n+\tmemmove(skb->data, skb->data + QCA_HDR_LEN, 2 * ETH_ALEN);\n+\tphdr = (u16 *)(skb->data + 2 * ETH_ALEN);\n+\n+\t/* Set the version field, and set destination port information */\n+\thdr = QCA_HDR_VERSION << QCA_HDR_XMIT_VERSION_S |\n+\t\tQCA_HDR_XMIT_FROM_CPU |\n+\t\t1 << reg_to_port(p->port);\n+\n+\t*phdr = htons(hdr);\n+\n+\tskb->dev = p->parent->dst->master_netdev;\n+\tdev_queue_xmit(skb);\n+\n+\treturn NETDEV_TX_OK;\n+\n+out_free:\n+\tkfree_skb(skb);\n+\treturn NETDEV_TX_OK;\n+}\n+\n+static int qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,\n+\t\t struct packet_type *pt, struct net_device *orig_dev)\n+{\n+\tstruct dsa_switch_tree *dst = dev->dsa_ptr;\n+\tstruct dsa_switch *ds;\n+\tu8 ver;\n+\tint port, phy;\n+\t__be16 *phdr, hdr;\n+\n+\tif (unlikely(!dst))\n+\t\tgoto out_drop;\n+\n+\tskb = skb_unshare(skb, GFP_ATOMIC);\n+\tif (!skb)\n+\t\tgoto out;\n+\n+\tif (unlikely(!pskb_may_pull(skb, QCA_HDR_LEN)))\n+\t\tgoto out_drop;\n+\n+\t/* Ethernet is added by the switch between src addr and Ethertype\n+\t * At this point, skb->data points to ethertype so header should be\n+\t * right before\n+\t */\n+\tphdr = (__be16 *)(skb->data - 2);\n+\thdr = ntohs(*phdr);\n+\n+\t/* Make sure the version is correct */\n+\tver = (hdr & QCA_HDR_RECV_VERSION_MASK) >> QCA_HDR_RECV_VERSION_S;\n+\tif (unlikely(ver != QCA_HDR_VERSION))\n+\t\tgoto out_drop;\n+\n+\t/* Remove QCA tag and recalculate checksum */\n+\tskb_pull_rcsum(skb, QCA_HDR_LEN);\n+\tmemmove(skb->data - ETH_HLEN, skb->data - ETH_HLEN - QCA_HDR_LEN,\n+\t\tETH_HLEN - QCA_HDR_LEN);\n+\n+\t/* This protocol doesn't support cascading multiple switches so it's\n+\t * safe to assume the switch is first in the tree\n+\t */\n+\tds = dst->ds[0];\n+\tif (!ds)\n+\t\tgoto out_drop;\n+\n+\t/* Get source port information */\n+\tport = (hdr & QCA_HDR_RECV_SOURCE_PORT_MASK);\n+\tphy = port_to_reg(port);\n+\tif (unlikely(phy < 0) || !ds->ports[phy])\n+\t\tgoto out_drop;\n+\n+\t/* Update skb & forward the frame accordingly */\n+\tskb_push(skb, ETH_HLEN);\n+\tskb->pkt_type = PACKET_HOST;\n+\tskb->dev = ds->ports[phy];\n+\tskb->protocol = eth_type_trans(skb, skb->dev);\n+\n+\tskb->dev->stats.rx_packets++;\n+\tskb->dev->stats.rx_bytes += skb->len;\n+\n+\tnetif_receive_skb(skb);\n+\n+\treturn 0;\n+\n+out_drop:\n+\tkfree_skb(skb);\n+out:\n+\treturn 0;\n+}\n+\n+const struct dsa_device_ops qca_netdev_ops = {\n+\t.xmit\t= qca_tag_xmit,\n+\t.rcv\t= qca_tag_rcv,\n+};\n", "prefixes": [ "4/7" ] }