Show a patch.

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

{
    "id": 41653,
    "url": "http://patches.dpdk.org/api/patches/41653/",
    "web_url": "http://patches.dpdk.org/patch/41653/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "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"
    },
    "msgid": "<1530096938-71399-3-git-send-email-nikhil.rao@intel.com>",
    "date": "2018-06-27T10:55:35",
    "name": "[v2,2/5] eventdev: improve err handling for Rx adapter queue add/del",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f3548a26cc3849517b7920a869633501d20b9fe5",
    "submitter": {
        "id": 528,
        "url": "http://patches.dpdk.org/api/people/528/",
        "name": "Nikhil Rao",
        "email": "nikhil.rao@intel.com"
    },
    "delegate": {
        "id": 310,
        "url": "http://patches.dpdk.org/api/users/310/",
        "username": "jerin",
        "first_name": "Jerin",
        "last_name": "Jacob",
        "email": "jerin.jacob@caviumnetworks.com"
    },
    "mbox": "http://patches.dpdk.org/patch/41653/mbox/",
    "series": [
        {
            "id": 260,
            "url": "http://patches.dpdk.org/api/series/260/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=260",
            "date": "2018-06-27T10:55:33",
            "name": "eventdev: add interrupt driven queues to Rx adapter",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/260/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/41653/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/41653/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "X-ExtLoop1": "1",
        "Errors-To": "dev-bounces@dpdk.org",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Mailer": "git-send-email 1.8.3.1",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 4188E1BE58;\n\tWed, 27 Jun 2018 12:55:59 +0200 (CEST)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n\tby dpdk.org (Postfix) with ESMTP id ED51D1BE17\n\tfor <dev@dpdk.org>; Wed, 27 Jun 2018 12:55:52 +0200 (CEST)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n\tby fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t27 Jun 2018 03:55:52 -0700",
            "from unknown (HELO localhost.localdomain.localdomain)\n\t([10.224.122.193])\n\tby orsmga008.jf.intel.com with ESMTP; 27 Jun 2018 03:55:51 -0700"
        ],
        "References": "<1528481718-7241-1-git-send-email-nikhil.rao@intel.com>\n\t<1530096938-71399-1-git-send-email-nikhil.rao@intel.com>",
        "X-Amp-File-Uploaded": "False",
        "X-BeenThere": "dev@dpdk.org",
        "Message-Id": "<1530096938-71399-3-git-send-email-nikhil.rao@intel.com>",
        "X-IronPort-AV": "E=Sophos;i=\"5.51,278,1526367600\"; d=\"scan'208\";a=\"52634795\"",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "Precedence": "list",
        "From": "Nikhil Rao <nikhil.rao@intel.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "In-Reply-To": "<1530096938-71399-1-git-send-email-nikhil.rao@intel.com>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "To": "jerin.jacob@caviumnetworks.com",
        "Delivered-To": "patchwork@dpdk.org",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Date": "Wed, 27 Jun 2018 16:25:35 +0530",
        "Cc": "nikhil.rao@intel.com,\n\tdev@dpdk.org",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Subject": "[dpdk-dev] [PATCH v2 2/5] eventdev: improve err handling for Rx\n\tadapter queue add/del"
    },
    "content": "The new WRR sequence applicable after queue add/del is set\nup after setting the new queue state, so a memory allocation\nfailure will leave behind an incorrect state.\n\nThis change separates the memory sizing + allocation for the\nRx poll and WRR array from calculation of the WRR sequence.\nIf there is a memory allocation failure, existing Rx queue\nconfiguration remains unchanged.\n\nSigned-off-by: Nikhil Rao <nikhil.rao@intel.com>\n---\n lib/librte_eventdev/rte_event_eth_rx_adapter.c | 418 ++++++++++++++++++-------\n 1 file changed, 302 insertions(+), 116 deletions(-)",
    "diff": "diff --git a/lib/librte_eventdev/rte_event_eth_rx_adapter.c b/lib/librte_eventdev/rte_event_eth_rx_adapter.c\nindex 9361d48..926f83a 100644\n--- a/lib/librte_eventdev/rte_event_eth_rx_adapter.c\n+++ b/lib/librte_eventdev/rte_event_eth_rx_adapter.c\n@@ -109,10 +109,16 @@ struct eth_device_info {\n \t * rx_adapter_stop callback needs to be invoked\n \t */\n \tuint8_t dev_rx_started;\n-\t/* If nb_dev_queues > 0, the start callback will\n+\t/* Number of queues added for this device */\n+\tuint16_t nb_dev_queues;\n+\t/* If nb_rx_poll > 0, the start callback will\n \t * be invoked if not already invoked\n \t */\n-\tuint16_t nb_dev_queues;\n+\tuint16_t nb_rx_poll;\n+\t/* sum(wrr(q)) for all queues within the device\n+\t * useful when deleting all device queues\n+\t */\n+\tuint32_t wrr_len;\n };\n \n /* Per Rx queue */\n@@ -188,13 +194,170 @@ static uint16_t rxa_gcd_u16(uint16_t a, uint16_t b)\n \t}\n }\n \n-/* Precalculate WRR polling sequence for all queues in rx_adapter */\n+static inline int\n+rxa_polled_queue(struct eth_device_info *dev_info,\n+\tint rx_queue_id)\n+{\n+\tstruct eth_rx_queue_info *queue_info;\n+\n+\tqueue_info = &dev_info->rx_queue[rx_queue_id];\n+\treturn !dev_info->internal_event_port &&\n+\t\tdev_info->rx_queue &&\n+\t\tqueue_info->queue_enabled && queue_info->wt != 0;\n+}\n+\n+/* Calculate size of the eth_rx_poll and wrr_sched arrays\n+ * after deleting poll mode rx queues\n+ */\n+static void\n+rxa_calc_nb_post_poll_del(struct rte_event_eth_rx_adapter *rx_adapter,\n+\t\t\tstruct eth_device_info *dev_info,\n+\t\t\tint rx_queue_id,\n+\t\t\tuint32_t *nb_rx_poll,\n+\t\t\tuint32_t *nb_wrr)\n+{\n+\tuint32_t poll_diff;\n+\tuint32_t wrr_len_diff;\n+\n+\tif (rx_queue_id == -1) {\n+\t\tpoll_diff = dev_info->nb_rx_poll;\n+\t\twrr_len_diff = dev_info->wrr_len;\n+\t} else {\n+\t\tpoll_diff = rxa_polled_queue(dev_info, rx_queue_id);\n+\t\twrr_len_diff = poll_diff ? dev_info->rx_queue[rx_queue_id].wt :\n+\t\t\t\t\t0;\n+\t}\n+\n+\t*nb_rx_poll = rx_adapter->num_rx_polled - poll_diff;\n+\t*nb_wrr = rx_adapter->wrr_len - wrr_len_diff;\n+}\n+\n+/* Calculate nb_rx_* after adding poll mode rx queues\n+ */\n+static void\n+rxa_calc_nb_post_add_poll(struct rte_event_eth_rx_adapter *rx_adapter,\n+\t\t\tstruct eth_device_info *dev_info,\n+\t\t\tint rx_queue_id,\n+\t\t\tuint16_t wt,\n+\t\t\tuint32_t *nb_rx_poll,\n+\t\t\tuint32_t *nb_wrr)\n+{\n+\tuint32_t poll_diff;\n+\tuint32_t wrr_len_diff;\n+\n+\tif (rx_queue_id == -1) {\n+\t\tpoll_diff = dev_info->dev->data->nb_rx_queues -\n+\t\t\t\t\t\tdev_info->nb_rx_poll;\n+\t\twrr_len_diff = wt*dev_info->dev->data->nb_rx_queues\n+\t\t\t\t- dev_info->wrr_len;\n+\t} else {\n+\t\tpoll_diff = !rxa_polled_queue(dev_info, rx_queue_id);\n+\t\twrr_len_diff = rxa_polled_queue(dev_info, rx_queue_id) ?\n+\t\t\t\twt - dev_info->rx_queue[rx_queue_id].wt :\n+\t\t\t\twt;\n+\t}\n+\n+\t*nb_rx_poll = rx_adapter->num_rx_polled + poll_diff;\n+\t*nb_wrr = rx_adapter->wrr_len + wrr_len_diff;\n+}\n+\n+/* Calculate nb_rx_* after adding rx_queue_id */\n+static void\n+rxa_calc_nb_post_add(struct rte_event_eth_rx_adapter *rx_adapter,\n+\t\tstruct eth_device_info *dev_info,\n+\t\tint rx_queue_id,\n+\t\tuint16_t wt,\n+\t\tuint32_t *nb_rx_poll,\n+\t\tuint32_t *nb_wrr)\n+{\n+\trxa_calc_nb_post_add_poll(rx_adapter, dev_info, rx_queue_id,\n+\t\t\t\twt, nb_rx_poll, nb_wrr);\n+}\n+\n+/* Calculate nb_rx_* after deleting rx_queue_id */\n+static void\n+rxa_calc_nb_post_del(struct rte_event_eth_rx_adapter *rx_adapter,\n+\t\tstruct eth_device_info *dev_info,\n+\t\tint rx_queue_id,\n+\t\tuint32_t *nb_rx_poll,\n+\t\tuint32_t *nb_wrr)\n+{\n+\trxa_calc_nb_post_poll_del(rx_adapter, dev_info, rx_queue_id, nb_rx_poll,\n+\t\t\t\tnb_wrr);\n+}\n+\n+/*\n+ * Allocate the rx_poll array\n+ */\n+static struct eth_rx_poll_entry *\n+rxa_alloc_poll(struct rte_event_eth_rx_adapter *rx_adapter,\n+\tuint32_t num_rx_polled)\n+{\n+\tsize_t len;\n+\n+\tlen  = RTE_ALIGN(num_rx_polled * sizeof(*rx_adapter->eth_rx_poll),\n+\t\t\t\t\t\t\tRTE_CACHE_LINE_SIZE);\n+\treturn  rte_zmalloc_socket(rx_adapter->mem_name,\n+\t\t\t\tlen,\n+\t\t\t\tRTE_CACHE_LINE_SIZE,\n+\t\t\t\trx_adapter->socket_id);\n+}\n+\n+/*\n+ * Allocate the WRR array\n+ */\n+static uint32_t *\n+rxa_alloc_wrr(struct rte_event_eth_rx_adapter *rx_adapter, int nb_wrr)\n+{\n+\tsize_t len;\n+\n+\tlen = RTE_ALIGN(nb_wrr * sizeof(*rx_adapter->wrr_sched),\n+\t\t\tRTE_CACHE_LINE_SIZE);\n+\treturn  rte_zmalloc_socket(rx_adapter->mem_name,\n+\t\t\t\tlen,\n+\t\t\t\tRTE_CACHE_LINE_SIZE,\n+\t\t\t\trx_adapter->socket_id);\n+}\n+\n static int\n-rxa_calc_wrr_sequence(struct rte_event_eth_rx_adapter *rx_adapter)\n+rxa_alloc_poll_arrays(struct rte_event_eth_rx_adapter *rx_adapter,\n+\t\tuint32_t nb_poll,\n+\t\tuint32_t nb_wrr,\n+\t\tstruct eth_rx_poll_entry **rx_poll,\n+\t\tuint32_t **wrr_sched)\n+{\n+\n+\tif (nb_poll == 0) {\n+\t\t*rx_poll = NULL;\n+\t\t*wrr_sched = NULL;\n+\t\treturn 0;\n+\t}\n+\n+\t*rx_poll = rxa_alloc_poll(rx_adapter, nb_poll);\n+\tif (*rx_poll == NULL) {\n+\t\t*wrr_sched = NULL;\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\t*wrr_sched = rxa_alloc_wrr(rx_adapter, nb_wrr);\n+\tif (*wrr_sched == NULL) {\n+\t\trte_free(*rx_poll);\n+\t\treturn -ENOMEM;\n+\t}\n+\treturn 0;\n+}\n+\n+/* Precalculate WRR polling sequence for all queues in rx_adapter */\n+static void\n+rxa_calc_wrr_sequence(struct rte_event_eth_rx_adapter *rx_adapter,\n+\t\tstruct eth_rx_poll_entry *rx_poll,\n+\t\tuint32_t *rx_wrr)\n {\n \tuint16_t d;\n \tuint16_t q;\n \tunsigned int i;\n+\tint prev = -1;\n+\tint cw = -1;\n \n \t/* Initialize variables for calculation of wrr schedule */\n \tuint16_t max_wrr_pos = 0;\n@@ -202,77 +365,48 @@ static uint16_t rxa_gcd_u16(uint16_t a, uint16_t b)\n \tuint16_t max_wt = 0;\n \tuint16_t gcd = 0;\n \n-\tstruct eth_rx_poll_entry *rx_poll = NULL;\n-\tuint32_t *rx_wrr = NULL;\n+\tif (rx_poll == NULL)\n+\t\treturn;\n \n-\tif (rx_adapter->num_rx_polled) {\n-\t\tsize_t len = RTE_ALIGN(rx_adapter->num_rx_polled *\n-\t\t\t\tsizeof(*rx_adapter->eth_rx_poll),\n-\t\t\t\tRTE_CACHE_LINE_SIZE);\n-\t\trx_poll = rte_zmalloc_socket(rx_adapter->mem_name,\n-\t\t\t\t\t     len,\n-\t\t\t\t\t     RTE_CACHE_LINE_SIZE,\n-\t\t\t\t\t     rx_adapter->socket_id);\n-\t\tif (rx_poll == NULL)\n-\t\t\treturn -ENOMEM;\n+\t/* Generate array of all queues to poll, the size of this\n+\t * array is poll_q\n+\t */\n+\tRTE_ETH_FOREACH_DEV(d) {\n+\t\tuint16_t nb_rx_queues;\n+\t\tstruct eth_device_info *dev_info =\n+\t\t\t\t&rx_adapter->eth_devices[d];\n+\t\tnb_rx_queues = dev_info->dev->data->nb_rx_queues;\n+\t\tif (dev_info->rx_queue == NULL)\n+\t\t\tcontinue;\n+\t\tif (dev_info->internal_event_port)\n+\t\t\tcontinue;\n+\t\tdev_info->wrr_len = 0;\n+\t\tfor (q = 0; q < nb_rx_queues; q++) {\n+\t\t\tstruct eth_rx_queue_info *queue_info =\n+\t\t\t\t&dev_info->rx_queue[q];\n+\t\t\tuint16_t wt;\n \n-\t\t/* Generate array of all queues to poll, the size of this\n-\t\t * array is poll_q\n-\t\t */\n-\t\tRTE_ETH_FOREACH_DEV(d) {\n-\t\t\tuint16_t nb_rx_queues;\n-\t\t\tstruct eth_device_info *dev_info =\n-\t\t\t\t\t&rx_adapter->eth_devices[d];\n-\t\t\tnb_rx_queues = dev_info->dev->data->nb_rx_queues;\n-\t\t\tif (dev_info->rx_queue == NULL)\n-\t\t\t\tcontinue;\n-\t\t\tif (dev_info->internal_event_port)\n+\t\t\tif (!rxa_polled_queue(dev_info, q))\n \t\t\t\tcontinue;\n-\t\t\tfor (q = 0; q < nb_rx_queues; q++) {\n-\t\t\t\tstruct eth_rx_queue_info *queue_info =\n-\t\t\t\t\t&dev_info->rx_queue[q];\n-\t\t\t\tif (queue_info->queue_enabled == 0)\n-\t\t\t\t\tcontinue;\n-\n-\t\t\t\tuint16_t wt = queue_info->wt;\n-\t\t\t\trx_poll[poll_q].eth_dev_id = d;\n-\t\t\t\trx_poll[poll_q].eth_rx_qid = q;\n-\t\t\t\tmax_wrr_pos += wt;\n-\t\t\t\tmax_wt = RTE_MAX(max_wt, wt);\n-\t\t\t\tgcd = (gcd) ? rxa_gcd_u16(gcd, wt) : wt;\n-\t\t\t\tpoll_q++;\n-\t\t\t}\n-\t\t}\n-\n-\t\tlen = RTE_ALIGN(max_wrr_pos * sizeof(*rx_wrr),\n-\t\t\t\tRTE_CACHE_LINE_SIZE);\n-\t\trx_wrr = rte_zmalloc_socket(rx_adapter->mem_name,\n-\t\t\t\t\t    len,\n-\t\t\t\t\t    RTE_CACHE_LINE_SIZE,\n-\t\t\t\t\t    rx_adapter->socket_id);\n-\t\tif (rx_wrr == NULL) {\n-\t\t\trte_free(rx_poll);\n-\t\t\treturn -ENOMEM;\n-\t\t}\n-\n-\t\t/* Generate polling sequence based on weights */\n-\t\tint prev = -1;\n-\t\tint cw = -1;\n-\t\tfor (i = 0; i < max_wrr_pos; i++) {\n-\t\t\trx_wrr[i] = rxa_wrr_next(rx_adapter, poll_q, &cw,\n-\t\t\t\t\t     rx_poll, max_wt, gcd, prev);\n-\t\t\tprev = rx_wrr[i];\n+\t\t\twt = queue_info->wt;\n+\t\t\trx_poll[poll_q].eth_dev_id = d;\n+\t\t\trx_poll[poll_q].eth_rx_qid = q;\n+\t\t\tmax_wrr_pos += wt;\n+\t\t\tdev_info->wrr_len += wt;\n+\t\t\tmax_wt = RTE_MAX(max_wt, wt);\n+\t\t\tgcd = (gcd) ? rxa_gcd_u16(gcd, wt) : wt;\n+\t\t\tpoll_q++;\n \t\t}\n \t}\n \n-\trte_free(rx_adapter->eth_rx_poll);\n-\trte_free(rx_adapter->wrr_sched);\n-\n-\trx_adapter->eth_rx_poll = rx_poll;\n-\trx_adapter->wrr_sched = rx_wrr;\n-\trx_adapter->wrr_len = max_wrr_pos;\n-\n-\treturn 0;\n+\t/* Generate polling sequence based on weights */\n+\tprev = -1;\n+\tcw = -1;\n+\tfor (i = 0; i < max_wrr_pos; i++) {\n+\t\trx_wrr[i] = rxa_wrr_next(rx_adapter, poll_q, &cw,\n+\t\t\t\t     rx_poll, max_wt, gcd, prev);\n+\t\tprev = rx_wrr[i];\n+\t}\n }\n \n static inline void\n@@ -719,31 +853,53 @@ static uint16_t rxa_gcd_u16(uint16_t a, uint16_t b)\n \t}\n }\n \n-static int\n+static void\n rxa_sw_del(struct rte_event_eth_rx_adapter *rx_adapter,\n \tstruct eth_device_info *dev_info,\n-\tuint16_t rx_queue_id)\n+\tint32_t rx_queue_id)\n {\n-\tstruct eth_rx_queue_info *queue_info;\n+\tint pollq;\n \n \tif (rx_adapter->nb_queues == 0)\n-\t\treturn 0;\n+\t\treturn;\n \n-\tqueue_info = &dev_info->rx_queue[rx_queue_id];\n-\trx_adapter->num_rx_polled -= queue_info->queue_enabled;\n+\tif (rx_queue_id == -1) {\n+\t\tuint16_t nb_rx_queues;\n+\t\tuint16_t i;\n+\n+\t\tnb_rx_queues = dev_info->dev->data->nb_rx_queues;\n+\t\tfor (i = 0; i <\tnb_rx_queues; i++)\n+\t\t\trxa_sw_del(rx_adapter, dev_info, i);\n+\t\treturn;\n+\t}\n+\n+\tpollq = rxa_polled_queue(dev_info, rx_queue_id);\n \trxa_update_queue(rx_adapter, dev_info, rx_queue_id, 0);\n-\treturn 0;\n+\trx_adapter->num_rx_polled -= pollq;\n+\tdev_info->nb_rx_poll -= pollq;\n }\n \n static void\n rxa_add_queue(struct rte_event_eth_rx_adapter *rx_adapter,\n \tstruct eth_device_info *dev_info,\n-\tuint16_t rx_queue_id,\n+\tint32_t rx_queue_id,\n \tconst struct rte_event_eth_rx_adapter_queue_conf *conf)\n-\n {\n \tstruct eth_rx_queue_info *queue_info;\n \tconst struct rte_event *ev = &conf->ev;\n+\tint pollq;\n+\n+\tif (rx_queue_id == -1) {\n+\t\tuint16_t nb_rx_queues;\n+\t\tuint16_t i;\n+\n+\t\tnb_rx_queues = dev_info->dev->data->nb_rx_queues;\n+\t\tfor (i = 0; i <\tnb_rx_queues; i++)\n+\t\t\trxa_add_queue(rx_adapter, dev_info, i, conf);\n+\t\treturn;\n+\t}\n+\n+\tpollq = rxa_polled_queue(dev_info, rx_queue_id);\n \n \tqueue_info = &dev_info->rx_queue[rx_queue_id];\n \tqueue_info->event_queue_id = ev->queue_id;\n@@ -757,9 +913,11 @@ static uint16_t rxa_gcd_u16(uint16_t a, uint16_t b)\n \t\tqueue_info->flow_id_mask = ~0;\n \t}\n \n-\t/* The same queue can be added more than once */\n-\trx_adapter->num_rx_polled += !queue_info->queue_enabled;\n \trxa_update_queue(rx_adapter, dev_info, rx_queue_id, 1);\n+\tif (rxa_polled_queue(dev_info, rx_queue_id)) {\n+\t\trx_adapter->num_rx_polled += !pollq;\n+\t\tdev_info->nb_rx_poll += !pollq;\n+\t}\n }\n \n static int rxa_sw_add(struct rte_event_eth_rx_adapter *rx_adapter,\n@@ -769,8 +927,12 @@ static int rxa_sw_add(struct rte_event_eth_rx_adapter *rx_adapter,\n {\n \tstruct eth_device_info *dev_info = &rx_adapter->eth_devices[eth_dev_id];\n \tstruct rte_event_eth_rx_adapter_queue_conf temp_conf;\n-\tuint32_t i;\n \tint ret;\n+\tstruct eth_rx_poll_entry *rx_poll;\n+\tstruct eth_rx_queue_info *rx_queue;\n+\tuint32_t *rx_wrr;\n+\tuint16_t nb_rx_queues;\n+\tuint32_t nb_rx_poll, nb_wrr;\n \n \tif (queue_conf->servicing_weight == 0) {\n \n@@ -787,31 +949,51 @@ static int rxa_sw_add(struct rte_event_eth_rx_adapter *rx_adapter,\n \t\tqueue_conf = &temp_conf;\n \t}\n \n+\tnb_rx_queues = dev_info->dev->data->nb_rx_queues;\n+\trx_queue = dev_info->rx_queue;\n+\n \tif (dev_info->rx_queue == NULL) {\n \t\tdev_info->rx_queue =\n \t\t    rte_zmalloc_socket(rx_adapter->mem_name,\n-\t\t\t\t       dev_info->dev->data->nb_rx_queues *\n+\t\t\t\t       nb_rx_queues *\n \t\t\t\t       sizeof(struct eth_rx_queue_info), 0,\n \t\t\t\t       rx_adapter->socket_id);\n \t\tif (dev_info->rx_queue == NULL)\n \t\t\treturn -ENOMEM;\n \t}\n+\trx_wrr = NULL;\n+\trx_poll = NULL;\n \n-\tif (rx_queue_id == -1) {\n-\t\tfor (i = 0; i < dev_info->dev->data->nb_rx_queues; i++)\n-\t\t\trxa_add_queue(rx_adapter, dev_info, i, queue_conf);\n-\t} else {\n-\t\trxa_add_queue(rx_adapter, dev_info, (uint16_t)rx_queue_id,\n-\t\t\tqueue_conf);\n-\t}\n+\trxa_calc_nb_post_add(rx_adapter, dev_info, rx_queue_id,\n+\t\t\tqueue_conf->servicing_weight,\n+\t\t\t&nb_rx_poll, &nb_wrr);\n \n-\tret = rxa_calc_wrr_sequence(rx_adapter);\n-\tif (ret) {\n-\t\trxa_sw_del(rx_adapter, dev_info, rx_queue_id);\n-\t\treturn ret;\n+\tret = rxa_alloc_poll_arrays(rx_adapter, nb_rx_poll, nb_wrr,\n+\t\t\t\t&rx_poll, &rx_wrr);\n+\tif (ret)\n+\t\tgoto err_free_rxqueue;\n+\n+\trxa_add_queue(rx_adapter, dev_info, rx_queue_id, queue_conf);\n+\trxa_calc_wrr_sequence(rx_adapter, rx_poll, rx_wrr);\n+\n+\trte_free(rx_adapter->eth_rx_poll);\n+\trte_free(rx_adapter->wrr_sched);\n+\n+\trx_adapter->eth_rx_poll = rx_poll;\n+\trx_adapter->wrr_sched = rx_wrr;\n+\trx_adapter->wrr_len = nb_wrr;\n+\treturn 0;\n+\n+err_free_rxqueue:\n+\tif (rx_queue == NULL) {\n+\t\trte_free(dev_info->rx_queue);\n+\t\tdev_info->rx_queue = NULL;\n \t}\n \n-\treturn ret;\n+\trte_free(rx_poll);\n+\trte_free(rx_wrr);\n+\n+\treturn 0;\n }\n \n static int\n@@ -995,7 +1177,6 @@ static int rxa_sw_add(struct rte_event_eth_rx_adapter *rx_adapter,\n \tstruct rte_event_eth_rx_adapter *rx_adapter;\n \tstruct rte_eventdev *dev;\n \tstruct eth_device_info *dev_info;\n-\tint start_service;\n \n \tRTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);\n \tRTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);\n@@ -1038,7 +1219,6 @@ static int rxa_sw_add(struct rte_event_eth_rx_adapter *rx_adapter,\n \t\treturn -EINVAL;\n \t}\n \n-\tstart_service = 0;\n \tdev_info = &rx_adapter->eth_devices[eth_dev_id];\n \n \tif (cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) {\n@@ -1068,21 +1248,19 @@ static int rxa_sw_add(struct rte_event_eth_rx_adapter *rx_adapter,\n \t\trte_spinlock_lock(&rx_adapter->rx_lock);\n \t\tdev_info->internal_event_port = 0;\n \t\tret = rxa_init_service(rx_adapter, id);\n-\t\tif (ret == 0)\n+\t\tif (ret == 0) {\n+\t\t\tuint32_t service_id = rx_adapter->service_id;\n \t\t\tret = rxa_sw_add(rx_adapter, eth_dev_id, rx_queue_id,\n \t\t\t\t\tqueue_conf);\n+\t\t\trte_service_component_runstate_set(service_id,\n+\t\t\t\trxa_sw_adapter_queue_count(rx_adapter));\n+\t\t}\n \t\trte_spinlock_unlock(&rx_adapter->rx_lock);\n-\t\tif (ret == 0)\n-\t\t\tstart_service =\n-\t\t\t\t!!rxa_sw_adapter_queue_count(rx_adapter);\n \t}\n \n \tif (ret)\n \t\treturn ret;\n \n-\tif (start_service)\n-\t\trte_service_component_runstate_set(rx_adapter->service_id, 1);\n-\n \treturn 0;\n }\n \n@@ -1095,7 +1273,10 @@ static int rxa_sw_add(struct rte_event_eth_rx_adapter *rx_adapter,\n \tstruct rte_event_eth_rx_adapter *rx_adapter;\n \tstruct eth_device_info *dev_info;\n \tuint32_t cap;\n-\tuint16_t i;\n+\tuint32_t nb_rx_poll = 0;\n+\tuint32_t nb_wrr = 0;\n+\tstruct eth_rx_poll_entry *rx_poll = NULL;\n+\tuint32_t *rx_wrr = NULL;\n \n \tRTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL);\n \tRTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL);\n@@ -1137,26 +1318,31 @@ static int rxa_sw_add(struct rte_event_eth_rx_adapter *rx_adapter,\n \t\t\t}\n \t\t}\n \t} else {\n-\t\tint rc;\n+\t\trxa_calc_nb_post_del(rx_adapter, dev_info, rx_queue_id,\n+\t\t\t&nb_rx_poll, &nb_wrr);\n+\t\tret = rxa_alloc_poll_arrays(rx_adapter, nb_rx_poll, nb_wrr,\n+\t\t\t&rx_poll, &rx_wrr);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n \t\trte_spinlock_lock(&rx_adapter->rx_lock);\n-\t\tif (rx_queue_id == -1) {\n-\t\t\tfor (i = 0; i < dev_info->dev->data->nb_rx_queues; i++)\n-\t\t\t\trxa_sw_del(rx_adapter, dev_info, i);\n-\t\t} else {\n-\t\t\trxa_sw_del(rx_adapter, dev_info, (uint16_t)rx_queue_id);\n-\t\t}\n+\t\trxa_sw_del(rx_adapter, dev_info, rx_queue_id);\n+\t\trxa_calc_wrr_sequence(rx_adapter, rx_poll, rx_wrr);\n+\n+\t\trte_free(rx_adapter->eth_rx_poll);\n+\t\trte_free(rx_adapter->wrr_sched);\n \n-\t\trc = rxa_calc_wrr_sequence(rx_adapter);\n-\t\tif (rc)\n-\t\t\tRTE_EDEV_LOG_ERR(\"WRR recalculation failed %\" PRId32,\n-\t\t\t\t\trc);\n+\t\trx_adapter->eth_rx_poll = rx_poll;\n+\t\trx_adapter->num_rx_polled = nb_rx_poll;\n+\t\trx_adapter->wrr_sched = rx_wrr;\n+\t\trx_adapter->wrr_len = nb_wrr;\n \n \t\tif (dev_info->nb_dev_queues == 0) {\n \t\t\trte_free(dev_info->rx_queue);\n \t\t\tdev_info->rx_queue = NULL;\n \t\t}\n-\n \t\trte_spinlock_unlock(&rx_adapter->rx_lock);\n+\n \t\trte_service_component_runstate_set(rx_adapter->service_id,\n \t\t\t\trxa_sw_adapter_queue_count(rx_adapter));\n \t}\n",
    "prefixes": [
        "v2",
        "2/5"
    ]
}