get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1141312,
    "url": "http://patchwork.ozlabs.org/api/patches/1141312/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20190802082533.23083-3-anthony.l.nguyen@intel.com/",
    "project": {
        "id": 46,
        "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api",
        "name": "Intel Wired Ethernet development",
        "link_name": "intel-wired-lan",
        "list_id": "intel-wired-lan.osuosl.org",
        "list_email": "intel-wired-lan@osuosl.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20190802082533.23083-3-anthony.l.nguyen@intel.com>",
    "list_archive_url": null,
    "date": "2019-08-02T08:25:21",
    "name": "[S26,03/15] ice: Alloc queue management bitmaps and arrays dynamically",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "135dd9f30bb3a70efbaa702e271b188da153ec15",
    "submitter": {
        "id": 68875,
        "url": "http://patchwork.ozlabs.org/api/people/68875/?format=api",
        "name": "Tony Nguyen",
        "email": "anthony.l.nguyen@intel.com"
    },
    "delegate": {
        "id": 68,
        "url": "http://patchwork.ozlabs.org/api/users/68/?format=api",
        "username": "jtkirshe",
        "first_name": "Jeff",
        "last_name": "Kirsher",
        "email": "jeffrey.t.kirsher@intel.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20190802082533.23083-3-anthony.l.nguyen@intel.com/mbox/",
    "series": [
        {
            "id": 123025,
            "url": "http://patchwork.ozlabs.org/api/series/123025/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=123025",
            "date": "2019-08-02T08:25:29",
            "name": "[S26,01/15] ice: add support for enabling/disabling single queues",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/123025/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1141312/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1141312/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@osuosl.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.137; helo=fraxinus.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=intel.com"
        ],
        "Received": [
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 460YCn6cQVz9sBF\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  3 Aug 2019 02:54:13 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 4574786B63;\n\tFri,  2 Aug 2019 16:54:12 +0000 (UTC)",
            "from fraxinus.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id b10heUx6fOPT; Fri,  2 Aug 2019 16:54:10 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id D447A86BA0;\n\tFri,  2 Aug 2019 16:54:09 +0000 (UTC)",
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id A3BA71BF296\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  2 Aug 2019 16:54:04 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id A0AD887733\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  2 Aug 2019 16:54:04 +0000 (UTC)",
            "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id G3yU5TxVxGlT for <intel-wired-lan@lists.osuosl.org>;\n\tFri,  2 Aug 2019 16:54:01 +0000 (UTC)",
            "from mga07.intel.com (mga07.intel.com [134.134.136.100])\n\tby whitealder.osuosl.org (Postfix) with ESMTPS id 01E14875F0\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  2 Aug 2019 16:54:00 +0000 (UTC)",
            "from orsmga003.jf.intel.com ([10.7.209.27])\n\tby orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t02 Aug 2019 09:53:58 -0700",
            "from unknown (HELO localhost.jf.intel.com) ([10.166.244.174])\n\tby orsmga003.jf.intel.com with ESMTP; 02 Aug 2019 09:53:58 -0700"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.64,338,1559545200\"; d=\"scan'208\";a=\"175640940\"",
        "From": "Tony Nguyen <anthony.l.nguyen@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Fri,  2 Aug 2019 01:25:21 -0700",
        "Message-Id": "<20190802082533.23083-3-anthony.l.nguyen@intel.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190802082533.23083-1-anthony.l.nguyen@intel.com>",
        "References": "<20190802082533.23083-1-anthony.l.nguyen@intel.com>",
        "MIME-Version": "1.0",
        "Subject": "[Intel-wired-lan] [PATCH S26 03/15] ice: Alloc queue management\n\tbitmaps and arrays dynamically",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>",
        "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"
    },
    "content": "From: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>\n\nThe total number of queues available on the device is divided between\nmultiple physical functions (PF) in the firmware and provided to the\ndriver when it gets function capabilities from the firmware. Thus\neach PF knows how many Tx/Rx queues it has. These queues are then\ndoled out to different VSIs (for LAN traffic, SR-IOV VF traffic, etc.)\n\nTo track usage of these queues at the PF level, the driver uses two\nbitmaps avail_txqs and avail_rxqs. At the VSI level (i.e. struct ice_vsi\ninstances) the driver uses two arrays txq_map and rxq_map, to track\nownership of VSIs' queues in avail_txqs and avail_rxqs respectively.\n\nThe aforementioned bitmaps and arrays should be allocated dynamically,\nbecause the number of queues supported by a PF is only available once\nfunction capabilities have been queried. The current static allocation\nconsumes way more memory than required.\n\nThis patch removes the DECLARE_BITMAP for avail_txqs and avail_rxqs\nand instead uses bitmap_zalloc to allocate the bitmaps during init.\nSimilarly txq_map and rxq_map are now allocated in ice_vsi_alloc_arrays.\nAs a result ICE_MAX_TXQS and ICE_MAX_RXQS defines are no longer needed.\nAlso as txq_map and rxq_map are now allocated and freed, some code\nreordering was required in ice_vsi_rebuild for correct functioning.\n\nSigned-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>\n---\n drivers/net/ethernet/intel/ice/ice.h      | 12 +++---\n drivers/net/ethernet/intel/ice/ice_lib.c  | 49 +++++++++++++++++------\n drivers/net/ethernet/intel/ice/ice_main.c | 40 ++++++++++++++----\n 3 files changed, 74 insertions(+), 27 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h\nindex 2165366e9250..1a64900e7030 100644\n--- a/drivers/net/ethernet/intel/ice/ice.h\n+++ b/drivers/net/ethernet/intel/ice/ice.h\n@@ -73,8 +73,6 @@ extern const char ice_drv_ver[];\n #define ICE_MBXRQ_LEN\t\t512\n #define ICE_MIN_MSIX\t\t2\n #define ICE_NO_VSI\t\t0xffff\n-#define ICE_MAX_TXQS\t\t2048\n-#define ICE_MAX_RXQS\t\t2048\n #define ICE_VSI_MAP_CONTIG\t0\n #define ICE_VSI_MAP_SCATTER\t1\n #define ICE_MAX_SCATTER_TXQS\t16\n@@ -284,8 +282,8 @@ struct ice_vsi {\n \t/* queue information */\n \tu8 tx_mapping_mode;\t\t /* ICE_MAP_MODE_[CONTIG|SCATTER] */\n \tu8 rx_mapping_mode;\t\t /* ICE_MAP_MODE_[CONTIG|SCATTER] */\n-\tu16 txq_map[ICE_MAX_TXQS];\t /* index in pf->avail_txqs */\n-\tu16 rxq_map[ICE_MAX_RXQS];\t /* index in pf->avail_rxqs */\n+\tu16 *txq_map;\t\t\t /* index in pf->avail_txqs */\n+\tu16 *rxq_map;\t\t\t /* index in pf->avail_rxqs */\n \tu16 alloc_txq;\t\t\t /* Allocated Tx queues */\n \tu16 num_txq;\t\t\t /* Used Tx queues */\n \tu16 alloc_rxq;\t\t\t /* Allocated Rx queues */\n@@ -357,9 +355,9 @@ struct ice_pf {\n \tu16 num_vf_qps;\t\t\t/* num queue pairs per VF */\n \tu16 num_vf_msix;\t\t/* num vectors per VF */\n \tDECLARE_BITMAP(state, __ICE_STATE_NBITS);\n-\tDECLARE_BITMAP(avail_txqs, ICE_MAX_TXQS);\n-\tDECLARE_BITMAP(avail_rxqs, ICE_MAX_RXQS);\n \tDECLARE_BITMAP(flags, ICE_PF_FLAGS_NBITS);\n+\tunsigned long *avail_txqs;\t/* bitmap to track PF Tx queue usage */\n+\tunsigned long *avail_rxqs;\t/* bitmap to track PF Rx queue usage */\n \tunsigned long serv_tmr_period;\n \tunsigned long serv_tmr_prev;\n \tstruct timer_list serv_tmr;\n@@ -370,6 +368,8 @@ struct ice_pf {\n \tu32 hw_csum_rx_error;\n \tu32 oicr_idx;\t\t/* Other interrupt cause MSIX vector index */\n \tu32 num_avail_sw_msix;\t/* remaining MSIX SW vectors left unclaimed */\n+\tu16 max_pf_txqs;\t/* Total Tx queues PF wide */\n+\tu16 max_pf_rxqs;\t/* Total Rx queues PF wide */\n \tu32 num_lan_msix;\t/* Total MSIX vectors for base driver */\n \tu16 num_lan_tx;\t\t/* num LAN Tx queues setup */\n \tu16 num_lan_rx;\t\t/* num LAN Rx queues setup */\ndiff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c\nindex 23124159c8bf..212c532fabd6 100644\n--- a/drivers/net/ethernet/intel/ice/ice_lib.c\n+++ b/drivers/net/ethernet/intel/ice/ice_lib.c\n@@ -263,12 +263,24 @@ static int ice_vsi_alloc_arrays(struct ice_vsi *vsi)\n \tvsi->tx_rings = devm_kcalloc(&pf->pdev->dev, vsi->alloc_txq,\n \t\t\t\t     sizeof(*vsi->tx_rings), GFP_KERNEL);\n \tif (!vsi->tx_rings)\n-\t\tgoto err_txrings;\n+\t\treturn -ENOMEM;\n \n \tvsi->rx_rings = devm_kcalloc(&pf->pdev->dev, vsi->alloc_rxq,\n \t\t\t\t     sizeof(*vsi->rx_rings), GFP_KERNEL);\n \tif (!vsi->rx_rings)\n-\t\tgoto err_rxrings;\n+\t\tgoto err_rings;\n+\n+\tvsi->txq_map = devm_kcalloc(&pf->pdev->dev, vsi->alloc_txq,\n+\t\t\t\t    sizeof(*vsi->txq_map), GFP_KERNEL);\n+\n+\tif (!vsi->txq_map)\n+\t\tgoto err_txq_map;\n+\n+\tvsi->rxq_map = devm_kcalloc(&pf->pdev->dev, vsi->alloc_rxq,\n+\t\t\t\t    sizeof(*vsi->rxq_map), GFP_KERNEL);\n+\tif (!vsi->rxq_map)\n+\t\tgoto err_rxq_map;\n+\n \n \t/* There is no need to allocate q_vectors for a loopback VSI. */\n \tif (vsi->type == ICE_VSI_LB)\n@@ -283,10 +295,13 @@ static int ice_vsi_alloc_arrays(struct ice_vsi *vsi)\n \treturn 0;\n \n err_vectors:\n+\tdevm_kfree(&pf->pdev->dev, vsi->rxq_map);\n+err_rxq_map:\n+\tdevm_kfree(&pf->pdev->dev, vsi->txq_map);\n+err_txq_map:\n \tdevm_kfree(&pf->pdev->dev, vsi->rx_rings);\n-err_rxrings:\n+err_rings:\n \tdevm_kfree(&pf->pdev->dev, vsi->tx_rings);\n-err_txrings:\n \treturn -ENOMEM;\n }\n \n@@ -441,6 +456,14 @@ static void ice_vsi_free_arrays(struct ice_vsi *vsi)\n \t\tdevm_kfree(&pf->pdev->dev, vsi->rx_rings);\n \t\tvsi->rx_rings = NULL;\n \t}\n+\tif (vsi->txq_map) {\n+\t\tdevm_kfree(&pf->pdev->dev, vsi->txq_map);\n+\t\tvsi->txq_map = NULL;\n+\t}\n+\tif (vsi->rxq_map) {\n+\t\tdevm_kfree(&pf->pdev->dev, vsi->rxq_map);\n+\t\tvsi->rxq_map = NULL;\n+\t}\n }\n \n /**\n@@ -672,7 +695,7 @@ static int ice_vsi_get_qs(struct ice_vsi *vsi)\n \tstruct ice_qs_cfg tx_qs_cfg = {\n \t\t.qs_mutex = &pf->avail_q_mutex,\n \t\t.pf_map = pf->avail_txqs,\n-\t\t.pf_map_size = ICE_MAX_TXQS,\n+\t\t.pf_map_size = pf->max_pf_txqs,\n \t\t.q_count = vsi->alloc_txq,\n \t\t.scatter_count = ICE_MAX_SCATTER_TXQS,\n \t\t.vsi_map = vsi->txq_map,\n@@ -682,7 +705,7 @@ static int ice_vsi_get_qs(struct ice_vsi *vsi)\n \tstruct ice_qs_cfg rx_qs_cfg = {\n \t\t.qs_mutex = &pf->avail_q_mutex,\n \t\t.pf_map = pf->avail_rxqs,\n-\t\t.pf_map_size = ICE_MAX_RXQS,\n+\t\t.pf_map_size = pf->max_pf_rxqs,\n \t\t.q_count = vsi->alloc_rxq,\n \t\t.scatter_count = ICE_MAX_SCATTER_RXQS,\n \t\t.vsi_map = vsi->rxq_map,\n@@ -3039,16 +3062,19 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi)\n \t\tvsi->base_vector = 0;\n \t}\n \n+\tice_vsi_put_qs(vsi);\n \tice_vsi_clear_rings(vsi);\n \tice_vsi_free_arrays(vsi);\n-\tif (vsi->req_txq || vsi->req_rxq)\n-\t\tice_vsi_put_qs(vsi);\n \tif (vsi->type == ICE_VSI_VF)\n \t\tice_vsi_set_num_qs(vsi, vf->vf_id);\n \telse\n \t\tice_vsi_set_num_qs(vsi, ICE_INVAL_VFID);\n-\tif (vsi->req_txq || vsi->req_rxq)\n-\t\tice_vsi_get_qs(vsi);\n+\n+\tret = ice_vsi_alloc_arrays(vsi);\n+\tif (ret < 0)\n+\t\tgoto err_vsi;\n+\n+\tice_vsi_get_qs(vsi);\n \tice_vsi_set_tc_cfg(vsi);\n \n \t/* Initialize VSI struct elements and create VSI in FW */\n@@ -3056,9 +3082,6 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi)\n \tif (ret < 0)\n \t\tgoto err_vsi;\n \n-\tret = ice_vsi_alloc_arrays(vsi);\n-\tif (ret < 0)\n-\t\tgoto err_vsi;\n \n \tswitch (vsi->type) {\n \tcase ICE_VSI_PF:\ndiff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c\nindex 655034e85d73..0eefac05eae1 100644\n--- a/drivers/net/ethernet/intel/ice/ice_main.c\n+++ b/drivers/net/ethernet/intel/ice/ice_main.c\n@@ -2243,13 +2243,23 @@ static void ice_deinit_pf(struct ice_pf *pf)\n \tice_service_task_stop(pf);\n \tmutex_destroy(&pf->sw_mutex);\n \tmutex_destroy(&pf->avail_q_mutex);\n+\n+\tif (pf->avail_txqs) {\n+\t\tbitmap_free(pf->avail_txqs);\n+\t\tpf->avail_txqs = NULL;\n+\t}\n+\n+\tif (pf->avail_rxqs) {\n+\t\tbitmap_free(pf->avail_rxqs);\n+\t\tpf->avail_rxqs = NULL;\n+\t}\n }\n \n /**\n  * ice_init_pf - Initialize general software structures (struct ice_pf)\n  * @pf: board private structure to initialize\n  */\n-static void ice_init_pf(struct ice_pf *pf)\n+static int ice_init_pf(struct ice_pf *pf)\n {\n \tbitmap_zero(pf->flags, ICE_PF_FLAGS_NBITS);\n #ifdef CONFIG_PCI_IOV\n@@ -2265,12 +2275,6 @@ static void ice_init_pf(struct ice_pf *pf)\n \tmutex_init(&pf->sw_mutex);\n \tmutex_init(&pf->avail_q_mutex);\n \n-\t/* Clear avail_[t|r]x_qs bitmaps (set all to avail) */\n-\tmutex_lock(&pf->avail_q_mutex);\n-\tbitmap_zero(pf->avail_txqs, ICE_MAX_TXQS);\n-\tbitmap_zero(pf->avail_rxqs, ICE_MAX_RXQS);\n-\tmutex_unlock(&pf->avail_q_mutex);\n-\n \tif (pf->hw.func_caps.common_cap.rss_table_size)\n \t\tset_bit(ICE_FLAG_RSS_ENA, pf->flags);\n \n@@ -2279,6 +2283,22 @@ static void ice_init_pf(struct ice_pf *pf)\n \tpf->serv_tmr_period = HZ;\n \tINIT_WORK(&pf->serv_task, ice_service_task);\n \tclear_bit(__ICE_SERVICE_SCHED, pf->state);\n+\n+\tpf->max_pf_txqs = pf->hw.func_caps.common_cap.num_txq;\n+\tpf->max_pf_rxqs = pf->hw.func_caps.common_cap.num_rxq;\n+\n+\tpf->avail_txqs = bitmap_zalloc(pf->max_pf_txqs, GFP_KERNEL);\n+\tif (!pf->avail_txqs)\n+\t\treturn -ENOMEM;\n+\n+\tpf->avail_rxqs = bitmap_zalloc(pf->max_pf_rxqs, GFP_KERNEL);\n+\tif (!pf->avail_rxqs) {\n+\t\tdevm_kfree(&pf->pdev->dev, pf->avail_txqs);\n+\t\tpf->avail_txqs = NULL;\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\treturn 0;\n }\n \n /**\n@@ -2503,7 +2523,11 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)\n \t\t hw->fw_maj_ver, hw->fw_min_ver, hw->fw_build,\n \t\t hw->api_maj_ver, hw->api_min_ver);\n \n-\tice_init_pf(pf);\n+\terr = ice_init_pf(pf);\n+\tif (err) {\n+\t\tdev_err(dev, \"ice_init_pf failed: %d\\n\", err);\n+\t\tgoto err_init_pf_unroll;\n+\t}\n \n \terr = ice_init_pf_dcb(pf, false);\n \tif (err) {\n",
    "prefixes": [
        "S26",
        "03/15"
    ]
}