From: Hariprasad Kelam <hkelam@marvell.com>
To: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <kuba@kernel.org>, <davem@davemloft.net>, <sgoutham@marvell.com>,
<lcherian@marvell.com>, <gakula@marvell.com>,
<jerinj@marvell.com>, <sbhatta@marvell.com>, <hkelam@marvell.com>
Subject: [net-next PATCH 2/8] octeontx2-pf: Add ethtool priv flag to control PAM4 on/off
Date: Sun, 21 Mar 2021 17:39:52 +0530 [thread overview]
Message-ID: <20210321120958.17531-3-hkelam@marvell.com> (raw)
In-Reply-To: <20210321120958.17531-1-hkelam@marvell.com>
From: Felix Manlunas <fmanlunas@marvell.com>
For PHYs that support changing modulation type (NRZ or PAM4), enable these
commands:
ethtool --set-priv-flags ethX pam4 on
ethtool --set-priv-flags ethX pam4 off # means NRZ modulation
ethtool --show-priv-flags ethX
Signed-off-by: Felix Manlunas <fmanlunas@marvell.com>
Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
---
.../marvell/octeontx2/nic/otx2_ethtool.c | 62 +++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
index f4962a97a07..552ecae1dbe 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
@@ -22,6 +22,11 @@
#define DRV_NAME "octeontx2-nicpf"
#define DRV_VF_NAME "octeontx2-nicvf"
+static const char otx2_priv_flags_strings[][ETH_GSTRING_LEN] = {
+#define OTX2_PRIV_FLAGS_PAM4 BIT(0)
+ "pam4",
+};
+
struct otx2_stat {
char name[ETH_GSTRING_LEN];
unsigned int index;
@@ -112,6 +117,12 @@ static void otx2_get_strings(struct net_device *netdev, u32 sset, u8 *data)
struct otx2_nic *pfvf = netdev_priv(netdev);
int stats;
+ if (sset == ETH_SS_PRIV_FLAGS) {
+ memcpy(data, otx2_priv_flags_strings,
+ ARRAY_SIZE(otx2_priv_flags_strings) * ETH_GSTRING_LEN);
+ return;
+ }
+
if (sset != ETH_SS_STATS)
return;
@@ -250,6 +261,9 @@ static int otx2_get_sset_count(struct net_device *netdev, int sset)
struct otx2_nic *pfvf = netdev_priv(netdev);
int qstats_count;
+ if (sset == ETH_SS_PRIV_FLAGS)
+ return ARRAY_SIZE(otx2_priv_flags_strings);
+
if (sset != ETH_SS_STATS)
return -EINVAL;
@@ -1219,6 +1233,52 @@ static int otx2_set_link_ksettings(struct net_device *netdev,
return err;
}
+static int otx2_set_priv_flags(struct net_device *netdev, u32 priv_flags)
+{
+ struct otx2_nic *pfvf = netdev_priv(netdev);
+ struct cgx_phy_mod_type *req;
+ struct cgx_fw_data *fwd;
+ int rc = -ENOMEM;
+
+ fwd = otx2_get_fwdata(pfvf);
+ if (IS_ERR(fwd))
+ return PTR_ERR(fwd);
+
+ /* ret here if phy does not support this feature */
+ if (!fwd->fwdata.phy.misc.can_change_mod_type)
+ return -EOPNOTSUPP;
+
+ mutex_lock(&pfvf->mbox.lock);
+ req = otx2_mbox_alloc_msg_cgx_set_phy_mod_type(&pfvf->mbox);
+ if (!req)
+ goto end;
+
+ req->mod = priv_flags & OTX2_PRIV_FLAGS_PAM4;
+ if (!otx2_sync_mbox_msg(&pfvf->mbox))
+ rc = 0;
+
+end:
+ mutex_unlock(&pfvf->mbox.lock);
+ return rc;
+}
+
+static u32 otx2_get_priv_flags(struct net_device *netdev)
+{
+ struct otx2_nic *pfvf = netdev_priv(netdev);
+ struct cgx_fw_data *rsp;
+ u32 priv_flags = 0;
+
+ rsp = otx2_get_fwdata(pfvf);
+
+ if (IS_ERR(rsp))
+ return 0;
+
+ if (rsp->fwdata.phy.misc.mod_type)
+ priv_flags |= OTX2_PRIV_FLAGS_PAM4;
+
+ return priv_flags;
+}
+
static const struct ethtool_ops otx2_ethtool_ops = {
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
ETHTOOL_COALESCE_MAX_FRAMES,
@@ -1250,6 +1310,8 @@ static const struct ethtool_ops otx2_ethtool_ops = {
.set_fecparam = otx2_set_fecparam,
.get_link_ksettings = otx2_get_link_ksettings,
.set_link_ksettings = otx2_set_link_ksettings,
+ .set_priv_flags = otx2_set_priv_flags,
+ .get_priv_flags = otx2_get_priv_flags,
};
void otx2_set_ethtool_ops(struct net_device *netdev)
--
2.17.1
next prev parent reply other threads:[~2021-03-21 12:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-21 12:09 [net-next PATCH 0/8] configuration support for switch headers & phy Hariprasad Kelam
2021-03-21 12:09 ` [net-next PATCH 1/8] octeontx2-af: Add new CGX_CMDs to set and get PHY modulation type Hariprasad Kelam
2021-03-21 12:09 ` Hariprasad Kelam [this message]
2021-03-21 14:27 ` [net-next PATCH 2/8] octeontx2-pf: Add ethtool priv flag to control PAM4 on/off Andrew Lunn
2021-03-21 12:09 ` [net-next PATCH 3/8] octeontx2-af: Support for parsing pkts with switch headers Hariprasad Kelam
2021-03-21 12:09 ` [net-next PATCH 4/8] octeontx2-af: Do not allow VFs to overwrite PKIND config Hariprasad Kelam
2021-03-21 12:09 ` [net-next PATCH 5/8] octeontx2-af: Put CGX LMAC also in Higig2 mode Hariprasad Kelam
2021-03-21 12:09 ` [net-next PATCH 6/8] octeontx2-pf: Support to enable EDSA/Higig2 pkts parsing Hariprasad Kelam
2021-03-21 12:09 ` [net-next PATCH 7/8] octeontx2-af: Add flow steering support for FDSA tag Hariprasad Kelam
2021-03-21 12:09 ` [net-next PATCH 8/8] octeontx2-pf: Add ntuple filter support for FDSA Hariprasad Kelam
2021-03-21 14:15 ` [net-next PATCH 0/8] configuration support for switch headers & phy Andrew Lunn
2021-03-23 18:59 [net-next PATCH 2/8] octeontx2-pf: Add ethtool priv flag to control PAM4 on/off Hariprasad Kelam
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=20210321120958.17531-3-hkelam@marvell.com \
--to=hkelam@marvell.com \
--cc=davem@davemloft.net \
--cc=gakula@marvell.com \
--cc=jerinj@marvell.com \
--cc=kuba@kernel.org \
--cc=lcherian@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sbhatta@marvell.com \
--cc=sgoutham@marvell.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
all inboxes | Powered by JetHome®