From patchwork Mon Jun 5 09:52:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mengyuan Lou X-Patchwork-Id: 13267138 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 2181B134BB for ; Mon, 5 Jun 2023 09:55:58 +0000 (UTC) Received: from smtpbg153.qq.com (smtpbg153.qq.com [13.245.218.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2DEAD3 for ; Mon, 5 Jun 2023 02:55:55 -0700 (PDT) X-QQ-mid: bizesmtp86t1685958945tf7p5e7d Received: from localhost.localdomain ( [60.177.99.31]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 05 Jun 2023 17:55:42 +0800 (CST) X-QQ-SSF: 01400000000000N0Z000000A0000000 X-QQ-FEAT: q+EIYT+FhZr/VWuGHW5yOVBJty4/KxOGCld9HRMpYcy/D5WeCYPAUYbZz9UH+ J/kAH6IeVNcesMFgtGGtJLGbwYvCyZlUFJGssk0Dz8LEe2RgAfCaZo+ZWAFLfzJMFnuIo0o SklNtt3yOzWkQmAHsvCAQtT4Z/eE2X/mVangy09ChbeBR+D8tZl6ESh1sR33jQCXvhNjJmt PhNv4l0EVvL1tJm/AZpQMU4nkuozLW9fpftWcyGlV0ehvTmFAOMJA0vDK5SaKwFSnKmva92 taBgQFUeb9JKQOE2zvIH2hHhHiDrpMs+QJYEigDaT8VJiBt0taLZwiTAqHEnHp1upD920W0 QD1lSWrZQcZaXVMzxOCvQPWT8TGs76h9HFYBn/vCP7Y0M+zXOawBwrh9X24N7OapQhkLQ9b X-QQ-GoodBg: 2 X-BIZMAIL-ID: 11037389191732909534 From: Mengyuan Lou To: netdev@vger.kernel.org Cc: jiawenwu@trustnetic.com, Mengyuan Lou Subject: [RFC,PATCH net-next 1/3] net: ngbe: add Wake on Lan support Date: Mon, 5 Jun 2023 17:52:50 +0800 Message-ID: <6DD3D5EDF01AE3F5+20230605095527.57898-2-mengyuanlou@net-swift.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230605095527.57898-1-mengyuanlou@net-swift.com> References: <20230605095527.57898-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:qybglogicsvrgz5a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,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 X-Patchwork-State: RFC Implement ethtool_ops get_wol. Implement Wake-on-LAN support. Magic packets are checked by fw, for now just support WAKE_MAGIC and do not supoort to set_wol. Signed-off-by: Mengyuan Lou --- drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c | 10 ++++++++++ drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 1 + 2 files changed, 11 insertions(+) diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c index 5b25834baf38..2bc54fdafb31 100644 --- a/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c +++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_ethtool.c @@ -8,12 +8,22 @@ #include "../libwx/wx_ethtool.h" #include "ngbe_ethtool.h" +static void ngbe_get_wol(struct net_device *netdev, + struct ethtool_wolinfo *wol) +{ + if (!netdev->wol_enabled) + return; + wol->supported = WAKE_MAGIC; + wol->wolopts = WAKE_MAGIC; +} + static const struct ethtool_ops ngbe_ethtool_ops = { .get_drvinfo = wx_get_drvinfo, .get_link = ethtool_op_get_link, .get_link_ksettings = phy_ethtool_get_link_ksettings, .set_link_ksettings = phy_ethtool_set_link_ksettings, .nway_reset = phy_ethtool_nway_reset, + .get_wol = ngbe_get_wol, }; void ngbe_set_ethtool_ops(struct net_device *netdev) diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c index c99a5d3de72e..5d013ac3acd1 100644 --- a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c +++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c @@ -628,6 +628,7 @@ static int ngbe_probe(struct pci_dev *pdev, wr32(wx, NGBE_PSR_WKUP_CTL, wx->wol); device_set_wakeup_enable(&pdev->dev, wx->wol); + netdev->wol_enabled = wx->wol_enabled; /* Save off EEPROM version number and Option Rom version which * together make a unique identify for the eeprom From patchwork Mon Jun 5 09:52:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mengyuan Lou X-Patchwork-Id: 13267139 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 81768156D0 for ; Mon, 5 Jun 2023 09:55:59 +0000 (UTC) Received: from smtpbg156.qq.com (smtpbg156.qq.com [15.184.82.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB6CDB8 for ; Mon, 5 Jun 2023 02:55:56 -0700 (PDT) X-QQ-mid: bizesmtp86t1685958949thg5h7d1 Received: from localhost.localdomain ( [60.177.99.31]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 05 Jun 2023 17:55:48 +0800 (CST) X-QQ-SSF: 01400000000000N0Z000000A0000000 X-QQ-FEAT: I8hG9CuxGDK0dYQWPu8BK+vCoQHoPW8MS8SPSQ87/wRkRRiNJs521qRw/iu+6 E8wXtilwc8HvhNUdviDfw3Wb+22TA4d2GRyi365FGivCrZ+BouYOCXGmIXP+YCiNCc2Ms2K zCzUXsDIhEPgZz7shRMNiErHr4mUKZpvgD9OCwSMLnKkxkgeeKy65Whr4etFYfWC3TfYF8k JS2k8VYBVe8niYhtA+0harSwgsjOMa+czWdH1Cf3dGpLACnWHA0skqtxJN4ZY0xCxH2aHCG KH8NzmUD5Nt/Q1IjnWetu9tIVfNhkgq8A0uFpxzKEvsp/5IF3zs0C3mh5MweDoA/sgRyP85 BXvp0UZHv/DTX7p0m3DBadeCOfVRe/IDbMxZEly64gYAJGncG5gAAxGVS2Lnahra0qPOKpP YTG6hNN49Ww= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 2369341711221289698 From: Mengyuan Lou To: netdev@vger.kernel.org Cc: jiawenwu@trustnetic.com, Mengyuan Lou Subject: [RFC,PATCH net-next 2/3] net: core: add member ncsi_enabled to net_device Date: Mon, 5 Jun 2023 17:52:51 +0800 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230605095527.57898-1-mengyuanlou@net-swift.com> References: <20230605095527.57898-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:qybglogicsvrgz5a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,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 X-Patchwork-State: RFC Add flag ncsi_enabled to struct net_device indicating whether NCSI is enabled. 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 | 4 +++- include/linux/netdevice.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 2cad9cc3f6b8..6587b35071e9 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1859,7 +1859,9 @@ int phy_suspend(struct phy_device *phydev) return 0; phy_ethtool_get_wol(phydev, &wol); - phydev->wol_enabled = wol.wolopts || (netdev && netdev->wol_enabled); + phydev->wol_enabled = wol.wolopts || + (netdev && netdev->wol_enabled) || + (netdev && netdev->ncsi_enabled); /* If the device has WOL enabled, we cannot suspend the PHY */ if (phydev->wol_enabled && !(phydrv->flags & PHY_ALWAYS_CALL_SUSPEND)) return -EBUSY; diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 08fbd4622ccf..7650b6a210ff 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2021,6 +2021,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 @@ -2390,6 +2392,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 Jun 5 09:52:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mengyuan Lou X-Patchwork-Id: 13267140 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 92980156D0 for ; Mon, 5 Jun 2023 09:56:03 +0000 (UTC) Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8339B8 for ; Mon, 5 Jun 2023 02:56:00 -0700 (PDT) X-QQ-mid: bizesmtp86t1685958952trabyio6 Received: from localhost.localdomain ( [60.177.99.31]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 05 Jun 2023 17:55:51 +0800 (CST) X-QQ-SSF: 01400000000000N0Z000000A0000000 X-QQ-FEAT: dKvkn8qoLrEQWQdYBXYHpS2gwex9CvNurH0iJ538W4eZNbWBuYTPXENg90Tlr HwY/vW07hk5T8cxR65K4RqNAAcXQtjHn58vkb5ndOf0YTkVqVJJ2twEK4ftkRyCg2OrPsdJ nI3Ibr9A/dqhfvx2e6P9fuy6HN0gf1czIx7ennuSdiG9bpw9Ph96amwUHbjzDg18b5z4I3W /LAHfFj4Y8qle1Z54btwo5NtHOwHmIVsB6Vpl9Mxn9HSQwSpN6tbqJStCJLqoTZY5W5VyX4 NIgAwJyaIeeLFggd72Pn8ZnZ0EVl0mRKU6/ZRaqTlDUFaVn/BYpbT0wkF7hT2n4Ho+95bFW dVv0EGC9sV5Ok+VR7UklWarfcpZDzmd0aESrM02RAbJOBj9ezkp+IYK5k5TToMBrwiUvEej isrilAXJBe0= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 2032313646085698842 From: Mengyuan Lou To: netdev@vger.kernel.org Cc: jiawenwu@trustnetic.com, Mengyuan Lou Subject: [RFC,PATCH net-next 3/3] net: ngbe: add support for ncsi nics Date: Mon, 5 Jun 2023 17:52:52 +0800 Message-ID: <5050D7292AC40763+20230605095527.57898-4-mengyuanlou@net-swift.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230605095527.57898-1-mengyuanlou@net-swift.com> References: <20230605095527.57898-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:qybglogicsvrgz5a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,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 X-Patchwork-State: RFC Pass ncsi_enabled through netdev to phy_supsend(). when ncsi_enabled is on, phy should not to supsend. Signed-off-by: Mengyuan Lou --- drivers/net/ethernet/wangxun/ngbe/ngbe_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c index 5d013ac3acd1..37d5e1f12d19 100644 --- a/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c +++ b/drivers/net/ethernet/wangxun/ngbe/ngbe_main.c @@ -629,6 +629,7 @@ static int ngbe_probe(struct pci_dev *pdev, device_set_wakeup_enable(&pdev->dev, wx->wol); netdev->wol_enabled = wx->wol_enabled; + netdev->ncsi_enabled = wx->ncsi_enabled; /* Save off EEPROM version number and Option Rom version which * together make a unique identify for the eeprom