All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver
@ 2020-09-29 16:13 Igor Russkikh
  2020-09-29 16:13 ` [PATCH net-next 1/3] ethtool: allow netdev driver to define phy tunables Igor Russkikh
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Igor Russkikh @ 2020-09-29 16:13 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Jakub Kicinski, Andrew Lunn, Igor Russkikh

This series implements phy tunables settings via MAC driver callbacks.

AQC 10G devices use integrated MAC+PHY solution, where PHY is fully controlled
by MAC firmware. Therefore, it is not possible to implement separate phy driver
for these.

We use ethtool ops callbacks to implement downshift and EDPC tunables.

Igor Russkikh (3):
  ethtool: allow netdev driver to define phy tunables
  net: atlantic: implement phy downshift feature
  net: atlantic: implement media detect feature via phy tunables

 .../ethernet/aquantia/atlantic/aq_ethtool.c   | 56 +++++++++++++++++++
 .../net/ethernet/aquantia/atlantic/aq_hw.h    |  4 ++
 .../net/ethernet/aquantia/atlantic/aq_nic.c   | 40 +++++++++++++
 .../net/ethernet/aquantia/atlantic/aq_nic.h   |  4 ++
 .../atlantic/hw_atl/hw_atl_utils_fw2x.c       | 37 ++++++++++++
 .../atlantic/hw_atl2/hw_atl2_utils_fw.c       | 13 +++++
 include/linux/ethtool.h                       |  4 ++
 net/ethtool/ioctl.c                           | 37 +++++++-----
 8 files changed, 182 insertions(+), 13 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH net-next 1/3] ethtool: allow netdev driver to define phy tunables
  2020-09-29 16:13 [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver Igor Russkikh
@ 2020-09-29 16:13 ` Igor Russkikh
  2020-09-29 16:13 ` [PATCH net-next 2/3] net: atlantic: implement phy downshift feature Igor Russkikh
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 19+ messages in thread
From: Igor Russkikh @ 2020-09-29 16:13 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Jakub Kicinski, Andrew Lunn, Igor Russkikh

Define get/set phy tunable callbacks in ethtool ops.
This will allow MAC drivers with integrated PHY still to implement
these tunables.

Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
---
 include/linux/ethtool.h |  4 ++++
 net/ethtool/ioctl.c     | 37 ++++++++++++++++++++++++-------------
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 060b20f0b20f..6408b446051f 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -505,6 +505,10 @@ struct ethtool_ops {
 				      struct ethtool_fecparam *);
 	void	(*get_ethtool_phy_stats)(struct net_device *,
 					 struct ethtool_stats *, u64 *);
+	int	(*get_phy_tunable)(struct net_device *,
+				   const struct ethtool_tunable *, void *);
+	int	(*set_phy_tunable)(struct net_device *,
+				   const struct ethtool_tunable *, const void *);
 };
 
 int ethtool_check_ops(const struct ethtool_ops *ops);
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 328d15cd4006..ec2cd7aab5ad 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -2459,14 +2459,15 @@ static int ethtool_phy_tunable_valid(const struct ethtool_tunable *tuna)
 
 static int get_phy_tunable(struct net_device *dev, void __user *useraddr)
 {
-	int ret;
-	struct ethtool_tunable tuna;
 	struct phy_device *phydev = dev->phydev;
+	struct ethtool_tunable tuna;
+	bool phy_drv_tunable;
 	void *data;
+	int ret;
 
-	if (!(phydev && phydev->drv && phydev->drv->get_tunable))
+	phy_drv_tunable = phydev && phydev->drv && phydev->drv->get_tunable;
+	if (!phy_drv_tunable && !dev->ethtool_ops->get_phy_tunable)
 		return -EOPNOTSUPP;
-
 	if (copy_from_user(&tuna, useraddr, sizeof(tuna)))
 		return -EFAULT;
 	ret = ethtool_phy_tunable_valid(&tuna);
@@ -2475,9 +2476,13 @@ static int get_phy_tunable(struct net_device *dev, void __user *useraddr)
 	data = kmalloc(tuna.len, GFP_USER);
 	if (!data)
 		return -ENOMEM;
-	mutex_lock(&phydev->lock);
-	ret = phydev->drv->get_tunable(phydev, &tuna, data);
-	mutex_unlock(&phydev->lock);
+	if (phy_drv_tunable) {
+		mutex_lock(&phydev->lock);
+		ret = phydev->drv->get_tunable(phydev, &tuna, data);
+		mutex_unlock(&phydev->lock);
+	} else {
+		ret = dev->ethtool_ops->get_phy_tunable(dev, &tuna, data);
+	}
 	if (ret)
 		goto out;
 	useraddr += sizeof(tuna);
@@ -2493,12 +2498,14 @@ static int get_phy_tunable(struct net_device *dev, void __user *useraddr)
 
 static int set_phy_tunable(struct net_device *dev, void __user *useraddr)
 {
-	int ret;
-	struct ethtool_tunable tuna;
 	struct phy_device *phydev = dev->phydev;
+	struct ethtool_tunable tuna;
+	bool phy_drv_tunable;
 	void *data;
+	int ret;
 
-	if (!(phydev && phydev->drv && phydev->drv->set_tunable))
+	phy_drv_tunable = phydev && phydev->drv && phydev->drv->get_tunable;
+	if (!phy_drv_tunable && !dev->ethtool_ops->set_phy_tunable)
 		return -EOPNOTSUPP;
 	if (copy_from_user(&tuna, useraddr, sizeof(tuna)))
 		return -EFAULT;
@@ -2509,9 +2516,13 @@ static int set_phy_tunable(struct net_device *dev, void __user *useraddr)
 	data = memdup_user(useraddr, tuna.len);
 	if (IS_ERR(data))
 		return PTR_ERR(data);
-	mutex_lock(&phydev->lock);
-	ret = phydev->drv->set_tunable(phydev, &tuna, data);
-	mutex_unlock(&phydev->lock);
+	if (phy_drv_tunable) {
+		mutex_lock(&phydev->lock);
+		ret = phydev->drv->set_tunable(phydev, &tuna, data);
+		mutex_unlock(&phydev->lock);
+	} else {
+		ret = dev->ethtool_ops->set_phy_tunable(dev, &tuna, data);
+	}
 
 	kfree(data);
 	return ret;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 2/3] net: atlantic: implement phy downshift feature
  2020-09-29 16:13 [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver Igor Russkikh
  2020-09-29 16:13 ` [PATCH net-next 1/3] ethtool: allow netdev driver to define phy tunables Igor Russkikh
