]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
i40e: enable mc magic pkt wakeup during power down
authorJoshua Hay <joshua.a.hay@intel.com>
Mon, 12 Dec 2016 23:44:08 +0000 (15:44 -0800)
committerJack Vogel <jack.vogel@oracle.com>
Sat, 10 Jun 2017 01:57:02 +0000 (18:57 -0700)
This patch adds a call to the mac_address_write admin q function during
power down to update the PRTPM_SAH/SAL registers with the MC_MAG_EN bit
thus enabling multicast magic packet wakeup.

A FW workaround is needed to write the multicast magic wake up enable
bit in the PRTPM_SAH register. The FW expects the mac address write
admin q cmd to be called first with one of the WRITE_TYPE_LAA flags
and then with the multicast relevant flags.

*Note: This solution only works for X722 devices currently. A PFR will
clear the previously mentioned bit by default, but X722 has support for a
WOL_PRESERVE_ON_PFR flag which prevents the bit from being cleared. Once
other devices support this flag, this solution should work as well.

Change-ID: I51bd5b8535bd9051c2676e27c999c1657f786827
Signed-off-by: Joshua Hay <joshua.a.hay@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Orabug: 26132523
(cherry picked from commit 1d68005db4e72082f3e537d6c0cf831a71a7e2ee)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Brian Maly <brian.maly@oracle.com>
drivers/net/ethernet/intel/i40e/i40e.h
drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
drivers/net/ethernet/intel/i40e/i40e_main.c

