get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/807992/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 807992,
    "url": "http://patchwork.ozlabs.org/api/patches/807992/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/1504138732-65383-9-git-send-email-f.fainelli@gmail.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": "<1504138732-65383-9-git-send-email-f.fainelli@gmail.com>",
    "list_archive_url": null,
    "date": "2017-08-31T00:18:52",
    "name": "[RFC,net-next,8/8] net: systemport: Establish DSA network device queue mapping",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": true,
    "hash": "4b054a9448950c5344990978cda08a8450a45a81",
    "submitter": {
        "id": 2800,
        "url": "http://patchwork.ozlabs.org/api/people/2800/?format=api",
        "name": "Florian Fainelli",
        "email": "f.fainelli@gmail.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/1504138732-65383-9-git-send-email-f.fainelli@gmail.com/mbox/",
    "series": [
        {
            "id": 728,
            "url": "http://patchwork.ozlabs.org/api/series/728/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=728",
            "date": "2017-08-31T00:18:44",
            "name": "net: dsa: Multi-queue awareness",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/728/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/807992/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/807992/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<netdev-owner@vger.kernel.org>",
        "X-Original-To": "patchwork-incoming@ozlabs.org",
        "Delivered-To": "patchwork-incoming@ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"EG6xaVWI\"; dkim-atps=neutral"
        ],
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xjNVf0kwgz9s83\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 31 Aug 2017 10:27:22 +1000 (AEST)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751425AbdHaA1T (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 30 Aug 2017 20:27:19 -0400",
            "from mail-wm0-f65.google.com ([74.125.82.65]:35515 \"EHLO\n\tmail-wm0-f65.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1750814AbdHaA1R (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 30 Aug 2017 20:27:17 -0400",
            "by mail-wm0-f65.google.com with SMTP id e204so3361060wma.2\n\tfor <netdev@vger.kernel.org>; Wed, 30 Aug 2017 17:27:17 -0700 (PDT)",
            "from stb-bld-04.irv.broadcom.com ([192.19.255.250])\n\tby smtp.gmail.com with ESMTPSA id\n\te74sm5296636wmg.39.2017.08.30.17.27.12\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tWed, 30 Aug 2017 17:27:15 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=pDsgVMKA90UIDgfQSBveN8YZXpJaLMiDQlzdHS5tdno=;\n\tb=EG6xaVWI6BkTkRmhGKsG1MYnEkVTAnkvViPEDlEhv8bzXtrnJDUX83VXZhKhBGJB+y\n\tcwOHEXwoMk/zElw+o2SXL+qo9PHux80SLA1vcu5YaOVpU9cGaqhOXXtTJe+SHRUYRv/T\n\tdj1FV2m4+INbBOsrAfLeawk0JlcMVyfVWS1dDU4ikOQd+nHSTdxg7/vcT7Byux6pDHWf\n\t0JYaTpJpRxGGpwzmRwvXt9AMdMyHh8mvkdgW3/Vh6ClC51LVQyCbKur13Jz8ECwYGcoN\n\t7K5aR9BspS7WuoU05pAJkhQzsO+rb3h9Ja1Negpx5NvrX5eMWKYVRt6HiyjeCdgr5Y26\n\tjDRA==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=pDsgVMKA90UIDgfQSBveN8YZXpJaLMiDQlzdHS5tdno=;\n\tb=SWpe9A8cwMuhLdliXih3JGUm0NMYyou7FCxRPvCcGFm1iMYU5vdWXfRbkrlUK4dhRU\n\tutvDd2iF3XI0oMiFX5r+u/cqM9v9MY7BQrrEk6x8RzCJjGGaOOD2pGS0oiYjhNe5e704\n\twT0qjfToTaKeY9HI7RKEtOgAtPacCUPXIEwXOavtBy5DwqGK5wrj35B6lhiAwGdUBb6l\n\tiakA1MiAJ53nYH+ePyk/+/QmWMBrEHCGJLm7sIZacKZG7xBtTNMtrx5xUi5cmvTVYNlj\n\ttm3m7PARQoNOT9x7IvEY8+tmsbSgR1t2XDYo3iZ+zTT/v+bydv1/ISdqQtS8bZhpAmwC\n\tf2ng==",
        "X-Gm-Message-State": "AHYfb5i+IXy/m7GrcLemFc/udp/h9c8P9cGPM9q+HCBQtxjcqTfcIwOo\n\tDXkFDYHPCuwzlnOUjTE=",
        "X-Received": "by 10.28.64.67 with SMTP id n64mr2132478wma.75.1504139236385;\n\tWed, 30 Aug 2017 17:27:16 -0700 (PDT)",
        "From": "Florian Fainelli <f.fainelli@gmail.com>",
        "To": "netdev@vger.kernel.org",
        "Cc": "jiri@resnulli.us, jhs@mojatatu.com, davem@davemloft.net,\n\txiyou.wangcong@gmail.com, andrew@lunn.ch,\n\tvivien.didelot@savoirfairelinux.com,\n\tFlorian Fainelli <f.fainelli@gmail.com>",
        "Subject": "[RFC net-next 8/8] net: systemport: Establish DSA network device\n\tqueue mapping",
        "Date": "Wed, 30 Aug 2017 17:18:52 -0700",
        "Message-Id": "<1504138732-65383-9-git-send-email-f.fainelli@gmail.com>",
        "X-Mailer": "git-send-email 1.9.1",
        "In-Reply-To": "<1504138732-65383-1-git-send-email-f.fainelli@gmail.com>",
        "References": "<1504138732-65383-1-git-send-email-f.fainelli@gmail.com>",
        "Sender": "netdev-owner@vger.kernel.org",
        "Precedence": "bulk",
        "List-ID": "<netdev.vger.kernel.org>",
        "X-Mailing-List": "netdev@vger.kernel.org"
    },
    "content": "Establish a queue mapping between the DSA slave network device queues\ncreated, and the transmit queue that SYSTEMPORT manages.\n\nWe need to configure the SYSTEMPORT transmit queue with the switch port\nnumber and switch port queue number in order for the switch and\nSYSTEMPORT hardware to utilize the out of band congestion notification.\nThis hardware mechanism works by looking at the switch port egress queue\nand determines whether there is enough buffers for this queue, with that\nclass of service for a successful transmission and if not, backpressures\nthe SYSTEMPORT queue that is being used.\n\nFor this to work, we register a network device notifier that listens for\nthe registration of DSA network devices, and when that happens, extracts\nthe number of queues for these devices and their associated port number,\nremembers that in the driver private structure and linearly maps those\nqueues to TX rings/queues that we manage.\n\nThis scheme works because DSA slave network deviecs always transmit\nthrough SYSTEMPORT so when DSA slave network devices are\ndestroyed/brought down, the corresponding SYSTEMPORT queues are no\nlonger used. Also, by design of the DSA framework, the master network\ndevice (SYSTEMPORT) is registered first.\n\nFor faster lookups we use an array of up to DSA_MAX_PORTS * number\nof queues per port, and then map pointers to bcm_sysport_tx_ring such\nthat our ndo_select_queue() implementation can just index into that\narray to locate the corresponding ring index.\n\nHere is an example mapping with this code:\n\nP0,Q0 -> Q0\n..\nP0,Q7 -> Q7\nP1,Q0 -> Q8\n..\nP1,Q7 -> Q15\nP2,Q0 -> Q16\n..\nP2,Q7 -> Q23\nP7,Q0 -> Q24\n..\nP7,Q7 -> Q31\n\nSigned-off-by: Florian Fainelli <f.fainelli@gmail.com>\n---\n drivers/net/ethernet/broadcom/bcmsysport.c | 100 +++++++++++++++++++++++++++--\n drivers/net/ethernet/broadcom/bcmsysport.h |  11 +++-\n 2 files changed, 106 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c\nindex 931751e4f369..eed4c3f672d7 100644\n--- a/drivers/net/ethernet/broadcom/bcmsysport.c\n+++ b/drivers/net/ethernet/broadcom/bcmsysport.c\n@@ -1387,7 +1387,14 @@ static int bcm_sysport_init_tx_ring(struct bcm_sysport_priv *priv,\n \ttdma_writel(priv, 0, TDMA_DESC_RING_COUNT(index));\n \ttdma_writel(priv, 1, TDMA_DESC_RING_INTR_CONTROL(index));\n \ttdma_writel(priv, 0, TDMA_DESC_RING_PROD_CONS_INDEX(index));\n-\ttdma_writel(priv, RING_IGNORE_STATUS, TDMA_DESC_RING_MAPPING(index));\n+\n+\t/* Configure QID and port mapping */\n+\treg = tdma_readl(priv, TDMA_DESC_RING_MAPPING(index));\n+\treg &= ~(RING_QID_MASK | RING_PORT_ID_MASK << RING_PORT_ID_SHIFT);\n+\treg |= ring->switch_queue & RING_QID_MASK;\n+\treg |= ring->switch_port << RING_PORT_ID_SHIFT;\n+\treg |= RING_IGNORE_STATUS;\n+\ttdma_writel(priv, reg, TDMA_DESC_RING_MAPPING(index));\n \ttdma_writel(priv, 0, TDMA_DESC_RING_PCP_DEI_VID(index));\n \n \t/* Program the number of descriptors as MAX_THRESHOLD and half of\n@@ -1405,8 +1412,9 @@ static int bcm_sysport_init_tx_ring(struct bcm_sysport_priv *priv,\n \tnapi_enable(&ring->napi);\n \n \tnetif_dbg(priv, hw, priv->netdev,\n-\t\t  \"TDMA cfg, size=%d, desc_cpu=%p\\n\",\n-\t\t  ring->size, ring->desc_cpu);\n+\t\t  \"TDMA cfg, size=%d, desc_cpu=%p switch q=%d,port=%d\\n\",\n+\t\t  ring->size, ring->desc_cpu, ring->switch_queue,\n+\t\t  ring->switch_port);\n \n \treturn 0;\n }\n@@ -1987,6 +1995,78 @@ static int bcm_sysport_stop(struct net_device *dev)\n \t.set_link_ksettings     = phy_ethtool_set_link_ksettings,\n };\n \n+static u16 bcm_sysport_select_queue(struct net_device *dev, struct sk_buff *skb,\n+\t\t\t\t    void *accel_priv,\n+\t\t\t\t    select_queue_fallback_t fallback)\n+{\n+\tstruct bcm_sysport_priv *priv = netdev_priv(dev);\n+\tu16 queue = skb_get_queue_mapping(skb);\n+\tstruct bcm_sysport_tx_ring *tx_ring;\n+\tunsigned int q, port;\n+\n+\tif (!netdev_uses_dsa(dev))\n+\t\treturn fallback(dev, skb);\n+\n+\t/* DSA tagging layer will have configured the correct queue */\n+\tq = queue & 0xff;\n+\tport = queue >> priv->per_port_num_tx_queues;\n+\ttx_ring = priv->ring_map[q + port * priv->per_port_num_tx_queues];\n+\n+\treturn tx_ring->index;\n+}\n+\n+static int bcm_sysport_map_queues(struct bcm_sysport_priv *priv,\n+\t\t\t\t  struct net_device *slave_dev)\n+{\n+\tstruct net_device *dev = priv->netdev;\n+\tstruct bcm_sysport_tx_ring *ring;\n+\tunsigned int num_tx_queues;\n+\tunsigned int q, start, port;\n+\n+\tport = dsa_slave_dev_port_num(slave_dev);\n+\tnum_tx_queues = slave_dev->num_tx_queues;\n+\n+\tif (priv->per_port_num_tx_queues &&\n+\t    priv->per_port_num_tx_queues != num_tx_queues)\n+\t\tnetdev_warn(slave_dev, \"asymetric number of per-port queues\\n\");\n+\n+\tpriv->per_port_num_tx_queues = num_tx_queues;\n+\n+\tstart = find_first_zero_bit(&priv->queue_bitmap, dev->num_tx_queues);\n+\tfor (q = 0; q < num_tx_queues; q++) {\n+\t\tring = &priv->tx_rings[q + start];\n+\n+\t\t/* Just remember the mapping actual programming done\n+\t\t * during bcm_sysport_init_tx_ring\n+\t\t */\n+\t\tring->switch_queue = q;\n+\t\tring->switch_port = port;\n+\t\tpriv->ring_map[q + port * num_tx_queues] = ring;\n+\n+\t\t/* Set all queues as being used now */\n+\t\tset_bit(q + start, &priv->queue_bitmap);\n+\t}\n+\n+\treturn NOTIFY_OK;\n+}\n+\n+static int bcm_sysport_notifier_event(struct notifier_block *nb,\n+\t\t\t\t      unsigned long event, void *ptr)\n+{\n+\tstruct net_device *dev = netdev_notifier_info_to_dev(ptr);\n+\tstruct bcm_sysport_priv *priv;\n+\n+\tpriv = container_of(nb, struct bcm_sysport_priv, queue_nb);\n+\n+\tif (!dsa_slave_dev_check(dev))\n+\t\treturn NOTIFY_DONE;\n+\n+\tif (event == NETDEV_REGISTER)\n+\t\treturn bcm_sysport_map_queues(priv, dev);\n+\n+\treturn NOTIFY_DONE;\n+}\n+\n static const struct net_device_ops bcm_sysport_netdev_ops = {\n \t.ndo_start_xmit\t\t= bcm_sysport_xmit,\n \t.ndo_tx_timeout\t\t= bcm_sysport_tx_timeout,\n@@ -1999,6 +2079,7 @@ static int bcm_sysport_stop(struct net_device *dev)\n \t.ndo_poll_controller\t= bcm_sysport_poll_controller,\n #endif\n \t.ndo_get_stats64\t= bcm_sysport_get_stats64,\n+\t.ndo_select_queue\t= bcm_sysport_select_queue,\n };\n \n #define REV_FMT\t\"v%2x.%02x\"\n@@ -2148,10 +2229,17 @@ static int bcm_sysport_probe(struct platform_device *pdev)\n \n \tu64_stats_init(&priv->syncp);\n \n+\tpriv->queue_nb.notifier_call = bcm_sysport_notifier_event;\n+\tret = register_netdevice_notifier(&priv->queue_nb);\n+\tif (ret) {\n+\t\tdev_err(&pdev->dev, \"failed to register notifier\\n\");\n+\t\tgoto err_deregister_fixed_link;\n+\t}\n+\n \tret = register_netdev(dev);\n \tif (ret) {\n \t\tdev_err(&pdev->dev, \"failed to register net_device\\n\");\n-\t\tgoto err_deregister_fixed_link;\n+\t\tgoto err_deregister_nb;\n \t}\n \n \tpriv->rev = topctrl_readl(priv, REV_CNTL) & REV_MASK;\n@@ -2164,6 +2252,8 @@ static int bcm_sysport_probe(struct platform_device *pdev)\n \n \treturn 0;\n \n+err_deregister_nb:\n+\tunregister_netdevice_notifier(&priv->queue_nb);\n err_deregister_fixed_link:\n \tif (of_phy_is_fixed_link(dn))\n \t\tof_phy_deregister_fixed_link(dn);\n@@ -2175,6 +2265,7 @@ static int bcm_sysport_probe(struct platform_device *pdev)\n static int bcm_sysport_remove(struct platform_device *pdev)\n {\n \tstruct net_device *dev = dev_get_drvdata(&pdev->dev);\n+\tstruct bcm_sysport_priv *priv = netdev_priv(dev);\n \tstruct device_node *dn = pdev->dev.of_node;\n \n \t/* Not much to do, ndo_close has been called\n@@ -2183,6 +2274,7 @@ static int bcm_sysport_remove(struct platform_device *pdev)\n \tunregister_netdev(dev);\n \tif (of_phy_is_fixed_link(dn))\n \t\tof_phy_deregister_fixed_link(dn);\n+\tunregister_netdevice_notifier(&priv->queue_nb);\n \tfree_netdev(dev);\n \tdev_set_drvdata(&pdev->dev, NULL);\n \ndiff --git a/drivers/net/ethernet/broadcom/bcmsysport.h b/drivers/net/ethernet/broadcom/bcmsysport.h\nindex 80b4ffff63b7..8913cb0cace6 100644\n--- a/drivers/net/ethernet/broadcom/bcmsysport.h\n+++ b/drivers/net/ethernet/broadcom/bcmsysport.h\n@@ -404,7 +404,7 @@ struct bcm_rsb {\n #define  RING_CONS_INDEX_MASK\t\t0xffff\n \n #define RING_MAPPING\t\t\t0x14\n-#define  RING_QID_MASK\t\t\t0x3\n+#define  RING_QID_MASK\t\t\t0x7\n #define  RING_PORT_ID_SHIFT\t\t3\n #define  RING_PORT_ID_MASK\t\t0x7\n #define  RING_IGNORE_STATUS\t\t(1 << 6)\n@@ -711,6 +711,8 @@ struct bcm_sysport_tx_ring {\n \tstruct bcm_sysport_priv *priv;\t/* private context backpointer */\n \tunsigned long\tpackets;\t/* packets statistics */\n \tunsigned long\tbytes;\t\t/* bytes statistics */\n+\tunsigned int\tswitch_queue;\t/* switch port queue number */\n+\tunsigned int\tswitch_port;\t/* switch port queue number */\n };\n \n /* Driver private structure */\n@@ -764,5 +766,12 @@ struct bcm_sysport_priv {\n \n \t/* For atomic update generic 64bit value on 32bit Machine */\n \tstruct u64_stats_sync\tsyncp;\n+\n+\t/* netdev notifier to map switch port queues */\n+\tstruct notifier_block\tqueue_nb;\n+\tunsigned int\t\tper_port_num_tx_queues;\n+\tunsigned long\t\tqueue_bitmap;\n+\tstruct bcm_sysport_tx_ring *ring_map[DSA_MAX_PORTS * 8];\n+\n };\n #endif /* __BCM_SYSPORT_H */\n",
    "prefixes": [
        "RFC",
        "net-next",
        "8/8"
    ]
}