@ 2020-09-29 16:13 ` Igor Russkikh
  2020-09-29 17:10   ` Andrew Lunn
  2020-09-29 16:13 ` [PATCH net-next 3/3] net: atlantic: implement media detect feature via phy tunables Igor Russkikh
  2020-09-29 17:04 ` [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver Andrew Lunn
  3 siblings, 1 reply; 19+ messages in thread
From: Igor Russkikh @ 2020-09-29 16:13 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Jakub Kicinski, Andrew Lunn, Igor Russkikh

PHY downshift allows phy to try renegotiate if link is unstable
and can carry higher speed.

AQC devices has integrated PHY which is controlled by MAC firmware.
Thus, driver defines new ethtool callbacks to implement phy tunables
via netdev.

Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
---
 .../ethernet/aquantia/atlantic/aq_ethtool.c   | 42 +++++++++++++++++++
 .../net/ethernet/aquantia/atlantic/aq_hw.h    |  2 +
 .../net/ethernet/aquantia/atlantic/aq_nic.c   | 24 +++++++++++
 .../net/ethernet/aquantia/atlantic/aq_nic.h   |  2 +
 .../atlantic/hw_atl/hw_atl_utils_fw2x.c       | 22 ++++++++++
 .../atlantic/hw_atl2/hw_atl2_utils_fw.c       | 13 ++++++
 6 files changed, 105 insertions(+)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c b/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
index 1ab5314c4c1b..1a6732e6bf54 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
@@ -917,6 +917,46 @@ static int aq_ethtool_set_priv_flags(struct net_device *ndev, u32 flags)
 	return ret;
 }
 
