Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp924109imu; Wed, 23 Jan 2019 08:01:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN7uQSPgwtExazPG4iPNgZab6G5P+/cSYoRYkfik9YatkqVH47psgPgSKvKNwU6b4x1MkdH9 X-Received: by 2002:a63:9809:: with SMTP id q9mr2434357pgd.109.1548259267532; Wed, 23 Jan 2019 08:01:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548259267; cv=none; d=google.com; s=arc-20160816; b=F8lwAvaX59vrTY3hX5B2dVNqzZuwHiYt5t/ZuT5MqL0WSTRUeWIelsF4aWPagB3FLr YEL9ioWtYoeKbqHuSLKXbNqEsecsD8jUpMui8cs7yyEf/MrIe9IqQJisJjL5Pn95GBSb V2Jsek09w25pWsGnDII3yeGeHJQlavUrqEN7WGIBPK/Z30cBN5YImtN7I/Qfd//g72zB 9EWLCCd0rU4KmVTBtp/r3dzTKVdBuIBzJ73juKs9oKn4JXgnPp5TP0QvAaAuO1fx6Erj N60pjtd5SphCyz/jcnlOwEjKwH7kBdozosupHE232Ucxb9DtGfNdD2vdLFEwlnEPCcQD WCiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Q4AeKdd3EsdSTMJtf0tfUjOjgkbAtRcAAb6PwHneqYE=; b=ntNtA3Tc5E2yCyOcdMYgHPIEurSH9lI/1TVwjj74R4ZmPT3qAWYSgL8jQXfB5ZkK62 M3LWb5JQEO2Yo0LEng7aqwDX8QCT82lxZndlOBZThLCUzvjDq0GI0Q9iZ53D3ts9o+sz wKp1kljwT2foo2+AmQAn9wYlILn0CKgocer+1VFoEi+Ue8ypDq92+SrvFF2PIA4OUhP7 0IJNDuOgGrFrcE1yLUCLFgqAEaJPN7/5wKqxImKapzqCUMALn/OFUlN6LrZtzJ2aGSIr zPMoeiTRTMmR3GJaLZ0DQfBkQ1enmShwoReuDD9Fbju4W4IzRboaJmKGevpbVuLntlvO FjwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k5si17556377pfi.176.2019.01.23.08.00.51; Wed, 23 Jan 2019 08:01:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727196AbfAWP7Y (ORCPT + 99 others); Wed, 23 Jan 2019 10:59:24 -0500 Received: from mail.bootlin.com ([62.4.15.54]:42272 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727040AbfAWP7S (ORCPT ); Wed, 23 Jan 2019 10:59:18 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 28361209EF; Wed, 23 Jan 2019 16:59:15 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost (aaubervilliers-681-1-87-206.w90-88.abo.wanadoo.fr [90.88.29.206]) by mail.bootlin.com (Postfix) with ESMTPSA id 3559120A15; Wed, 23 Jan 2019 16:58:57 +0100 (CET) From: Antoine Tenart To: davem@davemloft.net, sd@queasysnail.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com Cc: Antoine Tenart , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, alexandre.belloni@bootlin.com, quentin.schulz@bootlin.com, allan.nielsen@microchip.com Subject: [PATCH net-next 05/10] net: phy: introduce a phy_driver macsec helper Date: Wed, 23 Jan 2019 16:56:33 +0100 Message-Id: <20190123155638.13852-6-antoine.tenart@bootlin.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190123155638.13852-1-antoine.tenart@bootlin.com> References: <20190123155638.13852-1-antoine.tenart@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch introduces a phy_driver MACsec helper to allow PHYs to implement a MACsec offloading solution. The phy_driver MACsec helper is called through a wrapper, phy_macsec, to perform this call while holding the phydev lock. Signed-off-by: Antoine Tenart --- drivers/net/phy/phy.c | 17 +++++++++++++++++ include/linux/phy.h | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 631ed33fe9d9..6b37bb845ce9 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1095,6 +1095,23 @@ int phy_get_eee_err(struct phy_device *phydev) } EXPORT_SYMBOL(phy_get_eee_err); +int phy_macsec(struct phy_device *phydev, struct netdev_macsec *macsec) +{ + int ret = -EOPNOTSUPP; + + if (!phydev->drv) + return -EIO; + + mutex_lock(&phydev->lock); + + if (phydev->drv->macsec) + ret = phydev->drv->macsec(phydev, macsec); + + mutex_unlock(&phydev->lock); + return ret; +} +EXPORT_SYMBOL_GPL(phy_macsec); + /** * phy_ethtool_get_eee - get EEE supported and status * @phydev: target phy_device struct diff --git a/include/linux/phy.h b/include/linux/phy.h index 1f3873a2ff29..21839f352e7c 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -27,6 +27,10 @@ #include #include +#ifdef CONFIG_MACSEC +#include +#endif + #include #define PHY_DEFAULT_FEATURES (SUPPORTED_Autoneg | \ @@ -630,6 +634,10 @@ struct phy_driver { struct ethtool_tunable *tuna, const void *data); int (*set_loopback)(struct phy_device *dev, bool enable); + +#ifdef CONFIG_MACSEC + int (*macsec)(struct phy_device *dev, struct netdev_macsec *macsec); +#endif }; #define to_phy_driver(d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv) @@ -1072,6 +1080,7 @@ int phy_unregister_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask); int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable); int phy_get_eee_err(struct phy_device *phydev); +int phy_macsec(struct phy_device *phydev, struct netdev_macsec *macsec); int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data); int phy_ethtool_get_eee(struct phy_device *phydev, struct ethtool_eee *data); int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol); -- 2.20.1