From: Antoine Tenart <antoine.tenart@bootlin.com>
To: davem@davemloft.net, sd@queasysnail.net, andrew@lunn.ch,
f.fainelli@gmail.com, hkallweit1@gmail.com
Cc: Antoine Tenart <antoine.tenart@bootlin.com>,
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 [thread overview]
Message-ID: <20190123155638.13852-6-antoine.tenart@bootlin.com> (raw)
In-Reply-To: <20190123155638.13852-1-antoine.tenart@bootlin.com>
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 <antoine.tenart@bootlin.com>
---
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 <linux/workqueue.h>
#include <linux/mod_devicetable.h>
+#ifdef CONFIG_MACSEC
+#include <net/macsec.h>
+#endif
+
#include <linux/atomic.h>
#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
next prev parent reply other threads:[~2019-01-23 15:59 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-23 15:56 [PATCH net-next 00/10] net: macsec: initial support for hardware offloading Antoine Tenart
2019-01-23 15:56 ` [PATCH net-next 01/10] net: introduce the MACSEC netdev feature Antoine Tenart
2019-01-23 15:56 ` [PATCH net-next 02/10] net: macsec: convert to SPDX Antoine Tenart
2019-01-23 17:03 ` Andrew Lunn
2019-01-24 8:54 ` Antoine Tenart
2019-01-24 13:11 ` Andrew Lunn
2019-01-24 13:29 ` Antoine Tenart
2019-01-23 15:56 ` [PATCH net-next 03/10] net: macsec: move some definitions in a dedicated header Antoine Tenart
2019-01-23 20:11 ` Florian Fainelli
2019-01-24 1:00 ` David Miller
2019-01-24 8:58 ` Antoine Tenart
2019-01-23 15:56 ` [PATCH net-next 04/10] net: macsec: introduce the netdev_macsec structure Antoine Tenart
2019-01-23 15:56 ` Antoine Tenart [this message]
2019-01-23 17:08 ` [PATCH net-next 05/10] net: phy: introduce a phy_driver macsec helper Andrew Lunn
2019-01-24 8:56 ` Antoine Tenart
2019-01-23 15:56 ` [PATCH net-next 06/10] net: introduce a net_device_ops " Antoine Tenart
2019-01-23 20:16 ` Florian Fainelli
2019-01-24 9:23 ` Antoine Tenart
2019-01-31 9:26 ` Antoine Tenart
2019-02-01 3:50 ` Florian Fainelli
2019-01-24 14:58 ` Igor Russkikh
2019-01-24 15:05 ` Antoine Tenart
2019-01-23 15:56 ` [PATCH net-next 07/10] net: macsec: hardware offloading infrastructure Antoine Tenart
2019-01-23 15:56 ` [PATCH net-next 08/10] net: phy: export __phy_read_page/__phy_write_page Antoine Tenart
2019-01-23 15:56 ` [PATCH net-next 09/10] net: phy: mscc: macsec initialization Antoine Tenart
2019-01-23 15:56 ` [PATCH net-next 10/10] net: phy: mscc: macsec support Antoine Tenart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190123155638.13852-6-antoine.tenart@bootlin.com \
--to=antoine.tenart@bootlin.com \
--cc=alexandre.belloni@bootlin.com \
--cc=allan.nielsen@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=quentin.schulz@bootlin.com \
--cc=sd@queasysnail.net \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).