+static int aq_ethtool_get_phy_tunable(struct net_device *ndev,
+				      const struct ethtool_tunable *tuna, void *data)
+{
+	struct aq_nic_s *aq_nic = netdev_priv(ndev);
+
+	switch (tuna->id) {
+	case ETHTOOL_PHY_DOWNSHIFT: {
+		u8 *val = data;
+
+		*val = (u8)aq_nic->aq_nic_cfg.downshift_counter;
+		break;
+	}
+	default:
+		return -EOPNOTSUPP;
+	}
+
+	return 0;
+}
+
+static int aq_ethtool_set_phy_tunable(struct net_device *ndev,
+				      const struct ethtool_tunable *tuna, const void *data)
+{
+	int err = -EOPNOTSUPP;
+	struct aq_nic_s *aq_nic = netdev_priv(ndev);
+
+	switch (tuna->id) {
+	case ETHTOOL_PHY_DOWNSHIFT: {
+		const u8 *val = data;
+
+		aq_nic->aq_nic_cfg.downshift_counter = *val;
+		err = aq_nic_set_downshift(aq_nic);
+		break;
+	}
+	default:
+		break;
+	}
+
+	return err;
+}
+
 const struct ethtool_ops aq_ethtool_ops = {
 	.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
 				     ETHTOOL_COALESCE_MAX_FRAMES,
@@ -952,4 +992,6 @@ const struct ethtool_ops aq_ethtool_ops = {
 	.get_coalesce	     = aq_ethtool_get_coalesce,
 	.set_coalesce	     = aq_ethtool_set_coalesce,
 	.get_ts_info         = aq_ethtool_get_ts_info,
+	.get_phy_tunable     = aq_ethtool_get_phy_tunable,
+	.set_phy_tunable     = aq_ethtool_set_phy_tunable,
 };
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
index 7df74015fbc9..a17077b0dd49 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
@@ -386,6 +386,8 @@ struct aq_fw_ops {
 	int (*get_eee_rate)(struct aq_hw_s *self, u32 *rate,
 			    u32 *supported_rates);
 
+	int (*set_downshift)(struct aq_hw_s *self, u32 counter);
+
 	u32 (*get_link_capabilities)(struct aq_hw_s *self);
 
 	int (*send_macsec_req)(struct aq_hw_s *self,
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
index c6bdf1d677d1..f02d193cf609 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
@@ -405,6 +405,7 @@ int aq_nic_init(struct aq_nic_s *self)
 	mutex_unlock(&self->fwreq_mutex);
 	if (err < 0)
 		goto err_exit;
+	aq_nic_set_downshift(self);
 
 	err = self->aq_hw_ops->hw_init(self->aq_hw,
 				       aq_nic_get_ndev(self)->dev_addr);
@@ -1398,6 +1399,29 @@ void aq_nic_release_filter(struct aq_nic_s *self, enum aq_rx_filter_type type,
 	}
 }
 
+int aq_nic_set_downshift(struct aq_nic_s *self)
+{
+	int err = 0;
+	struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg;
+
+	if (!self->aq_fw_ops->set_downshift)
+		return -EOPNOTSUPP;
+
+	if (ATL_HW_IS_CHIP_FEATURE(self->aq_hw, ANTIGUA)) {
+		if (cfg->downshift_counter > 15)
+			cfg->downshift_counter = 15;
+	} else {
+		if (cfg->downshift_counter > 255)
+			cfg->downshift_counter = 255;
+	}
+
+	mutex_lock(&self->fwreq_mutex);
+	err = self->aq_fw_ops->set_downshift(self->aq_hw, cfg->downshift_counter);
+	mutex_unlock(&self->fwreq_mutex);
+
+	return err;
+}
+
 int aq_nic_setup_tc_mqprio(struct aq_nic_s *self, u32 tcs, u8 *prio_tc_map)
 {
 	struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg;
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
index eb7d8430f2f5..0ab29890cb4c 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
@@ -62,6 +62,7 @@ struct aq_nic_cfg_s {
 	bool is_lro;
 	bool is_qos;
 	bool is_ptp;
+	int downshift_counter;
 	enum aq_tc_mode tc_mode;
 	u32 priv_flags;
 	u8  tcs;
@@ -195,6 +196,7 @@ int aq_nic_set_link_ksettings(struct aq_nic_s *self,
 struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self);
 u32 aq_nic_get_fw_version(struct aq_nic_s *self);
 int aq_nic_set_loopback(struct aq_nic_s *self);
+int aq_nic_set_downshift(struct aq_nic_s *self);
 int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self);
 void aq_nic_shutdown(struct aq_nic_s *self);
 u8 aq_nic_reserve_filter(struct aq_nic_s *self, enum aq_rx_filter_type type);
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c
index 93c06dfa6c55..09500a95380b 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c
@@ -612,6 +612,27 @@ static u32 aq_fw2x_state2_get(struct aq_hw_s *self)
 	return aq_hw_read_reg(self, HW_ATL_FW2X_MPI_STATE2_ADDR);
 }
 
+static int aq_fw2x_set_downshift(struct aq_hw_s *self, u32 counter)
+{
+	int err = 0;
+	u32 mpi_opts;
+	u32 offset;
+
+	offset = offsetof(struct hw_atl_utils_settings, downshift_retry_count);
+	err = hw_atl_write_fwsettings_dwords(self, offset, &counter, 1);
+	if (err)
+		return err;
+
+	mpi_opts = aq_hw_read_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR);
+	if (counter)
+		mpi_opts |= HW_ATL_FW2X_CTRL_DOWNSHIFT;
+	else
+		mpi_opts &= ~HW_ATL_FW2X_CTRL_DOWNSHIFT;
+	aq_hw_write_reg(self, HW_ATL_FW2X_MPI_CONTROL2_ADDR, mpi_opts);
+
+	return err;
+}
+
 static u32 aq_fw2x_get_link_capabilities(struct aq_hw_s *self)
 {
 	int err = 0;
@@ -692,6 +713,7 @@ const struct aq_fw_ops aq_fw_2x_ops = {
 	.enable_ptp         = aq_fw3x_enable_ptp,
 	.led_control        = aq_fw2x_led_control,
 	.set_phyloopback    = aq_fw2x_set_phyloopback,
+	.set_downshift      = aq_fw2x_set_downshift,
 	.adjust_ptp         = aq_fw3x_adjust_ptp,
 	.get_link_capabilities = aq_fw2x_get_link_capabilities,
 	.send_macsec_req    = aq_fw2x_send_macsec_req,
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c
index 85628acbcc1d..dd259c8f2f4f 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_utils_fw.c
@@ -519,6 +519,18 @@ int hw_atl2_utils_get_action_resolve_table_caps(struct aq_hw_s *self,
 	return 0;
 }
 
+static int aq_a2_fw_set_downshift(struct aq_hw_s *self, u32 counter)
+{
+	struct link_options_s link_options;
+
+	hw_atl2_shared_buffer_get(self, link_options, link_options);
+	link_options.downshift = !!counter;
+	link_options.downshift_retry = counter;
+	hw_atl2_shared_buffer_write(self, link_options, link_options);
+
+	return hw_atl2_shared_buffer_finish_ack(self);
+}
+
 const struct aq_fw_ops aq_a2_fw_ops = {
 	.init               = aq_a2_fw_init,
 	.deinit             = aq_a2_fw_deinit,
@@ -536,4 +548,5 @@ const struct aq_fw_ops aq_a2_fw_ops = {
 	.set_flow_control   = aq_a2_fw_set_flow_control,
 	.get_flow_control   = aq_a2_fw_get_flow_control,
 	.set_phyloopback    = aq_a2_fw_set_phyloopback,
+	.set_downshift      = aq_a2_fw_set_downshift,
 };
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH net-next 3/3] net: atlantic: implement media detect feature via phy tunables
  2020-09-29 16:13 [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver Igor Russkikh
  2020-09-29 16:13 ` [PATCH net-next 1/3] ethtool: allow netdev driver to define phy tunables Igor Russkikh
  2020-09-29 16:13 ` [PATCH net-next 2/3] net: atlantic: implement phy downshift feature Igor Russkikh
@ 2020-09-29 16:13 ` Igor Russkikh
  2020-09-29 17:18   ` Andrew Lunn
  2020-09-29 17:04 ` [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver Andrew Lunn
  3 siblings, 1 reply; 19+ messages in thread
From: Igor Russkikh @ 2020-09-29 16:13 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Jakub Kicinski, Andrew Lunn, Igor Russkikh

Mediadetect is another name for the EDPD (energy detect power down).
This feature allows device to save extra power when no link is available.

PHY goes into the extreme power saving mode and only periodically wakes up
and checks for the link.

The feature may increase linkup time.

Signed-off-by: Igor Russkikh <irusskikh@marvell.com>
---
 .../net/ethernet/aquantia/atlantic/aq_ethtool.c  | 14 ++++++++++++++
 drivers/net/ethernet/aquantia/atlantic/aq_hw.h   |  2 ++
 drivers/net/ethernet/aquantia/atlantic/aq_nic.c  | 16 ++++++++++++++++
 drivers/net/ethernet/aquantia/atlantic/aq_nic.h  |  2 ++
 .../aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c | 15 +++++++++++++++
 5 files changed, 49 insertions(+)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c b/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
index 1a6732e6bf54..7c38f3ab073a 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c
@@ -923,6 +923,12 @@ static int aq_ethtool_get_phy_tunable(struct net_device *ndev,
 	struct aq_nic_s *aq_nic = netdev_priv(ndev);
 
 	switch (tuna->id) {
+	case ETHTOOL_PHY_EDPD: {
+		u16 *val = data;
+
+		*val = (u16)aq_nic->aq_nic_cfg.is_media_detect;
+		break;
+	}
 	case ETHTOOL_PHY_DOWNSHIFT: {
 		u8 *val = data;
 
@@ -943,6 +949,14 @@ static int aq_ethtool_set_phy_tunable(struct net_device *ndev,
 	struct aq_nic_s *aq_nic = netdev_priv(ndev);
 
 	switch (tuna->id) {
+	case ETHTOOL_PHY_EDPD: {
+		const u16 *val = data;
+
+		/* msecs plays no role - configuration is always fixed in PHY */
+		aq_nic->aq_nic_cfg.is_media_detect = *val ? 1 : 0;
+		err = aq_nic_set_media_detect(aq_nic);
+		break;
+	}
 	case ETHTOOL_PHY_DOWNSHIFT: {
 		const u8 *val = data;
 
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
index a17077b0dd49..77a01cf2530e 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_hw.h
@@ -388,6 +388,8 @@ struct aq_fw_ops {
 
 	int (*set_downshift)(struct aq_hw_s *self, u32 counter);
 
+	int (*set_media_detect)(struct aq_hw_s *self, bool enable);
+
 	u32 (*get_link_capabilities)(struct aq_hw_s *self);
 
 	int (*send_macsec_req)(struct aq_hw_s *self,
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
index f02d193cf609..a0e858c14769 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
@@ -405,6 +405,7 @@ int aq_nic_init(struct aq_nic_s *self)
 	mutex_unlock(&self->fwreq_mutex);
 	if (err < 0)
 		goto err_exit;
+	aq_nic_set_media_detect(self);
 	aq_nic_set_downshift(self);
 
 	err = self->aq_hw_ops->hw_init(self->aq_hw,
@@ -1422,6 +1423,21 @@ int aq_nic_set_downshift(struct aq_nic_s *self)
 	return err;
 }
 
+int aq_nic_set_media_detect(struct aq_nic_s *self)
+{
+	struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg;
+	int err = 0;
+
+	if (!self->aq_fw_ops->set_media_detect)
+		return -EOPNOTSUPP;
+
+	mutex_lock(&self->fwreq_mutex);
+	err = self->aq_fw_ops->set_media_detect(self->aq_hw, cfg->is_media_detect);
+	mutex_unlock(&self->fwreq_mutex);
+
+	return err;
+}
+
 int aq_nic_setup_tc_mqprio(struct aq_nic_s *self, u32 tcs, u8 *prio_tc_map)
 {
 	struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg;
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
index 0ab29890cb4c..9414a164bdcc 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h
@@ -62,6 +62,7 @@ struct aq_nic_cfg_s {
 	bool is_lro;
 	bool is_qos;
 	bool is_ptp;
+	bool is_media_detect;
 	int downshift_counter;
 	enum aq_tc_mode tc_mode;
 	u32 priv_flags;
@@ -197,6 +198,7 @@ struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self);
 u32 aq_nic_get_fw_version(struct aq_nic_s *self);
 int aq_nic_set_loopback(struct aq_nic_s *self);
 int aq_nic_set_downshift(struct aq_nic_s *self);
+int aq_nic_set_media_detect(struct aq_nic_s *self);
 int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self);
 void aq_nic_shutdown(struct aq_nic_s *self);
 u8 aq_nic_reserve_filter(struct aq_nic_s *self, enum aq_rx_filter_type type);
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c
index 09500a95380b..ee0c22d04935 100644
--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c
+++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils_fw2x.c
@@ -633,6 +633,20 @@ static int aq_fw2x_set_downshift(struct aq_hw_s *self, u32 counter)
 	return err;
 }
 
+static int aq_fw2x_set_media_detect(struct aq_hw_s *self, bool on)
+{
+	u32 enable;
+	u32 offset;
+
+	if (self->fw_ver_actual < HW_ATL_FW_VER_MEDIA_CONTROL)
+		return -EOPNOTSUPP;
+
+	offset = offsetof(struct hw_atl_utils_settings, media_detect);
+	enable = on;
+
+	return hw_atl_write_fwsettings_dwords(self, offset, &enable, 1);
+}
+
 static u32 aq_fw2x_get_link_capabilities(struct aq_hw_s *self)
 {
 	int err = 0;
@@ -714,6 +728,7 @@ const struct aq_fw_ops aq_fw_2x_ops = {
 	.led_control        = aq_fw2x_led_control,
 	.set_phyloopback    = aq_fw2x_set_phyloopback,
 	.set_downshift      = aq_fw2x_set_downshift,
+	.set_media_detect   = aq_fw2x_set_media_detect,
 	.adjust_ptp         = aq_fw3x_adjust_ptp,
 	.get_link_capabilities = aq_fw2x_get_link_capabilities,
 	.send_macsec_req    = aq_fw2x_send_macsec_req,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver
  2020-09-29 16:13 [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver Igor Russkikh
                   ` (2 preceding siblings ...)
  2020-09-29 16:13 ` [PATCH net-next 3/3] net: atlantic: implement media detect feature via phy tunables Igor Russkikh
@ 2020-09-29 17:04 ` Andrew Lunn
  2020-09-29 17:33   ` Jakub Kicinski
  2020-09-30 15:03   ` ethtool/phy tunables and extack (was Re: [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver) Michal Kubecek
  3 siblings, 2 replies; 19+ messages in thread
From: Andrew Lunn @ 2020-09-29 17:04 UTC (permalink / raw)
  To: Igor Russkikh; +Cc: netdev, David S . Miller, Jakub Kicinski

On Tue, Sep 29, 2020 at 07:13:04PM +0300, Igor Russkikh wrote:
> This series implements phy tunables settings via MAC driver callbacks.
> 
> AQC 10G devices use integrated MAC+PHY solution, where PHY is fully controlled
> by MAC firmware. Therefore, it is not possible to implement separate phy driver
> for these.
> 
> We use ethtool ops callbacks to implement downshift and EDPC tunables.

Hi Michal

Do you have any code to implement tunables via netlink?

This code is defining new ethtool calls. It seems like now would be a
good time to plumb in extack, so the driver can report back the valid
range of a tunable when given an unsupported value.

      Andrew

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next 2/3] net: atlantic: implement phy downshift feature
  2020-09-29 16:13 ` [PATCH net-next 2/3] net: atlantic: implement phy downshift feature Igor Russkikh
@ 2020-09-29 17:10   ` Andrew Lunn
  2020-09-30  8:34     ` Igor Russkikh
  0 siblings, 1 reply; 19+ messages in thread
From: Andrew Lunn @ 2020-09-29 17:10 UTC (permalink / raw)
  To: Igor Russkikh; +Cc: netdev, David S . Miller, Jakub Kicinski

> +int aq_nic_set_downshift(struct aq_nic_s *self)
> +{
> +	int err = 0;
> +	struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg;
> +
> +	if (!self->aq_fw_ops->set_downshift)
> +		return -EOPNOTSUPP;
> +
> +	if (ATL_HW_IS_CHIP_FEATURE(self->aq_hw, ANTIGUA)) {
> +		if (cfg->downshift_counter > 15)
> +			cfg->downshift_counter = 15;
> +	} else {
> +		if (cfg->downshift_counter > 255)
> +			cfg->downshift_counter = 255;
> +	}

Hi Igor

I think all other implementations return -EINVAL or -E2BIG or similar
when the value is not supported.

Also, given that a u8 is being passed, is cfg->downshift_counter > 255
possible? I'm not even sure 255 makes any sense. Autoneg takes around
1.5s, maybe longer. Do you really want to wait 255 * 1.5 seconds
before downshifting? Even 15*1.5 seems a long time.

	Andrew

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next 3/3] net: atlantic: implement media detect feature via phy tunables
  2020-09-29 16:13 ` [PATCH net-next 3/3] net: atlantic: implement media detect feature via phy tunables Igor Russkikh
@ 2020-09-29 17:18   ` Andrew Lunn
  2020-09-30  8:37     ` Igor Russkikh
  0 siblings, 1 reply; 19+ messages in thread
From: Andrew Lunn @ 2020-09-29 17:18 UTC (permalink / raw)
  To: Igor Russkikh; +Cc: netdev, David S . Miller, Jakub Kicinski

> @@ -923,6 +923,12 @@ static int aq_ethtool_get_phy_tunable(struct net_device *ndev,
>  	struct aq_nic_s *aq_nic = netdev_priv(ndev);
>  
>  	switch (tuna->id) {
> +	case ETHTOOL_PHY_EDPD: {
> +		u16 *val = data;
> +
> +		*val = (u16)aq_nic->aq_nic_cfg.is_media_detect;
> +		break;
> +	}
>  	case ETHTOOL_PHY_DOWNSHIFT: {
>  		u8 *val = data;
>  
> @@ -943,6 +949,14 @@ static int aq_ethtool_set_phy_tunable(struct net_device *ndev,
>  	struct aq_nic_s *aq_nic = netdev_priv(ndev);
>  
>  	switch (tuna->id) {
> +	case ETHTOOL_PHY_EDPD: {
> +		const u16 *val = data;
> +
> +		/* msecs plays no role - configuration is always fixed in PHY */
> +		aq_nic->aq_nic_cfg.is_media_detect = *val ? 1 : 0;

This is the wrong usage of the API:

include/uapi/linux/ethtool.h:

* The interval units for TX wake-up are in milliseconds, since this should
 * cover a reasonable range of intervals:
 *  - from 1 millisecond, which does not sound like much of a power-saver
 *  - to ~65 seconds which is quite a lot to wait for a link to come up when
 *    plugging a cable
 */

I guess your PHY is not hard coded to 1 millisecond? Please return the
real value. And the set call should really only allow 0, or the value
the PHY is using.

    Andrew

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver
  2020-09-29 17:04 ` [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver Andrew Lunn
@ 2020-09-29 17:33   ` Jakub Kicinski
  2020-09-29 18:47     ` Andrew Lunn
  2020-09-30 15:03   ` ethtool/phy tunables and extack (was Re: [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver) Michal Kubecek
  1 sibling, 1 reply; 19+ messages in thread
From: Jakub Kicinski @ 2020-09-29 17:33 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Igor Russkikh, netdev, David S . Miller

On Tue, 29 Sep 2020 19:04:13 +0200 Andrew Lunn wrote:
> On Tue, Sep 29, 2020 at 07:13:04PM +0300, Igor Russkikh wrote:
> > This series implements phy tunables settings via MAC driver callbacks.
> > 
> > AQC 10G devices use integrated MAC+PHY solution, where PHY is fully controlled
> > by MAC firmware. Therefore, it is not possible to implement separate phy driver
> > for these.
> > 
> > We use ethtool ops callbacks to implement downshift and EDPC tunables.  
> 
> Hi Michal
> 
> Do you have any code to implement tunables via netlink?
> 
> This code is defining new ethtool calls. It seems like now would be a
> good time to plumb in extack, so the driver can report back the valid
> range of a tunable when given an unsupported value.

Do you mean report supported range via extack? Perhaps we should have 
a real API for that kind of info? We can plumb it through to the core
for now and expose to user space once netlink comes.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver
  2020-09-29 17:33   ` Jakub Kicinski
@ 2020-09-29 18:47     ` Andrew Lunn
  2020-09-30  0:09       ` Jakub Kicinski
  0 siblings, 1 reply; 19+ messages in thread
From: Andrew Lunn @ 2020-09-29 18:47 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: Igor Russkikh, netdev, David S . Miller

> Do you mean report supported range via extack?

Yes.

811ac400ea33 ("net: phy: dp83869: Add speed optimization feature")

was merged recently. It has:

+       default:
+               phydev_err(phydev,
+                          "Downshift count must be 1, 2, 4 or 8\n");
+               return -EINVAL;

and there are more examples in PHY drivers where it would be good to
tell the uses what the valid values are. I guess most won't see this
kernel message, but if netlink ethtool printed:

Invalid Argument: Downshift count must be 1, 2, 4 or 8

it would be a lot more user friendly.

   Andrew

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver
  2020-09-29 18:47     ` Andrew Lunn
@ 2020-09-30  0:09       ` Jakub Kicinski
  2020-09-30  0:16         ` Andrew Lunn
  0 siblings, 1 reply; 19+ messages in thread
From: Jakub Kicinski @ 2020-09-30  0:09 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Igor Russkikh, netdev, David S . Miller

On Tue, 29 Sep 2020 20:47:23 +0200 Andrew Lunn wrote:
> > Do you mean report supported range via extack?  
> 
> Yes.
> 
> 811ac400ea33 ("net: phy: dp83869: Add speed optimization feature")
> 
> was merged recently. It has:
> 
> +       default:
> +               phydev_err(phydev,
> +                          "Downshift count must be 1, 2, 4 or 8\n");
> +               return -EINVAL;
> 
> and there are more examples in PHY drivers where it would be good to
> tell the uses what the valid values are. I guess most won't see this
> kernel message, but if netlink ethtool printed:
> 
> Invalid Argument: Downshift count must be 1, 2, 4 or 8
> 
> it would be a lot more user friendly.

Ah, now I recall, we already discussed this.

FWIW we could provision for the extack and just pass NULL for now?
Would that be too ugly?

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver
  2020-09-30  0:09       ` Jakub Kicinski
@ 2020-09-30  0:16         ` Andrew Lunn
  0 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2020-09-30  0:16 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: Igor Russkikh, netdev, David S . Miller

On Tue, Sep 29, 2020 at 05:09:48PM -0700, Jakub Kicinski wrote:
> On Tue, 29 Sep 2020 20:47:23 +0200 Andrew Lunn wrote:
> > > Do you mean report supported range via extack?  
> > 
> > Yes.
> > 
> > 811ac400ea33 ("net: phy: dp83869: Add speed optimization feature")
> > 
> > was merged recently. It has:
> > 
> > +       default:
> > +               phydev_err(phydev,
> > +                          "Downshift count must be 1, 2, 4 or 8\n");
> > +               return -EINVAL;
> > 
> > and there are more examples in PHY drivers where it would be good to
> > tell the uses what the valid values are. I guess most won't see this
> > kernel message, but if netlink ethtool printed:
> > 
> > Invalid Argument: Downshift count must be 1, 2, 4 or 8
> > 
> > it would be a lot more user friendly.
> 
> Ah, now I recall, we already discussed this.
> 
> FWIW we could provision for the extack and just pass NULL for now?
> Would that be too ugly?

If Michal does not have any code lying around in a drawer, what might
be a good idea. For the old IOCTL we will need to pass a NULL anyway.

  Andrew

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next 2/3] net: atlantic: implement phy downshift feature
  2020-09-29 17:10   ` Andrew Lunn
@ 2020-09-30  8:34     ` Igor Russkikh
  0 siblings, 0 replies; 19+ messages in thread
From: Igor Russkikh @ 2020-09-30  8:34 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev, David S . Miller, Jakub Kicinski



> 
> Hi Igor
> 
> I think all other implementations return -EINVAL or -E2BIG or similar
> when the value is not supported.
> 
> Also, given that a u8 is being passed, is cfg->downshift_counter > 255
> possible? I'm not even sure 255 makes any sense. Autoneg takes around
> 1.5s, maybe longer. Do you really want to wait 255 * 1.5 seconds
> before downshifting? Even 15*1.5 seems a long time.

Hi Andrew, here I'm just blindly follow the value limits of firmware interface
(two device revisions have different counter field width here).

To make behavior consistent you are right, we probably can leave 15 max and
return EINVAL otherwise.

Igor

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next 3/3] net: atlantic: implement media detect feature via phy tunables
  2020-09-29 17:18   ` Andrew Lunn
@ 2020-09-30  8:37     ` Igor Russkikh
  2020-09-30 14:22       ` Andrew Lunn
  0 siblings, 1 reply; 19+ messages in thread
From: Igor Russkikh @ 2020-09-30  8:37 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev, David S . Miller, Jakub Kicinski


>>  	switch (tuna->id) {
>> +	case ETHTOOL_PHY_EDPD: {
>> +		const u16 *val = data;
>> +
>> +		/* msecs plays no role - configuration is always fixed in
> PHY */
>> +		aq_nic->aq_nic_cfg.is_media_detect = *val ? 1 : 0;
> 
> This is the wrong usage of the API:
> 
> include/uapi/linux/ethtool.h:
> 
> * The interval units for TX wake-up are in milliseconds, since this should
>  * cover a reasonable range of intervals:
>  *  - from 1 millisecond, which does not sound like much of a power-saver
>  *  - to ~65 seconds which is quite a lot to wait for a link to come up
> when
>  *    plugging a cable
>  */
> 
> I guess your PHY is not hard coded to 1 millisecond? Please return the
> real value. And the set call should really only allow 0, or the value
> the PHY is using.

The problem here is that FW interface only allows us to switch this mode on or
off. We can't control the interval value for this device.
Thus, we only can enable it, or disable. Basically ignoring the interval value.

Igor

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH net-next 3/3] net: atlantic: implement media detect feature via phy tunables
  2020-09-30  8:37     ` Igor Russkikh
@ 2020-09-30 14:22       ` Andrew Lunn
  2020-10-01 10:18         ` [EXT] " Igor Russkikh
  0 siblings, 1 reply; 19+ messages in thread
From: Andrew Lunn @ 2020-09-30 14:22 UTC (permalink / raw)
  To: Igor Russkikh; +Cc: netdev, David S . Miller, Jakub Kicinski

> The problem here is that FW interface only allows us to switch this mode on or
> off. We can't control the interval value for this device.
> Thus, we only can enable it, or disable. Basically ignoring the interval value.

Hi Igor

Since this is your own PHY, not some magical black box, i assume you
actually know what value it is using? It probably even lists it in the
data sheet.

So just hard code that value in the driver. That has got to be better
than saying the incorrect value of 1ms.

   Andrew

^ permalink raw reply	[flat|nested] 19+ messages in thread

* ethtool/phy tunables and extack (was Re: [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver)
  2020-09-29 17:04 ` [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver Andrew Lunn
  2020-09-29 17:33   ` Jakub Kicinski
@ 2020-09-30 15:03   ` Michal Kubecek
  2020-09-30 15:16     ` Andrew Lunn
  1 sibling, 1 reply; 19+ messages in thread
From: Michal Kubecek @ 2020-09-30 15:03 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Igor Russkikh, netdev, David S . Miller, Jakub Kicinski

On Tue, Sep 29, 2020 at 07:04:13PM +0200, Andrew Lunn wrote:
> On Tue, Sep 29, 2020 at 07:13:04PM +0300, Igor Russkikh wrote:
> > This series implements phy tunables settings via MAC driver callbacks.
> > 
> > AQC 10G devices use integrated MAC+PHY solution, where PHY is fully controlled
> > by MAC firmware. Therefore, it is not possible to implement separate phy driver
> > for these.
> > 
> > We use ethtool ops callbacks to implement downshift and EDPC tunables.
> 
> Hi Michal
> 
> Do you have any code to implement tunables via netlink?

I already tried to open a discussion about tunables once but it somehow
died before we got somewhere and I'm not sure I was fully understood
then.

My view is that tunables (both the "ethtool" ones and PHY tunables) were
a workaround for lack of extensibility of the ioctl interface where
adding a new parameter to existing command was often impossible while
adding a tunable was relatively easy. But the implementation doesn't
really scale well so a rework would be necessary if the number of
tunables were to grow to the order of tens. Moreover, recently it
surfaced that while we have type id for string tunables, nobody seems to
know how exactly are they supposed to work.

With netlink, we can add new attributes easily and I don't see much
advantage in adding more tunables (assorted heap of unrelated values)
over adding either attributes to existing commands or new commands (for
new types of information or settings). PHY tunables could be probably
grouped into one command. Rx and Tx copybreak could belong together as
"skb handling parameters" (?) and I've seen someone proposing another
parameter (IIRC related to head split) which would also belong there.
I'm not sure about ETHTOOL_PFC_PREVENTION_TOUT.

What would IMHO justify a similar concept to current tunables would be
device (driver) specific tunables, i.e. generalization of private flags
to other data types. But as I said before, I'm not sure if we want such
feature as it would be probably too tempting to abuse by NIC vendors.

> This code is defining new ethtool calls. It seems like now would be a
> good time to plumb in extack, so the driver can report back the valid
> range of a tunable when given an unsupported value.

Adding an extack pointer to new ethtool ops seems like the most natural
solution. For existing ethtool ops, David Miller suggested that as all
of them are called under RTNL lock (and we cannot easily git rid of it
after many years of such guarantee), we could in fact use a global
variable. Or maybe rather a helper function.

Another question is how to allow ethtool ops setting not only the text
message but also the offending attribute. So far the idea I was able to
come with is that the ethtool_ops callback could set one (or two in case
of nested requests, we probably won't need more) integers to identify
the attribute (or top level and nested) and caller would translate them
to a pointer into the request message.

Michal

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ethtool/phy tunables and extack (was Re: [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver)
  2020-09-30 15:03   ` ethtool/phy tunables and extack (was Re: [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver) Michal Kubecek
@ 2020-09-30 15:16     ` Andrew Lunn
  2020-09-30 15:31       ` Michal Kubecek
  0 siblings, 1 reply; 19+ messages in thread
From: Andrew Lunn @ 2020-09-30 15:16 UTC (permalink / raw)
  To: Michal Kubecek; +Cc: Igor Russkikh, netdev, David S . Miller, Jakub Kicinski

> Another question is how to allow ethtool ops setting not only the text
> message but also the offending attribute.

For PHY tunables, i don't think it is needed. The current API only
allows a single value to be passed. That seems to be enough, and it
forces us to keep tunables simple. If need be, the core could set the
attribute, since there should only be one containing the value.

	   Andrew

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: ethtool/phy tunables and extack (was Re: [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver)
  2020-09-30 15:16     ` Andrew Lunn
@ 2020-09-30 15:31       ` Michal Kubecek
  0 siblings, 0 replies; 19+ messages in thread
From: Michal Kubecek @ 2020-09-30 15:31 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Igor Russkikh, netdev, David S . Miller, Jakub Kicinski

On Wed, Sep 30, 2020 at 05:16:56PM +0200, Andrew Lunn wrote:
> > Another question is how to allow ethtool ops setting not only the text
> > message but also the offending attribute.
> 
> For PHY tunables, i don't think it is needed. The current API only
> allows a single value to be passed. That seems to be enough, and it
> forces us to keep tunables simple. If need be, the core could set the
> attribute, since there should only be one containing the value.

It probably wasn't obvious but I mean the two parts of my e-mail as
independent, i.e. the second part was rather meant as a general thought
on allowing drivers to report errors/warnings via extack, not specific
to PHY tunables.

Michal

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [EXT] Re: [PATCH net-next 3/3] net: atlantic: implement media detect feature via phy tunables
  2020-09-30 14:22       ` Andrew Lunn
@ 2020-10-01 10:18         ` Igor Russkikh
  2020-10-01 12:56           ` Andrew Lunn
  0 siblings, 1 reply; 19+ messages in thread
From: Igor Russkikh @ 2020-10-01 10:18 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev, David S . Miller, Jakub Kicinski

Hi Andrew,

> Since this is your own PHY, not some magical black box, i assume you
> actually know what value it is using? It probably even lists it in the
> data sheet.
> 
> So just hard code that value in the driver. That has got to be better
> than saying the incorrect value of 1ms.

You mean always return that value in get_, and ignore what we get in set_ ?
That could be done, will investigate.

Thanks for the review,
  Igor

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [EXT] Re: [PATCH net-next 3/3] net: atlantic: implement media detect feature via phy tunables
  2020-10-01 10:18         ` [EXT] " Igor Russkikh
@ 2020-10-01 12:56           ` Andrew Lunn
  0 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2020-10-01 12:56 UTC (permalink / raw)
  To: Igor Russkikh; +Cc: netdev, David S . Miller, Jakub Kicinski

On Thu, Oct 01, 2020 at 01:18:06PM +0300, Igor Russkikh wrote:
> Hi Andrew,
> 
> > Since this is your own PHY, not some magical black box, i assume you
> > actually know what value it is using? It probably even lists it in the
> > data sheet.
> > 
> > So just hard code that value in the driver. That has got to be better
> > than saying the incorrect value of 1ms.
> 
> You mean always return that value in get_, and ignore what we get in set_ ?
> That could be done, will investigate.

You should validate the set as well. Only two values are valid, 0 to
turn the feature off, and whatever the firmware is hard coded with.

This is where extack would be very useful. When the user initially
tries to set it to 42, you can return -EINVAL, plus a message listing
the acceptable values. The best you can do at the moment is write the
text to the kernel log.

    Andrew

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2020-10-01 12:57 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 16:13 [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver Igor Russkikh
2020-09-29 16:13 ` [PATCH net-next 1/3] ethtool: allow netdev driver to define phy tunables Igor Russkikh
2020-09-29 16:13 ` [PATCH net-next 2/3] net: atlantic: implement phy downshift feature Igor Russkikh
2020-09-29 17:10   ` Andrew Lunn
2020-09-30  8:34     ` Igor Russkikh
2020-09-29 16:13 ` [PATCH net-next 3/3] net: atlantic: implement media detect feature via phy tunables Igor Russkikh
2020-09-29 17:18   ` Andrew Lunn
2020-09-30  8:37     ` Igor Russkikh
2020-09-30 14:22       ` Andrew Lunn
2020-10-01 10:18         ` [EXT] " Igor Russkikh
2020-10-01 12:56           ` Andrew Lunn
2020-09-29 17:04 ` [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver Andrew Lunn
2020-09-29 17:33   ` Jakub Kicinski
2020-09-29 18:47     ` Andrew Lunn
2020-09-30  0:09       ` Jakub Kicinski
2020-09-30  0:16         ` Andrew Lunn
2020-09-30 15:03   ` ethtool/phy tunables and extack (was Re: [PATCH net-next 0/3] net: atlantic: phy tunables from mac driver) Michal Kubecek
2020-09-30 15:16     ` Andrew Lunn
2020-09-30 15:31       ` Michal Kubecek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.