get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 972039,
    "url": "http://patchwork.ozlabs.org/api/patches/972039/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20180920002319.10971-2-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-2-anirudh.venkataramanan@intel.com>",
    "list_archive_url": null,
    "date": "2018-09-20T00:23:04",
    "name": "[01/16] ice: Move common functions out of ice_main.c part 1/7",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "4aa362b84b2e4cc0d0dbb12d2323954d0b45cd77",
    "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-2-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/972039/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/972039/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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\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 42FyBm1hR3z9s9J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 20 Sep 2018 10:23:44 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id CED7A87FF0;\n\tThu, 20 Sep 2018 00:23:42 +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 NxOye609uNhI; Thu, 20 Sep 2018 00:23:34 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 1061D882CE;\n\tThu, 20 Sep 2018 00:23:31 +0000 (UTC)",
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id 872F81C08AF\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Sep 2018 00:23:29 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 84B88227F5\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 20 Sep 2018 00:23:29 +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 ImZRC1T6162H 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 273CE22836\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:19 -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=\"265057690\"",
        "From": "Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Wed, 19 Sep 2018 17:23:04 -0700",
        "Message-Id": "<20180920002319.10971-2-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 01/16] ice: Move common functions out of\n\tice_main.c part 1/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": "The functions that are used for PF VSI/netdev setup will also be used\nfor SR-IOV support. To allow reuse of these functions, move these\nfunctions out of ice_main.c to ice_common.c/ice_lib.c\n\nThis move is done across multiple patches. Each patch moves a few\nfunctions and may have minor adjustments. For example, a function that was\npreviously static in ice_main.c will be made non-static temporarily in\nits new location to allow the driver to build cleanly. These adjustments\nwill be removed in subsequent patches where more code is moved out of\nice_main.c\n\nIn this particular patch, the following functions were moved out of\nice_main.c:\nint ice_add_mac_to_list\nice_free_fltr_list\nice_stat_update40\nice_stat_update32\nice_update_eth_stats\nice_vsi_add_vlan\nice_vsi_kill_vlan\nice_vsi_manage_vlan_insertion\nice_vsi_manage_vlan_stripping\n\nSigned-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>\n---\n drivers/net/ethernet/intel/ice/Makefile     |   1 +\n drivers/net/ethernet/intel/ice/ice_common.c |  61 ++++++\n drivers/net/ethernet/intel/ice/ice_common.h |   4 +\n drivers/net/ethernet/intel/ice/ice_lib.c    | 258 +++++++++++++++++++++++\n drivers/net/ethernet/intel/ice/ice_lib.h    |  23 ++\n drivers/net/ethernet/intel/ice/ice_main.c   | 316 +---------------------------\n 6 files changed, 348 insertions(+), 315 deletions(-)\n create mode 100644 drivers/net/ethernet/intel/ice/ice_lib.c\n create mode 100644 drivers/net/ethernet/intel/ice/ice_lib.h",
    "diff": "diff --git a/drivers/net/ethernet/intel/ice/Makefile b/drivers/net/ethernet/intel/ice/Makefile\nindex 4058673fd853..45125bd074d9 100644\n--- a/drivers/net/ethernet/intel/ice/Makefile\n+++ b/drivers/net/ethernet/intel/ice/Makefile\n@@ -13,5 +13,6 @@ ice-y := ice_main.o\t\\\n \t ice_nvm.o\t\\\n \t ice_switch.o\t\\\n \t ice_sched.o\t\\\n+\t ice_lib.o\t\\\n \t ice_txrx.o\t\\\n \t ice_ethtool.o\ndiff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c\nindex decfdb065a20..ef9229fa5510 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.c\n+++ b/drivers/net/ethernet/intel/ice/ice_common.c\n@@ -2652,3 +2652,64 @@ ice_cfg_vsi_lan(struct ice_port_info *pi, u16 vsi_id, u8 tc_bitmap,\n \treturn ice_cfg_vsi_qs(pi, vsi_id, tc_bitmap, max_lanqs,\n \t\t\t      ICE_SCHED_NODE_OWNER_LAN);\n }\n+\n+/**\n+ * ice_stat_update40 - read 40 bit stat from the chip and update stat values\n+ * @hw: ptr to the hardware info\n+ * @hireg: high 32 bit HW register to read from\n+ * @loreg: low 32 bit HW register to read from\n+ * @prev_stat_loaded: bool to specify if previous stats are loaded\n+ * @prev_stat: ptr to previous loaded stat value\n+ * @cur_stat: ptr to current stat value\n+ */\n+void ice_stat_update40(struct ice_hw *hw, u32 hireg, u32 loreg,\n+\t\t       bool prev_stat_loaded, u64 *prev_stat, u64 *cur_stat)\n+{\n+\tu64 new_data;\n+\n+\tnew_data = rd32(hw, loreg);\n+\tnew_data |= ((u64)(rd32(hw, hireg) & 0xFFFF)) << 32;\n+\n+\t/* device stats are not reset at PFR, they likely will not be zeroed\n+\t * when the driver starts. So save the first values read and use them as\n+\t * offsets to be subtracted from the raw values in order to report stats\n+\t * that count from zero.\n+\t */\n+\tif (!prev_stat_loaded)\n+\t\t*prev_stat = new_data;\n+\tif (new_data >= *prev_stat)\n+\t\t*cur_stat = new_data - *prev_stat;\n+\telse\n+\t\t/* to manage the potential roll-over */\n+\t\t*cur_stat = (new_data + BIT_ULL(40)) - *prev_stat;\n+\t*cur_stat &= 0xFFFFFFFFFFULL;\n+}\n+\n+/**\n+ * ice_stat_update32 - read 32 bit stat from the chip and update stat values\n+ * @hw: ptr to the hardware info\n+ * @reg: HW register to read from\n+ * @prev_stat_loaded: bool to specify if previous stats are loaded\n+ * @prev_stat: ptr to previous loaded stat value\n+ * @cur_stat: ptr to current stat value\n+ */\n+void ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,\n+\t\t       u64 *prev_stat, u64 *cur_stat)\n+{\n+\tu32 new_data;\n+\n+\tnew_data = rd32(hw, reg);\n+\n+\t/* device stats are not reset at PFR, they likely will not be zeroed\n+\t * when the driver starts. So save the first values read and use them as\n+\t * offsets to be subtracted from the raw values in order to report stats\n+\t * that count from zero.\n+\t */\n+\tif (!prev_stat_loaded)\n+\t\t*prev_stat = new_data;\n+\tif (new_data >= *prev_stat)\n+\t\t*cur_stat = new_data - *prev_stat;\n+\telse\n+\t\t/* to manage the potential roll-over */\n+\t\t*cur_stat = (new_data + BIT_ULL(32)) - *prev_stat;\n+}\ndiff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h\nindex aac2d6cadaaf..80d288a07731 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.h\n+++ b/drivers/net/ethernet/intel/ice/ice_common.h\n@@ -96,4 +96,8 @@ ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_id, u8 tc, u8 num_qgrps,\n \t\tstruct ice_aqc_add_tx_qgrp *buf, u16 buf_size,\n \t\tstruct ice_sq_cd *cd);\n void ice_output_fw_log(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf);\n+void ice_stat_update40(struct ice_hw *hw, u32 hireg, u32 loreg,\n+\t\t       bool prev_stat_loaded, u64 *prev_stat, u64 *cur_stat);\n+void ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,\n+\t\t       u64 *prev_stat, u64 *cur_stat);\n #endif /* _ICE_COMMON_H_ */\ndiff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c\nnew file mode 100644\nindex 000000000000..d938dad7bb5f\n--- /dev/null\n+++ b/drivers/net/ethernet/intel/ice/ice_lib.c\n@@ -0,0 +1,258 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/* Copyright (c) 2018, Intel Corporation. */\n+\n+#include \"ice.h\"\n+#include \"ice_lib.h\"\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+ * @add_list: pointer to the list which contains MAC filter entries\n+ * @macaddr: the MAC address to be added.\n+ *\n+ * Adds mac address filter entry to the temp list\n+ *\n+ * Returns 0 on success or ENOMEM on failure.\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+\tstruct ice_fltr_list_entry *tmp;\n+\tstruct ice_pf *pf = vsi->back;\n+\n+\ttmp = devm_kzalloc(&pf->pdev->dev, sizeof(*tmp), GFP_ATOMIC);\n+\tif (!tmp)\n+\t\treturn -ENOMEM;\n+\n+\ttmp->fltr_info.flag = ICE_FLTR_TX;\n+\ttmp->fltr_info.src = vsi->vsi_num;\n+\ttmp->fltr_info.lkup_type = ICE_SW_LKUP_MAC;\n+\ttmp->fltr_info.fltr_act = ICE_FWD_TO_VSI;\n+\ttmp->fltr_info.fwd_id.vsi_id = vsi->vsi_num;\n+\tether_addr_copy(tmp->fltr_info.l_data.mac.mac_addr, macaddr);\n+\n+\tINIT_LIST_HEAD(&tmp->list_entry);\n+\tlist_add(&tmp->list_entry, add_list);\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * ice_update_eth_stats - Update VSI-specific ethernet statistics counters\n+ * @vsi: the VSI to be updated\n+ */\n+void ice_update_eth_stats(struct ice_vsi *vsi)\n+{\n+\tstruct ice_eth_stats *prev_es, *cur_es;\n+\tstruct ice_hw *hw = &vsi->back->hw;\n+\tu16 vsi_num = vsi->vsi_num;    /* HW absolute index of a VSI */\n+\n+\tprev_es = &vsi->eth_stats_prev;\n+\tcur_es = &vsi->eth_stats;\n+\n+\tice_stat_update40(hw, GLV_GORCH(vsi_num), GLV_GORCL(vsi_num),\n+\t\t\t  vsi->stat_offsets_loaded, &prev_es->rx_bytes,\n+\t\t\t  &cur_es->rx_bytes);\n+\n+\tice_stat_update40(hw, GLV_UPRCH(vsi_num), GLV_UPRCL(vsi_num),\n+\t\t\t  vsi->stat_offsets_loaded, &prev_es->rx_unicast,\n+\t\t\t  &cur_es->rx_unicast);\n+\n+\tice_stat_update40(hw, GLV_MPRCH(vsi_num), GLV_MPRCL(vsi_num),\n+\t\t\t  vsi->stat_offsets_loaded, &prev_es->rx_multicast,\n+\t\t\t  &cur_es->rx_multicast);\n+\n+\tice_stat_update40(hw, GLV_BPRCH(vsi_num), GLV_BPRCL(vsi_num),\n+\t\t\t  vsi->stat_offsets_loaded, &prev_es->rx_broadcast,\n+\t\t\t  &cur_es->rx_broadcast);\n+\n+\tice_stat_update32(hw, GLV_RDPC(vsi_num), vsi->stat_offsets_loaded,\n+\t\t\t  &prev_es->rx_discards, &cur_es->rx_discards);\n+\n+\tice_stat_update40(hw, GLV_GOTCH(vsi_num), GLV_GOTCL(vsi_num),\n+\t\t\t  vsi->stat_offsets_loaded, &prev_es->tx_bytes,\n+\t\t\t  &cur_es->tx_bytes);\n+\n+\tice_stat_update40(hw, GLV_UPTCH(vsi_num), GLV_UPTCL(vsi_num),\n+\t\t\t  vsi->stat_offsets_loaded, &prev_es->tx_unicast,\n+\t\t\t  &cur_es->tx_unicast);\n+\n+\tice_stat_update40(hw, GLV_MPTCH(vsi_num), GLV_MPTCL(vsi_num),\n+\t\t\t  vsi->stat_offsets_loaded, &prev_es->tx_multicast,\n+\t\t\t  &cur_es->tx_multicast);\n+\n+\tice_stat_update40(hw, GLV_BPTCH(vsi_num), GLV_BPTCL(vsi_num),\n+\t\t\t  vsi->stat_offsets_loaded, &prev_es->tx_broadcast,\n+\t\t\t  &cur_es->tx_broadcast);\n+\n+\tice_stat_update32(hw, GLV_TEPC(vsi_num), vsi->stat_offsets_loaded,\n+\t\t\t  &prev_es->tx_errors, &cur_es->tx_errors);\n+\n+\tvsi->stat_offsets_loaded = true;\n+}\n+\n+/**\n+ * ice_free_fltr_list - free filter lists helper\n+ * @dev: pointer to the device struct\n+ * @h: pointer to the list head to be freed\n+ *\n+ * Helper function to free filter lists previously created using\n+ * ice_add_mac_to_list\n+ */\n+void ice_free_fltr_list(struct device *dev, struct list_head *h)\n+{\n+\tstruct ice_fltr_list_entry *e, *tmp;\n+\n+\tlist_for_each_entry_safe(e, tmp, h, list_entry) {\n+\t\tlist_del(&e->list_entry);\n+\t\tdevm_kfree(dev, e);\n+\t}\n+}\n+\n+/**\n+ * ice_vsi_add_vlan - Add vsi membership for given vlan\n+ * @vsi: the vsi being configured\n+ * @vid: vlan id to be added\n+ */\n+int ice_vsi_add_vlan(struct ice_vsi *vsi, u16 vid)\n+{\n+\tstruct ice_fltr_list_entry *tmp;\n+\tstruct ice_pf *pf = vsi->back;\n+\tLIST_HEAD(tmp_add_list);\n+\tenum ice_status status;\n+\tint err = 0;\n+\n+\ttmp = devm_kzalloc(&pf->pdev->dev, sizeof(*tmp), GFP_KERNEL);\n+\tif (!tmp)\n+\t\treturn -ENOMEM;\n+\n+\ttmp->fltr_info.lkup_type = ICE_SW_LKUP_VLAN;\n+\ttmp->fltr_info.fltr_act = ICE_FWD_TO_VSI;\n+\ttmp->fltr_info.flag = ICE_FLTR_TX;\n+\ttmp->fltr_info.src = vsi->vsi_num;\n+\ttmp->fltr_info.fwd_id.vsi_id = vsi->vsi_num;\n+\ttmp->fltr_info.l_data.vlan.vlan_id = vid;\n+\n+\tINIT_LIST_HEAD(&tmp->list_entry);\n+\tlist_add(&tmp->list_entry, &tmp_add_list);\n+\n+\tstatus = ice_add_vlan(&pf->hw, &tmp_add_list);\n+\tif (status) {\n+\t\terr = -ENODEV;\n+\t\tdev_err(&pf->pdev->dev, \"Failure Adding VLAN %d on VSI %i\\n\",\n+\t\t\tvid, vsi->vsi_num);\n+\t}\n+\n+\tice_free_fltr_list(&pf->pdev->dev, &tmp_add_list);\n+\treturn err;\n+}\n+\n+/**\n+ * ice_vsi_kill_vlan - Remove VSI membership for a given VLAN\n+ * @vsi: the VSI being configured\n+ * @vid: VLAN id to be removed\n+ *\n+ * Returns 0 on success and negative on failure\n+ */\n+int ice_vsi_kill_vlan(struct ice_vsi *vsi, u16 vid)\n+{\n+\tstruct ice_fltr_list_entry *list;\n+\tstruct ice_pf *pf = vsi->back;\n+\tLIST_HEAD(tmp_add_list);\n+\tint status = 0;\n+\n+\tlist = devm_kzalloc(&pf->pdev->dev, sizeof(*list), GFP_KERNEL);\n+\tif (!list)\n+\t\treturn -ENOMEM;\n+\n+\tlist->fltr_info.lkup_type = ICE_SW_LKUP_VLAN;\n+\tlist->fltr_info.fwd_id.vsi_id = vsi->vsi_num;\n+\tlist->fltr_info.fltr_act = ICE_FWD_TO_VSI;\n+\tlist->fltr_info.l_data.vlan.vlan_id = vid;\n+\tlist->fltr_info.flag = ICE_FLTR_TX;\n+\tlist->fltr_info.src = vsi->vsi_num;\n+\n+\tINIT_LIST_HEAD(&list->list_entry);\n+\tlist_add(&list->list_entry, &tmp_add_list);\n+\n+\tif (ice_remove_vlan(&pf->hw, &tmp_add_list)) {\n+\t\tdev_err(&pf->pdev->dev, \"Error removing VLAN %d on vsi %i\\n\",\n+\t\t\tvid, vsi->vsi_num);\n+\t\tstatus = -EIO;\n+\t}\n+\n+\tice_free_fltr_list(&pf->pdev->dev, &tmp_add_list);\n+\treturn status;\n+}\n+\n+/**\n+ * ice_vsi_manage_vlan_insertion - Manage VLAN insertion for the VSI for Tx\n+ * @vsi: the vsi being changed\n+ */\n+int ice_vsi_manage_vlan_insertion(struct ice_vsi *vsi)\n+{\n+\tstruct device *dev = &vsi->back->pdev->dev;\n+\tstruct ice_hw *hw = &vsi->back->hw;\n+\tstruct ice_vsi_ctx ctxt = { 0 };\n+\tenum ice_status status;\n+\n+\t/* Here we are configuring the VSI to let the driver add VLAN tags by\n+\t * setting vlan_flags to ICE_AQ_VSI_VLAN_MODE_ALL. The actual VLAN tag\n+\t * insertion happens in the Tx hot path, in ice_tx_map.\n+\t */\n+\tctxt.info.vlan_flags = ICE_AQ_VSI_VLAN_MODE_ALL;\n+\n+\tctxt.info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_VLAN_VALID);\n+\tctxt.vsi_num = vsi->vsi_num;\n+\n+\tstatus = ice_aq_update_vsi(hw, &ctxt, NULL);\n+\tif (status) {\n+\t\tdev_err(dev, \"update VSI for VLAN insert failed, err %d aq_err %d\\n\",\n+\t\t\tstatus, hw->adminq.sq_last_status);\n+\t\treturn -EIO;\n+\t}\n+\n+\tvsi->info.vlan_flags = ctxt.info.vlan_flags;\n+\treturn 0;\n+}\n+\n+/**\n+ * ice_vsi_manage_vlan_stripping - Manage VLAN stripping for the VSI for Rx\n+ * @vsi: the vsi being changed\n+ * @ena: boolean value indicating if this is a enable or disable request\n+ */\n+int ice_vsi_manage_vlan_stripping(struct ice_vsi *vsi, bool ena)\n+{\n+\tstruct device *dev = &vsi->back->pdev->dev;\n+\tstruct ice_hw *hw = &vsi->back->hw;\n+\tstruct ice_vsi_ctx ctxt = { 0 };\n+\tenum ice_status status;\n+\n+\t/* Here we are configuring what the VSI should do with the VLAN tag in\n+\t * the Rx packet. We can either leave the tag in the packet or put it in\n+\t * the Rx descriptor.\n+\t */\n+\tif (ena) {\n+\t\t/* Strip VLAN tag from Rx packet and put it in the desc */\n+\t\tctxt.info.vlan_flags = ICE_AQ_VSI_VLAN_EMOD_STR_BOTH;\n+\t} else {\n+\t\t/* Disable stripping. Leave tag in packet */\n+\t\tctxt.info.vlan_flags = ICE_AQ_VSI_VLAN_EMOD_NOTHING;\n+\t}\n+\n+\t/* Allow all packets untagged/tagged */\n+\tctxt.info.vlan_flags |= ICE_AQ_VSI_VLAN_MODE_ALL;\n+\n+\tctxt.info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_VLAN_VALID);\n+\tctxt.vsi_num = vsi->vsi_num;\n+\n+\tstatus = ice_aq_update_vsi(hw, &ctxt, NULL);\n+\tif (status) {\n+\t\tdev_err(dev, \"update VSI for VLAN strip failed, ena = %d err %d aq_err %d\\n\",\n+\t\t\tena, status, hw->adminq.sq_last_status);\n+\t\treturn -EIO;\n+\t}\n+\n+\tvsi->info.vlan_flags = ctxt.info.vlan_flags;\n+\treturn 0;\n+}\ndiff --git a/drivers/net/ethernet/intel/ice/ice_lib.h b/drivers/net/ethernet/intel/ice/ice_lib.h\nnew file mode 100644\nindex 000000000000..c10874d26eee\n--- /dev/null\n+++ b/drivers/net/ethernet/intel/ice/ice_lib.h\n@@ -0,0 +1,23 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+/* Copyright (c) 2018, Intel Corporation. */\n+\n+#ifndef _ICE_LIB_H_\n+#define _ICE_LIB_H_\n+\n+#include \"ice.h\"\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+void ice_free_fltr_list(struct device *dev, struct list_head *h);\n+\n+void ice_update_eth_stats(struct ice_vsi *vsi);\n+\n+int ice_vsi_add_vlan(struct ice_vsi *vsi, u16 vid);\n+\n+int ice_vsi_kill_vlan(struct ice_vsi *vsi, u16 vid);\n+\n+int ice_vsi_manage_vlan_insertion(struct ice_vsi *vsi);\n+\n+int ice_vsi_manage_vlan_stripping(struct ice_vsi *vsi, bool ena);\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 c0599d0b5c0a..a7c26b0f8f49 100644\n--- a/drivers/net/ethernet/intel/ice/ice_main.c\n+++ b/drivers/net/ethernet/intel/ice/ice_main.c\n@@ -6,6 +6,7 @@\n #define pr_fmt(fmt) KBUILD_MODNAME \": \" fmt\n \n #include \"ice.h\"\n+#include \"ice_lib.h\"\n \n #define DRV_VERSION\t\"0.7.1-k\"\n #define DRV_SUMMARY\t\"Intel(R) Ethernet Connection E800 Series Linux Driver\"\n@@ -243,39 +244,6 @@ static int ice_free_res(struct ice_res_tracker *res, u16 index, u16 id)\n \treturn count;\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- * @add_list: pointer to the list which contains MAC filter entries\n- * @macaddr: the MAC address to be added.\n- *\n- * Adds mac address filter entry to the temp list\n- *\n- * Returns 0 on success or ENOMEM on failure.\n- */\n-static int ice_add_mac_to_list(struct ice_vsi *vsi, struct list_head *add_list,\n-\t\t\t       const u8 *macaddr)\n-{\n-\tstruct ice_fltr_list_entry *tmp;\n-\tstruct ice_pf *pf = vsi->back;\n-\n-\ttmp = devm_kzalloc(&pf->pdev->dev, sizeof(*tmp), GFP_ATOMIC);\n-\tif (!tmp)\n-\t\treturn -ENOMEM;\n-\n-\ttmp->fltr_info.flag = ICE_FLTR_TX;\n-\ttmp->fltr_info.src = vsi->vsi_num;\n-\ttmp->fltr_info.lkup_type = ICE_SW_LKUP_MAC;\n-\ttmp->fltr_info.fltr_act = ICE_FWD_TO_VSI;\n-\ttmp->fltr_info.fwd_id.vsi_id = vsi->vsi_num;\n-\tether_addr_copy(tmp->fltr_info.l_data.mac.mac_addr, macaddr);\n-\n-\tINIT_LIST_HEAD(&tmp->list_entry);\n-\tlist_add(&tmp->list_entry, add_list);\n-\n-\treturn 0;\n-}\n-\n /**\n  * ice_add_mac_to_sync_list - creates list of mac addresses to be synced\n  * @netdev: the net device on which the sync is happening\n@@ -318,24 +286,6 @@ static int ice_add_mac_to_unsync_list(struct net_device *netdev, const u8 *addr)\n \treturn 0;\n }\n \n-/**\n- * ice_free_fltr_list - free filter lists helper\n- * @dev: pointer to the device struct\n- * @h: pointer to the list head to be freed\n- *\n- * Helper function to free filter lists previously created using\n- * ice_add_mac_to_list\n- */\n-static void ice_free_fltr_list(struct device *dev, struct list_head *h)\n-{\n-\tstruct ice_fltr_list_entry *e, *tmp;\n-\n-\tlist_for_each_entry_safe(e, tmp, h, list_entry) {\n-\t\tlist_del(&e->list_entry);\n-\t\tdevm_kfree(dev, e);\n-\t}\n-}\n-\n /**\n  * ice_vsi_fltr_changed - check if filter state changed\n  * @vsi: VSI to be checked\n@@ -3148,44 +3098,6 @@ ice_pf_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi)\n \treturn ice_vsi_setup(pf, pi, ICE_VSI_PF, ICE_INVAL_VFID);\n }\n \n-/**\n- * ice_vsi_add_vlan - Add vsi membership for given vlan\n- * @vsi: the vsi being configured\n- * @vid: vlan id to be added\n- */\n-static int ice_vsi_add_vlan(struct ice_vsi *vsi, u16 vid)\n-{\n-\tstruct ice_fltr_list_entry *tmp;\n-\tstruct ice_pf *pf = vsi->back;\n-\tLIST_HEAD(tmp_add_list);\n-\tenum ice_status status;\n-\tint err = 0;\n-\n-\ttmp = devm_kzalloc(&pf->pdev->dev, sizeof(*tmp), GFP_KERNEL);\n-\tif (!tmp)\n-\t\treturn -ENOMEM;\n-\n-\ttmp->fltr_info.lkup_type = ICE_SW_LKUP_VLAN;\n-\ttmp->fltr_info.fltr_act = ICE_FWD_TO_VSI;\n-\ttmp->fltr_info.flag = ICE_FLTR_TX;\n-\ttmp->fltr_info.src = vsi->vsi_num;\n-\ttmp->fltr_info.fwd_id.vsi_id = vsi->vsi_num;\n-\ttmp->fltr_info.l_data.vlan.vlan_id = vid;\n-\n-\tINIT_LIST_HEAD(&tmp->list_entry);\n-\tlist_add(&tmp->list_entry, &tmp_add_list);\n-\n-\tstatus = ice_add_vlan(&pf->hw, &tmp_add_list);\n-\tif (status) {\n-\t\terr = -ENODEV;\n-\t\tdev_err(&pf->pdev->dev, \"Failure Adding VLAN %d on VSI %i\\n\",\n-\t\t\tvid, vsi->vsi_num);\n-\t}\n-\n-\tice_free_fltr_list(&pf->pdev->dev, &tmp_add_list);\n-\treturn err;\n-}\n-\n /**\n  * ice_vlan_rx_add_vid - Add a vlan id filter to HW offload\n  * @netdev: network interface to be adjusted\n@@ -3229,44 +3141,6 @@ static int ice_vlan_rx_add_vid(struct net_device *netdev,\n \treturn ret;\n }\n \n-/**\n- * ice_vsi_kill_vlan - Remove VSI membership for a given VLAN\n- * @vsi: the VSI being configured\n- * @vid: VLAN id to be removed\n- *\n- * Returns 0 on success and negative on failure\n- */\n-static int ice_vsi_kill_vlan(struct ice_vsi *vsi, u16 vid)\n-{\n-\tstruct ice_fltr_list_entry *list;\n-\tstruct ice_pf *pf = vsi->back;\n-\tLIST_HEAD(tmp_add_list);\n-\tint status = 0;\n-\n-\tlist = devm_kzalloc(&pf->pdev->dev, sizeof(*list), GFP_KERNEL);\n-\tif (!list)\n-\t\treturn -ENOMEM;\n-\n-\tlist->fltr_info.lkup_type = ICE_SW_LKUP_VLAN;\n-\tlist->fltr_info.fwd_id.vsi_id = vsi->vsi_num;\n-\tlist->fltr_info.fltr_act = ICE_FWD_TO_VSI;\n-\tlist->fltr_info.l_data.vlan.vlan_id = vid;\n-\tlist->fltr_info.flag = ICE_FLTR_TX;\n-\tlist->fltr_info.src = vsi->vsi_num;\n-\n-\tINIT_LIST_HEAD(&list->list_entry);\n-\tlist_add(&list->list_entry, &tmp_add_list);\n-\n-\tif (ice_remove_vlan(&pf->hw, &tmp_add_list)) {\n-\t\tdev_err(&pf->pdev->dev, \"Error removing VLAN %d on vsi %i\\n\",\n-\t\t\tvid, vsi->vsi_num);\n-\t\tstatus = -EIO;\n-\t}\n-\n-\tice_free_fltr_list(&pf->pdev->dev, &tmp_add_list);\n-\treturn status;\n-}\n-\n /**\n  * ice_vlan_rx_kill_vid - Remove a vlan id filter from HW offload\n  * @netdev: network interface to be adjusted\n@@ -4023,78 +3897,6 @@ static int ice_fdb_del(struct ndmsg *ndm, __always_unused struct nlattr *tb[],\n \treturn err;\n }\n \n-/**\n- * ice_vsi_manage_vlan_insertion - Manage VLAN insertion for the VSI for Tx\n- * @vsi: the vsi being changed\n- */\n-static int ice_vsi_manage_vlan_insertion(struct ice_vsi *vsi)\n-{\n-\tstruct device *dev = &vsi->back->pdev->dev;\n-\tstruct ice_hw *hw = &vsi->back->hw;\n-\tstruct ice_vsi_ctx ctxt = { 0 };\n-\tenum ice_status status;\n-\n-\t/* Here we are configuring the VSI to let the driver add VLAN tags by\n-\t * setting vlan_flags to ICE_AQ_VSI_VLAN_MODE_ALL. The actual VLAN tag\n-\t * insertion happens in the Tx hot path, in ice_tx_map.\n-\t */\n-\tctxt.info.vlan_flags = ICE_AQ_VSI_VLAN_MODE_ALL;\n-\n-\tctxt.info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_VLAN_VALID);\n-\tctxt.vsi_num = vsi->vsi_num;\n-\n-\tstatus = ice_aq_update_vsi(hw, &ctxt, NULL);\n-\tif (status) {\n-\t\tdev_err(dev, \"update VSI for VLAN insert failed, err %d aq_err %d\\n\",\n-\t\t\tstatus, hw->adminq.sq_last_status);\n-\t\treturn -EIO;\n-\t}\n-\n-\tvsi->info.vlan_flags = ctxt.info.vlan_flags;\n-\treturn 0;\n-}\n-\n-/**\n- * ice_vsi_manage_vlan_stripping - Manage VLAN stripping for the VSI for Rx\n- * @vsi: the vsi being changed\n- * @ena: boolean value indicating if this is a enable or disable request\n- */\n-static int ice_vsi_manage_vlan_stripping(struct ice_vsi *vsi, bool ena)\n-{\n-\tstruct device *dev = &vsi->back->pdev->dev;\n-\tstruct ice_hw *hw = &vsi->back->hw;\n-\tstruct ice_vsi_ctx ctxt = { 0 };\n-\tenum ice_status status;\n-\n-\t/* Here we are configuring what the VSI should do with the VLAN tag in\n-\t * the Rx packet. We can either leave the tag in the packet or put it in\n-\t * the Rx descriptor.\n-\t */\n-\tif (ena) {\n-\t\t/* Strip VLAN tag from Rx packet and put it in the desc */\n-\t\tctxt.info.vlan_flags = ICE_AQ_VSI_VLAN_EMOD_STR_BOTH;\n-\t} else {\n-\t\t/* Disable stripping. Leave tag in packet */\n-\t\tctxt.info.vlan_flags = ICE_AQ_VSI_VLAN_EMOD_NOTHING;\n-\t}\n-\n-\t/* Allow all packets untagged/tagged */\n-\tctxt.info.vlan_flags |= ICE_AQ_VSI_VLAN_MODE_ALL;\n-\n-\tctxt.info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_VLAN_VALID);\n-\tctxt.vsi_num = vsi->vsi_num;\n-\n-\tstatus = ice_aq_update_vsi(hw, &ctxt, NULL);\n-\tif (status) {\n-\t\tdev_err(dev, \"update VSI for VALN strip failed, ena = %d err %d aq_err %d\\n\",\n-\t\t\tena, status, hw->adminq.sq_last_status);\n-\t\treturn -EIO;\n-\t}\n-\n-\tvsi->info.vlan_flags = ctxt.info.vlan_flags;\n-\treturn 0;\n-}\n-\n /**\n  * ice_set_features - set the netdev feature flags\n  * @netdev: ptr to the netdev being adjusted\n@@ -4727,122 +4529,6 @@ static void ice_fetch_u64_stats_per_ring(struct ice_ring *ring, u64 *pkts,\n \t} while (u64_stats_fetch_retry_irq(&ring->syncp, start));\n }\n \n-/**\n- * ice_stat_update40 - read 40 bit stat from the chip and update stat values\n- * @hw: ptr to the hardware info\n- * @hireg: high 32 bit HW register to read from\n- * @loreg: low 32 bit HW register to read from\n- * @prev_stat_loaded: bool to specify if previous stats are loaded\n- * @prev_stat: ptr to previous loaded stat value\n- * @cur_stat: ptr to current stat value\n- */\n-static void ice_stat_update40(struct ice_hw *hw, u32 hireg, u32 loreg,\n-\t\t\t      bool prev_stat_loaded, u64 *prev_stat,\n-\t\t\t      u64 *cur_stat)\n-{\n-\tu64 new_data;\n-\n-\tnew_data = rd32(hw, loreg);\n-\tnew_data |= ((u64)(rd32(hw, hireg) & 0xFFFF)) << 32;\n-\n-\t/* device stats are not reset at PFR, they likely will not be zeroed\n-\t * when the driver starts. So save the first values read and use them as\n-\t * offsets to be subtracted from the raw values in order to report stats\n-\t * that count from zero.\n-\t */\n-\tif (!prev_stat_loaded)\n-\t\t*prev_stat = new_data;\n-\tif (likely(new_data >= *prev_stat))\n-\t\t*cur_stat = new_data - *prev_stat;\n-\telse\n-\t\t/* to manage the potential roll-over */\n-\t\t*cur_stat = (new_data + BIT_ULL(40)) - *prev_stat;\n-\t*cur_stat &= 0xFFFFFFFFFFULL;\n-}\n-\n-/**\n- * ice_stat_update32 - read 32 bit stat from the chip and update stat values\n- * @hw: ptr to the hardware info\n- * @reg: HW register to read from\n- * @prev_stat_loaded: bool to specify if previous stats are loaded\n- * @prev_stat: ptr to previous loaded stat value\n- * @cur_stat: ptr to current stat value\n- */\n-static void ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,\n-\t\t\t      u64 *prev_stat, u64 *cur_stat)\n-{\n-\tu32 new_data;\n-\n-\tnew_data = rd32(hw, reg);\n-\n-\t/* device stats are not reset at PFR, they likely will not be zeroed\n-\t * when the driver starts. So save the first values read and use them as\n-\t * offsets to be subtracted from the raw values in order to report stats\n-\t * that count from zero.\n-\t */\n-\tif (!prev_stat_loaded)\n-\t\t*prev_stat = new_data;\n-\tif (likely(new_data >= *prev_stat))\n-\t\t*cur_stat = new_data - *prev_stat;\n-\telse\n-\t\t/* to manage the potential roll-over */\n-\t\t*cur_stat = (new_data + BIT_ULL(32)) - *prev_stat;\n-}\n-\n-/**\n- * ice_update_eth_stats - Update VSI-specific ethernet statistics counters\n- * @vsi: the VSI to be updated\n- */\n-static void ice_update_eth_stats(struct ice_vsi *vsi)\n-{\n-\tstruct ice_eth_stats *prev_es, *cur_es;\n-\tstruct ice_hw *hw = &vsi->back->hw;\n-\tu16 vsi_num = vsi->vsi_num;    /* HW absolute index of a VSI */\n-\n-\tprev_es = &vsi->eth_stats_prev;\n-\tcur_es = &vsi->eth_stats;\n-\n-\tice_stat_update40(hw, GLV_GORCH(vsi_num), GLV_GORCL(vsi_num),\n-\t\t\t  vsi->stat_offsets_loaded, &prev_es->rx_bytes,\n-\t\t\t  &cur_es->rx_bytes);\n-\n-\tice_stat_update40(hw, GLV_UPRCH(vsi_num), GLV_UPRCL(vsi_num),\n-\t\t\t  vsi->stat_offsets_loaded, &prev_es->rx_unicast,\n-\t\t\t  &cur_es->rx_unicast);\n-\n-\tice_stat_update40(hw, GLV_MPRCH(vsi_num), GLV_MPRCL(vsi_num),\n-\t\t\t  vsi->stat_offsets_loaded, &prev_es->rx_multicast,\n-\t\t\t  &cur_es->rx_multicast);\n-\n-\tice_stat_update40(hw, GLV_BPRCH(vsi_num), GLV_BPRCL(vsi_num),\n-\t\t\t  vsi->stat_offsets_loaded, &prev_es->rx_broadcast,\n-\t\t\t  &cur_es->rx_broadcast);\n-\n-\tice_stat_update32(hw, GLV_RDPC(vsi_num), vsi->stat_offsets_loaded,\n-\t\t\t  &prev_es->rx_discards, &cur_es->rx_discards);\n-\n-\tice_stat_update40(hw, GLV_GOTCH(vsi_num), GLV_GOTCL(vsi_num),\n-\t\t\t  vsi->stat_offsets_loaded, &prev_es->tx_bytes,\n-\t\t\t  &cur_es->tx_bytes);\n-\n-\tice_stat_update40(hw, GLV_UPTCH(vsi_num), GLV_UPTCL(vsi_num),\n-\t\t\t  vsi->stat_offsets_loaded, &prev_es->tx_unicast,\n-\t\t\t  &cur_es->tx_unicast);\n-\n-\tice_stat_update40(hw, GLV_MPTCH(vsi_num), GLV_MPTCL(vsi_num),\n-\t\t\t  vsi->stat_offsets_loaded, &prev_es->tx_multicast,\n-\t\t\t  &cur_es->tx_multicast);\n-\n-\tice_stat_update40(hw, GLV_BPTCH(vsi_num), GLV_BPTCL(vsi_num),\n-\t\t\t  vsi->stat_offsets_loaded, &prev_es->tx_broadcast,\n-\t\t\t  &cur_es->tx_broadcast);\n-\n-\tice_stat_update32(hw, GLV_TEPC(vsi_num), vsi->stat_offsets_loaded,\n-\t\t\t  &prev_es->tx_errors, &cur_es->tx_errors);\n-\n-\tvsi->stat_offsets_loaded = true;\n-}\n-\n /**\n  * ice_update_vsi_ring_stats - Update VSI stats counters\n  * @vsi: the VSI to be updated\n",
    "prefixes": [
        "01/16"
    ]
}