Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/972037/?format=api
{ "id": 972037, "url": "http://patchwork.ozlabs.org/api/patches/972037/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20180920002319.10971-8-anirudh.venkataramanan@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": "<20180920002319.10971-8-anirudh.venkataramanan@intel.com>", "list_archive_url": null, "date": "2018-09-20T00:23:10", "name": "[07/16] ice: Move common functions out of ice_main.c part 7/7", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "9acd38149f9332867958220ada56ee34d1f0c280", "submitter": { "id": 73601, "url": "http://patchwork.ozlabs.org/api/people/73601/?format=api", "name": "Anirudh Venkataramanan", "email": "anirudh.venkataramanan@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/20180920002319.10971-8-anirudh.venkataramanan@intel.com/mbox/", "series": [ { "id": 66525, "url": "http://patchwork.ozlabs.org/api/series/66525/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=66525", "date": "2018-09-20T00:23:03", "name": "Implementation updates for ice", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/66525/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/972037/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/972037/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.136; helo=silver.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 silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\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 42FyBh5ffLz9s9J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 20 Sep 2018 10:23:40 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 3B3CD3024C;\n\tThu, 20 Sep 2018 00:23:39 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 5lHOEBRuxqLH; Thu, 20 Sep 2018 00:23:34 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id D8465302BD;\n\tThu, 20 Sep 2018 00:23:34 +0000 (UTC)", "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id B9F051C08AF\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Sep 2018 00:23:30 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id B4E7B227F5\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Sep 2018 00:23:30 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id YzilTd7bhdkk for <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Sep 2018 00:23:24 +0000 (UTC)", "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n\tby silver.osuosl.org (Postfix) with ESMTPS id 7B49030932\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Sep 2018 00:23:24 +0000 (UTC)", "from fmsmga006.fm.intel.com ([10.253.24.20])\n\tby fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t19 Sep 2018 17:23:23 -0700", "from shasta.jf.intel.com ([10.166.241.11])\n\tby fmsmga006.fm.intel.com with ESMTP; 19 Sep 2018 17:23:20 -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.53,396,1531810800\"; d=\"scan'208\";a=\"265057697\"", "From": "Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Wed, 19 Sep 2018 17:23:10 -0700", "Message-Id": "<20180920002319.10971-8-anirudh.venkataramanan@intel.com>", "X-Mailer": "git-send-email 2.14.3", "In-Reply-To": "<20180920002319.10971-1-anirudh.venkataramanan@intel.com>", "References": "<20180920002319.10971-1-anirudh.venkataramanan@intel.com>", "Subject": "[Intel-wired-lan] [PATCH 07/16] ice: Move common functions out of\n\tice_main.c part 7/7", "X-BeenThere": "intel-wired-lan@osuosl.org", "X-Mailman-Version": "2.1.24", "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>", "MIME-Version": "1.0", "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": "This patch completes the code move out of ice_main.c\n\nThe following top level functions and related dependency functions) were\nmoved to ice_lib.c:\nice_vsi_setup\nice_vsi_cfg_tc\n\nThe following functions were made static again:\nice_vsi_setup_vector_base\nice_vsi_alloc_q_vectors\nice_vsi_get_qs\nvoid ice_vsi_map_rings_to_vectors\nice_vsi_alloc_rings\nice_vsi_set_rss_params\nice_vsi_set_num_qs\nice_get_free_slot\nice_vsi_init\nice_vsi_alloc_arrays\n\nSigned-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>\n---\n drivers/net/ethernet/intel/ice/ice_lib.c | 253 ++++++++++++++++++++++++++++--\n drivers/net/ethernet/intel/ice/ice_lib.h | 26 +--\n drivers/net/ethernet/intel/ice/ice_main.c | 252 -----------------------------\n 3 files changed, 249 insertions(+), 282 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c\nindex b17cba3ae887..3d6d8a33b7bc 100644\n--- a/drivers/net/ethernet/intel/ice/ice_lib.c\n+++ b/drivers/net/ethernet/intel/ice/ice_lib.c\n@@ -233,7 +233,7 @@ static int ice_vsi_ctrl_rx_rings(struct ice_vsi *vsi, bool ena)\n * On error: returns error code (negative)\n * On success: returns 0\n */\n-int ice_vsi_alloc_arrays(struct ice_vsi *vsi, bool alloc_qvectors)\n+static int ice_vsi_alloc_arrays(struct ice_vsi *vsi, bool alloc_qvectors)\n {\n \tstruct ice_pf *pf = vsi->back;\n \n@@ -274,7 +274,7 @@ int ice_vsi_alloc_arrays(struct ice_vsi *vsi, bool alloc_qvectors)\n *\n * Return 0 on success and a negative value on error\n */\n-void ice_vsi_set_num_qs(struct ice_vsi *vsi)\n+static void ice_vsi_set_num_qs(struct ice_vsi *vsi)\n {\n \tstruct ice_pf *pf = vsi->back;\n \n@@ -301,7 +301,7 @@ void ice_vsi_set_num_qs(struct ice_vsi *vsi)\n * void * is being used to keep the functionality generic. This lets us use this\n * function on any array of pointers.\n */\n-int ice_get_free_slot(void *array, int size, int curr)\n+static int ice_get_free_slot(void *array, int size, int curr)\n {\n \tint **tmp_array = (int **)array;\n \tint next;\n@@ -423,6 +423,70 @@ irqreturn_t ice_msix_clean_rings(int __always_unused irq, void *data)\n \treturn IRQ_HANDLED;\n }\n \n+/**\n+ * ice_vsi_alloc - Allocates the next available struct vsi in the PF\n+ * @pf: board private structure\n+ * @type: type of VSI\n+ *\n+ * returns a pointer to a VSI on success, NULL on failure.\n+ */\n+static struct ice_vsi *ice_vsi_alloc(struct ice_pf *pf, enum ice_vsi_type type)\n+{\n+\tstruct ice_vsi *vsi = NULL;\n+\n+\t/* Need to protect the allocation of the VSIs at the PF level */\n+\tmutex_lock(&pf->sw_mutex);\n+\n+\t/* If we have already allocated our maximum number of VSIs,\n+\t * pf->next_vsi will be ICE_NO_VSI. If not, pf->next_vsi index\n+\t * is available to be populated\n+\t */\n+\tif (pf->next_vsi == ICE_NO_VSI) {\n+\t\tdev_dbg(&pf->pdev->dev, \"out of VSI slots!\\n\");\n+\t\tgoto unlock_pf;\n+\t}\n+\n+\tvsi = devm_kzalloc(&pf->pdev->dev, sizeof(*vsi), GFP_KERNEL);\n+\tif (!vsi)\n+\t\tgoto unlock_pf;\n+\n+\tvsi->type = type;\n+\tvsi->back = pf;\n+\tset_bit(__ICE_DOWN, vsi->state);\n+\tvsi->idx = pf->next_vsi;\n+\tvsi->work_lmt = ICE_DFLT_IRQ_WORK;\n+\n+\tice_vsi_set_num_qs(vsi);\n+\n+\tswitch (vsi->type) {\n+\tcase ICE_VSI_PF:\n+\t\tif (ice_vsi_alloc_arrays(vsi, true))\n+\t\t\tgoto err_rings;\n+\n+\t\t/* Setup default MSIX irq handler for VSI */\n+\t\tvsi->irq_handler = ice_msix_clean_rings;\n+\t\tbreak;\n+\tdefault:\n+\t\tdev_warn(&pf->pdev->dev, \"Unknown VSI type %d\\n\", vsi->type);\n+\t\tgoto unlock_pf;\n+\t}\n+\n+\t/* fill VSI slot in the PF struct */\n+\tpf->vsi[pf->next_vsi] = vsi;\n+\n+\t/* prepare pf->next_vsi for next use */\n+\tpf->next_vsi = ice_get_free_slot(pf->vsi, pf->num_alloc_vsi,\n+\t\t\t\t\t pf->next_vsi);\n+\tgoto unlock_pf;\n+\n+err_rings:\n+\tdevm_kfree(&pf->pdev->dev, vsi);\n+\tvsi = NULL;\n+unlock_pf:\n+\tmutex_unlock(&pf->sw_mutex);\n+\treturn vsi;\n+}\n+\n /**\n * ice_vsi_get_qs_contig - Assign a contiguous chunk of queues to VSI\n * @vsi: the VSI getting queues\n@@ -533,7 +597,7 @@ static int ice_vsi_get_qs_scatter(struct ice_vsi *vsi)\n *\n * Returns 0 on success and a negative value on error\n */\n-int ice_vsi_get_qs(struct ice_vsi *vsi)\n+static int ice_vsi_get_qs(struct ice_vsi *vsi)\n {\n \tint ret = 0;\n \n@@ -602,7 +666,7 @@ static void ice_rss_clean(struct ice_vsi *vsi)\n * ice_vsi_set_rss_params - Setup RSS capabilities per VSI type\n * @vsi: the VSI being configured\n */\n-void ice_vsi_set_rss_params(struct ice_vsi *vsi)\n+static void ice_vsi_set_rss_params(struct ice_vsi *vsi)\n {\n \tstruct ice_hw_common_caps *cap;\n \tstruct ice_pf *pf = vsi->back;\n@@ -793,7 +857,7 @@ static void ice_set_rss_vsi_ctx(struct ice_vsi_ctx *ctxt, struct ice_vsi *vsi)\n * This initializes a VSI context depending on the VSI type to be added and\n * passes it down to the add_vsi aq command to create a new VSI.\n */\n-int ice_vsi_init(struct ice_vsi *vsi)\n+static int ice_vsi_init(struct ice_vsi *vsi)\n {\n \tstruct ice_vsi_ctx ctxt = { 0 };\n \tstruct ice_pf *pf = vsi->back;\n@@ -922,7 +986,7 @@ static int ice_vsi_alloc_q_vector(struct ice_vsi *vsi, int v_idx)\n * We allocate one q_vector per queue interrupt. If allocation fails we\n * return -ENOMEM.\n */\n-int ice_vsi_alloc_q_vectors(struct ice_vsi *vsi)\n+static int ice_vsi_alloc_q_vectors(struct ice_vsi *vsi)\n {\n \tstruct ice_pf *pf = vsi->back;\n \tint v_idx = 0, num_q_vectors;\n@@ -970,7 +1034,7 @@ int ice_vsi_alloc_q_vectors(struct ice_vsi *vsi)\n *\n * Returns 0 on success or negative on failure\n */\n-int ice_vsi_setup_vector_base(struct ice_vsi *vsi)\n+static int ice_vsi_setup_vector_base(struct ice_vsi *vsi)\n {\n \tstruct ice_pf *pf = vsi->back;\n \tint num_q_vectors = 0;\n@@ -1038,7 +1102,7 @@ static void ice_vsi_clear_rings(struct ice_vsi *vsi)\n * ice_vsi_alloc_rings - Allocates Tx and Rx rings for the VSI\n * @vsi: VSI which is having rings allocated\n */\n-int ice_vsi_alloc_rings(struct ice_vsi *vsi)\n+static int ice_vsi_alloc_rings(struct ice_vsi *vsi)\n {\n \tstruct ice_pf *pf = vsi->back;\n \tint i;\n@@ -1096,7 +1160,7 @@ int ice_vsi_alloc_rings(struct ice_vsi *vsi)\n * through the MSI-X enabling code. On a constrained vector budget, we map Tx\n * and Rx rings to the vector as \"efficiently\" as possible.\n */\n-void ice_vsi_map_rings_to_vectors(struct ice_vsi *vsi)\n+static void ice_vsi_map_rings_to_vectors(struct ice_vsi *vsi)\n {\n \tint q_vectors = vsi->num_q_vectors;\n \tint tx_rings_rem, rx_rings_rem;\n@@ -1142,6 +1206,69 @@ void ice_vsi_map_rings_to_vectors(struct ice_vsi *vsi)\n \t}\n }\n \n+/**\n+ * ice_vsi_cfg_rss_lut_key - Configure RSS params for a VSI\n+ * @vsi: VSI to be configured\n+ */\n+static int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi)\n+{\n+\tu8 seed[ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE];\n+\tstruct ice_aqc_get_set_rss_keys *key;\n+\tstruct ice_pf *pf = vsi->back;\n+\tenum ice_status status;\n+\tint err = 0;\n+\tu8 *lut;\n+\n+\tvsi->rss_size = min_t(int, vsi->rss_size, vsi->num_rxq);\n+\n+\tlut = devm_kzalloc(&pf->pdev->dev, vsi->rss_table_size, GFP_KERNEL);\n+\tif (!lut)\n+\t\treturn -ENOMEM;\n+\n+\tif (vsi->rss_lut_user)\n+\t\tmemcpy(lut, vsi->rss_lut_user, vsi->rss_table_size);\n+\telse\n+\t\tice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size);\n+\n+\tstatus = ice_aq_set_rss_lut(&pf->hw, vsi->vsi_num, vsi->rss_lut_type,\n+\t\t\t\t lut, vsi->rss_table_size);\n+\n+\tif (status) {\n+\t\tdev_err(&vsi->back->pdev->dev,\n+\t\t\t\"set_rss_lut failed, error %d\\n\", status);\n+\t\terr = -EIO;\n+\t\tgoto ice_vsi_cfg_rss_exit;\n+\t}\n+\n+\tkey = devm_kzalloc(&vsi->back->pdev->dev, sizeof(*key), GFP_KERNEL);\n+\tif (!key) {\n+\t\terr = -ENOMEM;\n+\t\tgoto ice_vsi_cfg_rss_exit;\n+\t}\n+\n+\tif (vsi->rss_hkey_user)\n+\t\tmemcpy(seed, vsi->rss_hkey_user,\n+\t\t ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE);\n+\telse\n+\t\tnetdev_rss_key_fill((void *)seed,\n+\t\t\t\t ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE);\n+\tmemcpy(&key->standard_rss_key, seed,\n+\t ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE);\n+\n+\tstatus = ice_aq_set_rss_key(&pf->hw, vsi->vsi_num, key);\n+\n+\tif (status) {\n+\t\tdev_err(&vsi->back->pdev->dev, \"set_rss_key failed, error %d\\n\",\n+\t\t\tstatus);\n+\t\terr = -EIO;\n+\t}\n+\n+\tdevm_kfree(&pf->pdev->dev, key);\n+ice_vsi_cfg_rss_exit:\n+\tdevm_kfree(&pf->pdev->dev, lut);\n+\treturn err;\n+}\n+\n /**\n * ice_add_mac_to_list - Add a mac address filter entry to the list\n * @vsi: the VSI to be forwarded to\n@@ -1722,6 +1849,112 @@ int ice_cfg_vlan_pruning(struct ice_vsi *vsi, bool ena)\n \treturn -EIO;\n }\n \n+/**\n+ * ice_vsi_setup - Set up a VSI by a given type\n+ * @pf: board private structure\n+ * @pi: pointer to the port_info instance\n+ * @type: VSI type\n+ * @vf_id: defines VF id to which this VSI connects. This field is meant to be\n+ * used only for ICE_VSI_VF VSI type. For other VSI types, should\n+ * fill-in ICE_INVAL_VFID as input.\n+ *\n+ * This allocates the sw VSI structure and its queue resources.\n+ *\n+ * Returns pointer to the successfully allocated and configured VSI sw struct on\n+ * success, NULL on failure.\n+ */\n+struct ice_vsi *\n+ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,\n+\t enum ice_vsi_type type, u16 __always_unused vf_id)\n+{\n+\tu16 max_txqs[ICE_MAX_TRAFFIC_CLASS] = { 0 };\n+\tstruct device *dev = &pf->pdev->dev;\n+\tstruct ice_vsi *vsi;\n+\tint ret, i;\n+\n+\tvsi = ice_vsi_alloc(pf, type);\n+\tif (!vsi) {\n+\t\tdev_err(dev, \"could not allocate VSI\\n\");\n+\t\treturn NULL;\n+\t}\n+\n+\tvsi->port_info = pi;\n+\tvsi->vsw = pf->first_sw;\n+\n+\tif (ice_vsi_get_qs(vsi)) {\n+\t\tdev_err(dev, \"Failed to allocate queues. vsi->idx = %d\\n\",\n+\t\t\tvsi->idx);\n+\t\tgoto unroll_get_qs;\n+\t}\n+\n+\t/* set RSS capabilities */\n+\tice_vsi_set_rss_params(vsi);\n+\n+\t/* create the VSI */\n+\tret = ice_vsi_init(vsi);\n+\tif (ret)\n+\t\tgoto unroll_get_qs;\n+\n+\tswitch (vsi->type) {\n+\tcase ICE_VSI_PF:\n+\t\tret = ice_vsi_alloc_q_vectors(vsi);\n+\t\tif (ret)\n+\t\t\tgoto unroll_vsi_init;\n+\n+\t\tret = ice_vsi_setup_vector_base(vsi);\n+\t\tif (ret)\n+\t\t\tgoto unroll_alloc_q_vector;\n+\n+\t\tret = ice_vsi_alloc_rings(vsi);\n+\t\tif (ret)\n+\t\t\tgoto unroll_vector_base;\n+\n+\t\tice_vsi_map_rings_to_vectors(vsi);\n+\n+\t\t/* Do not exit if configuring RSS had an issue, at least\n+\t\t * receive traffic on first queue. Hence no need to capture\n+\t\t * return value\n+\t\t */\n+\t\tif (test_bit(ICE_FLAG_RSS_ENA, pf->flags))\n+\t\t\tice_vsi_cfg_rss_lut_key(vsi);\n+\t\tbreak;\n+\tdefault:\n+\t\t/* if vsi type is not recognized, clean up the resources and\n+\t\t * exit\n+\t\t */\n+\t\tgoto unroll_vsi_init;\n+\t}\n+\n+\tice_vsi_set_tc_cfg(vsi);\n+\n+\t/* configure VSI nodes based on number of queues and TC's */\n+\tfor (i = 0; i < vsi->tc_cfg.numtc; i++)\n+\t\tmax_txqs[i] = vsi->num_txq;\n+\n+\tret = ice_cfg_vsi_lan(vsi->port_info, vsi->vsi_num,\n+\t\t\t vsi->tc_cfg.ena_tc, max_txqs);\n+\tif (ret) {\n+\t\tdev_info(&pf->pdev->dev, \"Failed VSI lan queue config\\n\");\n+\t\tgoto unroll_vector_base;\n+\t}\n+\n+\treturn vsi;\n+\n+unroll_vector_base:\n+\tice_free_res(vsi->back->irq_tracker, vsi->base_vector, vsi->idx);\n+unroll_alloc_q_vector:\n+\tice_vsi_free_q_vectors(vsi);\n+unroll_vsi_init:\n+\tice_vsi_delete(vsi);\n+unroll_get_qs:\n+\tice_vsi_put_qs(vsi);\n+\tpf->q_left_tx += vsi->alloc_txq;\n+\tpf->q_left_rx += vsi->alloc_rxq;\n+\tice_vsi_clear(vsi);\n+\n+\treturn NULL;\n+}\n+\n /**\n * ice_vsi_release_msix - Clear the queue to Interrupt mapping in HW\n * @vsi: the VSI being cleaned up\ndiff --git a/drivers/net/ethernet/intel/ice/ice_lib.h b/drivers/net/ethernet/intel/ice/ice_lib.h\nindex aaab3fc4b018..a76cde895bf3 100644\n--- a/drivers/net/ethernet/intel/ice/ice_lib.h\n+++ b/drivers/net/ethernet/intel/ice/ice_lib.h\n@@ -6,26 +6,6 @@\n \n #include \"ice.h\"\n \n-int ice_vsi_setup_vector_base(struct ice_vsi *vsi);\n-\n-int ice_vsi_alloc_q_vectors(struct ice_vsi *vsi);\n-\n-int ice_vsi_get_qs(struct ice_vsi *vsi);\n-\n-void ice_vsi_map_rings_to_vectors(struct ice_vsi *vsi);\n-\n-int ice_vsi_alloc_rings(struct ice_vsi *vsi);\n-\n-void ice_vsi_set_rss_params(struct ice_vsi *vsi);\n-\n-void ice_vsi_set_num_qs(struct ice_vsi *vsi);\n-\n-int ice_get_free_slot(void *array, int size, int curr);\n-\n-int ice_vsi_init(struct ice_vsi *vsi);\n-\n-int ice_vsi_alloc_arrays(struct ice_vsi *vsi, bool alloc_qvectors);\n-\n int ice_add_mac_to_list(struct ice_vsi *vsi, struct list_head *add_list,\n \t\t\tconst u8 *macaddr);\n \n@@ -59,6 +39,10 @@ void ice_vsi_delete(struct ice_vsi *vsi);\n \n int ice_vsi_clear(struct ice_vsi *vsi);\n \n+struct ice_vsi *\n+ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,\n+\t enum ice_vsi_type type, u16 vf_id);\n+\n int ice_vsi_release(struct ice_vsi *vsi);\n \n void ice_vsi_close(struct ice_vsi *vsi);\n@@ -84,5 +68,7 @@ void ice_vsi_free_rx_rings(struct ice_vsi *vsi);\n \n void ice_vsi_free_tx_rings(struct ice_vsi *vsi);\n \n+int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc);\n+\n irqreturn_t ice_msix_clean_rings(int __always_unused irq, void *data);\n #endif /* !_ICE_LIB_H_ */\ndiff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c\nindex 2741ba729ab5..0abf0aef366d 100644\n--- a/drivers/net/ethernet/intel/ice/ice_main.c\n+++ b/drivers/net/ethernet/intel/ice/ice_main.c\n@@ -1312,70 +1312,6 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)\n \treturn ret;\n }\n \n-/**\n- * ice_vsi_alloc - Allocates the next available struct vsi in the PF\n- * @pf: board private structure\n- * @type: type of VSI\n- *\n- * returns a pointer to a VSI on success, NULL on failure.\n- */\n-static struct ice_vsi *ice_vsi_alloc(struct ice_pf *pf, enum ice_vsi_type type)\n-{\n-\tstruct ice_vsi *vsi = NULL;\n-\n-\t/* Need to protect the allocation of the VSIs at the PF level */\n-\tmutex_lock(&pf->sw_mutex);\n-\n-\t/* If we have already allocated our maximum number of VSIs,\n-\t * pf->next_vsi will be ICE_NO_VSI. If not, pf->next_vsi index\n-\t * is available to be populated\n-\t */\n-\tif (pf->next_vsi == ICE_NO_VSI) {\n-\t\tdev_dbg(&pf->pdev->dev, \"out of VSI slots!\\n\");\n-\t\tgoto unlock_pf;\n-\t}\n-\n-\tvsi = devm_kzalloc(&pf->pdev->dev, sizeof(*vsi), GFP_KERNEL);\n-\tif (!vsi)\n-\t\tgoto unlock_pf;\n-\n-\tvsi->type = type;\n-\tvsi->back = pf;\n-\tset_bit(__ICE_DOWN, vsi->state);\n-\tvsi->idx = pf->next_vsi;\n-\tvsi->work_lmt = ICE_DFLT_IRQ_WORK;\n-\n-\tice_vsi_set_num_qs(vsi);\n-\n-\tswitch (vsi->type) {\n-\tcase ICE_VSI_PF:\n-\t\tif (ice_vsi_alloc_arrays(vsi, true))\n-\t\t\tgoto err_rings;\n-\n-\t\t/* Setup default MSIX irq handler for VSI */\n-\t\tvsi->irq_handler = ice_msix_clean_rings;\n-\t\tbreak;\n-\tdefault:\n-\t\tdev_warn(&pf->pdev->dev, \"Unknown VSI type %d\\n\", vsi->type);\n-\t\tgoto unlock_pf;\n-\t}\n-\n-\t/* fill VSI slot in the PF struct */\n-\tpf->vsi[pf->next_vsi] = vsi;\n-\n-\t/* prepare pf->next_vsi for next use */\n-\tpf->next_vsi = ice_get_free_slot(pf->vsi, pf->num_alloc_vsi,\n-\t\t\t\t\t pf->next_vsi);\n-\tgoto unlock_pf;\n-\n-err_rings:\n-\tdevm_kfree(&pf->pdev->dev, vsi);\n-\tvsi = NULL;\n-unlock_pf:\n-\tmutex_unlock(&pf->sw_mutex);\n-\treturn vsi;\n-}\n-\n /**\n * ice_free_irq_msix_misc - Unroll misc vector setup\n * @pf: board private structure\n@@ -1597,194 +1533,6 @@ void ice_fill_rss_lut(u8 *lut, u16 rss_table_size, u16 rss_size)\n \t\tlut[i] = i % rss_size;\n }\n \n-/**\n- * ice_vsi_cfg_rss - Configure RSS params for a VSI\n- * @vsi: VSI to be configured\n- */\n-static int ice_vsi_cfg_rss(struct ice_vsi *vsi)\n-{\n-\tu8 seed[ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE];\n-\tstruct ice_aqc_get_set_rss_keys *key;\n-\tstruct ice_pf *pf = vsi->back;\n-\tenum ice_status status;\n-\tint err = 0;\n-\tu8 *lut;\n-\n-\tvsi->rss_size = min_t(int, vsi->rss_size, vsi->num_rxq);\n-\n-\tlut = devm_kzalloc(&pf->pdev->dev, vsi->rss_table_size, GFP_KERNEL);\n-\tif (!lut)\n-\t\treturn -ENOMEM;\n-\n-\tif (vsi->rss_lut_user)\n-\t\tmemcpy(lut, vsi->rss_lut_user, vsi->rss_table_size);\n-\telse\n-\t\tice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size);\n-\n-\tstatus = ice_aq_set_rss_lut(&pf->hw, vsi->vsi_num, vsi->rss_lut_type,\n-\t\t\t\t lut, vsi->rss_table_size);\n-\n-\tif (status) {\n-\t\tdev_err(&vsi->back->pdev->dev,\n-\t\t\t\"set_rss_lut failed, error %d\\n\", status);\n-\t\terr = -EIO;\n-\t\tgoto ice_vsi_cfg_rss_exit;\n-\t}\n-\n-\tkey = devm_kzalloc(&vsi->back->pdev->dev, sizeof(*key), GFP_KERNEL);\n-\tif (!key) {\n-\t\terr = -ENOMEM;\n-\t\tgoto ice_vsi_cfg_rss_exit;\n-\t}\n-\n-\tif (vsi->rss_hkey_user)\n-\t\tmemcpy(seed, vsi->rss_hkey_user,\n-\t\t ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE);\n-\telse\n-\t\tnetdev_rss_key_fill((void *)seed,\n-\t\t\t\t ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE);\n-\tmemcpy(&key->standard_rss_key, seed,\n-\t ICE_AQC_GET_SET_RSS_KEY_DATA_RSS_KEY_SIZE);\n-\n-\tstatus = ice_aq_set_rss_key(&pf->hw, vsi->vsi_num, key);\n-\n-\tif (status) {\n-\t\tdev_err(&vsi->back->pdev->dev, \"set_rss_key failed, error %d\\n\",\n-\t\t\tstatus);\n-\t\terr = -EIO;\n-\t}\n-\n-\tdevm_kfree(&pf->pdev->dev, key);\n-ice_vsi_cfg_rss_exit:\n-\tdevm_kfree(&pf->pdev->dev, lut);\n-\treturn err;\n-}\n-\n-/**\n- * ice_vsi_setup - Set up a VSI by a given type\n- * @pf: board private structure\n- * @pi: pointer to the port_info instance\n- * @type: VSI type\n- * @vf_id: defines VF id to which this VSI connects. This field is meant to be\n- * used only for ICE_VSI_VF VSI type. For other VSI types, should\n- * fill-in ICE_INVAL_VFID as input.\n- *\n- * This allocates the sw VSI structure and its queue resources.\n- *\n- * Returns pointer to the successfully allocated and configured VSI sw struct on\n- * success, NULL on failure.\n- */\n-static struct ice_vsi *\n-ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi,\n-\t enum ice_vsi_type type, u16 __always_unused vf_id)\n-{\n-\tu16 max_txqs[ICE_MAX_TRAFFIC_CLASS] = { 0 };\n-\tstruct device *dev = &pf->pdev->dev;\n-\tstruct ice_vsi *vsi;\n-\tint ret, i;\n-\n-\tvsi = ice_vsi_alloc(pf, type);\n-\tif (!vsi) {\n-\t\tdev_err(dev, \"could not allocate VSI\\n\");\n-\t\treturn NULL;\n-\t}\n-\n-\tvsi->port_info = pi;\n-\tvsi->vsw = pf->first_sw;\n-\n-\tif (ice_vsi_get_qs(vsi)) {\n-\t\tdev_err(dev, \"Failed to allocate queues. vsi->idx = %d\\n\",\n-\t\t\tvsi->idx);\n-\t\tgoto err_get_qs;\n-\t}\n-\n-\t/* set RSS capabilities */\n-\tice_vsi_set_rss_params(vsi);\n-\n-\t/* create the VSI */\n-\tret = ice_vsi_init(vsi);\n-\tif (ret)\n-\t\tgoto err_vsi;\n-\n-\tswitch (vsi->type) {\n-\tcase ICE_VSI_PF:\n-\t\tret = ice_cfg_netdev(vsi);\n-\t\tif (ret)\n-\t\t\tgoto err_cfg_netdev;\n-\n-\t\tret = register_netdev(vsi->netdev);\n-\t\tif (ret)\n-\t\t\tgoto err_register_netdev;\n-\n-\t\tnetif_carrier_off(vsi->netdev);\n-\n-\t\t/* make sure transmit queues start off as stopped */\n-\t\tnetif_tx_stop_all_queues(vsi->netdev);\n-\t\tret = ice_vsi_alloc_q_vectors(vsi);\n-\t\tif (ret)\n-\t\t\tgoto err_msix;\n-\n-\t\tret = ice_vsi_setup_vector_base(vsi);\n-\t\tif (ret)\n-\t\t\tgoto err_rings;\n-\n-\t\tret = ice_vsi_alloc_rings(vsi);\n-\t\tif (ret)\n-\t\t\tgoto err_rings;\n-\n-\t\tice_vsi_map_rings_to_vectors(vsi);\n-\n-\t\t/* Do not exit if configuring RSS had an issue, at least\n-\t\t * receive traffic on first queue. Hence no need to capture\n-\t\t * return value\n-\t\t */\n-\t\tif (test_bit(ICE_FLAG_RSS_ENA, pf->flags))\n-\t\t\tice_vsi_cfg_rss(vsi);\n-\t\tbreak;\n-\tdefault:\n-\t\t/* if vsi type is not recognized, clean up the resources and\n-\t\t * exit\n-\t\t */\n-\t\tgoto err_rings;\n-\t}\n-\n-\tice_vsi_set_tc_cfg(vsi);\n-\n-\t/* configure VSI nodes based on number of queues and TC's */\n-\tfor (i = 0; i < vsi->tc_cfg.numtc; i++)\n-\t\tmax_txqs[i] = vsi->num_txq;\n-\n-\tret = ice_cfg_vsi_lan(vsi->port_info, vsi->vsi_num,\n-\t\t\t vsi->tc_cfg.ena_tc, max_txqs);\n-\tif (ret) {\n-\t\tdev_info(&pf->pdev->dev, \"Failed VSI lan queue config\\n\");\n-\t\tgoto err_rings;\n-\t}\n-\n-\treturn vsi;\n-\n-err_rings:\n-\tice_vsi_free_q_vectors(vsi);\n-err_msix:\n-\tif (vsi->netdev && vsi->netdev->reg_state == NETREG_REGISTERED)\n-\t\tunregister_netdev(vsi->netdev);\n-err_register_netdev:\n-\tif (vsi->netdev) {\n-\t\tfree_netdev(vsi->netdev);\n-\t\tvsi->netdev = NULL;\n-\t}\n-err_cfg_netdev:\n-\tice_vsi_delete(vsi);\n-err_vsi:\n-\tice_vsi_put_qs(vsi);\n-err_get_qs:\n-\tpf->q_left_tx += vsi->alloc_txq;\n-\tpf->q_left_rx += vsi->alloc_rxq;\n-\tice_vsi_clear(vsi);\n-\n-\treturn NULL;\n-}\n-\n /**\n * ice_pf_vsi_setup - Set up a PF VSI\n * @pf: board private structure\n", "prefixes": [ "07/16" ] }