get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 736079,
    "url": "http://patchwork.ozlabs.org/api/patches/736079/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1488874826-5978-2-git-send-email-yury.kylulin@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": "<1488874826-5978-2-git-send-email-yury.kylulin@intel.com>",
    "list_archive_url": null,
    "date": "2017-03-07T08:20:25",
    "name": "[1/2] igb: improve MAC filter handling",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "cc2ec35f8dc2535059c91ed118b36ec117c78449",
    "submitter": {
        "id": 66563,
        "url": "http://patchwork.ozlabs.org/api/people/66563/?format=api",
        "name": "Yury Kylulin",
        "email": "yury.kylulin@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/1488874826-5978-2-git-send-email-yury.kylulin@intel.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/736079/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/736079/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@lists.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"
        ],
        "Received": [
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3vcqNk6ylnz9sN1\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue,  7 Mar 2017 19:20:54 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 4F1CF31279;\n\tTue,  7 Mar 2017 08:20:53 +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 G3kF1StGCG2L; Tue,  7 Mar 2017 08:20:50 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id AEA753127B;\n\tTue,  7 Mar 2017 08:20:50 +0000 (UTC)",
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id 5548D1C2B48\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue,  7 Mar 2017 08:20:49 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 50238C1BCE\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue,  7 Mar 2017 08:20:49 +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 WdaNESmseXGk for <intel-wired-lan@lists.osuosl.org>;\n\tTue,  7 Mar 2017 08:20:47 +0000 (UTC)",
            "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id B2626C1BC4\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue,  7 Mar 2017 08:20:47 +0000 (UTC)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby fmsmga105.fm.intel.com with ESMTP; 07 Mar 2017 00:20:46 -0800",
            "from devnode2.inn.intel.com ([10.125.24.131])\n\tby orsmga001.jf.intel.com with ESMTP; 07 Mar 2017 00:20:44 -0800"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos; i=\"5.35,257,1484035200\"; d=\"scan'208\";\n\ta=\"1105667084\"",
        "From": "Yury Kylulin <yury.kylulin@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Tue,  7 Mar 2017 11:20:25 +0300",
        "Message-Id": "<1488874826-5978-2-git-send-email-yury.kylulin@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1488874826-5978-1-git-send-email-yury.kylulin@intel.com>",
        "References": "<1488874826-5978-1-git-send-email-yury.kylulin@intel.com>",
        "Subject": "[Intel-wired-lan] [PATCH 1/2] igb: improve MAC filter handling",
        "X-BeenThere": "intel-wired-lan@lists.osuosl.org",
        "X-Mailman-Version": "2.1.18-1",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.lists.osuosl.org>",
        "List-Unsubscribe": "<http://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@lists.osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@lists.osuosl.org?subject=help>",
        "List-Subscribe": "<http://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.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@lists.osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@lists.osuosl.org>"
    },
    "content": "Using the work which was done for ixgbe driver by Jacob Keller\ncommit 5d7daa35b9eb (\"ixgbe: improve mac filter handling\") and Alexander\nDuyck commit 0f079d22834a (\"ixgbe: Use __dev_uc_sync and __dev_uc_unsync\nfor unicast addresses\") and out-of-tree igb driver add functionality to\nmanage (add and delete) MAC filters.\n\nSigned-off-by: Yury Kylulin <yury.kylulin@intel.com>\n---\n drivers/net/ethernet/intel/igb/igb.h      |  11 ++\n drivers/net/ethernet/intel/igb/igb_main.c | 246 ++++++++++++++++++++++--------\n 2 files changed, 192 insertions(+), 65 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h\nindex dc6e298..97f348a 100644\n--- a/drivers/net/ethernet/intel/igb/igb.h\n+++ b/drivers/net/ethernet/intel/igb/igb.h\n@@ -449,6 +449,15 @@ struct igb_nfc_filter {\n \tu16 action;\n };\n \n+struct igb_mac_addr {\n+\tu8 addr[ETH_ALEN];\n+\tu8 queue;\n+\tu8 state; /* bitmask */\n+};\n+\n+#define IGB_MAC_STATE_DEFAULT\t0x1\n+#define IGB_MAC_STATE_IN_USE\t0x2\n+\n /* board specific private data structure */\n struct igb_adapter {\n \tunsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];\n@@ -575,6 +584,8 @@ struct igb_adapter {\n \t/* lock for RX network flow classification filter */\n \tspinlock_t nfc_lock;\n \tbool etype_bitmap[MAX_ETYPE_FILTER];\n+\n+\tstruct igb_mac_addr *mac_table;\n };\n \n /* flags controlling PTP/1588 function */\ndiff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c\nindex 26a821f..bb5d5ac 100644\n--- a/drivers/net/ethernet/intel/igb/igb_main.c\n+++ b/drivers/net/ethernet/intel/igb/igb_main.c\n@@ -161,11 +161,16 @@ static void igb_vlan_mode(struct net_device *netdev,\n static int igb_vlan_rx_add_vid(struct net_device *, __be16, u16);\n static int igb_vlan_rx_kill_vid(struct net_device *, __be16, u16);\n static void igb_restore_vlan(struct igb_adapter *);\n-static void igb_rar_set_qsel(struct igb_adapter *, u8 *, u32 , u8);\n+static void igb_rar_set_index(struct igb_adapter *, u32);\n static void igb_ping_all_vfs(struct igb_adapter *);\n static void igb_msg_task(struct igb_adapter *);\n static void igb_vmm_control(struct igb_adapter *);\n static int igb_set_vf_mac(struct igb_adapter *, int, unsigned char *);\n+static void igb_flush_mac_table(struct igb_adapter *);\n+static int igb_available_rars(struct igb_adapter *, u8);\n+static void igb_set_default_mac_filter(struct igb_adapter *);\n+static int igb_uc_sync(struct net_device *, const unsigned char *);\n+static int igb_uc_unsync(struct net_device *, const unsigned char *);\n static void igb_restore_vf_multicasts(struct igb_adapter *adapter);\n static int igb_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac);\n static int igb_ndo_set_vf_vlan(struct net_device *netdev,\n@@ -1987,6 +1992,13 @@ void igb_reset(struct igb_adapter *adapter)\n \tif (hw->mac.ops.init_hw(hw))\n \t\tdev_err(&pdev->dev, \"Hardware Error\\n\");\n \n+\t/* RAR registers were cleared during init_hw, clear mac table */\n+\tigb_flush_mac_table(adapter);\n+\t__dev_uc_unsync(adapter->netdev, NULL);\n+\n+\t/* Recover default RAR entry */\n+\tigb_set_default_mac_filter(adapter);\n+\n \t/* Flow control settings reset on hardware reset, so guarantee flow\n \t * control is off when forcing speed.\n \t */\n@@ -2095,11 +2107,9 @@ static int igb_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],\n \t/* guarantee we can provide a unique filter for the unicast address */\n \tif (is_unicast_ether_addr(addr) || is_link_local_ether_addr(addr)) {\n \t\tstruct igb_adapter *adapter = netdev_priv(dev);\n-\t\tstruct e1000_hw *hw = &adapter->hw;\n \t\tint vfn = adapter->vfs_allocated_count;\n-\t\tint rar_entries = hw->mac.rar_entry_count - (vfn + 1);\n \n-\t\tif (netdev_uc_count(dev) >= rar_entries)\n+\t\tif (netdev_uc_count(dev) >= igb_available_rars(adapter, vfn))\n \t\t\treturn -ENOMEM;\n \t}\n \n@@ -2517,6 +2527,8 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n \t\tgoto err_eeprom;\n \t}\n \n+\tigb_set_default_mac_filter(adapter);\n+\n \t/* get firmware version for ethtool -i */\n \tigb_set_fw_version(adapter);\n \n@@ -2761,6 +2773,7 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n \tif (hw->flash_address)\n \t\tiounmap(hw->flash_address);\n err_sw_init:\n+\tkfree(adapter->mac_table);\n \tkfree(adapter->shadow_vfta);\n \tigb_clear_interrupt_scheme(adapter);\n #ifdef CONFIG_PCI_IOV\n@@ -2937,6 +2950,7 @@ static void igb_remove(struct pci_dev *pdev)\n \t\tiounmap(hw->flash_address);\n \tpci_release_mem_regions(pdev);\n \n+\tkfree(adapter->mac_table);\n \tkfree(adapter->shadow_vfta);\n \tfree_netdev(netdev);\n \n@@ -3099,6 +3113,11 @@ static int igb_sw_init(struct igb_adapter *adapter)\n \t/* Assume MSI-X interrupts, will be checked during IRQ allocation */\n \tadapter->flags |= IGB_FLAG_HAS_MSIX;\n \n+\tadapter->mac_table = kzalloc(sizeof(struct igb_mac_addr) *\n+\t\t\t\t     hw->mac.rar_entry_count, GFP_ATOMIC);\n+\tif (!adapter->mac_table)\n+\t\treturn -ENOMEM;\n+\n \tigb_probe_vfs(adapter);\n \n \tigb_init_queue_configuration(adapter);\n@@ -3810,8 +3829,7 @@ static void igb_configure_rx(struct igb_adapter *adapter)\n \tint i;\n \n \t/* set the correct pool for the PF default MAC address in entry 0 */\n-\tigb_rar_set_qsel(adapter, adapter->hw.mac.addr, 0,\n-\t\t\t adapter->vfs_allocated_count);\n+\tigb_set_default_mac_filter(adapter);\n \n \t/* Setup the HW Rx Head and Tail Descriptor Pointers and\n \t * the Base and Length of the Rx Descriptor Ring\n@@ -4051,8 +4069,7 @@ static int igb_set_mac(struct net_device *netdev, void *p)\n \tmemcpy(hw->mac.addr, addr->sa_data, netdev->addr_len);\n \n \t/* set the correct pool for the new PF MAC address in entry 0 */\n-\tigb_rar_set_qsel(adapter, hw->mac.addr, 0,\n-\t\t\t adapter->vfs_allocated_count);\n+\tigb_set_default_mac_filter(adapter);\n \n \treturn 0;\n }\n@@ -4096,49 +4113,6 @@ static int igb_write_mc_addr_list(struct net_device *netdev)\n \treturn netdev_mc_count(netdev);\n }\n \n-/**\n- *  igb_write_uc_addr_list - write unicast addresses to RAR table\n- *  @netdev: network interface device structure\n- *\n- *  Writes unicast address list to the RAR table.\n- *  Returns: -ENOMEM on failure/insufficient address space\n- *           0 on no addresses written\n- *           X on writing X addresses to the RAR table\n- **/\n-static int igb_write_uc_addr_list(struct net_device *netdev)\n-{\n-\tstruct igb_adapter *adapter = netdev_priv(netdev);\n-\tstruct e1000_hw *hw = &adapter->hw;\n-\tunsigned int vfn = adapter->vfs_allocated_count;\n-\tunsigned int rar_entries = hw->mac.rar_entry_count - (vfn + 1);\n-\tint count = 0;\n-\n-\t/* return ENOMEM indicating insufficient memory for addresses */\n-\tif (netdev_uc_count(netdev) > rar_entries)\n-\t\treturn -ENOMEM;\n-\n-\tif (!netdev_uc_empty(netdev) && rar_entries) {\n-\t\tstruct netdev_hw_addr *ha;\n-\n-\t\tnetdev_for_each_uc_addr(ha, netdev) {\n-\t\t\tif (!rar_entries)\n-\t\t\t\tbreak;\n-\t\t\tigb_rar_set_qsel(adapter, ha->addr,\n-\t\t\t\t\t rar_entries--,\n-\t\t\t\t\t vfn);\n-\t\t\tcount++;\n-\t\t}\n-\t}\n-\t/* write the addresses in reverse order to avoid write combining */\n-\tfor (; rar_entries > 0 ; rar_entries--) {\n-\t\twr32(E1000_RAH(rar_entries), 0);\n-\t\twr32(E1000_RAL(rar_entries), 0);\n-\t}\n-\twrfl();\n-\n-\treturn count;\n-}\n-\n static int igb_vlan_promisc_enable(struct igb_adapter *adapter)\n {\n \tstruct e1000_hw *hw = &adapter->hw;\n@@ -4311,8 +4285,7 @@ static void igb_set_rx_mode(struct net_device *netdev)\n \t * sufficient space to store all the addresses then enable\n \t * unicast promiscuous mode\n \t */\n-\tcount = igb_write_uc_addr_list(netdev);\n-\tif (count < 0) {\n+\tif (__dev_uc_sync(netdev, igb_uc_sync, igb_uc_unsync)) {\n \t\trctl |= E1000_RCTL_UPE;\n \t\tvmolr |= E1000_VMOLR_ROPE;\n \t}\n@@ -6369,7 +6342,6 @@ static void igb_vf_reset_msg(struct igb_adapter *adapter, u32 vf)\n {\n \tstruct e1000_hw *hw = &adapter->hw;\n \tunsigned char *vf_mac = adapter->vf_data[vf].vf_mac_addresses;\n-\tint rar_entry = hw->mac.rar_entry_count - (vf + 1);\n \tu32 reg, msgbuf[3];\n \tu8 *addr = (u8 *)(&msgbuf[1]);\n \n@@ -6377,7 +6349,7 @@ static void igb_vf_reset_msg(struct igb_adapter *adapter, u32 vf)\n \tigb_vf_reset(adapter, vf);\n \n \t/* set vf mac address */\n-\tigb_rar_set_qsel(adapter, vf_mac, rar_entry, vf);\n+\tigb_set_vf_mac(adapter, vf, vf_mac);\n \n \t/* enable transmit and receive for vf */\n \treg = rd32(E1000_VFTE);\n@@ -6397,6 +6369,138 @@ static void igb_vf_reset_msg(struct igb_adapter *adapter, u32 vf)\n \tigb_write_mbx(hw, msgbuf, 3, vf);\n }\n \n+static void igb_flush_mac_table(struct igb_adapter *adapter)\n+{\n+\tstruct e1000_hw *hw = &adapter->hw;\n+\tint i;\n+\n+\tfor (i = 0; i < hw->mac.rar_entry_count; i++) {\n+\t\tadapter->mac_table[i].state &= ~IGB_MAC_STATE_IN_USE;\n+\t\tmemset(adapter->mac_table[i].addr, 0, ETH_ALEN);\n+\t\tadapter->mac_table[i].queue = 0;\n+\t\tigb_rar_set_index(adapter, i);\n+\t}\n+}\n+\n+static int igb_available_rars(struct igb_adapter *adapter, u8 queue)\n+{\n+\tstruct e1000_hw *hw = &adapter->hw;\n+\t/* do not count rar entries reserved for VFs MAC addresses */\n+\tint rar_entries = hw->mac.rar_entry_count -\n+\t\t\t  adapter->vfs_allocated_count;\n+\tint i, count = 0;\n+\n+\tfor (i = 0; i < rar_entries; i++) {\n+\t\t/* do not count default entries */\n+\t\tif (adapter->mac_table[i].state & IGB_MAC_STATE_DEFAULT)\n+\t\t\tcontinue;\n+\n+\t\t/* do not count \"in use\" entries for different queues */\n+\t\tif ((adapter->mac_table[i].state & IGB_MAC_STATE_IN_USE) &&\n+\t\t    (adapter->mac_table[i].queue != queue))\n+\t\t\tcontinue;\n+\n+\t\tcount++;\n+\t}\n+\n+\treturn count;\n+}\n+\n+/* Set default MAC address for the PF in the first RAR entry */\n+static void igb_set_default_mac_filter(struct igb_adapter *adapter)\n+{\n+\tstruct igb_mac_addr *mac_table = &adapter->mac_table[0];\n+\n+\tether_addr_copy(mac_table->addr, adapter->hw.mac.addr);\n+\tmac_table->queue = adapter->vfs_allocated_count;\n+\tmac_table->state = IGB_MAC_STATE_DEFAULT | IGB_MAC_STATE_IN_USE;\n+\n+\tigb_rar_set_index(adapter, 0);\n+}\n+\n+int igb_add_mac_filter(struct igb_adapter *adapter, const u8 *addr,\n+\t\t       const u8 queue)\n+{\n+\tstruct e1000_hw *hw = &adapter->hw;\n+\tint rar_entries = hw->mac.rar_entry_count -\n+\t\t\t  adapter->vfs_allocated_count;\n+\tint i;\n+\n+\tif (is_zero_ether_addr(addr))\n+\t\treturn -EINVAL;\n+\n+\t/* Search for the first empty entry in the MAC table.\n+\t * Do not touch entries at the end of the table reserved for the VF MAC\n+\t * addresses.\n+\t */\n+\tfor (i = 0; i < rar_entries; i++) {\n+\t\tif (adapter->mac_table[i].state & IGB_MAC_STATE_IN_USE)\n+\t\t\tcontinue;\n+\n+\t\tether_addr_copy(adapter->mac_table[i].addr, addr);\n+\t\tadapter->mac_table[i].queue = queue;\n+\t\tadapter->mac_table[i].state |= IGB_MAC_STATE_IN_USE;\n+\n+\t\tigb_rar_set_index(adapter, i);\n+\t\treturn i;\n+\t}\n+\n+\treturn -ENOSPC;\n+}\n+\n+int igb_del_mac_filter(struct igb_adapter *adapter, const u8 *addr,\n+\t\t       const u8 queue)\n+{\n+\tstruct e1000_hw *hw = &adapter->hw;\n+\tint rar_entries = hw->mac.rar_entry_count -\n+\t\t\t  adapter->vfs_allocated_count;\n+\tint i;\n+\n+\tif (is_zero_ether_addr(addr))\n+\t\treturn -EINVAL;\n+\n+\t/* Search for matching entry in the MAC table based on given address\n+\t * and queue. Do not touch entries at the end of the table reserved\n+\t * for the VF MAC addresses.\n+\t */\n+\tfor (i = 0; i < rar_entries; i++) {\n+\t\tif (!(adapter->mac_table[i].state & IGB_MAC_STATE_IN_USE))\n+\t\t\tcontinue;\n+\t\tif (adapter->mac_table[i].queue != queue)\n+\t\t\tcontinue;\n+\t\tif (!ether_addr_equal(adapter->mac_table[i].addr, addr))\n+\t\t\tcontinue;\n+\n+\t\tadapter->mac_table[i].state &= ~IGB_MAC_STATE_IN_USE;\n+\t\tmemset(adapter->mac_table[i].addr, 0, ETH_ALEN);\n+\t\tadapter->mac_table[i].queue = 0;\n+\n+\t\tigb_rar_set_index(adapter, i);\n+\t\treturn 0;\n+\t}\n+\n+\treturn -ENOENT;\n+}\n+\n+static int igb_uc_sync(struct net_device *netdev, const unsigned char *addr)\n+{\n+\tstruct igb_adapter *adapter = netdev_priv(netdev);\n+\tint ret;\n+\n+\tret = igb_add_mac_filter(adapter, addr, adapter->vfs_allocated_count);\n+\n+\treturn min_t(int, ret, 0);\n+}\n+\n+static int igb_uc_unsync(struct net_device *netdev, const unsigned char *addr)\n+{\n+\tstruct igb_adapter *adapter = netdev_priv(netdev);\n+\n+\tigb_del_mac_filter(adapter, addr, adapter->vfs_allocated_count);\n+\n+\treturn 0;\n+}\n+\n static int igb_set_vf_mac_addr(struct igb_adapter *adapter, u32 *msg, int vf)\n {\n \t/* The VF MAC Address is stored in a packed array of bytes\n@@ -8078,11 +8182,16 @@ static void igb_io_resume(struct pci_dev *pdev)\n \tigb_get_hw_control(adapter);\n }\n \n-static void igb_rar_set_qsel(struct igb_adapter *adapter, u8 *addr, u32 index,\n-\t\t\t     u8 qsel)\n+/**\n+ *  igb_rar_set_index - Sync RAL[index] and RAH[index] registers with MAC table\n+ *  @adapter: Pointer to adapter structure\n+ *  @index: Index of the RAR entry which need to be synced with MAC table\n+ **/\n+static void igb_rar_set_index(struct igb_adapter *adapter, u32 index)\n {\n \tstruct e1000_hw *hw = &adapter->hw;\n \tu32 rar_low, rar_high;\n+\tu8 *addr = adapter->mac_table[index].addr;\n \n \t/* HW expects these to be in network order when they are plugged\n \t * into the registers which are little endian.  In order to guarantee\n@@ -8093,12 +8202,16 @@ static void igb_rar_set_qsel(struct igb_adapter *adapter, u8 *addr, u32 index,\n \trar_high = le16_to_cpup((__le16 *)(addr + 4));\n \n \t/* Indicate to hardware the Address is Valid. */\n-\trar_high |= E1000_RAH_AV;\n+\tif (adapter->mac_table[index].state & IGB_MAC_STATE_IN_USE) {\n+\t\trar_high |= E1000_RAH_AV;\n \n-\tif (hw->mac.type == e1000_82575)\n-\t\trar_high |= E1000_RAH_POOL_1 * qsel;\n-\telse\n-\t\trar_high |= E1000_RAH_POOL_1 << qsel;\n+\t\tif (hw->mac.type == e1000_82575)\n+\t\t\trar_high |= E1000_RAH_POOL_1 *\n+\t\t\t\t    adapter->mac_table[index].queue;\n+\t\telse\n+\t\t\trar_high |= E1000_RAH_POOL_1 <<\n+\t\t\t\t    adapter->mac_table[index].queue;\n+\t}\n \n \twr32(E1000_RAL(index), rar_low);\n \twrfl();\n@@ -8114,10 +8227,13 @@ static int igb_set_vf_mac(struct igb_adapter *adapter,\n \t * towards the first, as a result a collision should not be possible\n \t */\n \tint rar_entry = hw->mac.rar_entry_count - (vf + 1);\n+\tunsigned char *vf_mac_addr = adapter->vf_data[vf].vf_mac_addresses;\n \n-\tmemcpy(adapter->vf_data[vf].vf_mac_addresses, mac_addr, ETH_ALEN);\n-\n-\tigb_rar_set_qsel(adapter, mac_addr, rar_entry, vf);\n+\tether_addr_copy(vf_mac_addr, mac_addr);\n+\tether_addr_copy(adapter->mac_table[rar_entry].addr, mac_addr);\n+\tadapter->mac_table[rar_entry].queue = vf;\n+\tadapter->mac_table[rar_entry].state |= IGB_MAC_STATE_IN_USE;\n+\tigb_rar_set_index(adapter, rar_entry);\n \n \treturn 0;\n }\n",
    "prefixes": [
        "1/2"
    ]
}