get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 25999,
    "url": "https://patches.dpdk.org/api/patches/25999/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20170629173035.13140-1-tomaszx.kulasek@intel.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20170629173035.13140-1-tomaszx.kulasek@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20170629173035.13140-1-tomaszx.kulasek@intel.com",
    "date": "2017-06-29T17:30:35",
    "name": "[dpdk-dev,v2] bonding: allow to create master bonding",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "aa85104078ed5081f822ea78b4890f83b9ce62d3",
    "submitter": {
        "id": 155,
        "url": "https://patches.dpdk.org/api/people/155/?format=api",
        "name": "Tomasz Kulasek",
        "email": "tomaszx.kulasek@intel.com"
    },
    "delegate": {
        "id": 319,
        "url": "https://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20170629173035.13140-1-tomaszx.kulasek@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/25999/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/25999/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 7405058CD;\n\tThu, 29 Jun 2017 19:31:07 +0200 (CEST)",
            "from mga07.intel.com (mga07.intel.com [134.134.136.100])\n\tby dpdk.org (Postfix) with ESMTP id 048585689\n\tfor <dev@dpdk.org>; Thu, 29 Jun 2017 19:31:05 +0200 (CEST)",
            "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby orsmga105.jf.intel.com with ESMTP; 29 Jun 2017 10:31:04 -0700",
            "from unknown (HELO Sent) ([10.103.103.85])\n\tby fmsmga001.fm.intel.com with SMTP; 29 Jun 2017 10:31:03 -0700",
            "by Sent (sSMTP sendmail emulation); Thu, 29 Jun 2017 19:30:41 +0200"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.40,282,1496127600\"; d=\"scan'208\";\n\ta=\"1166261864\"",
        "From": "Tomasz Kulasek <tomaszx.kulasek@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Thu, 29 Jun 2017 19:30:35 +0200",
        "Message-Id": "<20170629173035.13140-1-tomaszx.kulasek@intel.com>",
        "X-Mailer": "git-send-email 2.12.3",
        "In-Reply-To": "<1496001247-476-1-git-send-email-tomaszx.kulasek@intel.com>",
        "References": "<1496001247-476-1-git-send-email-tomaszx.kulasek@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2] bonding: allow to create master bonding",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch removes restrictions in bonded device library which prevent a\nbonded device to be added to another bonded device.\n\nAdded link speed calculation for a bonding with fallowed rules:\n - BROADCAST - Minimal slaves link speed\n - ACTIVE_BACKUP - Current primary slave\n - ROUND_ROBIN, BALANCE, 8023AD, TLB, ALB - Sum of slaves link speeds\n\nThere's two limitations to create master bonding:\n\n - Total depth of nesting is limited to two levels,\n - 802.3ad mode is not supported if one or more slaves is a bond device,\n\n---\nv2 changes:\n - added dynamic link speed recalculation for a bonding\n\nSigned-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>\n---\n drivers/net/bonding/rte_eth_bond_api.c     | 63 ++++++++++++++++++++------\n drivers/net/bonding/rte_eth_bond_pmd.c     | 73 +++++++++++++++++++++++++++---\n drivers/net/bonding/rte_eth_bond_private.h |  7 ++-\n 3 files changed, 123 insertions(+), 20 deletions(-)",
    "diff": "diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c\nindex 55d71d9..e1e7564 100644\n--- a/drivers/net/bonding/rte_eth_bond_api.c\n+++ b/drivers/net/bonding/rte_eth_bond_api.c\n@@ -1,7 +1,7 @@\n /*-\n  *   BSD LICENSE\n  *\n- *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.\n+ *   Copyright(c) 2010-2017 Intel Corporation. All rights reserved.\n  *   All rights reserved.\n  *\n  *   Redistribution and use in source and binary forms, with or without\n@@ -63,13 +63,45 @@\n }\n \n int\n-valid_slave_port_id(uint8_t port_id)\n+check_for_master_bonded_ethdev(const struct rte_eth_dev *eth_dev) {\n+\tint i;\n+\tstruct bond_dev_private *internals;\n+\n+\tif (check_for_bonded_ethdev(eth_dev) != 0)\n+\t\treturn 0;\n+\n+\tinternals = eth_dev->data->dev_private;\n+\n+\t/* Check if any of slave devices is a bonded device */\n+\tfor (i = 0; i < internals->slave_count; i++)\n+\t\tif (valid_bonded_port_id(internals->slaves[i].port_id) == 0)\n+\t\t\treturn 1;\n+\n+\treturn 0;\n+}\n+\n+int\n+valid_slave_port_id(uint8_t port_id, uint8_t mode)\n {\n \tRTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1);\n \n \t/* Verify that port_id refers to a non bonded port */\n-\tif (check_for_bonded_ethdev(&rte_eth_devices[port_id]) == 0)\n-\t\treturn -1;\n+\tif (check_for_bonded_ethdev(&rte_eth_devices[port_id]) == 0) {\n+\t\tif (mode == BONDING_MODE_8023AD) {\n+\t\t\tRTE_BOND_LOG(ERR, \"One or more slaves is a bond device,\"\n+\t\t\t\t\t\" there 802.3ad mode can not be\"\n+\t\t\t\t\t\" supported on this bond device.\");\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tif (check_for_master_bonded_ethdev(&rte_eth_devices[port_id])) {\n+\t\t\tRTE_BOND_LOG(ERR, \"Too many levels of bonding\");\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\t/* Slave is in master bonding */\n+\t\treturn 1;\n+\t}\n \n \treturn 0;\n }\n@@ -234,14 +266,19 @@\n \tstruct bond_dev_private *internals;\n \tstruct rte_eth_link link_props;\n \tstruct rte_eth_dev_info dev_info;\n-\n-\tif (valid_slave_port_id(slave_port_id) != 0)\n-\t\treturn -1;\n+\tint status;\n \n \tbonded_eth_dev = &rte_eth_devices[bonded_port_id];\n \tinternals = bonded_eth_dev->data->dev_private;\n \n+\tstatus = valid_slave_port_id(slave_port_id, internals->mode);\n+\n+\t/* Slave is invalid */\n+\tif (status < 0)\n+\t\treturn -1;\n+\n \tslave_eth_dev = &rte_eth_devices[slave_port_id];\n+\n \tif (slave_eth_dev->data->dev_flags & RTE_ETH_DEV_BONDED_SLAVE) {\n \t\tRTE_BOND_LOG(ERR, \"Slave device is already a slave of a bonded device\");\n \t\treturn -1;\n@@ -386,12 +423,12 @@\n \tstruct rte_eth_dev *slave_eth_dev;\n \tint i, slave_idx;\n \n-\tif (valid_slave_port_id(slave_port_id) != 0)\n-\t\treturn -1;\n-\n \tbonded_eth_dev = &rte_eth_devices[bonded_port_id];\n \tinternals = bonded_eth_dev->data->dev_private;\n \n+\tif (valid_slave_port_id(slave_port_id, internals->mode) < 0)\n+\t\treturn -1;\n+\n \t/* first remove from active slave list */\n \tslave_idx = find_slave_by_id(internals->active_slaves,\n \t\tinternals->active_slave_count, slave_port_id);\n@@ -512,11 +549,11 @@\n \tif (valid_bonded_port_id(bonded_port_id) != 0)\n \t\treturn -1;\n \n-\tif (valid_slave_port_id(slave_port_id) != 0)\n-\t\treturn -1;\n-\n \tinternals =  rte_eth_devices[bonded_port_id].data->dev_private;\n \n+\tif (valid_slave_port_id(slave_port_id, internals->mode) < 0)\n+\t\treturn -1;\n+\n \tinternals->user_defined_primary_port = 1;\n \tinternals->primary_port = slave_port_id;\n \ndiff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c\nindex a8d9780..73e1032 100644\n--- a/drivers/net/bonding/rte_eth_bond_pmd.c\n+++ b/drivers/net/bonding/rte_eth_bond_pmd.c\n@@ -79,6 +79,50 @@\n \treturn vlan_offset;\n }\n \n+static uint32_t\n+get_link_speed(struct rte_eth_dev *bonded_eth_dev)\n+{\n+\tstruct bond_dev_private *internals = bonded_eth_dev->data->dev_private;\n+\tint i;\n+\n+\tstruct rte_eth_link link_status;\n+\tuint32_t link_speed;\n+\n+\tif (internals->active_slave_count < 1)\n+\t\treturn 0;\n+\n+\tswitch (internals->mode) {\n+\tcase BONDING_MODE_BROADCAST:\n+\t\t/* Minimal slaves link speed */\n+\t\trte_eth_link_get(internals->active_slaves[0], &link_status);\n+\t\tlink_speed = link_status.link_speed;\n+\t\tfor (i = 1; i < internals->active_slave_count; i++) {\n+\t\t\trte_eth_link_get(internals->active_slaves[i], &link_status);\n+\t\t\tif (link_status.link_speed < link_speed)\n+\t\t\t\tlink_speed = link_status.link_speed;\n+\t\t}\n+\t\tbreak;\n+\tcase BONDING_MODE_ACTIVE_BACKUP:\n+\t\t/* Current primary slave */\n+\t\trte_eth_link_get(internals->current_primary_port, &link_status);\n+\t\tlink_speed = link_status.link_speed;\n+\t\tbreak;\n+\tcase BONDING_MODE_ROUND_ROBIN:\n+\tcase BONDING_MODE_BALANCE:\n+\tcase BONDING_MODE_8023AD:\n+\tcase BONDING_MODE_TLB:\n+\tcase BONDING_MODE_ALB:\n+\tdefault:\n+\t\t/* Sum of slaves link speeds */\n+\t\tlink_speed = 0;\n+\t\tfor (i = 0; i < internals->active_slave_count; i++) {\n+\t\t\trte_eth_link_get(internals->active_slaves[i], &link_status);\n+\t\t\tlink_speed += link_status.link_speed;\n+\t\t}\n+\t}\n+\treturn link_speed;\n+}\n+\n static uint16_t\n bond_ethdev_rx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)\n {\n@@ -1139,9 +1183,10 @@ struct bwg_slave {\n \n \tif (slave_dev_link->link_status &&\n \t\tbonded_eth_dev->data->dev_started) {\n-\t\tbonded_dev_link->link_duplex = slave_dev_link->link_duplex;\n-\t\tbonded_dev_link->link_speed = slave_dev_link->link_speed;\n-\n+\t\tinternals->slave_link.link_duplex = slave_dev_link->link_duplex;\n+\t\tinternals->slave_link.link_speed = slave_dev_link->link_speed;\n+\t\tmemcpy(bonded_dev_link, &internals->slave_link,\n+\t\t\t\tsizeof(struct rte_eth_link));\n \t\tinternals->link_props_set = 1;\n \t}\n }\n@@ -1153,6 +1198,8 @@ struct bwg_slave {\n \n \tmemset(&(bonded_eth_dev->data->dev_link), 0,\n \t\t\tsizeof(bonded_eth_dev->data->dev_link));\n+\tmemset(&(internals->slave_link), 0,\n+\t\t\tsizeof(bonded_eth_dev->data->dev_link));\n \n \tinternals->link_props_set = 0;\n }\n@@ -1292,6 +1339,12 @@ struct bwg_slave {\n \t\teth_dev->rx_pkt_burst = bond_ethdev_rx_burst;\n \t\tbreak;\n \tcase BONDING_MODE_8023AD:\n+\t\tif (check_for_master_bonded_ethdev(eth_dev) == 1) {\n+\t\t\tRTE_BOND_LOG(ERR, \"One or more slaves is a bond device,\"\n+\t\t\t\t\t\" there 802.3ad mode can not be\"\n+\t\t\t\t\t\" supported on this bond device.\");\n+\t\t\treturn -1;\n+\t\t}\n \t\tif (bond_mode_8023ad_enable(eth_dev) != 0)\n \t\t\treturn -1;\n \n@@ -1887,6 +1940,8 @@ struct bwg_slave {\n \t\t}\n \n \t\tbonded_eth_dev->data->dev_link.link_status = link_up;\n+\t\tbonded_eth_dev->data->dev_link.link_speed = get_link_speed(\n+\t\t\t\tbonded_eth_dev);\n \t}\n \n \treturn 0;\n@@ -2009,6 +2064,7 @@ struct bwg_slave {\n \tint i, valid_slave = 0;\n \tuint8_t active_pos;\n \tuint8_t lsc_flag = 0;\n+\tuint8_t master_bonding;\n \n \tif (type != RTE_ETH_EVENT_INTR_LSC || param == NULL)\n \t\treturn;\n@@ -2058,9 +2114,11 @@ struct bwg_slave {\n \t\t\tlink_properties_set(bonded_eth_dev,\n \t\t\t\t\t&(slave_eth_dev->data->dev_link));\n \t\t} else {\n-\t\t\tif (link_properties_valid(\n-\t\t\t\t&bonded_eth_dev->data->dev_link, &link) != 0) {\n-\t\t\t\tslave_eth_dev->data->dev_flags &=\n+\t\t\tmaster_bonding = check_for_master_bonded_ethdev(\n+\t\t\t\t\tbonded_eth_dev);\n+\t\t\tif ((master_bonding == 0) && link_properties_valid(\n+\t\t\t\t&internals->slave_link, &link) != 0) {\n+\t\t\t\t\tslave_eth_dev->data->dev_flags &=\n \t\t\t\t\t(~RTE_ETH_DEV_BONDED_SLAVE);\n \t\t\t\tRTE_LOG(ERR, PMD,\n \t\t\t\t\t\"port %u invalid speed/duplex\\n\",\n@@ -2128,6 +2186,9 @@ struct bwg_slave {\n \t\t\t\t\t\tRTE_ETH_EVENT_INTR_LSC, NULL);\n \t\t}\n \t}\n+\n+\tbonded_eth_dev->data->dev_link.link_speed = get_link_speed(\n+\t\t\tbonded_eth_dev);\n }\n \n static int\ndiff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h\nindex 50d908d..e27ceb8 100644\n--- a/drivers/net/bonding/rte_eth_bond_private.h\n+++ b/drivers/net/bonding/rte_eth_bond_private.h\n@@ -135,6 +135,8 @@ struct bond_dev_private {\n \tuint8_t link_props_set;\n \t/**< flag to denote if the link properties are set */\n \n+\tstruct rte_eth_link slave_link;\n+\n \tuint8_t link_status_polling_enabled;\n \tuint32_t link_status_polling_interval_ms;\n \n@@ -184,6 +186,9 @@ struct bond_dev_private {\n int\n check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev);\n \n+int\n+check_for_master_bonded_ethdev(const struct rte_eth_dev *eth_dev);\n+\n /* Search given slave array to find position of given id.\n  * Return slave pos or slaves_count if not found. */\n static inline uint8_t\n@@ -205,7 +210,7 @@ struct bond_dev_private {\n valid_bonded_port_id(uint8_t port_id);\n \n int\n-valid_slave_port_id(uint8_t port_id);\n+valid_slave_port_id(uint8_t port_id, uint8_t mode);\n \n void\n deactivate_slave(struct rte_eth_dev *eth_dev, uint8_t port_id);\n",
    "prefixes": [
        "dpdk-dev",
        "v2"
    ]
}