From patchwork Mon Jul 24 09:24:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mengyuan Lou X-Patchwork-Id: 13323631 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B77B96FD0 for ; Mon, 24 Jul 2023 09:26:16 +0000 (UTC) Received: from smtpbg153.qq.com (smtpbg153.qq.com [13.245.218.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6910A122 for ; Mon, 24 Jul 2023 02:26:12 -0700 (PDT) X-QQ-mid: bizesmtp83t1690190762tm8q600v Received: from localhost.localdomain ( [183.128.134.159]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 24 Jul 2023 17:26:00 +0800 (CST) X-QQ-SSF: 01400000000000N0Z000000A0000000 X-QQ-FEAT: RrZlkntZBfmNHGYSiNU1ffJfJ6PGtic3Fm7B6sBLjciq+QX4PRG8YkFMh637n n+MwkqT3kH6FUmf+4MWiBimsg24eAeKJ4o2ESvfZC1cmBxs/4ODWS3BT0aLdEMI1lr/2H0R al31g6PYUnrs0jjC1jkhvgB8cqgt+bcfKtWAzTnyM/UwUhVUKDZJNnwzYR/BwA6GiEgyXdQ ajeLe91WeL7hbi9pOINmbsaqz+loyCZC8oeB1TtDFv6OwUpGuduXzfAcSH3vcXk9y7z6Z1F g7sVhyxVzX6zopBtcEe5c5sMcYfCdnP6+HA+x8dOOsfIV9l/k8Yt0gpj7mOO5EtdknMRlIc FSbzIKPVWPtAYrh2wA3J7VCB8srE9D/WNYXOI161sPUoZeDzePl8FqRMJXeHp4wcadyRozQ UQmxHHpgM3g= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 14770940883638647669 From: Mengyuan Lou To: netdev@vger.kernel.org Cc: Mengyuan Lou Subject: [PATCH net-next 1/2] net: ngbe: add ncsi_enable flag for wangxun nics Date: Mon, 24 Jul 2023 17:24:58 +0800 Message-ID: <6E913AD9617D9BC9+20230724092544.73531-2-mengyuanlou@net-swift.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230724092544.73531-1-mengyuanlou@net-swift.com> References: <20230724092544.73531-1-mengyuanlou@net-swift.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:net-swift.com:qybglogicsvrgz:qybglogicsvrgz6a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add ncsi_enabled flag to struct netdev to indicate wangxun nics which support NCSI. Signed-off-by: Mengyuan Lou --- drivers/net/ethernet/wangxun/libwx/wx_type.h | 2 +- drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 5 +++-- include/linux/netdevice.h | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/wangxun/libwx/wx_type.h b/drivers/net/ethernet/wangxun/libwx/wx_type.h index 1de88a33a698..1b932e66044e 100644 --- a/drivers/net/ethernet/wangxun/libwx/wx_type.h +++ b/drivers/net/ethernet/wangxun/libwx/wx_type.h @@ -851,7 +851,7 @@ struct wx { struct phy_device *phydev; bool wol_hw_supported; - bool ncsi_enabled; + bool ncsi_hw_supported; bool gpio_ctrl; raw_spinlock_t gpio_lock; diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c index 2b431db6085a..e42e4dd26700 100644 --- a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c +++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c @@ -63,8 +63,8 @@ static void ngbe_init_type_code(struct wx *wx) em_mac_type_mdi; wx->wol_hw_supported = (wol_mask == NGBE_WOL_SUP) ? 1 : 0; - wx->ncsi_enabled = (ncsi_mask == NGBE_NCSI_MASK || - type_mask == NGBE_SUBID_OCP_CARD) ? 1 : 0; + wx->ncsi_hw_supported = (ncsi_mask == NGBE_NCSI_MASK || + type_mask == NGBE_SUBID_OCP_CARD) ? 1 : 0; switch (type_mask) { case NGBE_SUBID_LY_YT8521S_SFP: @@ -639,6 +639,7 @@ static int ngbe_probe(struct pci_dev *pdev, netdev->wol_enabled = !!(wx->wol); wr32(wx, NGBE_PSR_WKUP_CTL, wx->wol); device_set_wakeup_enable(&pdev->dev, wx->wol); + netdev->ncsi_enabled = wx->ncsi_hw_supported; /* Save off EEPROM version number and Option Rom version which * together make a unique identify for the eeprom diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index b828c7a75be2..dfa14e4c8e95 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2024,6 +2024,8 @@ enum netdev_ml_priv_type { * * @wol_enabled: Wake-on-LAN is enabled * + * @ncsi_enabled: NCSI is enabled. + * * @threaded: napi threaded mode is enabled * * @net_notifier_list: List of per-net netdev notifier block @@ -2393,6 +2395,7 @@ struct net_device { struct lock_class_key *qdisc_tx_busylock; bool proto_down; unsigned wol_enabled:1; + unsigned ncsi_enabled:1; unsigned threaded:1; struct list_head net_notifier_list; From patchwork Mon Jul 24 09:24:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mengyuan Lou X-Patchwork-Id: 13323630 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A4AE6FD1 for ; Mon, 24 Jul 2023 09:26:15 +0000 (UTC) Received: from smtpbguseast2.qq.com (smtpbguseast2.qq.com [54.204.34.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15310121 for ; Mon, 24 Jul 2023 02:26:12 -0700 (PDT) X-QQ-mid: bizesmtp83t1690190766t0gssa93 Received: from localhost.localdomain ( [183.128.134.159]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 24 Jul 2023 17:26:05 +0800 (CST) X-QQ-SSF: 01400000000000N0Z000000A0000000 X-QQ-FEAT: CR3LFp2JE4kd1ybrnLj6GfQjTY3QjQVqUVGuHUI0u91KMDVc/8IVhT+vylt6k t7t7q4z74CdWclyZLGN3YkV+qLKVrtw7nzVOshmQunpaEZgmEWjN5IHONT/F02e6ytGMYua EoPl3XaKn07nNZn4wXk0286siUFMvz3xafST5OwA4APEkifoHGKLZ9v5gXfxpAY5eeL8gW5 WT79YC6vh86GcCvx8vh3h5zgjiA5dQVDNmIKsrkPVQWk1JC4XhomKHAwDHtjkoJApCL9e3m +KhQMfXo1NMrIJ5/YlPZaLaPYMn3IbuKcXS0aBTz3fp8Ial40WMNrOUIhuJw1WC6Eu5oZJc 5UW69e9X0jIIR+LWLaTUmyEnBSusN3KJz/+aYjXvd4mO5NujGR/3tZnQSBrqLa9bz42RsYn 65PVdrBcnnKtghSm0VLwJw== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 11289264760922880588 From: Mengyuan Lou To: netdev@vger.kernel.org Cc: Mengyuan Lou Subject: [PATCH net-next 2/2] net: phy: add keep_data_connection to struct phydev Date: Mon, 24 Jul 2023 17:24:59 +0800 Message-ID: <20207E0578DCE44C+20230724092544.73531-3-mengyuanlou@net-swift.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230724092544.73531-1-mengyuanlou@net-swift.com> References: <20230724092544.73531-1-mengyuanlou@net-swift.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:net-swift.com:qybglogicsvrgz:qybglogicsvrgz6a-1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add flag keep_data_connection to struct phydev indicating whether phy need to keep data connection. Phy_suspend() will use it to decide whether PHY can be suspended or not. Signed-off-by: Mengyuan Lou --- drivers/net/phy/phy_device.c | 6 ++++-- include/linux/phy.h | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 0c2014accba7..4fe26660458e 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1860,8 +1860,10 @@ int phy_suspend(struct phy_device *phydev) phy_ethtool_get_wol(phydev, &wol); phydev->wol_enabled = wol.wolopts || (netdev && netdev->wol_enabled); - /* If the device has WOL enabled, we cannot suspend the PHY */ - if (phydev->wol_enabled && !(phydrv->flags & PHY_ALWAYS_CALL_SUSPEND)) + phydev->keep_data_connection = phydev->wol_enabled || + (netdev && netdev->ncsi_enabled); + /* We cannot suspend the PHY, when phy and mac need to receive packets. */ + if (phydev->keep_data_connection && !(phydrv->flags & PHY_ALWAYS_CALL_SUSPEND)) return -EBUSY; if (!phydrv || !phydrv->suspend) diff --git a/include/linux/phy.h b/include/linux/phy.h index 11c1e91563d4..bda646e7cc23 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -554,6 +554,8 @@ struct macsec_ops; * @mac_managed_pm: Set true if MAC driver takes of suspending/resuming PHY * @wol_enabled: Set to true if the PHY or the attached MAC have Wake-on-LAN * enabled. + * @keep_data_connection: Set to true if the PHY or the attached MAC need + * physical connection to receive packets. * @state: State of the PHY for management purposes * @dev_flags: Device-specific flags used by the PHY driver. * @@ -651,6 +653,7 @@ struct phy_device { unsigned is_on_sfp_module:1; unsigned mac_managed_pm:1; unsigned wol_enabled:1; + unsigned keep_data_connection:1; unsigned autoneg:1; /* The most recently read link state */