index 4d059742fa55f46fe63cb0fe226b056714a89b28..b858a825d2b6d954325a2825e0796ddaa4b4895b 100644 (file)
@@ -348,6 +348,7 @@ struct i40e_pf {
 #define I40E_FLAG_TRUE_PROMISC_SUPPORT         BIT_ULL(51)
 #define I40E_FLAG_HAVE_CRT_RETIMER             BIT_ULL(52)
 #define I40E_FLAG_PTP_L4_CAPABLE               BIT_ULL(53)
+#define I40E_FLAG_WOL_MC_MAGIC_PKT_WAKE                BIT_ULL(54)
 
        /* tracks features that get auto disabled by errors */
        u64 auto_disable_flags;
index b2101a51534cd0e8be8785f3291116d14b448c2b..451f48b7540aa0360615599b6681e2d31f2b6554 100644 (file)
@@ -538,6 +538,8 @@ I40E_CHECK_STRUCT_LEN(24, i40e_aqc_mac_address_read_data);
 /* Manage MAC Address Write Command (0x0108) */
 struct i40e_aqc_mac_address_write {
        __le16  command_flags;
+#define I40E_AQC_MC_MAG_EN             0x0100
+#define I40E_AQC_WOL_PRESERVE_ON_PFR   0x0200
 #define I40E_AQC_WRITE_TYPE_LAA_ONLY   0x0000
 #define I40E_AQC_WRITE_TYPE_LAA_WOL    0x4000
 #define I40E_AQC_WRITE_TYPE_PORT       0x8000
index cfe66ae64fd8b71203aaf441c9d8439838a089d3..7f2e15dffe12829249cf841dc785c16770cbfda8 100644 (file)
@@ -8754,16 +8754,17 @@ static int i40e_sw_init(struct i40e_pf *pf)
        }
 #endif /* CONFIG_PCI_IOV */
        if (pf->hw.mac.type == I40E_MAC_X722) {
-               pf->flags |= I40E_FLAG_RSS_AQ_CAPABLE |
-                            I40E_FLAG_128_QP_RSS_CAPABLE |
-                            I40E_FLAG_HW_ATR_EVICT_CAPABLE |
-                            I40E_FLAG_OUTER_UDP_CSUM_CAPABLE |
-                            I40E_FLAG_WB_ON_ITR_CAPABLE |
-                            I40E_FLAG_MULTIPLE_TCP_UDP_RSS_PCTYPE |
-                            I40E_FLAG_NO_PCI_LINK_CHECK |
-                            I40E_FLAG_USE_SET_LLDP_MIB |
-                            I40E_FLAG_GENEVE_OFFLOAD_CAPABLE |
-                            I40E_FLAG_PTP_L4_CAPABLE;
+               pf->flags |= I40E_FLAG_RSS_AQ_CAPABLE
+                            | I40E_FLAG_128_QP_RSS_CAPABLE
+                            | I40E_FLAG_HW_ATR_EVICT_CAPABLE
+                            | I40E_FLAG_OUTER_UDP_CSUM_CAPABLE
+                            | I40E_FLAG_WB_ON_ITR_CAPABLE
+                            | I40E_FLAG_MULTIPLE_TCP_UDP_RSS_PCTYPE
+                            | I40E_FLAG_NO_PCI_LINK_CHECK
+                            | I40E_FLAG_USE_SET_LLDP_MIB
+                            | I40E_FLAG_GENEVE_OFFLOAD_CAPABLE
+                            | I40E_FLAG_PTP_L4_CAPABLE
+                            | I40E_FLAG_WOL_MC_MAGIC_PKT_WAKE;
        } else if ((pf->hw.aq.api_maj_ver > 1) ||
                   ((pf->hw.aq.api_maj_ver == 1) &&
                    (pf->hw.aq.api_min_ver > 4))) {
@@ -11661,6 +11662,53 @@ static void i40e_pci_error_resume(struct pci_dev *pdev)
        rtnl_unlock();
 }
 
+/**
+ * i40e_enable_mc_magic_wake - enable multicast magic packet wake up
+ * using the mac_address_write admin q function
+ * @pf: pointer to i40e_pf struct
+ **/
+static void i40e_enable_mc_magic_wake(struct i40e_pf *pf)
+{
+       struct i40e_hw *hw = &pf->hw;
+       i40e_status ret;
+       u8 mac_addr[6];
+       u16 flags = 0;
+
+       /* Get current MAC address in case it's an LAA */
+       if (pf->vsi[pf->lan_vsi] && pf->vsi[pf->lan_vsi]->netdev) {
+               ether_addr_copy(mac_addr,
+                               pf->vsi[pf->lan_vsi]->netdev->dev_addr);
+       } else {
+               dev_err(&pf->pdev->dev,
+                       "Failed to retrieve MAC address; using default\n");
+               ether_addr_copy(mac_addr, hw->mac.addr);
+       }
+
+       /* The FW expects the mac address write cmd to first be called with
+        * one of these flags before calling it again with the multicast
+        * enable flags.
+        */
+       flags = I40E_AQC_WRITE_TYPE_LAA_WOL;
+
+       if (hw->func_caps.flex10_enable && hw->partition_id != 1)
+               flags = I40E_AQC_WRITE_TYPE_LAA_ONLY;
+
+       ret = i40e_aq_mac_address_write(hw, flags, mac_addr, NULL);
+       if (ret) {
+               dev_err(&pf->pdev->dev,
+                       "Failed to update MAC address registers; cannot enable Multicast Magic packet wake up");
+               return;
+       }
+
+       flags = I40E_AQC_MC_MAG_EN
+                       | I40E_AQC_WOL_PRESERVE_ON_PFR
+                       | I40E_AQC_WRITE_TYPE_UPDATE_MC_MAG;
+       ret = i40e_aq_mac_address_write(hw, flags, mac_addr, NULL);
+       if (ret)
+               dev_err(&pf->pdev->dev,
+                       "Failed to enable Multicast Magic Packet wake up\n");
+}
+
 /**
  * i40e_shutdown - PCI callback for shutting down
  * @pdev: PCI device information struct
@@ -11683,6 +11731,9 @@ static void i40e_shutdown(struct pci_dev *pdev)
        cancel_work_sync(&pf->service_task);
        i40e_fdir_teardown(pf);
 
+       if (pf->wol_en && (pf->flags & I40E_FLAG_WOL_MC_MAGIC_PKT_WAKE))
+               i40e_enable_mc_magic_wake(pf);
+
        rtnl_lock();
        i40e_prep_for_reset(pf);
        rtnl_unlock();
@@ -11714,6 +11765,9 @@ static int i40e_suspend(struct pci_dev *pdev, pm_message_t state)
        set_bit(__I40E_SUSPENDED, &pf->state);
        set_bit(__I40E_DOWN, &pf->state);
 
+       if (pf->wol_en && (pf->flags & I40E_FLAG_WOL_MC_MAGIC_PKT_WAKE))
+               i40e_enable_mc_magic_wake(pf);
+
        rtnl_lock();
        i40e_prep_for_reset(pf);
        rtnl_unlock();