Netdev List
 help / color / mirror / Atom feed
* [net 3/9] net/mlx5e: Avoid dealing with vport representors if not being e-switch manager
From: Saeed Mahameed @ 2018-06-27  0:21 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Or Gerlitz, Saeed Mahameed
In-Reply-To: <20180627002118.9856-1-saeedm@mellanox.com>

From: Or Gerlitz <ogerlitz@mellanox.com>

In smartnic env, the host (PF) driver might not be an e-switch
manager, hence the switchdev mode representors are running on
the embedded cpu (EC) and not at the host.

As such, we should avoid dealing with vport representors if
not being esw manager.

While here, make sure to disallow eswitch switchdev related
setups through devlink if we are not esw managers.

Fixes: cb67b832921c ('net/mlx5e: Introduce SRIOV VF representors')
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Eli Cohen <eli@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c    | 12 ++++++------
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c     |  2 +-
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c   |  4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 56c1b6f5593e..dae4156a710d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2846,7 +2846,7 @@ void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
 	mlx5e_activate_channels(&priv->channels);
 	netif_tx_start_all_queues(priv->netdev);
 
-	if (MLX5_VPORT_MANAGER(priv->mdev))
+	if (MLX5_ESWITCH_MANAGER(priv->mdev))
 		mlx5e_add_sqs_fwd_rules(priv);
 
 	mlx5e_wait_channels_min_rx_wqes(&priv->channels);
@@ -2857,7 +2857,7 @@ void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)
 {
 	mlx5e_redirect_rqts_to_drop(priv);
 
-	if (MLX5_VPORT_MANAGER(priv->mdev))
+	if (MLX5_ESWITCH_MANAGER(priv->mdev))
 		mlx5e_remove_sqs_fwd_rules(priv);
 
 	/* FIXME: This is a W/A only for tx timeout watch dog false alarm when
@@ -4597,7 +4597,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
 	mlx5e_set_netdev_dev_addr(netdev);
 
 #if IS_ENABLED(CONFIG_MLX5_ESWITCH)
-	if (MLX5_VPORT_MANAGER(mdev))
+	if (MLX5_ESWITCH_MANAGER(mdev))
 		netdev->switchdev_ops = &mlx5e_switchdev_ops;
 #endif
 
@@ -4753,7 +4753,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
 
 	mlx5e_enable_async_events(priv);
 
-	if (MLX5_VPORT_MANAGER(priv->mdev))
+	if (MLX5_ESWITCH_MANAGER(priv->mdev))
 		mlx5e_register_vport_reps(priv);
 
 	if (netdev->reg_state != NETREG_REGISTERED)
@@ -4788,7 +4788,7 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
 
 	queue_work(priv->wq, &priv->set_rx_mode_work);
 
-	if (MLX5_VPORT_MANAGER(priv->mdev))
+	if (MLX5_ESWITCH_MANAGER(priv->mdev))
 		mlx5e_unregister_vport_reps(priv);
 
 	mlx5e_disable_async_events(priv);
@@ -4972,7 +4972,7 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
 		return NULL;
 
 #ifdef CONFIG_MLX5_ESWITCH
-	if (MLX5_VPORT_MANAGER(mdev)) {
+	if (MLX5_ESWITCH_MANAGER(mdev)) {
 		rpriv = mlx5e_alloc_nic_rep_priv(mdev);
 		if (!rpriv) {
 			mlx5_core_warn(mdev, "Failed to alloc NIC rep priv data\n");
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 60236f73373c..2b8040a3cdbd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -823,7 +823,7 @@ bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv)
 	struct mlx5e_rep_priv *rpriv = priv->ppriv;
 	struct mlx5_eswitch_rep *rep;
 
-	if (!MLX5_CAP_GEN(priv->mdev, vport_group_manager))
+	if (!MLX5_ESWITCH_MANAGER(priv->mdev))
 		return false;
 
 	rep = rpriv->rep;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index cecd201f0b73..91f1209886ff 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -1079,8 +1079,8 @@ static int mlx5_devlink_eswitch_check(struct devlink *devlink)
 	if (MLX5_CAP_GEN(dev, port_type) != MLX5_CAP_PORT_TYPE_ETH)
 		return -EOPNOTSUPP;
 
-	if (!MLX5_CAP_GEN(dev, vport_group_manager))
-		return -EOPNOTSUPP;
+	if(!MLX5_ESWITCH_MANAGER(dev))
+		return -EPERM;
 
 	if (dev->priv.eswitch->mode == SRIOV_NONE)
 		return -EOPNOTSUPP;
-- 
2.17.0

^ permalink raw reply related

* [net 2/9] net/mlx5: E-Switch, Avoid setup attempt if not being e-switch manager
From: Saeed Mahameed @ 2018-06-27  0:21 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Or Gerlitz, Saeed Mahameed
In-Reply-To: <20180627002118.9856-1-saeedm@mellanox.com>

From: Or Gerlitz <ogerlitz@mellanox.com>

In smartnic env, the host (PF) driver might not be an e-switch
manager, hence the FW will err on driver attempts to deal with
setting/unsetting the eswitch and as a result the overall setup
of sriov will fail.

Fix that by avoiding the operation if e-switch management is not
allowed for this driver instance. While here, move to use the
correct name for the esw manager capability name.

Fixes: 81848731ff40 ('net/mlx5: E-Switch, Add SR-IOV (FDB) support')
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reported-by: Guy Kushnir <guyk@mellanox.com>
Reviewed-by: Eli Cohen <eli@melloanox.com>
Tested-by: Eli Cohen <eli@melloanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c  | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 3 ++-
 drivers/net/ethernet/mellanox/mlx5/core/fw.c      | 5 +++--
 drivers/net/ethernet/mellanox/mlx5/core/sriov.c   | 7 ++++++-
 include/linux/mlx5/eswitch.h                      | 2 ++
 include/linux/mlx5/mlx5_ifc.h                     | 2 +-
 7 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 378ad74518ec..60236f73373c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -839,7 +839,7 @@ static bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv)
 	struct mlx5e_rep_priv *rpriv = priv->ppriv;
 	struct mlx5_eswitch_rep *rep;
 
-	if (!MLX5_CAP_GEN(priv->mdev, eswitch_flow_table))
+	if (!MLX5_ESWITCH_MANAGER(priv->mdev))
 		return false;
 
 	rep = rpriv->rep;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index f63dfbcd29fe..103fd6a0cc65 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1604,7 +1604,7 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
 	if (!ESW_ALLOWED(esw))
 		return 0;
 
-	if (!MLX5_CAP_GEN(esw->dev, eswitch_flow_table) ||
+	if (!MLX5_ESWITCH_MANAGER(esw->dev) ||
 	    !MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, ft_support)) {
 		esw_warn(esw->dev, "E-Switch FDB is not supported, aborting ...\n");
 		return -EOPNOTSUPP;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
index 49a75d31185e..f1a86cea86a0 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
@@ -32,6 +32,7 @@
 
 #include <linux/mutex.h>
 #include <linux/mlx5/driver.h>
+#include <linux/mlx5/eswitch.h>
 
 #include "mlx5_core.h"
 #include "fs_core.h"
@@ -2652,7 +2653,7 @@ int mlx5_init_fs(struct mlx5_core_dev *dev)
 			goto err;
 	}
 
-	if (MLX5_CAP_GEN(dev, eswitch_flow_table)) {
+	if (MLX5_ESWITCH_MANAGER(dev)) {
 		if (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, ft_support)) {
 			err = init_fdb_root_ns(steering);
 			if (err)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw.c b/drivers/net/ethernet/mellanox/mlx5/core/fw.c
index afd9f4fa22f4..41ad24f0de2c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fw.c
@@ -32,6 +32,7 @@
 
 #include <linux/mlx5/driver.h>
 #include <linux/mlx5/cmd.h>
+#include <linux/mlx5/eswitch.h>
 #include <linux/module.h>
 #include "mlx5_core.h"
 #include "../../mlxfw/mlxfw.h"
@@ -159,13 +160,13 @@ int mlx5_query_hca_caps(struct mlx5_core_dev *dev)
 	}
 
 	if (MLX5_CAP_GEN(dev, vport_group_manager) &&
-	    MLX5_CAP_GEN(dev, eswitch_flow_table)) {
+	    MLX5_ESWITCH_MANAGER(dev)) {
 		err = mlx5_core_get_caps(dev, MLX5_CAP_ESWITCH_FLOW_TABLE);
 		if (err)
 			return err;
 	}
 
-	if (MLX5_CAP_GEN(dev, eswitch_flow_table)) {
+	if (MLX5_ESWITCH_MANAGER(dev)) {
 		err = mlx5_core_get_caps(dev, MLX5_CAP_ESWITCH);
 		if (err)
 			return err;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sriov.c b/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
index 2a8b529ce6dd..a0674962f02c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/sriov.c
@@ -88,6 +88,9 @@ static int mlx5_device_enable_sriov(struct mlx5_core_dev *dev, int num_vfs)
 		return -EBUSY;
 	}
 
+	if (!MLX5_ESWITCH_MANAGER(dev))
+		goto enable_vfs_hca;
+
 	err = mlx5_eswitch_enable_sriov(dev->priv.eswitch, num_vfs, SRIOV_LEGACY);
 	if (err) {
 		mlx5_core_warn(dev,
@@ -95,6 +98,7 @@ static int mlx5_device_enable_sriov(struct mlx5_core_dev *dev, int num_vfs)
 		return err;
 	}
 
+enable_vfs_hca:
 	for (vf = 0; vf < num_vfs; vf++) {
 		err = mlx5_core_enable_hca(dev, vf + 1);
 		if (err) {
@@ -140,7 +144,8 @@ static void mlx5_device_disable_sriov(struct mlx5_core_dev *dev)
 	}
 
 out:
-	mlx5_eswitch_disable_sriov(dev->priv.eswitch);
+	if (MLX5_ESWITCH_MANAGER(dev))
+		mlx5_eswitch_disable_sriov(dev->priv.eswitch);
 
 	if (mlx5_wait_for_vf_pages(dev))
 		mlx5_core_warn(dev, "timeout reclaiming VFs pages\n");
diff --git a/include/linux/mlx5/eswitch.h b/include/linux/mlx5/eswitch.h
index d3c9db492b30..fab5121ffb8f 100644
--- a/include/linux/mlx5/eswitch.h
+++ b/include/linux/mlx5/eswitch.h
@@ -8,6 +8,8 @@
 
 #include <linux/mlx5/driver.h>
 
+#define MLX5_ESWITCH_MANAGER(mdev) MLX5_CAP_GEN(mdev, eswitch_manager)
+
 enum {
 	SRIOV_NONE,
 	SRIOV_LEGACY,
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 27134c4fcb76..ac281f5ec9b8 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -922,7 +922,7 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 	u8         vnic_env_queue_counters[0x1];
 	u8         ets[0x1];
 	u8         nic_flow_table[0x1];
-	u8         eswitch_flow_table[0x1];
+	u8         eswitch_manager[0x1];
 	u8         device_memory[0x1];
 	u8         mcam_reg[0x1];
 	u8         pcam_reg[0x1];
-- 
2.17.0

^ permalink raw reply related

* [pull request][net 0/9] Mellanox, mlx5 fixes 2018-06-26
From: Saeed Mahameed @ 2018-06-27  0:21 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Or Gerlitz, Saeed Mahameed

Hi Dave,

This pull request includes fixes for mlx5 netdev and core driver,
for more information please see the tag log below and for.

Please pull and let me know if there's any issue.

For -stable:

For -stable v4.0
    net/mlx5: Fix incorrect raw command length parsing

For -stable v4.6
    net/mlx5: Fix wrong size allocation for QoS ETC TC regitster

Most of the patches dealing with eswitch below rely on:
[1] net/mlx5: E-Switch, Avoid setup attempt if not being e-switch manager

And they apply cleanly, but [1] has some very trivial conflicts to resolve
when applied to v4.12, I hope this won't be an issue.

For -stable v4.12
    net/mlx5: E-Switch, Avoid setup attempt if not being e-switch manager
    net/mlx5e: Don't attempt to dereference the ppriv struct if not being eswitch manager

For -stable v4.13
    net/mlx5: Fix command interface race in polling mode

For -stable v4.14
    net/mlx5e: Avoid dealing with vport representors if not being e-switch manager
    net/mlx5: Fix required capability for manipulating MPFS

For -stable v4.17
    IB/mlx5: Avoid dealing with vport representors if not being e-switch manager

Thanks,
Saeed.

---

The following changes since commit ce397d215ccd07b8ae3f71db689aedb85d56ab40:

  Linux 4.18-rc1 (2018-06-17 08:04:49 +0900)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2018-06-26

for you to fetch changes up to d412c31dae053bf30a1bc15582a9990df297a660:

  net/mlx5: Fix command interface race in polling mode (2018-06-26 15:26:34 -0700)

----------------------------------------------------------------
mlx5-fixes-2018-06-26

Fixes for mlx5 core and netdev driver:

Two fixes from Alex Vesker to address command interface issues
 - Race in command interface polling mode
 - Incorrect raw command length parsing

>From Shay Agroskin, Fix wrong size allocation for QoS ETC TC regitster.

>From Or Gerlitz and Eli Cohin, Address backward compatability issues for when
Eswitch capability is not advertised for the PF host driver
    - Fix required capability for manipulating MPFS
    - E-Switch, Disallow vlan/spoofcheck setup if not being esw manager
    - Avoid dealing with vport IB/eth representors if not being e-switch manager
    - E-Switch, Avoid setup attempt if not being e-switch manager
    - Don't attempt to dereference the ppriv struct if not being eswitch manager

----------------------------------------------------------------
Alex Vesker (2):
      net/mlx5: Fix incorrect raw command length parsing
      net/mlx5: Fix command interface race in polling mode

Eli Cohen (2):
      net/mlx5: E-Switch, Disallow vlan/spoofcheck setup if not being esw manager
      net/mlx5: Fix required capability for manipulating MPFS

Or Gerlitz (4):
      net/mlx5e: Don't attempt to dereference the ppriv struct if not being eswitch manager
      net/mlx5: E-Switch, Avoid setup attempt if not being e-switch manager
      net/mlx5e: Avoid dealing with vport representors if not being e-switch manager
      IB/mlx5: Avoid dealing with vport representors if not being e-switch manager

Shay Agroskin (1):
      net/mlx5: Fix wrong size allocation for QoS ETC TC regitster

 drivers/infiniband/hw/mlx5/main.c                          |  2 +-
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c              |  8 ++++----
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c          | 12 ++++++------
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c           |  8 ++++++--
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c          | 12 +++++-------
 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c |  4 ++--
 drivers/net/ethernet/mellanox/mlx5/core/fs_core.c          |  3 ++-
 drivers/net/ethernet/mellanox/mlx5/core/fw.c               |  5 +++--
 drivers/net/ethernet/mellanox/mlx5/core/lib/mpfs.c         |  9 +++++----
 drivers/net/ethernet/mellanox/mlx5/core/port.c             |  4 ++--
 drivers/net/ethernet/mellanox/mlx5/core/sriov.c            |  7 ++++++-
 drivers/net/ethernet/mellanox/mlx5/core/vport.c            |  2 --
 include/linux/mlx5/eswitch.h                               |  2 ++
 include/linux/mlx5/mlx5_ifc.h                              |  2 +-
 14 files changed, 45 insertions(+), 35 deletions(-)

^ permalink raw reply

* [net 1/9] net/mlx5e: Don't attempt to dereference the ppriv struct if not being eswitch manager
From: Saeed Mahameed @ 2018-06-27  0:21 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Or Gerlitz, Saeed Mahameed
In-Reply-To: <20180627002118.9856-1-saeedm@mellanox.com>

From: Or Gerlitz <ogerlitz@mellanox.com>

The check for cpu hit statistics was not returning immediate false for
any non vport rep netdev and hence we crashed (say on mlx5 probed VFs) if
user-space tool was calling into any possible netdev in the system.

Fix that by doing a proper check before dereferencing.

Fixes: 1d447a39142e ('net/mlx5e: Extendable vport representor netdev private data')
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reported-by: Eli Cohen <eli@melloanox.com>
Reviewed-by: Eli Cohen <eli@melloanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 57987f6546e8..378ad74518ec 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -837,8 +837,12 @@ bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv)
 static bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv)
 {
 	struct mlx5e_rep_priv *rpriv = priv->ppriv;
-	struct mlx5_eswitch_rep *rep = rpriv->rep;
+	struct mlx5_eswitch_rep *rep;
 
+	if (!MLX5_CAP_GEN(priv->mdev, eswitch_flow_table))
+		return false;
+
+	rep = rpriv->rep;
 	if (rep && rep->vport != FDB_UPLINK_VPORT)
 		return true;
 
-- 
2.17.0

^ permalink raw reply related

* Re: [net-next PATCH v4 6/7] net-sysfs: Add interface for Rx queue(s) map per Tx queue
From: Nambiar, Amritha @ 2018-06-27  0:21 UTC (permalink / raw)
  To: Willem de Bruijn
  Cc: Network Development, David Miller, Alexander Duyck,
	Samudrala, Sridhar, Alexander Duyck, Eric Dumazet,
	Hannes Frederic Sowa, Tom Herbert
In-Reply-To: <CAF=yD-JG_HtSarajsbPQYrMQp+ftwNTkqLVxtFBCB1VCzsgC0Q@mail.gmail.com>

On 6/26/2018 3:55 AM, Willem de Bruijn wrote:
> On Mon, Jun 25, 2018 at 7:06 PM Amritha Nambiar
> <amritha.nambiar@intel.com> wrote:
>>
>> Extend transmit queue sysfs attribute to configure Rx queue(s) map
>> per Tx queue. By default no receive queues are configured for the
>> Tx queue.
>>
>> - /sys/class/net/eth0/queues/tx-*/xps_rxqs
>>
>> Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
>> ---
> 
>> +static ssize_t xps_rxqs_show(struct netdev_queue *queue, char *buf)
>> +{
>> +       struct net_device *dev = queue->dev;
>> +       struct xps_dev_maps *dev_maps;
>> +       unsigned long *mask, index;
>> +       int j, len, num_tc = 1, tc = 0;
>> +
>> +       mask = kcalloc(BITS_TO_LONGS(dev->num_rx_queues), sizeof(long),
>> +                      GFP_KERNEL);
>> +       if (!mask)
>> +               return -ENOMEM;
>> +
>> +       index = get_netdev_queue_index(queue);
>> +
>> +       if (dev->num_tc) {
>> +               num_tc = dev->num_tc;
>> +               tc = netdev_txq_to_tc(dev, index);
>> +               if (tc < 0)
>> +                       return -EINVAL;
> 
> Must free mask
> 
>> +static ssize_t xps_rxqs_store(struct netdev_queue *queue, const char *buf,
>> +                             size_t len)
>> +{
>> +       struct net_device *dev = queue->dev;
>> +       unsigned long *mask, index;
>> +       int err;
>> +
>> +       if (!capable(CAP_NET_ADMIN))
>> +               return -EPERM;
> 
> ns_capable?
> 
Will change this to ns_capable.

^ permalink raw reply

* Re: [bpf-next PATCH 2/2] samples/bpf: xdp_rxq_info action XDP_TX must adjust MAC-addrs
From: Song Liu @ 2018-06-27  0:09 UTC (permalink / raw)
  To: Jesper Dangaard Brouer
  Cc: Networking, Daniel Borkmann, Toke Høiland-Jørgensen,
	Alexei Starovoitov
In-Reply-To: <152993686871.8835.4524876041721452950.stgit@firesoul>

On Mon, Jun 25, 2018 at 7:27 AM, Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
> XDP_TX requires also changing the MAC-addrs, else some hardware
> may drop the TX packet before reaching the wire.  This was
> observed with driver mlx5.
>
> If xdp_rxq_info select --action XDP_TX the swapmac functionality
> is activated.  It is also possible to manually enable via cmdline
> option --swapmac.  This is practical if wanting to measure the
> overhead of writing/updating payload for other action types.
>
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
> ---
>  samples/bpf/xdp_rxq_info_kern.c |   26 +++++++++++++++++++++++++-
>  samples/bpf/xdp_rxq_info_user.c |   11 +++++++++++
>  2 files changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/samples/bpf/xdp_rxq_info_kern.c b/samples/bpf/xdp_rxq_info_kern.c
> index 61af6210df2f..222a83eed1cb 100644
> --- a/samples/bpf/xdp_rxq_info_kern.c
> +++ b/samples/bpf/xdp_rxq_info_kern.c
> @@ -21,6 +21,7 @@ struct config {
>  enum cfg_options_flags {
>         NO_TOUCH = 0x0U,
>         READ_MEM = 0x1U,
> +       SWAP_MAC = 0x2U,
>  };
>  struct bpf_map_def SEC("maps") config_map = {
>         .type           = BPF_MAP_TYPE_ARRAY,
> @@ -52,6 +53,23 @@ struct bpf_map_def SEC("maps") rx_queue_index_map = {
>         .max_entries    = MAX_RXQs + 1,
>  };
>
> +static __always_inline
> +void swap_src_dst_mac(void *data)
> +{
> +       unsigned short *p = data;
> +       unsigned short dst[3];
> +
> +       dst[0] = p[0];
> +       dst[1] = p[1];
> +       dst[2] = p[2];
> +       p[0] = p[3];
> +       p[1] = p[4];
> +       p[2] = p[5];
> +       p[3] = dst[0];
> +       p[4] = dst[1];
> +       p[5] = dst[2];
> +}
> +
>  SEC("xdp_prog0")
>  int  xdp_prognum0(struct xdp_md *ctx)
>  {
> @@ -98,7 +116,7 @@ int  xdp_prognum0(struct xdp_md *ctx)
>                 rxq_rec->issue++;
>
>         /* Default: Don't touch packet data, only count packets */
> -       if (unlikely(config->options & READ_MEM)) {
> +       if (unlikely(config->options & (READ_MEM|SWAP_MAC))) {
>                 struct ethhdr *eth = data;
>
>                 if (eth + 1 > data_end)
> @@ -107,6 +125,12 @@ int  xdp_prognum0(struct xdp_md *ctx)
>                 /* Avoid compiler removing this: Drop non 802.3 Ethertypes */
>                 if (ntohs(eth->h_proto) < ETH_P_802_3_MIN)
>                         return XDP_ABORTED;
> +
> +               /* XDP_TX requires changing MAC-addrs, else HW may drop.
> +                * Can also be enabled with --swapmac (for test purposes)
> +                */
> +               if (unlikely(config->options & SWAP_MAC))
> +                       swap_src_dst_mac(data);
>         }
>
>         return config->action;
> diff --git a/samples/bpf/xdp_rxq_info_user.c b/samples/bpf/xdp_rxq_info_user.c
> index 435485d4f49e..248a7eab9531 100644
> --- a/samples/bpf/xdp_rxq_info_user.c
> +++ b/samples/bpf/xdp_rxq_info_user.c
> @@ -51,6 +51,7 @@ static const struct option long_options[] = {
>         {"no-separators", no_argument,          NULL, 'z' },
>         {"action",      required_argument,      NULL, 'a' },
>         {"readmem",     no_argument,            NULL, 'r' },
> +       {"swapmac",     no_argument,            NULL, 'm' },
>         {0, 0, NULL,  0 }
>  };
>
> @@ -72,6 +73,7 @@ struct config {
>  enum cfg_options_flags {
>         NO_TOUCH = 0x0U,
>         READ_MEM = 0x1U,
> +       SWAP_MAC = 0x2U,
>  };
>  #define XDP_ACTION_MAX (XDP_TX + 1)
>  #define XDP_ACTION_MAX_STRLEN 11
> @@ -119,6 +121,8 @@ static char* options2str(enum cfg_options_flags flag)
>  {
>         if (flag == NO_TOUCH)
>                 return "no_touch";
> +       if (flag & SWAP_MAC)
> +               return "swapmac";
>         if (flag & READ_MEM)
>                 return "read";

I guess SWAP_MAC also reads the memory, so it "includes" READ_MEM?
It is OK for now. We may need to refactor this part when adding other
flags in the
future.

Thanks,
Song


>         fprintf(stderr, "ERR: Unknown config option flags");
> @@ -517,6 +521,9 @@ int main(int argc, char **argv)
>                 case 'r':
>                         cfg_options |= READ_MEM;
>                         break;
> +               case 'm':
> +                       cfg_options |= SWAP_MAC;
> +                       break;
>                 case 'h':
>                 error:
>                 default:
> @@ -543,6 +550,10 @@ int main(int argc, char **argv)
>                 }
>         }
>         cfg.action = action;
> +
> +       /* XDP_TX requires changing MAC-addrs, else HW may drop */
> +       if (action == XDP_TX)
> +               cfg_options |= SWAP_MAC;
>         cfg.options = cfg_options;
>
>         /* Trick to pretty printf with thousands separators use %' */
>

^ permalink raw reply

* [PATCH v7 11/11] net: pch_gbe: Allow build on MIPS platforms
From: Paul Burton @ 2018-06-27  0:06 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Andrew Lunn, paul.burton
In-Reply-To: <20180627000612.27263-1-paul.burton@mips.com>

Allow the pch_gbe driver to be built on MIPS platforms, allowing its use
on the MIPS Boston development board.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org

---

Changes in v7: None

 drivers/net/ethernet/oki-semi/pch_gbe/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig b/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig
index 5276f4ff3b63..8e3630b9a9d1 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig
@@ -4,7 +4,7 @@
 
 config PCH_GBE
 	tristate "OKI SEMICONDUCTOR IOH(ML7223/ML7831) GbE"
-	depends on PCI && (X86_32 || COMPILE_TEST)
+	depends on PCI && (X86_32 || MIPS || COMPILE_TEST)
 	select PHYLIB
 	imply AT803X_PHY if X86_32
 	select PTP_1588_CLOCK_PCH
-- 
2.18.0

^ permalink raw reply related

* [PATCH v7 09/11] net: pch_gbe: Convert to mdiobus and phylib
From: Paul Burton @ 2018-06-27  0:06 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Andrew Lunn, paul.burton
In-Reply-To: <20180627000612.27263-1-paul.burton@mips.com>

From: Andrew Lunn <andrew@lunn.ch>

Convert this driver to use the mdio bus and phylib infrastructure. It
will then use the common AT803X PHY driver, rather than use its own
code. Have the shared code also handle the GPIO used to reset the PHY.

Over all, these changes should make it easier to use other PHYs with the
MAC chip, and reduces the lines of code.

[paul.burton@mips.com:
  - Select CONFIG_PHYLIB.
  - Drop selection of CONFIG_MII.
  - Imply AT803X_PHY for X86_32, rather than selecting it for all.
  - Add GPIOF_ACTIVE_LOW to the minnow PHY reset GPIO flags.
  - Rebase atop changes in the rest of the series.
  - Drop the AR8031 PHY hibernation disable fixup.]

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org

---

Changes in v7:
- Heavy rebasing atop earlier patches.

Changes in v6:
- New patch

 drivers/net/ethernet/oki-semi/pch_gbe/Kconfig |   3 +-
 .../net/ethernet/oki-semi/pch_gbe/Makefile    |   2 +-
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe.h   |   7 +-
 .../oki-semi/pch_gbe/pch_gbe_ethtool.c        |  88 +----
 .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c  | 239 ++++++-------
 .../ethernet/oki-semi/pch_gbe/pch_gbe_param.c | 265 --------------
 .../ethernet/oki-semi/pch_gbe/pch_gbe_phy.c   | 335 ------------------
 .../ethernet/oki-semi/pch_gbe/pch_gbe_phy.h   |  34 --
 8 files changed, 126 insertions(+), 847 deletions(-)
 delete mode 100644 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c
 delete mode 100644 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig b/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig
index 5f7a35212796..5276f4ff3b63 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig
@@ -5,7 +5,8 @@
 config PCH_GBE
 	tristate "OKI SEMICONDUCTOR IOH(ML7223/ML7831) GbE"
 	depends on PCI && (X86_32 || COMPILE_TEST)
-	select MII
+	select PHYLIB
+	imply AT803X_PHY if X86_32
 	select PTP_1588_CLOCK_PCH
 	select NET_PTP_CLASSIFY
 	---help---
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/Makefile b/drivers/net/ethernet/oki-semi/pch_gbe/Makefile
index 862de0f3bc41..133c89bc2933 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/Makefile
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/Makefile
@@ -1,4 +1,4 @@
 obj-$(CONFIG_PCH_GBE) += pch_gbe.o
 
-pch_gbe-y := pch_gbe_phy.o pch_gbe_ethtool.o pch_gbe_param.o
+pch_gbe-y := pch_gbe_ethtool.o pch_gbe_param.o
 pch_gbe-y += pch_gbe_main.o
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
index f8acd8031951..e6a0bd053ae5 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
@@ -22,7 +22,8 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/mii.h>
+#include <linux/mdio.h>
+#include <linux/phy.h>
 #include <linux/delay.h>
 #include <linux/pci.h>
 #include <linux/netdevice.h>
@@ -578,8 +579,8 @@ struct pch_gbe_adapter {
 	struct pch_gbe_hw hw;
 	struct pch_gbe_hw_stats stats;
 	struct work_struct reset_task;
-	struct mii_if_info mii;
-	struct timer_list watchdog_timer;
+	struct mii_bus *mdiobus;
+	struct phy_device *phydev;
 	u32 wake_up_evt;
 	struct pch_gbe_tx_ring *tx_ring;
 	struct pch_gbe_rx_ring *rx_ring;
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c
index adaa0024adfe..5dc08eccb7e6 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_ethtool.c
@@ -17,7 +17,6 @@
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #include "pch_gbe.h"
-#include "pch_gbe_phy.h"
 
 /**
  * pch_gbe_stats - Stats item information
@@ -71,41 +70,8 @@ static const struct pch_gbe_stats pch_gbe_gstrings_stats[] = {
 #define PCH_GBE_STATS_LEN (PCH_GBE_GLOBAL_STATS_LEN + PCH_GBE_QUEUE_STATS_LEN)
 
 #define PCH_GBE_MAC_REGS_LEN    (sizeof(struct pch_gbe_regs) / 4)
+#define PCH_GBE_PHY_REGS_LEN	32
 #define PCH_GBE_REGS_LEN        (PCH_GBE_MAC_REGS_LEN + PCH_GBE_PHY_REGS_LEN)
-/**
- * pch_gbe_get_link_ksettings - Get device-specific settings
- * @netdev: Network interface device structure
- * @ecmd:   Ethtool command
- * Returns:
- *	0:			Successful.
- *	Negative value:		Failed.
- */
-static int pch_gbe_get_link_ksettings(struct net_device *netdev,
-				      struct ethtool_link_ksettings *ecmd)
-{
-	struct pch_gbe_adapter *adapter = netdev_priv(netdev);
-	u32 supported, advertising;
-
-	mii_ethtool_get_link_ksettings(&adapter->mii, ecmd);
-
-	ethtool_convert_link_mode_to_legacy_u32(&supported,
-						ecmd->link_modes.supported);
-	ethtool_convert_link_mode_to_legacy_u32(&advertising,
-						ecmd->link_modes.advertising);
-
-	supported &= ~(SUPPORTED_TP | SUPPORTED_1000baseT_Half);
-	advertising &= ~(ADVERTISED_TP | ADVERTISED_1000baseT_Half);
-
-	ethtool_convert_legacy_u32_to_link_mode(ecmd->link_modes.supported,
-						supported);
-	ethtool_convert_legacy_u32_to_link_mode(ecmd->link_modes.advertising,
-						advertising);
-
-	if (!netif_carrier_ok(adapter->netdev))
-		ecmd->base.speed = SPEED_UNKNOWN;
-
-	return 0;
-}
 
 /**
  * pch_gbe_set_link_ksettings - Set device-specific settings
@@ -119,34 +85,22 @@ static int pch_gbe_set_link_ksettings(struct net_device *netdev,
 				      const struct ethtool_link_ksettings *ecmd)
 {
 	struct pch_gbe_adapter *adapter = netdev_priv(netdev);
+	struct phy_device *phydev = adapter->phydev;
 	struct pch_gbe_hw *hw = &adapter->hw;
-	struct ethtool_link_ksettings copy_ecmd;
-	u32 speed = ecmd->base.speed;
 	u32 advertising;
 	int ret;
 
-	pch_gbe_phy_write_reg_miic(hw, MII_BMCR, BMCR_RESET);
-
-	memcpy(&copy_ecmd, ecmd, sizeof(*ecmd));
-
-	/* when set_settings() is called with a ethtool_cmd previously
-	 * filled by get_settings() on a down link, speed is -1: */
-	if (speed == UINT_MAX) {
-		speed = SPEED_1000;
-		copy_ecmd.base.speed = speed;
-		copy_ecmd.base.duplex = DUPLEX_FULL;
-	}
-	ret = mii_ethtool_set_link_ksettings(&adapter->mii, &copy_ecmd);
+	ret = phy_ethtool_set_link_ksettings(netdev, ecmd);
 	if (ret) {
-		netdev_err(netdev, "Error: mii_ethtool_set_link_ksettings\n");
+		netdev_err(netdev, "Error: phy_ethtool_set_link_ksettings\n");
 		return ret;
 	}
-	hw->mac.link_speed = speed;
-	hw->mac.link_duplex = copy_ecmd.base.duplex;
+	hw->mac.link_speed = phydev->speed;
+	hw->mac.link_duplex = phydev->duplex;
 	ethtool_convert_link_mode_to_legacy_u32(
-		&advertising, copy_ecmd.link_modes.advertising);
+		&advertising, ecmd->link_modes.advertising);
 	hw->phy.autoneg_advertised = advertising;
-	hw->mac.autoneg = copy_ecmd.base.autoneg;
+	hw->mac.autoneg = ecmd->base.autoneg;
 
 	/* reset the link */
 	if (netif_running(adapter->netdev)) {
@@ -197,16 +151,14 @@ static void pch_gbe_get_regs(struct net_device *netdev,
 	struct pch_gbe_hw *hw = &adapter->hw;
 	struct pci_dev *pdev = adapter->pdev;
 	u32 *regs_buff = p;
-	u16 i, tmp;
+	u16 i;
 
 	regs->version = 0x1000000 | (__u32)pdev->revision << 16 | pdev->device;
 	for (i = 0; i < PCH_GBE_MAC_REGS_LEN; i++)
 		*regs_buff++ = ioread32(&hw->reg->INT_ST + i);
 	/* PHY register */
-	for (i = 0; i < PCH_GBE_PHY_REGS_LEN; i++) {
-		pch_gbe_phy_read_reg_miic(&adapter->hw, i, &tmp);
-		*regs_buff++ = tmp;
-	}
+	for (i = 0; i < PCH_GBE_PHY_REGS_LEN; i++)
+		*regs_buff++ = phy_read(adapter->phydev, i);
 }
 
 /**
@@ -261,20 +213,6 @@ static int pch_gbe_set_wol(struct net_device *netdev,
 	return 0;
 }
 
-/**
- * pch_gbe_nway_reset - Restart autonegotiation
- * @netdev: Network interface device structure
- * Returns:
- *	0:			Successful.
- *	Negative value:		Failed.
- */
-static int pch_gbe_nway_reset(struct net_device *netdev)
-{
-	struct pch_gbe_adapter *adapter = netdev_priv(netdev);
-
-	return mii_nway_restart(&adapter->mii);
-}
-
 /**
  * pch_gbe_get_ringparam - Report ring sizes
  * @netdev:  Network interface device structure
@@ -497,7 +435,7 @@ static const struct ethtool_ops pch_gbe_ethtool_ops = {
 	.get_regs = pch_gbe_get_regs,
 	.get_wol = pch_gbe_get_wol,
 	.set_wol = pch_gbe_set_wol,
-	.nway_reset = pch_gbe_nway_reset,
+	.nway_reset = phy_ethtool_nway_reset,
 	.get_link = ethtool_op_get_link,
 	.get_ringparam = pch_gbe_get_ringparam,
 	.set_ringparam = pch_gbe_set_ringparam,
@@ -506,7 +444,7 @@ static const struct ethtool_ops pch_gbe_ethtool_ops = {
 	.get_strings = pch_gbe_get_strings,
 	.get_ethtool_stats = pch_gbe_get_ethtool_stats,
 	.get_sset_count = pch_gbe_get_sset_count,
-	.get_link_ksettings = pch_gbe_get_link_ksettings,
+	.get_link_ksettings = phy_ethtool_get_link_ksettings,
 	.set_link_ksettings = pch_gbe_set_link_ksettings,
 };
 
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 123c7818698d..7fd10550cc57 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -18,11 +18,11 @@
  */
 
 #include "pch_gbe.h"
-#include "pch_gbe_phy.h"
 #include <linux/module.h>
 #include <linux/net_tstamp.h>
 #include <linux/ptp_classify.h>
 #include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 
 #define DRV_VERSION     "1.01"
 const char pch_driver_version[] = DRV_VERSION;
@@ -33,7 +33,6 @@ const char pch_driver_version[] = DRV_VERSION;
 #define DSC_INIT16			0xC000
 #define PCH_GBE_DMA_ALIGN		0
 #define PCH_GBE_DMA_PADDING		2
-#define PCH_GBE_WATCHDOG_PERIOD		(5 * HZ)	/* watchdog time */
 #define PCH_GBE_PCI_BAR			1
 #define PCH_GBE_RESERVE_MEMORY		0x200000	/* 2MB */
 
@@ -112,9 +111,8 @@ const char pch_driver_version[] = DRV_VERSION;
 
 #define MINNOW_PHY_RESET_GPIO		13
 
-static int pch_gbe_mdio_read(struct net_device *netdev, int addr, int reg);
-static void pch_gbe_mdio_write(struct net_device *netdev, int addr, int reg,
-			       int data);
+#define	PCH_GBE_PHY_RESET_DELAY_US	10
+
 static void pch_gbe_set_multi(struct net_device *netdev);
 
 static int pch_ptp_match(struct sk_buff *skb, u16 uid_hi, u32 uid_lo, u16 seqid)
@@ -569,66 +567,6 @@ static void pch_gbe_init_stats(struct pch_gbe_adapter *adapter)
 	return;
 }
 
-/**
- * pch_gbe_init_phy - Initialize PHY
- * @adapter:  Board private structure to initialize
- * Returns:
- *	0:	Successfully
- *	Negative value:	Failed
- */
-static int pch_gbe_init_phy(struct pch_gbe_adapter *adapter)
-{
-	struct net_device *netdev = adapter->netdev;
-	struct pch_gbe_hw *hw = &adapter->hw;
-	u32 addr;
-	u16 bmcr, stat;
-	s32 ret_val;
-
-	/* Discover phy addr by searching addrs in order {1,0,2,..., 31} */
-	for (addr = 0; addr < PCH_GBE_PHY_REGS_LEN; addr++) {
-		adapter->mii.phy_id = (addr == 0) ? 1 : (addr == 1) ? 0 : addr;
-		bmcr = pch_gbe_mdio_read(netdev, adapter->mii.phy_id, MII_BMCR);
-		stat = pch_gbe_mdio_read(netdev, adapter->mii.phy_id, MII_BMSR);
-		stat = pch_gbe_mdio_read(netdev, adapter->mii.phy_id, MII_BMSR);
-		if (!((bmcr == 0xFFFF) || ((stat == 0) && (bmcr == 0))))
-			break;
-	}
-	adapter->hw.phy.addr = adapter->mii.phy_id;
-	netdev_dbg(netdev, "phy_addr = %d\n", adapter->mii.phy_id);
-	if (addr == PCH_GBE_PHY_REGS_LEN)
-		return -EAGAIN;
-	/* Selected the phy and isolate the rest */
-	for (addr = 0; addr < PCH_GBE_PHY_REGS_LEN; addr++) {
-		if (addr != adapter->mii.phy_id) {
-			pch_gbe_mdio_write(netdev, addr, MII_BMCR,
-					   BMCR_ISOLATE);
-		} else {
-			bmcr = pch_gbe_mdio_read(netdev, addr, MII_BMCR);
-			pch_gbe_mdio_write(netdev, addr, MII_BMCR,
-					   bmcr & ~BMCR_ISOLATE);
-		}
-	}
-
-	/* MII setup */
-	adapter->mii.phy_id_mask = 0x1F;
-	adapter->mii.reg_num_mask = 0x1F;
-	adapter->mii.dev = adapter->netdev;
-	adapter->mii.mdio_read = pch_gbe_mdio_read;
-	adapter->mii.mdio_write = pch_gbe_mdio_write;
-	adapter->mii.supports_gmii = mii_check_gmii_support(&adapter->mii);
-
-	ret_val = pch_gbe_phy_get_id(hw);
-	if (ret_val) {
-		netdev_err(adapter->netdev, "pch_gbe_phy_get_id error\n");
-		return -EIO;
-	}
-	pch_gbe_phy_init_setting(hw);
-	/* Setup Mac interface option RGMII */
-	pch_gbe_phy_set_rgmii(hw);
-
-	return 0;
-}
-
 /**
  * pch_gbe_mdio_read - The read function for mii
  * @netdev: Network interface device structure
@@ -638,13 +576,12 @@ static int pch_gbe_init_phy(struct pch_gbe_adapter *adapter)
  *	0:	Successfully
  *	Negative value:	Failed
  */
-static int pch_gbe_mdio_read(struct net_device *netdev, int addr, int reg)
+static int pch_gbe_mdio_read(struct mii_bus *bus, int addr, int reg)
 {
-	struct pch_gbe_adapter *adapter = netdev_priv(netdev);
+	struct pch_gbe_adapter *adapter = bus->priv;
 	struct pch_gbe_hw *hw = &adapter->hw;
 
-	return pch_gbe_mac_ctrl_miim(hw, addr, PCH_GBE_HAL_MIIM_READ, reg,
-				     (u16) 0);
+	return pch_gbe_mac_ctrl_miim(hw, addr, PCH_GBE_HAL_MIIM_READ, reg, 0);
 }
 
 /**
@@ -654,13 +591,34 @@ static int pch_gbe_mdio_read(struct net_device *netdev, int addr, int reg)
  * @reg:    Access location
  * @data:   Write data
  */
-static void pch_gbe_mdio_write(struct net_device *netdev,
-			       int addr, int reg, int data)
+static int pch_gbe_mdio_write(struct mii_bus *bus, int addr, int reg, u16 data)
 {
-	struct pch_gbe_adapter *adapter = netdev_priv(netdev);
+	struct pch_gbe_adapter *adapter = bus->priv;
 	struct pch_gbe_hw *hw = &adapter->hw;
 
-	pch_gbe_mac_ctrl_miim(hw, addr, PCH_GBE_HAL_MIIM_WRITE, reg, data);
+	return pch_gbe_mac_ctrl_miim(hw, addr, PCH_GBE_HAL_MIIM_WRITE, reg,
+				     data);
+}
+
+static int pch_gbe_init_mdio(struct pch_gbe_adapter *adapter)
+{
+	struct device *dev = &adapter->pdev->dev;
+	struct mii_bus *bus;
+
+	bus = devm_mdiobus_alloc(dev);
+	if (!bus)
+		return -ENOMEM;
+
+	bus->read = pch_gbe_mdio_read;
+	bus->write = pch_gbe_mdio_write;
+	bus->parent = dev;
+	bus->name = "pch_gbe";
+	snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(dev));
+	bus->priv = adapter;
+
+	adapter->mdiobus = bus;
+
+	return mdiobus_register(bus);
 }
 
 /**
@@ -1829,7 +1787,6 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter)
 	}
 	adapter->tx_queue_len = netdev->tx_queue_len;
 
-	mod_timer(&adapter->watchdog_timer, jiffies);
 	return 0;
 
 freeirq:
@@ -1855,8 +1812,6 @@ void pch_gbe_down(struct pch_gbe_adapter *adapter)
 	pch_gbe_irq_disable(adapter);
 	pch_gbe_free_irq(adapter);
 
-	del_timer_sync(&adapter->watchdog_timer);
-
 	netdev->tx_queue_len = adapter->tx_queue_len;
 	netif_carrier_off(netdev);
 	netif_stop_queue(netdev);
@@ -1877,32 +1832,22 @@ void pch_gbe_down(struct pch_gbe_adapter *adapter)
  * pch_gbe_watchdog - Watchdog process
  * @data:  Board private structure
  */
-static void pch_gbe_watchdog(struct timer_list *t)
+static void pch_gbe_change_link(struct net_device *netdev)
 {
-	struct pch_gbe_adapter *adapter = from_timer(adapter, t,
-						     watchdog_timer);
+	struct pch_gbe_adapter *adapter = netdev_priv(netdev);
 	struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring;
 	struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring;
-	struct net_device *netdev = adapter->netdev;
+	struct phy_device *phydev = adapter->phydev;
 	struct pch_gbe_hw *hw = &adapter->hw;
 
 	netdev_dbg(netdev, "right now = %ld\n", jiffies);
 
 	pch_gbe_update_stats(adapter);
-	if ((mii_link_ok(&adapter->mii)) && (!netif_carrier_ok(netdev))) {
-		struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET };
 
+	if (phydev->link) {
 		netdev->tx_queue_len = adapter->tx_queue_len;
-		/* mii library handles link maintenance tasks */
-		if (mii_ethtool_gset(&adapter->mii, &cmd)) {
-			netdev_err(netdev, "ethtool get setting Error\n");
-			mod_timer(&adapter->watchdog_timer,
-				  round_jiffies(jiffies +
-						PCH_GBE_WATCHDOG_PERIOD));
-			return;
-		}
-		hw->mac.link_speed = ethtool_cmd_speed(&cmd);
-		hw->mac.link_duplex = cmd.duplex;
+		hw->mac.link_speed = phydev->speed;
+		hw->mac.link_duplex = phydev->duplex;
 
 		pch_gbe_reset(adapter);
 
@@ -1927,23 +1872,43 @@ static void pch_gbe_watchdog(struct timer_list *t)
 		napi_enable(&adapter->napi);
 		pch_gbe_irq_enable(adapter);
 		netif_start_queue(adapter->netdev);
-
-		netdev_dbg(netdev,
-			   "Link is Up %d Mbps %s-Duplex\n",
-			   hw->mac.link_speed,
-			   cmd.duplex == DUPLEX_FULL ? "Full" : "Half");
-		netif_carrier_on(netdev);
 		netif_wake_queue(netdev);
-	} else if ((!mii_link_ok(&adapter->mii)) &&
-		   (netif_carrier_ok(netdev))) {
-		netdev_dbg(netdev, "NIC Link is Down\n");
+	} else if (!phydev->link && netif_carrier_ok(netdev)) {
 		hw->mac.link_speed = SPEED_10;
 		hw->mac.link_duplex = DUPLEX_HALF;
-		netif_carrier_off(netdev);
 		netif_stop_queue(netdev);
 	}
-	mod_timer(&adapter->watchdog_timer,
-		  round_jiffies(jiffies + PCH_GBE_WATCHDOG_PERIOD));
+
+	phy_print_status(phydev);
+}
+
+/**
+ * pch_gbe_init_phy - Initialize PHY
+ * @adapter:  Board private structure to initialize
+ * Returns:
+ *	0:	Successfully
+ *	Negative value:	Failed
+ */
+static int pch_gbe_init_phy(struct pch_gbe_adapter *adapter)
+{
+	struct net_device *netdev = adapter->netdev;
+	int ret;
+
+	adapter->phydev = phy_find_first(adapter->mdiobus);
+	if (!adapter->phydev)
+		return -ENODEV;
+
+	if (adapter->pdata && adapter->pdata->platform_init)
+		adapter->pdata->platform_init(adapter->pdev);
+
+	ret = phy_connect_direct(netdev, adapter->phydev, pch_gbe_change_link,
+				 PHY_INTERFACE_MODE_RGMII_TXID);
+	if (ret) {
+		netdev_err(netdev, "Could not attach to PHY\n");
+		return ret;
+	}
+
+	return 0;
 }
 
 /**
@@ -1990,7 +1955,6 @@ static int pch_gbe_sw_init(struct pch_gbe_adapter *adapter)
 static int pch_gbe_open(struct net_device *netdev)
 {
 	struct pch_gbe_adapter *adapter = netdev_priv(netdev);
-	struct pch_gbe_hw *hw = &adapter->hw;
 	int err;
 
 	/* allocate transmit descriptors */
@@ -2001,7 +1965,7 @@ static int pch_gbe_open(struct net_device *netdev)
 	err = pch_gbe_setup_rx_resources(adapter, adapter->rx_ring);
 	if (err)
 		goto err_setup_rx;
-	pch_gbe_phy_power_up(hw);
+	phy_start(adapter->phydev);
 	err = pch_gbe_up(adapter);
 	if (err)
 		goto err_up;
@@ -2010,7 +1974,7 @@ static int pch_gbe_open(struct net_device *netdev)
 
 err_up:
 	if (!adapter->wake_up_evt)
-		pch_gbe_phy_power_down(hw);
+		phy_stop(adapter->phydev);
 	pch_gbe_free_rx_resources(adapter, adapter->rx_ring);
 err_setup_rx:
 	pch_gbe_free_tx_resources(adapter, adapter->tx_ring);
@@ -2029,11 +1993,10 @@ static int pch_gbe_open(struct net_device *netdev)
 static int pch_gbe_stop(struct net_device *netdev)
 {
 	struct pch_gbe_adapter *adapter = netdev_priv(netdev);
-	struct pch_gbe_hw *hw = &adapter->hw;
 
 	pch_gbe_down(adapter);
 	if (!adapter->wake_up_evt)
-		pch_gbe_phy_power_down(hw);
+		phy_stop(adapter->phydev);
 	pch_gbe_free_tx_resources(adapter, adapter->tx_ring);
 	pch_gbe_free_rx_resources(adapter, adapter->rx_ring);
 	return 0;
@@ -2245,7 +2208,7 @@ static int pch_gbe_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
 	if (cmd == SIOCSHWTSTAMP)
 		return hwtstamp_ioctl(netdev, ifr, cmd);
 
-	return generic_mii_ioctl(&adapter->mii, if_mii(ifr), cmd, NULL);
+	return phy_mii_ioctl(adapter->phydev, ifr, cmd);
 }
 
 /**
@@ -2363,7 +2326,7 @@ static pci_ers_result_t pch_gbe_io_slot_reset(struct pci_dev *pdev)
 	}
 	pci_set_master(pdev);
 	pci_enable_wake(pdev, PCI_D0, 0);
-	pch_gbe_phy_power_up(hw);
+	phy_start(adapter->phydev);
 	pch_gbe_reset(adapter);
 	/* Clear wake up status */
 	pch_gbe_mac_set_wol_event(hw, 0);
@@ -2408,7 +2371,7 @@ static int __pch_gbe_suspend(struct pci_dev *pdev)
 		pch_gbe_mac_set_wol_event(hw, wufc);
 		pci_disable_device(pdev);
 	} else {
-		pch_gbe_phy_power_down(hw);
+		phy_stop(adapter->phydev);
 		pch_gbe_mac_set_wol_event(hw, wufc);
 		pci_disable_device(pdev);
 	}
@@ -2437,7 +2400,7 @@ static int pch_gbe_resume(struct device *device)
 		return err;
 	}
 	pci_set_master(pdev);
-	pch_gbe_phy_power_up(hw);
+	phy_start(adapter->phydev);
 	pch_gbe_reset(adapter);
 	/* Clear wake on lan control and status */
 	pch_gbe_mac_set_wol_event(hw, 0);
@@ -2467,7 +2430,9 @@ static void pch_gbe_remove(struct pci_dev *pdev)
 	cancel_work_sync(&adapter->reset_task);
 	unregister_netdev(netdev);
 
-	pch_gbe_phy_hw_reset(&adapter->hw);
+	phy_stop(adapter->phydev);
+	phy_detach(adapter->phydev);
+	mdiobus_unregister(adapter->mdiobus);
 
 	free_netdev(netdev);
 }
@@ -2517,8 +2482,6 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 	adapter->hw.back = adapter;
 	adapter->hw.reg = pcim_iomap_table(pdev)[PCH_GBE_PCI_BAR];
 	adapter->pdata = (struct pch_gbe_privdata *)pci_id->driver_data;
-	if (adapter->pdata && adapter->pdata->platform_init)
-		adapter->pdata->platform_init(pdev);
 
 	adapter->ptp_pdev =
 		pci_get_domain_bus_and_slot(pci_domain_nr(adapter->pdev->bus),
@@ -2526,7 +2489,6 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 					    PCI_DEVFN(12, 4));
 
 	netdev->netdev_ops = &pch_gbe_netdev_ops;
-	netdev->watchdog_timeo = PCH_GBE_WATCHDOG_PERIOD;
 	netif_napi_add(netdev, &adapter->napi,
 		       pch_gbe_napi_poll, PCH_GBE_RX_WEIGHT);
 	netdev->hw_features = NETIF_F_RXCSUM |
@@ -2548,18 +2510,24 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 
 	pch_gbe_check_options(adapter);
 
+	ret = pch_gbe_init_mdio(adapter);
+	if (ret) {
+		dev_err(&pdev->dev, "MDIO initialize error\n");
+		goto err_free_netdev;
+	}
+
 	/* Initialize PHY */
 	ret = pch_gbe_init_phy(adapter);
 	if (ret) {
 		dev_err(&pdev->dev, "PHY initialize error\n");
-		goto err_free_adapter;
+		goto err_free_mdiobus;
 	}
 
 	/* Read the MAC address. and store to the private data */
 	ret = pch_gbe_mac_read_mac_addr(&adapter->hw);
 	if (ret) {
 		dev_err(&pdev->dev, "MAC address Read Error\n");
-		goto err_free_adapter;
+		goto err_free_phy;
 	}
 
 	memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len);
@@ -2573,7 +2541,6 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 		dev_err(&pdev->dev, "Invalid MAC address, "
 		                    "interface disabled.\n");
 	}
-	timer_setup(&adapter->watchdog_timer, pch_gbe_watchdog, 0);
 
 	INIT_WORK(&adapter->reset_task, pch_gbe_reset_task);
 
@@ -2583,7 +2550,8 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 
 	ret = register_netdev(netdev);
 	if (ret)
-		goto err_free_adapter;
+		goto err_free_phy;
+
 	/* tell the stack to leave us alone until pch_gbe_open() is called */
 	netif_carrier_off(netdev);
 	netif_stop_queue(netdev);
@@ -2593,8 +2561,10 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 	device_set_wakeup_enable(&pdev->dev, 1);
 	return 0;
 
-err_free_adapter:
-	pch_gbe_phy_hw_reset(&adapter->hw);
+err_free_phy:
+	phy_disconnect(adapter->phydev);
+err_free_mdiobus:
+	mdiobus_unregister(adapter->mdiobus);
 err_free_netdev:
 	free_netdev(netdev);
 	return ret;
@@ -2605,23 +2575,26 @@ static int pch_gbe_probe(struct pci_dev *pdev,
  */
 static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
 {
-	unsigned long flags = GPIOF_DIR_OUT | GPIOF_INIT_HIGH | GPIOF_EXPORT;
+	unsigned long flags = GPIOF_DIR_OUT | GPIOF_INIT_HIGH |
+		GPIOF_EXPORT | GPIOF_ACTIVE_LOW;
+	struct net_device *netdev = pci_get_drvdata(pdev);
+	struct pch_gbe_adapter *adapter = netdev_priv(netdev);
+	struct phy_device *phydev = adapter->phydev;
+	struct device *dev = &adapter->pdev->dev;
 	unsigned gpio = MINNOW_PHY_RESET_GPIO;
 	int ret;
 
-	ret = devm_gpio_request_one(&pdev->dev, gpio, flags,
-				    "minnow_phy_reset");
+	ret = devm_gpio_request_one(dev, gpio, flags, "minnow_phy_reset");
 	if (ret) {
-		dev_err(&pdev->dev,
-			"ERR: Can't request PHY reset GPIO line '%d'\n", gpio);
+		netdev_err(netdev,
+			   "ERR: Can't request PHY reset GPIO line '%d'\n",
+			   gpio);
 		return ret;
 	}
 
-	gpio_set_value(gpio, 0);
-	usleep_range(1250, 1500);
-	gpio_set_value(gpio, 1);
-	usleep_range(1250, 1500);
-
+	phydev->mdio.reset = gpio_to_desc(gpio);
+	phydev->mdio.reset_assert_delay = 1500;
+	phydev->mdio.reset_deassert_delay = 1500;
 	return ret;
 }
 
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_param.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_param.c
index e097e6baaac4..c1fd66cadc76 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_param.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_param.c
@@ -42,60 +42,6 @@ static int RxDescriptors = OPTION_UNSET;
 module_param(RxDescriptors, int, 0);
 MODULE_PARM_DESC(RxDescriptors, "Number of receive descriptors");
 
-/**
- * Speed - User Specified Speed Override
- * @Valid Range: 0, 10, 100, 1000
- *   - 0:    auto-negotiate at all supported speeds
- *   - 10:   only link at 10 Mbps
- *   - 100:  only link at 100 Mbps
- *   - 1000: only link at 1000 Mbps
- * @Default Value: 0
- */
-static int Speed = OPTION_UNSET;
-module_param(Speed, int, 0);
-MODULE_PARM_DESC(Speed, "Speed setting");
-
-/**
- * Duplex - User Specified Duplex Override
- * @Valid Range: 0-2
- *   - 0:  auto-negotiate for duplex
- *   - 1:  only link at half duplex
- *   - 2:  only link at full duplex
- * @Default Value: 0
- */
-static int Duplex = OPTION_UNSET;
-module_param(Duplex, int, 0);
-MODULE_PARM_DESC(Duplex, "Duplex setting");
-
-#define HALF_DUPLEX 1
-#define FULL_DUPLEX 2
-
-/**
- * AutoNeg - Auto-negotiation Advertisement Override
- * @Valid Range: 0x01-0x0F, 0x20-0x2F
- *
- *       The AutoNeg value is a bit mask describing which speed and duplex
- *       combinations should be advertised during auto-negotiation.
- *       The supported speed and duplex modes are listed below
- *
- *       Bit           7     6     5      4      3     2     1      0
- *       Speed (Mbps)  N/A   N/A   1000   N/A    100   100   10     10
- *       Duplex                    Full          Full  Half  Full   Half
- *
- * @Default Value: 0x2F (copper)
- */
-static int AutoNeg = OPTION_UNSET;
-module_param(AutoNeg, int, 0);
-MODULE_PARM_DESC(AutoNeg, "Advertised auto-negotiation setting");
-
-#define PHY_ADVERTISE_10_HALF      0x0001
-#define PHY_ADVERTISE_10_FULL      0x0002
-#define PHY_ADVERTISE_100_HALF     0x0004
-#define PHY_ADVERTISE_100_FULL     0x0008
-#define PHY_ADVERTISE_1000_HALF    0x0010 /* Not used, just FYI */
-#define PHY_ADVERTISE_1000_FULL    0x0020
-#define PCH_AUTONEG_ADVERTISE_DEFAULT   0x2F
-
 /**
  * FlowControl - User Specified Flow Control Override
  * @Valid Range: 0-3
@@ -159,54 +105,6 @@ struct pch_gbe_option {
 	} arg;
 };
 
-static const struct pch_gbe_opt_list speed_list[] = {
-	{ 0, "" },
-	{ SPEED_10, "" },
-	{ SPEED_100, "" },
-	{ SPEED_1000, "" }
-};
-
-static const struct pch_gbe_opt_list dplx_list[] = {
-	{ 0, "" },
-	{ HALF_DUPLEX, "" },
-	{ FULL_DUPLEX, "" }
-};
-
-static const struct pch_gbe_opt_list an_list[] =
-	#define AA "AutoNeg advertising "
-	{{ 0x01, AA "10/HD" },
-	 { 0x02, AA "10/FD" },
-	 { 0x03, AA "10/FD, 10/HD" },
-	 { 0x04, AA "100/HD" },
-	 { 0x05, AA "100/HD, 10/HD" },
-	 { 0x06, AA "100/HD, 10/FD" },
-	 { 0x07, AA "100/HD, 10/FD, 10/HD" },
-	 { 0x08, AA "100/FD" },
-	 { 0x09, AA "100/FD, 10/HD" },
-	 { 0x0a, AA "100/FD, 10/FD" },
-	 { 0x0b, AA "100/FD, 10/FD, 10/HD" },
-	 { 0x0c, AA "100/FD, 100/HD" },
-	 { 0x0d, AA "100/FD, 100/HD, 10/HD" },
-	 { 0x0e, AA "100/FD, 100/HD, 10/FD" },
-	 { 0x0f, AA "100/FD, 100/HD, 10/FD, 10/HD" },
-	 { 0x20, AA "1000/FD" },
-	 { 0x21, AA "1000/FD, 10/HD" },
-	 { 0x22, AA "1000/FD, 10/FD" },
-	 { 0x23, AA "1000/FD, 10/FD, 10/HD" },
-	 { 0x24, AA "1000/FD, 100/HD" },
-	 { 0x25, AA "1000/FD, 100/HD, 10/HD" },
-	 { 0x26, AA "1000/FD, 100/HD, 10/FD" },
-	 { 0x27, AA "1000/FD, 100/HD, 10/FD, 10/HD" },
-	 { 0x28, AA "1000/FD, 100/FD" },
-	 { 0x29, AA "1000/FD, 100/FD, 10/HD" },
-	 { 0x2a, AA "1000/FD, 100/FD, 10/FD" },
-	 { 0x2b, AA "1000/FD, 100/FD, 10/FD, 10/HD" },
-	 { 0x2c, AA "1000/FD, 100/FD, 100/HD" },
-	 { 0x2d, AA "1000/FD, 100/FD, 100/HD, 10/HD" },
-	 { 0x2e, AA "1000/FD, 100/FD, 100/HD, 10/FD" },
-	 { 0x2f, AA "1000/FD, 100/FD, 100/HD, 10/FD, 10/HD" }
-};
-
 static const struct pch_gbe_opt_list fc_list[] = {
 	{ PCH_GBE_FC_NONE, "Flow Control Disabled" },
 	{ PCH_GBE_FC_RX_PAUSE, "Flow Control Receive Only" },
@@ -275,167 +173,6 @@ static int pch_gbe_validate_option(int *value,
 	return -1;
 }
 
-/**
- * pch_gbe_check_copper_options - Range Checking for Link Options, Copper Version
- * @adapter:  Board private structure
- */
-static void pch_gbe_check_copper_options(struct pch_gbe_adapter *adapter)
-{
-	struct pch_gbe_hw *hw = &adapter->hw;
-	int speed, dplx;
-
-	{ /* Speed */
-		static const struct pch_gbe_option opt = {
-			.type = list_option,
-			.name = "Speed",
-			.err  = "parameter ignored",
-			.def  = 0,
-			.arg  = { .l = { .nr = (int)ARRAY_SIZE(speed_list),
-					 .p = speed_list } }
-		};
-		speed = Speed;
-		pch_gbe_validate_option(&speed, &opt, adapter);
-	}
-	{ /* Duplex */
-		static const struct pch_gbe_option opt = {
-			.type = list_option,
-			.name = "Duplex",
-			.err  = "parameter ignored",
-			.def  = 0,
-			.arg  = { .l = { .nr = (int)ARRAY_SIZE(dplx_list),
-					 .p = dplx_list } }
-		};
-		dplx = Duplex;
-		pch_gbe_validate_option(&dplx, &opt, adapter);
-	}
-
-	{ /* Autoneg */
-		static const struct pch_gbe_option opt = {
-			.type = list_option,
-			.name = "AutoNeg",
-			.err  = "parameter ignored",
-			.def  = PCH_AUTONEG_ADVERTISE_DEFAULT,
-			.arg  = { .l = { .nr = (int)ARRAY_SIZE(an_list),
-					 .p = an_list} }
-		};
-		if (speed || dplx) {
-			netdev_dbg(adapter->netdev,
-				   "AutoNeg specified along with Speed or Duplex, AutoNeg parameter ignored\n");
-			hw->phy.autoneg_advertised = opt.def;
-		} else {
-			int tmp = AutoNeg;
-
-			pch_gbe_validate_option(&tmp, &opt, adapter);
-			hw->phy.autoneg_advertised = tmp;
-		}
-	}
-
-	switch (speed + dplx) {
-	case 0:
-		hw->mac.autoneg = hw->mac.fc_autoneg = 1;
-		if ((speed || dplx))
-			netdev_dbg(adapter->netdev,
-				   "Speed and duplex autonegotiation enabled\n");
-		hw->mac.link_speed = SPEED_10;
-		hw->mac.link_duplex = DUPLEX_HALF;
-		break;
-	case HALF_DUPLEX:
-		netdev_dbg(adapter->netdev,
-			   "Half Duplex specified without Speed\n");
-		netdev_dbg(adapter->netdev,
-			   "Using Autonegotiation at Half Duplex only\n");
-		hw->mac.autoneg = hw->mac.fc_autoneg = 1;
-		hw->phy.autoneg_advertised = PHY_ADVERTISE_10_HALF |
-						PHY_ADVERTISE_100_HALF;
-		hw->mac.link_speed = SPEED_10;
-		hw->mac.link_duplex = DUPLEX_HALF;
-		break;
-	case FULL_DUPLEX:
-		netdev_dbg(adapter->netdev,
-			   "Full Duplex specified without Speed\n");
-		netdev_dbg(adapter->netdev,
-			   "Using Autonegotiation at Full Duplex only\n");
-		hw->mac.autoneg = hw->mac.fc_autoneg = 1;
-		hw->phy.autoneg_advertised = PHY_ADVERTISE_10_FULL |
-						PHY_ADVERTISE_100_FULL |
-						PHY_ADVERTISE_1000_FULL;
-		hw->mac.link_speed = SPEED_10;
-		hw->mac.link_duplex = DUPLEX_FULL;
-		break;
-	case SPEED_10:
-		netdev_dbg(adapter->netdev,
-			   "10 Mbps Speed specified without Duplex\n");
-		netdev_dbg(adapter->netdev,
-			   "Using Autonegotiation at 10 Mbps only\n");
-		hw->mac.autoneg = hw->mac.fc_autoneg = 1;
-		hw->phy.autoneg_advertised = PHY_ADVERTISE_10_HALF |
-						PHY_ADVERTISE_10_FULL;
-		hw->mac.link_speed = SPEED_10;
-		hw->mac.link_duplex = DUPLEX_HALF;
-		break;
-	case SPEED_10 + HALF_DUPLEX:
-		netdev_dbg(adapter->netdev, "Forcing to 10 Mbps Half Duplex\n");
-		hw->mac.autoneg = hw->mac.fc_autoneg = 0;
-		hw->phy.autoneg_advertised = 0;
-		hw->mac.link_speed = SPEED_10;
-		hw->mac.link_duplex = DUPLEX_HALF;
-		break;
-	case SPEED_10 + FULL_DUPLEX:
-		netdev_dbg(adapter->netdev, "Forcing to 10 Mbps Full Duplex\n");
-		hw->mac.autoneg = hw->mac.fc_autoneg = 0;
-		hw->phy.autoneg_advertised = 0;
-		hw->mac.link_speed = SPEED_10;
-		hw->mac.link_duplex = DUPLEX_FULL;
-		break;
-	case SPEED_100:
-		netdev_dbg(adapter->netdev,
-			   "100 Mbps Speed specified without Duplex\n");
-		netdev_dbg(adapter->netdev,
-			   "Using Autonegotiation at 100 Mbps only\n");
-		hw->mac.autoneg = hw->mac.fc_autoneg = 1;
-		hw->phy.autoneg_advertised = PHY_ADVERTISE_100_HALF |
-						PHY_ADVERTISE_100_FULL;
-		hw->mac.link_speed = SPEED_100;
-		hw->mac.link_duplex = DUPLEX_HALF;
-		break;
-	case SPEED_100 + HALF_DUPLEX:
-		netdev_dbg(adapter->netdev,
-			   "Forcing to 100 Mbps Half Duplex\n");
-		hw->mac.autoneg = hw->mac.fc_autoneg = 0;
-		hw->phy.autoneg_advertised = 0;
-		hw->mac.link_speed = SPEED_100;
-		hw->mac.link_duplex = DUPLEX_HALF;
-		break;
-	case SPEED_100 + FULL_DUPLEX:
-		netdev_dbg(adapter->netdev,
-			   "Forcing to 100 Mbps Full Duplex\n");
-		hw->mac.autoneg = hw->mac.fc_autoneg = 0;
-		hw->phy.autoneg_advertised = 0;
-		hw->mac.link_speed = SPEED_100;
-		hw->mac.link_duplex = DUPLEX_FULL;
-		break;
-	case SPEED_1000:
-		netdev_dbg(adapter->netdev,
-			   "1000 Mbps Speed specified without Duplex\n");
-		goto full_duplex_only;
-	case SPEED_1000 + HALF_DUPLEX:
-		netdev_dbg(adapter->netdev,
-			   "Half Duplex is not supported at 1000 Mbps\n");
-		/* fall through */
-	case SPEED_1000 + FULL_DUPLEX:
-full_duplex_only:
-		netdev_dbg(adapter->netdev,
-			   "Using Autonegotiation at 1000 Mbps Full Duplex only\n");
-		hw->mac.autoneg = hw->mac.fc_autoneg = 1;
-		hw->phy.autoneg_advertised = PHY_ADVERTISE_1000_FULL;
-		hw->mac.link_speed = SPEED_1000;
-		hw->mac.link_duplex = DUPLEX_FULL;
-		break;
-	default:
-		BUG();
-	}
-}
-
 /**
  * pch_gbe_check_options - Range Checking for Command Line Parameters
  * @adapter:  Board private structure
@@ -516,6 +253,4 @@ void pch_gbe_check_options(struct pch_gbe_adapter *adapter)
 		pch_gbe_validate_option(&tmp, &opt, adapter);
 		hw->mac.fc = tmp;
 	}
-
-	pch_gbe_check_copper_options(adapter);
 }
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c
deleted file mode 100644
index 561e71880c29..000000000000
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Copyright (C) 1999 - 2010 Intel Corporation.
- * Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD.
- *
- * This code was derived from the Intel e1000e Linux driver.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "pch_gbe.h"
-#include "pch_gbe_phy.h"
-
-#define PHY_MAX_REG_ADDRESS   0x1F	/* 5 bit address bus (0-0x1F) */
-
-/* PHY 1000 MII Register/Bit Definitions */
-/* PHY Registers defined by IEEE */
-#define PHY_CONTROL           0x00  /* Control Register */
-#define PHY_STATUS            0x01  /* Status Regiser */
-#define PHY_ID1               0x02  /* Phy Id Register (word 1) */
-#define PHY_ID2               0x03  /* Phy Id Register (word 2) */
-#define PHY_AUTONEG_ADV       0x04  /* Autoneg Advertisement */
-#define PHY_LP_ABILITY        0x05  /* Link Partner Ability (Base Page) */
-#define PHY_AUTONEG_EXP       0x06  /* Autoneg Expansion Register */
-#define PHY_NEXT_PAGE_TX      0x07  /* Next Page TX */
-#define PHY_LP_NEXT_PAGE      0x08  /* Link Partner Next Page */
-#define PHY_1000T_CTRL        0x09  /* 1000Base-T Control Register */
-#define PHY_1000T_STATUS      0x0A  /* 1000Base-T Status Register */
-#define PHY_EXT_STATUS        0x0F  /* Extended Status Register */
-#define PHY_PHYSP_CONTROL     0x10  /* PHY Specific Control Register */
-#define PHY_EXT_PHYSP_CONTROL 0x14  /* Extended PHY Specific Control Register */
-#define PHY_LED_CONTROL       0x18  /* LED Control Register */
-#define PHY_EXT_PHYSP_STATUS  0x1B  /* Extended PHY Specific Status Register */
-
-/* PHY Control Register */
-#define MII_CR_SPEED_SELECT_MSB 0x0040	/* bits 6,13: 10=1000, 01=100, 00=10 */
-#define MII_CR_COLL_TEST_ENABLE 0x0080	/* Collision test enable */
-#define MII_CR_FULL_DUPLEX      0x0100	/* FDX =1, half duplex =0 */
-#define MII_CR_RESTART_AUTO_NEG 0x0200	/* Restart auto negotiation */
-#define MII_CR_ISOLATE          0x0400	/* Isolate PHY from MII */
-#define MII_CR_POWER_DOWN       0x0800	/* Power down */
-#define MII_CR_AUTO_NEG_EN      0x1000	/* Auto Neg Enable */
-#define MII_CR_SPEED_SELECT_LSB 0x2000	/* bits 6,13: 10=1000, 01=100, 00=10 */
-#define MII_CR_LOOPBACK         0x4000	/* 0 = normal, 1 = loopback */
-#define MII_CR_RESET            0x8000	/* 0 = normal, 1 = PHY reset */
-#define MII_CR_SPEED_1000       0x0040
-#define MII_CR_SPEED_100        0x2000
-#define MII_CR_SPEED_10         0x0000
-
-/* PHY Status Register */
-#define MII_SR_EXTENDED_CAPS     0x0001	/* Extended register capabilities */
-#define MII_SR_JABBER_DETECT     0x0002	/* Jabber Detected */
-#define MII_SR_LINK_STATUS       0x0004	/* Link Status 1 = link */
-#define MII_SR_AUTONEG_CAPS      0x0008	/* Auto Neg Capable */
-#define MII_SR_REMOTE_FAULT      0x0010	/* Remote Fault Detect */
-#define MII_SR_AUTONEG_COMPLETE  0x0020	/* Auto Neg Complete */
-#define MII_SR_PREAMBLE_SUPPRESS 0x0040	/* Preamble may be suppressed */
-#define MII_SR_EXTENDED_STATUS   0x0100	/* Ext. status info in Reg 0x0F */
-#define MII_SR_100T2_HD_CAPS     0x0200	/* 100T2 Half Duplex Capable */
-#define MII_SR_100T2_FD_CAPS     0x0400	/* 100T2 Full Duplex Capable */
-#define MII_SR_10T_HD_CAPS       0x0800	/* 10T   Half Duplex Capable */
-#define MII_SR_10T_FD_CAPS       0x1000	/* 10T   Full Duplex Capable */
-#define MII_SR_100X_HD_CAPS      0x2000	/* 100X  Half Duplex Capable */
-#define MII_SR_100X_FD_CAPS      0x4000	/* 100X  Full Duplex Capable */
-#define MII_SR_100T4_CAPS        0x8000	/* 100T4 Capable */
-
-/* AR8031 PHY Debug Registers */
-#define PHY_AR803X_ID           0x00001374
-#define PHY_AR8031_DBG_OFF      0x1D
-#define PHY_AR8031_DBG_DAT      0x1E
-#define PHY_AR8031_SERDES       0x05
-#define PHY_AR8031_SERDES_TX_CLK_DLY   0x0100 /* TX clock delay of 2.0ns */
-
-/* Phy Id Register (word 2) */
-#define PHY_REVISION_MASK        0x000F
-
-/* PHY Specific Control Register */
-#define PHYSP_CTRL_ASSERT_CRS_TX  0x0800
-
-
-/* Default value of PHY register */
-#define PHY_CONTROL_DEFAULT         0x1140 /* Control Register */
-#define PHY_AUTONEG_ADV_DEFAULT     0x01e0 /* Autoneg Advertisement */
-#define PHY_NEXT_PAGE_TX_DEFAULT    0x2001 /* Next Page TX */
-#define PHY_1000T_CTRL_DEFAULT      0x0300 /* 1000Base-T Control Register */
-#define PHY_PHYSP_CONTROL_DEFAULT   0x01EE /* PHY Specific Control Register */
-
-/**
- * pch_gbe_phy_get_id - Retrieve the PHY ID and revision
- * @hw:	       Pointer to the HW structure
- * Returns
- *	0:			Successful.
- *	Negative value:		Failed.
- */
-s32 pch_gbe_phy_get_id(struct pch_gbe_hw *hw)
-{
-	struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
-	struct pch_gbe_phy_info *phy = &hw->phy;
-	s32 ret;
-	u16 phy_id1;
-	u16 phy_id2;
-
-	ret = pch_gbe_phy_read_reg_miic(hw, PHY_ID1, &phy_id1);
-	if (ret)
-		return ret;
-	ret = pch_gbe_phy_read_reg_miic(hw, PHY_ID2, &phy_id2);
-	if (ret)
-		return ret;
-	/*
-	 * PHY_ID1: [bit15-0:ID(21-6)]
-	 * PHY_ID2: [bit15-10:ID(5-0)][bit9-4:Model][bit3-0:revision]
-	 */
-	phy->id = (u32)phy_id1;
-	phy->id = ((phy->id << 6) | ((phy_id2 & 0xFC00) >> 10));
-	phy->revision = (u32) (phy_id2 & 0x000F);
-	netdev_dbg(adapter->netdev,
-		   "phy->id : 0x%08x  phy->revision : 0x%08x\n",
-		   phy->id, phy->revision);
-	return 0;
-}
-
-/**
- * pch_gbe_phy_read_reg_miic - Read MII control register
- * @hw:	     Pointer to the HW structure
- * @offset:  Register offset to be read
- * @data:    Pointer to the read data
- * Returns
- *	0:		Successful.
- *	-EINVAL:	Invalid argument.
- */
-s32 pch_gbe_phy_read_reg_miic(struct pch_gbe_hw *hw, u32 offset, u16 *data)
-{
-	struct pch_gbe_phy_info *phy = &hw->phy;
-
-	if (offset > PHY_MAX_REG_ADDRESS) {
-		struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
-
-		netdev_err(adapter->netdev, "PHY Address %d is out of range\n",
-			   offset);
-		return -EINVAL;
-	}
-	*data = pch_gbe_mac_ctrl_miim(hw, phy->addr, PCH_GBE_HAL_MIIM_READ,
-				      offset, (u16)0);
-	return 0;
-}
-
-/**
- * pch_gbe_phy_write_reg_miic - Write MII control register
- * @hw:	     Pointer to the HW structure
- * @offset:  Register offset to be read
- * @data:    data to write to register at offset
- * Returns
- *	0:		Successful.
- *	-EINVAL:	Invalid argument.
- */
-s32 pch_gbe_phy_write_reg_miic(struct pch_gbe_hw *hw, u32 offset, u16 data)
-{
-	struct pch_gbe_phy_info *phy = &hw->phy;
-
-	if (offset > PHY_MAX_REG_ADDRESS) {
-		struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
-
-		netdev_err(adapter->netdev, "PHY Address %d is out of range\n",
-			   offset);
-		return -EINVAL;
-	}
-	pch_gbe_mac_ctrl_miim(hw, phy->addr, PCH_GBE_HAL_MIIM_WRITE,
-				 offset, data);
-	return 0;
-}
-
-/**
- * pch_gbe_phy_sw_reset - PHY software reset
- * @hw:	            Pointer to the HW structure
- */
-static void pch_gbe_phy_sw_reset(struct pch_gbe_hw *hw)
-{
-	u16 phy_ctrl;
-
-	pch_gbe_phy_read_reg_miic(hw, PHY_CONTROL, &phy_ctrl);
-	phy_ctrl |= MII_CR_RESET;
-	pch_gbe_phy_write_reg_miic(hw, PHY_CONTROL, phy_ctrl);
-	udelay(1);
-}
-
-/**
- * pch_gbe_phy_hw_reset - PHY hardware reset
- * @hw:	   Pointer to the HW structure
- */
-void pch_gbe_phy_hw_reset(struct pch_gbe_hw *hw)
-{
-	pch_gbe_phy_write_reg_miic(hw, PHY_CONTROL, PHY_CONTROL_DEFAULT);
-	pch_gbe_phy_write_reg_miic(hw, PHY_AUTONEG_ADV,
-					PHY_AUTONEG_ADV_DEFAULT);
-	pch_gbe_phy_write_reg_miic(hw, PHY_NEXT_PAGE_TX,
-					PHY_NEXT_PAGE_TX_DEFAULT);
-	pch_gbe_phy_write_reg_miic(hw, PHY_1000T_CTRL, PHY_1000T_CTRL_DEFAULT);
-	pch_gbe_phy_write_reg_miic(hw, PHY_PHYSP_CONTROL,
-					PHY_PHYSP_CONTROL_DEFAULT);
-}
-
-/**
- * pch_gbe_phy_power_up - restore link in case the phy was powered down
- * @hw:	   Pointer to the HW structure
- */
-void pch_gbe_phy_power_up(struct pch_gbe_hw *hw)
-{
-	u16 mii_reg;
-
-	mii_reg = 0;
-	/* Just clear the power down bit to wake the phy back up */
-	/* according to the manual, the phy will retain its
-	 * settings across a power-down/up cycle */
-	pch_gbe_phy_read_reg_miic(hw, PHY_CONTROL, &mii_reg);
-	mii_reg &= ~MII_CR_POWER_DOWN;
-	pch_gbe_phy_write_reg_miic(hw, PHY_CONTROL, mii_reg);
-}
-
-/**
- * pch_gbe_phy_power_down - Power down PHY
- * @hw:	   Pointer to the HW structure
- */
-void pch_gbe_phy_power_down(struct pch_gbe_hw *hw)
-{
-	u16 mii_reg;
-
-	mii_reg = 0;
-	/* Power down the PHY so no link is implied when interface is down *
-	 * The PHY cannot be powered down if any of the following is TRUE *
-	 * (a) WoL is enabled
-	 * (b) AMT is active
-	 */
-	pch_gbe_phy_read_reg_miic(hw, PHY_CONTROL, &mii_reg);
-	mii_reg |= MII_CR_POWER_DOWN;
-	pch_gbe_phy_write_reg_miic(hw, PHY_CONTROL, mii_reg);
-	mdelay(1);
-}
-
-/**
- * pch_gbe_phy_set_rgmii - RGMII interface setting
- * @hw:	            Pointer to the HW structure
- */
-void pch_gbe_phy_set_rgmii(struct pch_gbe_hw *hw)
-{
-	pch_gbe_phy_sw_reset(hw);
-}
-
-/**
- * pch_gbe_phy_tx_clk_delay - Setup TX clock delay via the PHY
- * @hw:	            Pointer to the HW structure
- * Returns
- *	0:		Successful.
- *	-EINVAL:	Invalid argument.
- */
-static int pch_gbe_phy_tx_clk_delay(struct pch_gbe_hw *hw)
-{
-	/* The RGMII interface requires a ~2ns TX clock delay. This is typically
-	 * done in layout with a longer trace or via PHY strapping, but can also
-	 * be done via PHY configuration registers.
-	 */
-	struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
-	u16 mii_reg;
-	int ret = 0;
-
-	switch (hw->phy.id) {
-	case PHY_AR803X_ID:
-		netdev_dbg(adapter->netdev,
-			   "Configuring AR803X PHY for 2ns TX clock delay\n");
-		pch_gbe_phy_read_reg_miic(hw, PHY_AR8031_DBG_OFF, &mii_reg);
-		ret = pch_gbe_phy_write_reg_miic(hw, PHY_AR8031_DBG_OFF,
-						 PHY_AR8031_SERDES);
-		if (ret)
-			break;
-
-		pch_gbe_phy_read_reg_miic(hw, PHY_AR8031_DBG_DAT, &mii_reg);
-		mii_reg |= PHY_AR8031_SERDES_TX_CLK_DLY;
-		ret = pch_gbe_phy_write_reg_miic(hw, PHY_AR8031_DBG_DAT,
-						 mii_reg);
-		break;
-	default:
-		netdev_err(adapter->netdev,
-			   "Unknown PHY (%x), could not set TX clock delay\n",
-			   hw->phy.id);
-		return -EINVAL;
-	}
-
-	if (ret)
-		netdev_err(adapter->netdev,
-			   "Could not configure tx clock delay for PHY\n");
-	return ret;
-}
-
-/**
- * pch_gbe_phy_init_setting - PHY initial setting
- * @hw:	            Pointer to the HW structure
- */
-void pch_gbe_phy_init_setting(struct pch_gbe_hw *hw)
-{
-	struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
-	struct ethtool_cmd     cmd = { .cmd = ETHTOOL_GSET };
-	int ret;
-	u16 mii_reg;
-
-	ret = mii_ethtool_gset(&adapter->mii, &cmd);
-	if (ret)
-		netdev_err(adapter->netdev, "Error: mii_ethtool_gset\n");
-
-	ethtool_cmd_speed_set(&cmd, hw->mac.link_speed);
-	cmd.duplex = hw->mac.link_duplex;
-	cmd.advertising = hw->phy.autoneg_advertised;
-	cmd.autoneg = hw->mac.autoneg;
-	pch_gbe_phy_write_reg_miic(hw, MII_BMCR, BMCR_RESET);
-	ret = mii_ethtool_sset(&adapter->mii, &cmd);
-	if (ret)
-		netdev_err(adapter->netdev, "Error: mii_ethtool_sset\n");
-
-	pch_gbe_phy_sw_reset(hw);
-
-	pch_gbe_phy_read_reg_miic(hw, PHY_PHYSP_CONTROL, &mii_reg);
-	mii_reg |= PHYSP_CTRL_ASSERT_CRS_TX;
-	pch_gbe_phy_write_reg_miic(hw, PHY_PHYSP_CONTROL, mii_reg);
-
-	/* Setup a TX clock delay on certain platforms */
-	if (adapter->pdata && adapter->pdata->phy_tx_clk_delay)
-		pch_gbe_phy_tx_clk_delay(hw);
-}
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h
deleted file mode 100644
index a80644b4fce8..000000000000
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 1999 - 2010 Intel Corporation.
- * Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD.
- *
- * This code was derived from the Intel e1000e Linux driver.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-#ifndef _PCH_GBE_PHY_H_
-#define _PCH_GBE_PHY_H_
-
-#define PCH_GBE_PHY_REGS_LEN		32
-#define	PCH_GBE_PHY_RESET_DELAY_US	10
-
-s32 pch_gbe_phy_get_id(struct pch_gbe_hw *hw);
-s32 pch_gbe_phy_read_reg_miic(struct pch_gbe_hw *hw, u32 offset, u16 *data);
-s32 pch_gbe_phy_write_reg_miic(struct pch_gbe_hw *hw, u32 offset, u16 data);
-void pch_gbe_phy_hw_reset(struct pch_gbe_hw *hw);
-void pch_gbe_phy_power_up(struct pch_gbe_hw *hw);
-void pch_gbe_phy_power_down(struct pch_gbe_hw *hw);
-void pch_gbe_phy_set_rgmii(struct pch_gbe_hw *hw);
-void pch_gbe_phy_init_setting(struct pch_gbe_hw *hw);
-
-#endif /* _PCH_GBE_PHY_H_ */
-- 
2.18.0

^ permalink raw reply related

* [PATCH v7 10/11] ptp: pch: Allow build on MIPS platforms
From: Paul Burton @ 2018-06-27  0:06 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Andrew Lunn, paul.burton
In-Reply-To: <20180627000612.27263-1-paul.burton@mips.com>

Allow the ptp_pch driver to be built on MIPS platforms in preparation
for use on the MIPS Boston board.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

Changes in v7: None

 drivers/ptp/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
index d137c480db46..fd5f2c6c18ba 100644
--- a/drivers/ptp/Kconfig
+++ b/drivers/ptp/Kconfig
@@ -90,7 +90,7 @@ config DP83640_PHY
 
 config PTP_1588_CLOCK_PCH
 	tristate "Intel PCH EG20T as PTP clock"
-	depends on X86_32 || COMPILE_TEST
+	depends on X86_32 || MIPS || COMPILE_TEST
 	depends on HAS_IOMEM && NET
 	imply PTP_1588_CLOCK
 	help
-- 
2.18.0

^ permalink raw reply related

* [PATCH v7 08/11] net: pch_gbe: Clean up resets
From: Paul Burton @ 2018-06-27  0:06 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Andrew Lunn, paul.burton
In-Reply-To: <20180627000612.27263-1-paul.burton@mips.com>

Currently pch_gbe_reset() performs a number of tasks:

  1) Calls pch_gbe_reset_hw(), which:

     1a) Reads the MAC address from the hardware, even though we already
         did that in pch_gbe_open() & it should not have changed.

     1b) Writes to the RESET register to reset the MAC.

     1c) Writes the MODE register to configure GMII/RGMII mode,
         potentially before the MAC reset has finished.

     1d) Polls for the completion of the MAC reset.

     1e) Configures the device MAC address.

  2) Calls pch_gbe_set_multi() to configure multicast addresses &
     hardware MAC filtering.

  3) Calls pch_gbe_mac_init_rx_addrs(), which:

     3a) Configures the device MAC address again, duplicating step 1e.

     3b) Masks & clears all other MAC registers, wiping out the
         configuration performed by step 2.

This is needlessly repetitive & split across 3 functions for no good
reason. This patch cleans this up significantly by:

  a) Inlining pch_gbe_mac_reset_hw() into pch_gbe_reset(), moving the
     MODE register write to after the MAC reset has completed & removing
     the initial read of the MAC address.

  b) Removing pch_gbe_mac_init_rx_addrs() entirely, leaving the
     address configuration performed by pch_gbe_set_multi() intact.

With this done we know that pch_gbe_reset() will leave us with the
multicast MAC addresses & filtering configured correctly, so we can
remove the call to pch_gbe_set_multi() in pch_gbe_watchdog().

Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

Changes in v7: New patch

 .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c  | 54 ++++---------------
 1 file changed, 11 insertions(+), 43 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index c9b064ac06a1..123c7818698d 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -357,22 +357,6 @@ static void pch_gbe_mac_mar_set(struct pch_gbe_hw *hw, u8 * addr, u32 index)
 	pch_gbe_wait_clr_bit(&hw->reg->ADDR_MASK, PCH_GBE_BUSY);
 }
 
-/**
- * pch_gbe_mac_reset_hw - Reset hardware
- * @hw:	Pointer to the HW structure
- */
-static void pch_gbe_mac_reset_hw(struct pch_gbe_hw *hw)
-{
-	/* Read the MAC address. and store to the private data */
-	pch_gbe_mac_read_mac_addr(hw);
-	iowrite32(PCH_GBE_ALL_RST, &hw->reg->RESET);
-	iowrite32(PCH_GBE_MODE_GMII_ETHER, &hw->reg->MODE);
-	pch_gbe_wait_clr_bit(&hw->reg->RESET, PCH_GBE_ALL_RST);
-	/* Setup the receive addresses */
-	pch_gbe_mac_mar_set(hw, hw->mac.addr, 0);
-	return;
-}
-
 static void pch_gbe_disable_mac_rx(struct pch_gbe_hw *hw)
 {
 	u32 rctl;
@@ -389,28 +373,6 @@ static void pch_gbe_enable_mac_rx(struct pch_gbe_hw *hw)
 	iowrite32((rctl | PCH_GBE_MRE_MAC_RX_EN), &hw->reg->MAC_RX_EN);
 }
 
-/**
- * pch_gbe_mac_init_rx_addrs - Initialize receive address's
- * @hw:	Pointer to the HW structure
- * @mar_count: Receive address registers
- */
-static void pch_gbe_mac_init_rx_addrs(struct pch_gbe_hw *hw, u16 mar_count)
-{
-	u32 i;
-
-	/* Setup the receive address */
-	pch_gbe_mac_mar_set(hw, hw->mac.addr, 0);
-
-	/* Zero out the other receive addresses */
-	for (i = 1; i < mar_count; i++) {
-		iowrite32(0, &hw->reg->mac_adr[i].high);
-		iowrite32(0, &hw->reg->mac_adr[i].low);
-	}
-	iowrite32(0xFFFE, &hw->reg->ADDR_MASK);
-	/* wait busy */
-	pch_gbe_wait_clr_bit(&hw->reg->ADDR_MASK, PCH_GBE_BUSY);
-}
-
 /**
  * pch_gbe_mac_force_mac_fc - Force the MAC's flow control settings
  * @hw:	            Pointer to the HW structure
@@ -734,11 +696,18 @@ void pch_gbe_reset(struct pch_gbe_adapter *adapter)
 	struct net_device *netdev = adapter->netdev;
 	struct pch_gbe_hw *hw = &adapter->hw;
 
-	pch_gbe_mac_reset_hw(hw);
-	/* reprogram multicast address register after reset */
+	/* Perform the reset & wait for it to complete */
+	iowrite32(PCH_GBE_ALL_RST, &hw->reg->RESET);
+	pch_gbe_wait_clr_bit(&hw->reg->RESET, PCH_GBE_ALL_RST);
+
+	/* Configure GMII/RGMII mode */
+	iowrite32(PCH_GBE_MODE_GMII_ETHER, &hw->reg->MODE);
+
+	/* Program the MAC address */
+	pch_gbe_mac_mar_set(hw, hw->mac.addr, 0);
+
+	/* Configure multicast addresses & filtering */
 	pch_gbe_set_multi(netdev);
-	/* Setup the receive address. */
-	pch_gbe_mac_init_rx_addrs(hw, PCH_GBE_MAR_ENTRIES);
 }
 
 /**
@@ -1944,7 +1913,6 @@ static void pch_gbe_watchdog(struct timer_list *t)
 		pch_gbe_set_mode(adapter, hw->mac.link_speed,
 				 hw->mac.link_duplex);
 
-		pch_gbe_set_multi(netdev);
 		pch_gbe_setup_tctl(adapter);
 		pch_gbe_configure_tx(adapter);
 		pch_gbe_setup_rctl(adapter);
-- 
2.18.0

^ permalink raw reply related

* [PATCH v7 07/11] net: pch_gbe: Remove AR8031 PHY hibernation disable
From: Paul Burton @ 2018-06-27  0:06 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Andrew Lunn, paul.burton
In-Reply-To: <20180627000612.27263-1-paul.burton@mips.com>

We should now be able to cope with the PHY entering hibernation, ie.
ceasing to provide the RX clock, whilst the ethernet link is down.

Remove the code responsible for disabling the AR8031 PHY's hibernation
feature, allowing the PHY to enter its low power hibernation state.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

Changes in v7: New patch

 .../net/ethernet/oki-semi/pch_gbe/pch_gbe.h   |  2 -
 .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c  |  5 ---
 .../ethernet/oki-semi/pch_gbe/pch_gbe_phy.c   | 42 -------------------
 .../ethernet/oki-semi/pch_gbe/pch_gbe_phy.h   |  1 -
 4 files changed, 50 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
index 1bb0ea4f5503..f8acd8031951 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
@@ -542,13 +542,11 @@ struct pch_gbe_hw_stats {
 /**
  * struct pch_gbe_privdata - PCI Device ID driver data
  * @phy_tx_clk_delay:		Bool, configure the PHY TX delay in software
- * @phy_disable_hibernate:	Bool, disable PHY hibernation
  * @platform_init:		Platform initialization callback, called from
  *				probe, prior to PHY initialization.
  */
 struct pch_gbe_privdata {
 	bool phy_tx_clk_delay;
-	bool phy_disable_hibernate;
 	int (*platform_init)(struct pci_dev *pdev);
 };
 
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 721ce29b6467..c9b064ac06a1 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -2622,10 +2622,6 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 
 	dev_dbg(&pdev->dev, "PCH Network Connection\n");
 
-	/* Disable hibernation on certain platforms */
-	if (adapter->pdata && adapter->pdata->phy_disable_hibernate)
-		pch_gbe_phy_disable_hibernate(&adapter->hw);
-
 	device_set_wakeup_enable(&pdev->dev, 1);
 	return 0;
 
@@ -2663,7 +2659,6 @@ static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
 
 static struct pch_gbe_privdata pch_gbe_minnow_privdata = {
 	.phy_tx_clk_delay = true,
-	.phy_disable_hibernate = true,
 	.platform_init = pch_gbe_minnow_platform_init,
 };
 
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c
index 6b35b573beef..561e71880c29 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c
@@ -78,9 +78,7 @@
 #define PHY_AR8031_DBG_OFF      0x1D
 #define PHY_AR8031_DBG_DAT      0x1E
 #define PHY_AR8031_SERDES       0x05
-#define PHY_AR8031_HIBERNATE    0x0B
 #define PHY_AR8031_SERDES_TX_CLK_DLY   0x0100 /* TX clock delay of 2.0ns */
-#define PHY_AR8031_PS_HIB_EN           0x8000 /* Hibernate enable */
 
 /* Phy Id Register (word 2) */
 #define PHY_REVISION_MASK        0x000F
@@ -335,43 +333,3 @@ void pch_gbe_phy_init_setting(struct pch_gbe_hw *hw)
 	if (adapter->pdata && adapter->pdata->phy_tx_clk_delay)
 		pch_gbe_phy_tx_clk_delay(hw);
 }
-
-/**
- * pch_gbe_phy_disable_hibernate - Disable the PHY low power state
- * @hw:	            Pointer to the HW structure
- * Returns
- *	0:		Successful.
- *	-EINVAL:	Invalid argument.
- */
-int pch_gbe_phy_disable_hibernate(struct pch_gbe_hw *hw)
-{
-	struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
-	u16 mii_reg;
-	int ret = 0;
-
-	switch (hw->phy.id) {
-	case PHY_AR803X_ID:
-		netdev_dbg(adapter->netdev,
-			   "Disabling hibernation for AR803X PHY\n");
-		ret = pch_gbe_phy_write_reg_miic(hw, PHY_AR8031_DBG_OFF,
-						 PHY_AR8031_HIBERNATE);
-		if (ret)
-			break;
-
-		pch_gbe_phy_read_reg_miic(hw, PHY_AR8031_DBG_DAT, &mii_reg);
-		mii_reg &= ~PHY_AR8031_PS_HIB_EN;
-		ret = pch_gbe_phy_write_reg_miic(hw, PHY_AR8031_DBG_DAT,
-						 mii_reg);
-		break;
-	default:
-		netdev_err(adapter->netdev,
-			   "Unknown PHY (%x), could not disable hibernation\n",
-			   hw->phy.id);
-		return -EINVAL;
-	}
-
-	if (ret)
-		netdev_err(adapter->netdev,
-			   "Could not disable PHY hibernation\n");
-	return ret;
-}
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h
index 23ac38711619..a80644b4fce8 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h
@@ -30,6 +30,5 @@ void pch_gbe_phy_power_up(struct pch_gbe_hw *hw);
 void pch_gbe_phy_power_down(struct pch_gbe_hw *hw);
 void pch_gbe_phy_set_rgmii(struct pch_gbe_hw *hw);
 void pch_gbe_phy_init_setting(struct pch_gbe_hw *hw);
-int pch_gbe_phy_disable_hibernate(struct pch_gbe_hw *hw);
 
 #endif /* _PCH_GBE_PHY_H_ */
-- 
2.18.0

^ permalink raw reply related

* [PATCH v7 06/11] net: pch_gbe: Only enable MAC when PHY link is active
From: Paul Burton @ 2018-06-27  0:06 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Andrew Lunn, paul.burton
In-Reply-To: <20180627000612.27263-1-paul.burton@mips.com>

When using a PHY connected via RGMII, as the pch_gbe driver presumes is
the case, the RX clock is provided by the PHY to the MAC. Various PHYs,
including both the AR8031 used by the Minnowboard & the RTL8211E used by
the MIPS Boston development board, will stop generating the RX clock
when the ethernet link is down (eg. the ethernet cable is unplugged).

Various pieces of functionality in the EG20T MAC, ranging from basics
like completing a MAC reset to programming MAC addresses, rely upon the
RX clock being provided. When the clock is not provided these pieces of
functionality simply never complete, and the busy bits that indicate
they're in progress remain set indefinitely.

The pch_gbe driver currently requires that the RX clock is always
provided, and attempts to enforce this by disabling the hibernation
feature of the AR8031 PHY to keep it generating the RX clock. This patch
moves us away from this model by only configuring the MAC when the PHY
indicates that the ethernet link is up. When the link is up we should be
able to safely expect that the RX clock is being provided, and therefore
safely reset & configure the MAC.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

Changes in v7: New patch

 .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c  | 44 +++++++++----------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index eb290c1edce0..721ce29b6467 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -1837,7 +1837,6 @@ static int pch_gbe_request_irq(struct pch_gbe_adapter *adapter)
 int pch_gbe_up(struct pch_gbe_adapter *adapter)
 {
 	struct net_device *netdev = adapter->netdev;
-	struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring;
 	struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring;
 	int err = -EINVAL;
 
@@ -1847,14 +1846,6 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter)
 		goto out;
 	}
 
-	/* hardware has been reset, we need to reload some things */
-	pch_gbe_set_multi(netdev);
-
-	pch_gbe_setup_tctl(adapter);
-	pch_gbe_configure_tx(adapter);
-	pch_gbe_setup_rctl(adapter);
-	pch_gbe_configure_rx(adapter);
-
 	err = pch_gbe_request_irq(adapter);
 	if (err) {
 		netdev_err(netdev,
@@ -1867,18 +1858,9 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter)
 			   "Error: can't bring device up - alloc rx buffers pool failed\n");
 		goto freeirq;
 	}
-	pch_gbe_alloc_tx_buffers(adapter, tx_ring);
-	pch_gbe_alloc_rx_buffers(adapter, rx_ring, rx_ring->count);
 	adapter->tx_queue_len = netdev->tx_queue_len;
-	pch_gbe_enable_dma_rx(&adapter->hw);
-	pch_gbe_enable_mac_rx(&adapter->hw);
 
 	mod_timer(&adapter->watchdog_timer, jiffies);
-
-	napi_enable(&adapter->napi);
-	pch_gbe_irq_enable(adapter);
-	netif_start_queue(adapter->netdev);
-
 	return 0;
 
 freeirq:
@@ -1930,6 +1912,8 @@ static void pch_gbe_watchdog(struct timer_list *t)
 {
 	struct pch_gbe_adapter *adapter = from_timer(adapter, t,
 						     watchdog_timer);
+	struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring;
+	struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring;
 	struct net_device *netdev = adapter->netdev;
 	struct pch_gbe_hw *hw = &adapter->hw;
 
@@ -1950,12 +1934,32 @@ static void pch_gbe_watchdog(struct timer_list *t)
 		}
 		hw->mac.link_speed = ethtool_cmd_speed(&cmd);
 		hw->mac.link_duplex = cmd.duplex;
+
+		pch_gbe_reset(adapter);
+
 		/* Set the RGMII control. */
 		pch_gbe_set_rgmii_ctrl(adapter, hw->mac.link_speed,
 				       hw->mac.link_duplex);
 		/* Set the communication mode */
 		pch_gbe_set_mode(adapter, hw->mac.link_speed,
 				 hw->mac.link_duplex);
+
+		pch_gbe_set_multi(netdev);
+		pch_gbe_setup_tctl(adapter);
+		pch_gbe_configure_tx(adapter);
+		pch_gbe_setup_rctl(adapter);
+		pch_gbe_configure_rx(adapter);
+
+		pch_gbe_alloc_tx_buffers(adapter, tx_ring);
+		pch_gbe_alloc_rx_buffers(adapter, rx_ring, rx_ring->count);
+
+		pch_gbe_enable_dma_rx(&adapter->hw);
+		pch_gbe_enable_mac_rx(&adapter->hw);
+
+		napi_enable(&adapter->napi);
+		pch_gbe_irq_enable(adapter);
+		netif_start_queue(adapter->netdev);
+
 		netdev_dbg(netdev,
 			   "Link is Up %d Mbps %s-Duplex\n",
 			   hw->mac.link_speed,
@@ -2568,7 +2572,6 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 			  (ETH_HLEN + ETH_FCS_LEN);
 
 	pch_gbe_mac_load_mac_addr(&adapter->hw);
-	pch_gbe_mac_reset_hw(&adapter->hw);
 
 	/* setup the private structure */
 	ret = pch_gbe_sw_init(adapter);
@@ -2610,9 +2613,6 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 	adapter->wake_up_evt = PCH_GBE_WL_INIT_SETTING;
 	dev_info(&pdev->dev, "MAC address : %pM\n", netdev->dev_addr);
 
-	/* reset the hardware with the new settings */
-	pch_gbe_reset(adapter);
-
 	ret = register_netdev(netdev);
 	if (ret)
 		goto err_free_adapter;
-- 
2.18.0

^ permalink raw reply related

* [PATCH v7 05/11] net: pch_gbe: Move pch_gbe_watchdog lower in pch_gbe_main.c
From: Paul Burton @ 2018-06-27  0:06 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Andrew Lunn, paul.burton
In-Reply-To: <20180627000612.27263-1-paul.burton@mips.com>

This patch moves the pch_gbe_watchdog() function lower in pch_gbe_main.c
in order to allow use of other functions in the next patch, without
requiring lots of forward declarations. Doing this as a separate patch
makes it clearer what actually changed in the next patch.

The function is unmodified except for whitespace changes to satisfy
checkpatch.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

Changes in v7: New patch

 .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c  | 103 +++++++++---------
 1 file changed, 52 insertions(+), 51 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index ee38bba8b9ce..eb290c1edce0 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -1046,57 +1046,6 @@ static void pch_gbe_set_mode(struct pch_gbe_adapter *adapter, u16 speed,
 	iowrite32(mode, &hw->reg->MODE);
 }
 
-/**
- * pch_gbe_watchdog - Watchdog process
- * @data:  Board private structure
- */
-static void pch_gbe_watchdog(struct timer_list *t)
-{
-	struct pch_gbe_adapter *adapter = from_timer(adapter, t,
-						     watchdog_timer);
-	struct net_device *netdev = adapter->netdev;
-	struct pch_gbe_hw *hw = &adapter->hw;
-
-	netdev_dbg(netdev, "right now = %ld\n", jiffies);
-
-	pch_gbe_update_stats(adapter);
-	if ((mii_link_ok(&adapter->mii)) && (!netif_carrier_ok(netdev))) {
-		struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET };
-		netdev->tx_queue_len = adapter->tx_queue_len;
-		/* mii library handles link maintenance tasks */
-		if (mii_ethtool_gset(&adapter->mii, &cmd)) {
-			netdev_err(netdev, "ethtool get setting Error\n");
-			mod_timer(&adapter->watchdog_timer,
-				  round_jiffies(jiffies +
-						PCH_GBE_WATCHDOG_PERIOD));
-			return;
-		}
-		hw->mac.link_speed = ethtool_cmd_speed(&cmd);
-		hw->mac.link_duplex = cmd.duplex;
-		/* Set the RGMII control. */
-		pch_gbe_set_rgmii_ctrl(adapter, hw->mac.link_speed,
-						hw->mac.link_duplex);
-		/* Set the communication mode */
-		pch_gbe_set_mode(adapter, hw->mac.link_speed,
-				 hw->mac.link_duplex);
-		netdev_dbg(netdev,
-			   "Link is Up %d Mbps %s-Duplex\n",
-			   hw->mac.link_speed,
-			   cmd.duplex == DUPLEX_FULL ? "Full" : "Half");
-		netif_carrier_on(netdev);
-		netif_wake_queue(netdev);
-	} else if ((!mii_link_ok(&adapter->mii)) &&
-		   (netif_carrier_ok(netdev))) {
-		netdev_dbg(netdev, "NIC Link is Down\n");
-		hw->mac.link_speed = SPEED_10;
-		hw->mac.link_duplex = DUPLEX_HALF;
-		netif_carrier_off(netdev);
-		netif_stop_queue(netdev);
-	}
-	mod_timer(&adapter->watchdog_timer,
-		  round_jiffies(jiffies + PCH_GBE_WATCHDOG_PERIOD));
-}
-
 /**
  * pch_gbe_tx_queue - Carry out queuing of the transmission data
  * @adapter:  Board private structure
@@ -1973,6 +1922,58 @@ void pch_gbe_down(struct pch_gbe_adapter *adapter)
 	rx_ring->rx_buff_pool = NULL;
 }
 
+/**
+ * pch_gbe_watchdog - Watchdog process
+ * @data:  Board private structure
+ */
+static void pch_gbe_watchdog(struct timer_list *t)
+{
+	struct pch_gbe_adapter *adapter = from_timer(adapter, t,
+						     watchdog_timer);
+	struct net_device *netdev = adapter->netdev;
+	struct pch_gbe_hw *hw = &adapter->hw;
+
+	netdev_dbg(netdev, "right now = %ld\n", jiffies);
+
+	pch_gbe_update_stats(adapter);
+	if ((mii_link_ok(&adapter->mii)) && (!netif_carrier_ok(netdev))) {
+		struct ethtool_cmd cmd = { .cmd = ETHTOOL_GSET };
+
+		netdev->tx_queue_len = adapter->tx_queue_len;
+		/* mii library handles link maintenance tasks */
+		if (mii_ethtool_gset(&adapter->mii, &cmd)) {
+			netdev_err(netdev, "ethtool get setting Error\n");
+			mod_timer(&adapter->watchdog_timer,
+				  round_jiffies(jiffies +
+						PCH_GBE_WATCHDOG_PERIOD));
+			return;
+		}
+		hw->mac.link_speed = ethtool_cmd_speed(&cmd);
+		hw->mac.link_duplex = cmd.duplex;
+		/* Set the RGMII control. */
+		pch_gbe_set_rgmii_ctrl(adapter, hw->mac.link_speed,
+				       hw->mac.link_duplex);
+		/* Set the communication mode */
+		pch_gbe_set_mode(adapter, hw->mac.link_speed,
+				 hw->mac.link_duplex);
+		netdev_dbg(netdev,
+			   "Link is Up %d Mbps %s-Duplex\n",
+			   hw->mac.link_speed,
+			   cmd.duplex == DUPLEX_FULL ? "Full" : "Half");
+		netif_carrier_on(netdev);
+		netif_wake_queue(netdev);
+	} else if ((!mii_link_ok(&adapter->mii)) &&
+		   (netif_carrier_ok(netdev))) {
+		netdev_dbg(netdev, "NIC Link is Down\n");
+		hw->mac.link_speed = SPEED_10;
+		hw->mac.link_duplex = DUPLEX_HALF;
+		netif_carrier_off(netdev);
+		netif_stop_queue(netdev);
+	}
+	mod_timer(&adapter->watchdog_timer,
+		  round_jiffies(jiffies + PCH_GBE_WATCHDOG_PERIOD));
+}
+
 /**
  * pch_gbe_sw_init - Initialize general software structures (struct pch_gbe_adapter)
  * @adapter:  Board private structure to initialize
-- 
2.18.0

^ permalink raw reply related

* [PATCH v7 04/11] net: pch_gbe: Remove irq_sem
From: Paul Burton @ 2018-06-27  0:06 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Andrew Lunn, paul.burton
In-Reply-To: <20180627000612.27263-1-paul.burton@mips.com>

The pch_gbe driver uses an irq_sem variable to implement a sempahore
that seems to inconsistently count the number of times we enable or
disable interrupts, and only write to the interrupt enable register when
this count hits 0. This makes absolutely no sense to me, both from the
perspective of how the implementation is modifying the variable & more
fundamentally the fact that we know when we want or do not want
interrupts enabled without any need for the semaphore.

This patch removes irq_sem, so pch_gbe_irq_enable() &
pch_gbe_irq_disable() will both always write to the INT_EN register.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

Changes in v7: New patch

 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h      | 2 --
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 7 +------
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
index be218ac81f21..1bb0ea4f5503 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
@@ -555,7 +555,6 @@ struct pch_gbe_privdata {
 /**
  * struct pch_gbe_adapter - board specific private data structure
  * @stats_lock:	Spinlock structure for status
- * @irq_sem:		Semaphore for interrupt
  * @netdev:		Pointer of network device structure
  * @pdev:		Pointer of pci device structure
  * @napi:		NAPI structure
@@ -574,7 +573,6 @@ struct pch_gbe_privdata {
 
 struct pch_gbe_adapter {
 	spinlock_t stats_lock;
-	atomic_t irq_sem;
 	struct net_device *netdev;
 	struct pci_dev *pdev;
 	int irq;
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 5157cea16773..ee38bba8b9ce 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -761,7 +761,6 @@ static void pch_gbe_irq_disable(struct pch_gbe_adapter *adapter)
 {
 	struct pch_gbe_hw *hw = &adapter->hw;
 
-	atomic_inc(&adapter->irq_sem);
 	iowrite32(0, &hw->reg->INT_EN);
 	ioread32(&hw->reg->INT_ST);
 	synchronize_irq(adapter->irq);
@@ -778,8 +777,7 @@ static void pch_gbe_irq_enable(struct pch_gbe_adapter *adapter)
 {
 	struct pch_gbe_hw *hw = &adapter->hw;
 
-	if (likely(atomic_dec_and_test(&adapter->irq_sem)))
-		iowrite32(PCH_GBE_INT_ENABLE_MASK, &hw->reg->INT_EN);
+	iowrite32(PCH_GBE_INT_ENABLE_MASK, &hw->reg->INT_EN);
 	ioread32(&hw->reg->INT_ST);
 	netdev_dbg(adapter->netdev, "INT_EN reg : 0x%08x\n",
 		   ioread32(&hw->reg->INT_EN));
@@ -1345,7 +1343,6 @@ static irqreturn_t pch_gbe_intr(int irq, void *data)
 	    (adapter->rx_stop_flag)) {
 		if (likely(napi_schedule_prep(&adapter->napi))) {
 			/* Enable only Rx Descriptor empty */
-			atomic_inc(&adapter->irq_sem);
 			int_en = ioread32(&hw->reg->INT_EN);
 			int_en &=
 			    ~(PCH_GBE_INT_RX_DMA_CMPLT | PCH_GBE_INT_TX_CMPLT);
@@ -1954,7 +1951,6 @@ void pch_gbe_down(struct pch_gbe_adapter *adapter)
 	/* signal that we're down so the interrupt handler does not
 	 * reschedule our watchdog timer */
 	napi_disable(&adapter->napi);
-	atomic_set(&adapter->irq_sem, 0);
 
 	pch_gbe_irq_disable(adapter);
 	pch_gbe_free_irq(adapter);
@@ -2000,7 +1996,6 @@ static int pch_gbe_sw_init(struct pch_gbe_adapter *adapter)
 	}
 	spin_lock_init(&adapter->hw.miim_lock);
 	spin_lock_init(&adapter->stats_lock);
-	atomic_set(&adapter->irq_sem, 0);
 	pch_gbe_irq_disable(adapter);
 
 	pch_gbe_init_stats(adapter);
-- 
2.18.0

^ permalink raw reply related

* Re: [RFC PATCH v2 net-next 01/12] net: core: trivial netif_receive_skb_list() entry point
From: Eric Dumazet @ 2018-06-27  0:06 UTC (permalink / raw)
  To: Edward Cree, linux-net-drivers, netdev; +Cc: davem
In-Reply-To: <55a58487-584a-9b1e-33d3-08e00af35bd8@solarflare.com>



On 06/26/2018 11:17 AM, Edward Cree wrote:
> Just calls netif_receive_skb() in a loop.

...

> +void netif_receive_skb_list(struct sk_buff_head *list)


Please use a standard list_head and standard list operators.

(In all your patches)

1) We do not want to carry a spinlock_t + count per list...

2) We get nice debugging features with CONFIG_DEBUG_LIST=y

Note that we now have skb->list after 
commit d4546c2509b1e9cd082e3682dcec98472e37ee5a ("net: Convert GRO SKB handling to list_head.")

Thanks !

^ permalink raw reply

* [PATCH v7 03/11] net: pch_gbe: Probe PHY ID & initialize only once
From: Paul Burton @ 2018-06-27  0:06 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Andrew Lunn, paul.burton
In-Reply-To: <20180627000612.27263-1-paul.burton@mips.com>

The pch_gbe driver currently probes for the PHY ID & configures the PHY
every time the MAC is reset, even though we know that the PHY won't have
changed since the last MAC reset [1].

This patch moves the PHY probe to instead happen only once when the
driver is probed, saving time & moving us closer to the behavior we'll
have with phylib.

[1] Please, someone patent PHY hotplugging & rigorously enforce said
    patent such that nobody can do it. At least not with an EG20T MAC.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

Changes in v7: New patch

 .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c  | 26 ++++++++++---------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 9651fa02d4bb..5157cea16773 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -617,8 +617,10 @@ static void pch_gbe_init_stats(struct pch_gbe_adapter *adapter)
 static int pch_gbe_init_phy(struct pch_gbe_adapter *adapter)
 {
 	struct net_device *netdev = adapter->netdev;
+	struct pch_gbe_hw *hw = &adapter->hw;
 	u32 addr;
 	u16 bmcr, stat;
+	s32 ret_val;
 
 	/* Discover phy addr by searching addrs in order {1,0,2,..., 31} */
 	for (addr = 0; addr < PCH_GBE_PHY_REGS_LEN; addr++) {
@@ -652,6 +654,16 @@ static int pch_gbe_init_phy(struct pch_gbe_adapter *adapter)
 	adapter->mii.mdio_read = pch_gbe_mdio_read;
 	adapter->mii.mdio_write = pch_gbe_mdio_write;
 	adapter->mii.supports_gmii = mii_check_gmii_support(&adapter->mii);
+
+	ret_val = pch_gbe_phy_get_id(hw);
+	if (ret_val) {
+		netdev_err(adapter->netdev, "pch_gbe_phy_get_id error\n");
+		return -EIO;
+	}
+	pch_gbe_phy_init_setting(hw);
+	/* Setup Mac interface option RGMII */
+	pch_gbe_phy_set_rgmii(hw);
+
 	return 0;
 }
 
@@ -721,22 +733,12 @@ void pch_gbe_reset(struct pch_gbe_adapter *adapter)
 {
 	struct net_device *netdev = adapter->netdev;
 	struct pch_gbe_hw *hw = &adapter->hw;
-	s32 ret_val;
 
 	pch_gbe_mac_reset_hw(hw);
 	/* reprogram multicast address register after reset */
 	pch_gbe_set_multi(netdev);
 	/* Setup the receive address. */
 	pch_gbe_mac_init_rx_addrs(hw, PCH_GBE_MAR_ENTRIES);
-
-	ret_val = pch_gbe_phy_get_id(hw);
-	if (ret_val) {
-		netdev_err(adapter->netdev, "pch_gbe_phy_get_id error\n");
-		return;
-	}
-	pch_gbe_phy_init_setting(hw);
-	/* Setup Mac interface option RGMII */
-	pch_gbe_phy_set_rgmii(hw);
 }
 
 /**
@@ -2577,6 +2579,8 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 	if (ret)
 		goto err_free_netdev;
 
+	pch_gbe_check_options(adapter);
+
 	/* Initialize PHY */
 	ret = pch_gbe_init_phy(adapter);
 	if (ret) {
@@ -2606,8 +2610,6 @@ static int pch_gbe_probe(struct pci_dev *pdev,
 
 	INIT_WORK(&adapter->reset_task, pch_gbe_reset_task);
 
-	pch_gbe_check_options(adapter);
-
 	/* initialize the wol settings based on the eeprom settings */
 	adapter->wake_up_evt = PCH_GBE_WL_INIT_SETTING;
 	dev_info(&pdev->dev, "MAC address : %pM\n", netdev->dev_addr);
-- 
2.18.0

^ permalink raw reply related

* [PATCH v7 02/11] net: pch_gbe: Mask spare MAC addresses all at once
From: Paul Burton @ 2018-06-27  0:06 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Andrew Lunn, paul.burton
In-Reply-To: <20180627000612.27263-1-paul.burton@mips.com>

pch_gbe_set_multi() loops through each unused MAC address register,
masking them one by one & waiting for a bit to clear indicating that the
change has taken effect before zeroing out the MAC register.

This is needlessly inefficient. We can instead set all the desired mask
bits with a single write to the ADDR_MASK register & wait only once for
the busy bit to clear indicating that the addresses are masked (ie.
ignored) as required.

It's pointless zeroing the MAC registers since they're masked anyway so
their contents are irrelevant, so we can avoid looping over them here
entirely.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

Changes in v7: New patch

 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 8908ef654d94..9651fa02d4bb 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -2140,15 +2140,13 @@ static void pch_gbe_set_multi(struct net_device *netdev)
 		pch_gbe_mac_mar_set(hw, ha->addr, i++);
 
 	/* If there are spare MAC registers, mask & clear them */
-	for (; i < PCH_GBE_MAR_ENTRIES; i++) {
-		/* Clear MAC address mask */
+	if (i < PCH_GBE_MAR_ENTRIES) {
 		adrmask = ioread32(&hw->reg->ADDR_MASK);
-		iowrite32(adrmask | BIT(i), &hw->reg->ADDR_MASK);
+		adrmask |= GENMASK(PCH_GBE_MAR_ENTRIES - 1, i);
+		iowrite32(adrmask, &hw->reg->ADDR_MASK);
+
 		/* wait busy */
 		pch_gbe_wait_clr_bit(&hw->reg->ADDR_MASK, PCH_GBE_BUSY);
-		/* Clear MAC address */
-		iowrite32(0, &hw->reg->mac_adr[i].high);
-		iowrite32(0, &hw->reg->mac_adr[i].low);
 	}
 
 	netdev_dbg(netdev,
-- 
2.18.0

^ permalink raw reply related

* [PATCH v7 01/11] net: pch_gbe: Remove unused struct pch_gbe_adapter fields
From: Paul Burton @ 2018-06-27  0:06 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Andrew Lunn, paul.burton
In-Reply-To: <20180627000612.27263-1-paul.burton@mips.com>

Remove a bunch of unused fields from struct pch_gbe_adapter. Among these
polling_netdev, config_space & led_status are entirely unused.
ethtool_lock is initialized but we never attempt to acquire the lock, so
that is effectively unused too. A msg_enable field was documented but
missing, so drop that from the kerneldoc comment.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---

Changes in v7: New patch

 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h      | 9 ---------
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 1 -
 2 files changed, 10 deletions(-)

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
index 44c2f291e766..be218ac81f21 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h
@@ -555,11 +555,9 @@ struct pch_gbe_privdata {
 /**
  * struct pch_gbe_adapter - board specific private data structure
  * @stats_lock:	Spinlock structure for status
- * @ethtool_lock:	Spinlock structure for ethtool
  * @irq_sem:		Semaphore for interrupt
  * @netdev:		Pointer of network device structure
  * @pdev:		Pointer of pci device structure
- * @polling_netdev:	Pointer of polling network device structure
  * @napi:		NAPI structure
  * @hw:			Pointer of hardware structure
  * @stats:		Hardware status
@@ -567,9 +565,6 @@ struct pch_gbe_privdata {
  * @mii:		MII information structure
  * @watchdog_timer:	Watchdog timer list
  * @wake_up_evt:	Wake up event
- * @config_space:	Configuration space
- * @msg_enable:		Driver message level
- * @led_status:		LED status
  * @tx_ring:		Pointer of Tx descriptor ring structure
  * @rx_ring:		Pointer of Rx descriptor ring structure
  * @rx_buffer_len:	Receive buffer length
@@ -579,12 +574,10 @@ struct pch_gbe_privdata {
 
 struct pch_gbe_adapter {
 	spinlock_t stats_lock;
-	spinlock_t ethtool_lock;
 	atomic_t irq_sem;
 	struct net_device *netdev;
 	struct pci_dev *pdev;
 	int irq;
-	struct net_device *polling_netdev;
 	struct napi_struct napi;
 	struct pch_gbe_hw hw;
 	struct pch_gbe_hw_stats stats;
@@ -592,8 +585,6 @@ struct pch_gbe_adapter {
 	struct mii_if_info mii;
 	struct timer_list watchdog_timer;
 	u32 wake_up_evt;
-	u32 *config_space;
-	unsigned long led_status;
 	struct pch_gbe_tx_ring *tx_ring;
 	struct pch_gbe_rx_ring *rx_ring;
 	unsigned long rx_buffer_len;
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 43c0c10dfeb7..8908ef654d94 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -1998,7 +1998,6 @@ static int pch_gbe_sw_init(struct pch_gbe_adapter *adapter)
 	}
 	spin_lock_init(&adapter->hw.miim_lock);
 	spin_lock_init(&adapter->stats_lock);
-	spin_lock_init(&adapter->ethtool_lock);
 	atomic_set(&adapter->irq_sem, 0);
 	pch_gbe_irq_disable(adapter);
 
-- 
2.18.0

^ permalink raw reply related

* [PATCH v7 00/11] net: pch_gbe: Fixes, conversion to phylib, enable for MIPS
From: Paul Burton @ 2018-06-27  0:06 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Andrew Lunn, paul.burton

This series cleans up & reworks the pch_gbe driver such that it no
longer contains PHY-specific code, converts it to phylib & enables it to
be built on MIPS systems for use with the MIPS Boston development board.

Unfortunately I don't have access to a Minnowboard, which the driver
contains some platform-specific code for, so I haven't been able to test
the end result there.

Applies cleanly atop net-next as of commit 27a2628b3c24 ("selftests:
forwarding: mirror_gre_vlan_bridge_1q: Unset rp_filter").

Thanks,
    Paul

Andrew Lunn (1):
  net: pch_gbe: Convert to mdiobus and phylib

Paul Burton (10):
  net: pch_gbe: Remove unused struct pch_gbe_adapter fields
  net: pch_gbe: Mask spare MAC addresses all at once
  net: pch_gbe: Probe PHY ID & initialize only once
  net: pch_gbe: Remove irq_sem
  net: pch_gbe: Move pch_gbe_watchdog lower in pch_gbe_main.c
  net: pch_gbe: Only enable MAC when PHY link is active
  net: pch_gbe: Remove AR8031 PHY hibernation disable
  net: pch_gbe: Clean up resets
  ptp: pch: Allow build on MIPS platforms
  net: pch_gbe: Allow build on MIPS platforms

 drivers/net/ethernet/oki-semi/pch_gbe/Kconfig |   5 +-
 .../net/ethernet/oki-semi/pch_gbe/Makefile    |   2 +-
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe.h   |  20 +-
 .../oki-semi/pch_gbe/pch_gbe_ethtool.c        |  88 +---
 .../ethernet/oki-semi/pch_gbe/pch_gbe_main.c  | 407 ++++++++----------
 .../ethernet/oki-semi/pch_gbe/pch_gbe_param.c | 265 ------------
 .../ethernet/oki-semi/pch_gbe/pch_gbe_phy.c   | 377 ----------------
 .../ethernet/oki-semi/pch_gbe/pch_gbe_phy.h   |  35 --
 drivers/ptp/Kconfig                           |   2 +-
 9 files changed, 191 insertions(+), 1010 deletions(-)
 delete mode 100644 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c
 delete mode 100644 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h

-- 
2.18.0

^ permalink raw reply

* Re: [patch net-next v2 0/9] net: sched: introduce chain templates support with offloading to mlxsw
From: Cong Wang @ 2018-06-27  0:04 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: Linux Kernel Network Developers, David Miller, Jamal Hadi Salim,
	Jakub Kicinski, Simon Horman, john.hurley, David Ahern, mlxsw
In-Reply-To: <20180626080000.12964-1-jiri@resnulli.us>

On Tue, Jun 26, 2018 at 1:01 AM Jiri Pirko <jiri@resnulli.us> wrote:
> Create dummy device with clsact first:
> # ip link add type dummy
> # tc qdisc add dev dummy0 clsact
>
> There is no template assigned by default:
> # tc filter template show dev dummy0 ingress
>
> Add a template of type flower allowing to insert rules matching on last
> 2 bytes of destination mac address:
> # tc filter template add dev dummy0 ingress proto ip flower dst_mac 00:00:00:00:00:00/00:00:00:00:FF:FF

Now you are extending 'tc filter' command with a new
subcommand 'template', which looks weird.

Why not make it a new property of filter like you did for chain?
Like:

tc filter add dev dummy0 ingress proto ip template flower

which is much better IMHO.

^ permalink raw reply

* Re: [net-next PATCH v4 3/7] net: sock: Change tx_queue_mapping in sock_common to unsigned short
From: Nambiar, Amritha @ 2018-06-27  0:00 UTC (permalink / raw)
  To: Willem de Bruijn
  Cc: Network Development, David Miller, Alexander Duyck,
	Samudrala, Sridhar, Alexander Duyck, Eric Dumazet,
	Hannes Frederic Sowa, Tom Herbert
In-Reply-To: <CAF=yD-+gAp8qMYGgpFA8cwPnpt50XjMS0DdJGnmNKzQDpUotFQ@mail.gmail.com>

On 6/26/2018 3:58 AM, Willem de Bruijn wrote:
> On Mon, Jun 25, 2018 at 7:06 PM Amritha Nambiar
> <amritha.nambiar@intel.com> wrote:
>>
>> Change 'skc_tx_queue_mapping' field in sock_common structure from
>> 'int' to 'unsigned short' type with 0 indicating unset and
>> a positive queue value being set. This way it is consistent with
>> the queue_mapping field in the sk_buff. This will also accommodate
>> adding a new 'unsigned short' field in sock_common in the next
>> patch for rx_queue_mapping.
>>
>> Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
>> ---
> 
>>  static inline void sk_tx_queue_set(struct sock *sk, int tx_queue)
>>  {
>> -       sk->sk_tx_queue_mapping = tx_queue;
>> +       /* sk_tx_queue_mapping accept only upto a 16-bit value */
>> +       WARN_ON((unsigned short)tx_queue > USHRT_MAX);
>> +       sk->sk_tx_queue_mapping = tx_queue + 1;
>>  }
> 
> WARN_ON_ONCE to avoid flooding the kernel buffer.
> 
Will fix.

^ permalink raw reply

* Re: [net-next PATCH v4 3/7] net: sock: Change tx_queue_mapping in sock_common to unsigned short
From: Nambiar, Amritha @ 2018-06-26 23:54 UTC (permalink / raw)
  To: Alexander Duyck, Tom Herbert
  Cc: Linux Kernel Network Developers, David S. Miller, Alexander Duyck,
	Willem de Bruijn, Sridhar Samudrala, Eric Dumazet,
	Hannes Frederic Sowa
In-Reply-To: <CAKgT0UdPWPtmatsWtAGTpEMA_SxEqm4OehD3Obg-mA2noBZtOw@mail.gmail.com>

On 6/25/2018 8:25 PM, Alexander Duyck wrote:
> On Mon, Jun 25, 2018 at 6:34 PM, Tom Herbert <tom@herbertland.com> wrote:
>>
>>
>> On Mon, Jun 25, 2018 at 11:04 AM, Amritha Nambiar
>> <amritha.nambiar@intel.com> wrote:
>>>
>>> Change 'skc_tx_queue_mapping' field in sock_common structure from
>>> 'int' to 'unsigned short' type with 0 indicating unset and
>>> a positive queue value being set. This way it is consistent with
>>> the queue_mapping field in the sk_buff. This will also accommodate
>>> adding a new 'unsigned short' field in sock_common in the next
>>> patch for rx_queue_mapping.
>>>
>>> Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
>>> ---
>>>  include/net/sock.h |   10 ++++++----
>>>  1 file changed, 6 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/include/net/sock.h b/include/net/sock.h
>>> index b3b7541..009fd30 100644
>>> --- a/include/net/sock.h
>>> +++ b/include/net/sock.h
>>> @@ -214,7 +214,7 @@ struct sock_common {
>>>                 struct hlist_node       skc_node;
>>>                 struct hlist_nulls_node skc_nulls_node;
>>>         };
>>> -       int                     skc_tx_queue_mapping;
>>> +       unsigned short          skc_tx_queue_mapping;
>>>         union {
>>>                 int             skc_incoming_cpu;
>>>                 u32             skc_rcv_wnd;
>>> @@ -1681,17 +1681,19 @@ static inline int sk_receive_skb(struct sock *sk,
>>> struct sk_buff *skb,
>>>
>>>  static inline void sk_tx_queue_set(struct sock *sk, int tx_queue)
>>>  {
>>> -       sk->sk_tx_queue_mapping = tx_queue;
>>> +       /* sk_tx_queue_mapping accept only upto a 16-bit value */
>>> +       WARN_ON((unsigned short)tx_queue > USHRT_MAX);
>>
>>
>> Shouldn't this be USHRT_MAX - 1 ?
> 
> Actually just a ">=" would probably do as well.

Ugh! Will definitely fix this.

> 
>>
>>> +       sk->sk_tx_queue_mapping = tx_queue + 1;
>>>  }
>>>
>>>  static inline void sk_tx_queue_clear(struct sock *sk)
>>>  {
>>> -       sk->sk_tx_queue_mapping = -1;
>>>
>>> +       sk->sk_tx_queue_mapping = 0;
>>
>>
>> I think it's slightly better to define a new constant like NO_QUEUE_MAPPING
>> to be USHRT_MAX. That avoids needing to do the arithmetic every time the
>> value is accessed.

The idea was to have avoid having to make any changes to the callers of
these functions and make this similar to queue_mapping in skbuff with 0
indicating unset and +ve value for set. sk_tx_queue_get returns -1 on
invalid and the callers were validating -ve values.  With
sk_tx_queue_mapping initialized to USHRT_MAX, and having an additional
check in sk_tx_queue_get to return -1 if sk_tx_queue_mapping has
USHRT_MAX, I think I can keep changes minimal and avoid the arithmetic
if that's a more acceptable solution.

>>>
>>>  }
>>>
>>>  static inline int sk_tx_queue_get(const struct sock *sk)
>>>  {
>>> -       return sk ? sk->sk_tx_queue_mapping : -1;
>>> +       return sk ? sk->sk_tx_queue_mapping - 1 : -1;
>>
>>
>> Doesn't the comparison in __netdev_pick_tx need to be simultaneously changed
>> for this?
> 
> This doesn't change the result. It was still -1 if the queue mapping
> is not set. It was just initialized to 0 instead of to -1 so we have
> to perform the operation to get there.
> 
> Also in regards to the comment above about needing an extra operation
> I am not sure it makes much difference.
> 
> In the case of us starting with 0 as a reserved value I think the
> instruction count should be about the same. We move the unsigned short
> into an unsigned in, then decrement, and if the value is non-negative
> we can assume it is valid. Although maybe I should double check the
> code to make certain it is doing what I thought it was supposed to be
> doing.
> 
>>
>>>
>>>
>>>
>>>  }
>>>
>>>  static inline void sk_set_socket(struct sock *sk, struct socket *sock)
>>>
>>

^ permalink raw reply

* Re: [PATCH net-next] net: preserve sock reference when scrubbing the skb.
From: Eric Dumazet @ 2018-06-26 23:53 UTC (permalink / raw)
  To: Cong Wang, Flavio Leitner
  Cc: Linux Kernel Network Developers, Paolo Abeni, David Miller,
	Florian Westphal, NetFilter
In-Reply-To: <CAM_iQpU8E5OuXx87Dm+jbqwbkkwETNF_RZh-VnUkF5seFPvv_A@mail.gmail.com>



On 06/26/2018 03:47 PM, Cong Wang wrote:
> 
> You need to justify why you want to break the TSQ's scope here,
> which is obviously not compatible with netns design.

You have to explain why you do not want us to fix this buggy behavior.

Right now TSQ (and more generally back pressure) is broken by this skb_orphan()

So we want to restore TSQ (and back pressure)

TSQ scope never mentioned netns.
We (TCP stack TSQ handler) want to be notified when this packet leaves the host,
even if it had to traverse multiple netns (for whatever reasons).

_If_ a packet is locally 'consumed' (like on loopback device, or veth pair),
then the skb_orphan() will automatically be done.

If you have a case where this skb_orphan() is needed, please add it at the needed place.

^ permalink raw reply

* Re: [bpf-next PATCH 1/2] samples/bpf: extend xdp_rxq_info to read packet payload
From: Song Liu @ 2018-06-26 23:53 UTC (permalink / raw)
  To: Jesper Dangaard Brouer
  Cc: Networking, Daniel Borkmann, Toke Høiland-Jørgensen,
	Alexei Starovoitov
In-Reply-To: <152993686364.8835.3914229981165096265.stgit@firesoul>

On Mon, Jun 25, 2018 at 7:27 AM, Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
> There is a cost associated with reading the packet data payload
> that this test ignored.  Add option --read to allow enabling
> reading part of the payload.
>
> This sample/tool helps us analyse an issue observed with a NIC
> mlx5 (ConnectX-5 Ex) and an Intel(R) Xeon(R) CPU E5-1650 v4.
>
> With no_touch of data:
>
> Running XDP on dev:mlx5p1 (ifindex:8) action:XDP_DROP options:no_touch
> XDP stats       CPU     pps         issue-pps
> XDP-RX CPU      0       14,465,157  0
> XDP-RX CPU      1       14,464,728  0
> XDP-RX CPU      2       14,465,283  0
> XDP-RX CPU      3       14,465,282  0
> XDP-RX CPU      4       14,464,159  0
> XDP-RX CPU      5       14,465,379  0
> XDP-RX CPU      total   86,789,992
>
> When not touching data, we observe that the CPUs have idle cycles.
> When reading data the CPUs are 100% busy in softirq.
>
> With reading data:
>
> Running XDP on dev:mlx5p1 (ifindex:8) action:XDP_DROP options:read
> XDP stats       CPU     pps         issue-pps
> XDP-RX CPU      0       9,620,639   0
> XDP-RX CPU      1       9,489,843   0
> XDP-RX CPU      2       9,407,854   0
> XDP-RX CPU      3       9,422,289   0
> XDP-RX CPU      4       9,321,959   0
> XDP-RX CPU      5       9,395,242   0
> XDP-RX CPU      total   56,657,828
>
> The effect seen above is a result of cache-misses occuring when
> more RXQs are being used.  Based on perf-event observations, our
> conclusion is that the CPUs DDIO (Direct Data I/O) choose to
> deliver packet into main memory, instead of L3-cache.  We also
> found, that this can be mitigated by either using less RXQs or by
> reducing NICs the RX-ring size.
>
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
> ---
>  samples/bpf/xdp_rxq_info_kern.c |   19 +++++++++++++++++++
>  samples/bpf/xdp_rxq_info_user.c |   34 ++++++++++++++++++++++++++++------
>  2 files changed, 47 insertions(+), 6 deletions(-)
>
> diff --git a/samples/bpf/xdp_rxq_info_kern.c b/samples/bpf/xdp_rxq_info_kern.c
> index 3fd209291653..61af6210df2f 100644
> --- a/samples/bpf/xdp_rxq_info_kern.c
> +++ b/samples/bpf/xdp_rxq_info_kern.c
> @@ -4,6 +4,8 @@
>   *  Example howto extract XDP RX-queue info
>   */
>  #include <uapi/linux/bpf.h>
> +#include <uapi/linux/if_ether.h>
> +#include <uapi/linux/in.h>
>  #include "bpf_helpers.h"
>
>  /* Config setup from with userspace
> @@ -14,6 +16,11 @@
>  struct config {
>         __u32 action;
>         int ifindex;
> +       __u32 options;
> +};
> +enum cfg_options_flags {
> +       NO_TOUCH = 0x0U,
> +       READ_MEM = 0x1U,
>  };
>  struct bpf_map_def SEC("maps") config_map = {
>         .type           = BPF_MAP_TYPE_ARRAY,
> @@ -90,6 +97,18 @@ int  xdp_prognum0(struct xdp_md *ctx)
>         if (key == MAX_RXQs)
>                 rxq_rec->issue++;
>
> +       /* Default: Don't touch packet data, only count packets */
> +       if (unlikely(config->options & READ_MEM)) {
> +               struct ethhdr *eth = data;
> +
> +               if (eth + 1 > data_end)
> +                       return XDP_ABORTED;
> +
> +               /* Avoid compiler removing this: Drop non 802.3 Ethertypes */
> +               if (ntohs(eth->h_proto) < ETH_P_802_3_MIN)
> +                       return XDP_ABORTED;
> +       }
> +
>         return config->action;
>  }
>
> diff --git a/samples/bpf/xdp_rxq_info_user.c b/samples/bpf/xdp_rxq_info_user.c
> index e4e9ba52bff0..435485d4f49e 100644
> --- a/samples/bpf/xdp_rxq_info_user.c
> +++ b/samples/bpf/xdp_rxq_info_user.c
> @@ -50,6 +50,7 @@ static const struct option long_options[] = {
>         {"sec",         required_argument,      NULL, 's' },
>         {"no-separators", no_argument,          NULL, 'z' },
>         {"action",      required_argument,      NULL, 'a' },
> +       {"readmem",     no_argument,            NULL, 'r' },
>         {0, 0, NULL,  0 }
>  };
>
> @@ -66,6 +67,11 @@ static void int_exit(int sig)
>  struct config {
>         __u32 action;
>         int ifindex;
> +       __u32 options;
> +};
> +enum cfg_options_flags {
> +       NO_TOUCH = 0x0U,
> +       READ_MEM = 0x1U,
>  };
>  #define XDP_ACTION_MAX (XDP_TX + 1)
>  #define XDP_ACTION_MAX_STRLEN 11
> @@ -109,6 +115,16 @@ static void list_xdp_actions(void)
>         printf("\n");
>  }
>
> +static char* options2str(enum cfg_options_flags flag)
> +{
> +       if (flag == NO_TOUCH)
> +               return "no_touch";
> +       if (flag & READ_MEM)
> +               return "read";
> +       fprintf(stderr, "ERR: Unknown config option flags");
> +       exit(EXIT_FAIL);
> +}
> +

enum cfg_options_flags is used as a bitmap in other parts of the sample.
So this function is a little weird (with more flags added).

Thanks,
Song

>  static void usage(char *argv[])
>  {
>         int i;
> @@ -305,7 +321,7 @@ static __u64 calc_errs_pps(struct datarec *r,
>
>  static void stats_print(struct stats_record *stats_rec,
>                         struct stats_record *stats_prev,
> -                       int action)
> +                       int action, __u32 cfg_opt)
>  {
>         unsigned int nr_rxqs = bpf_map__def(rx_queue_index_map)->max_entries;
>         unsigned int nr_cpus = bpf_num_possible_cpus();
> @@ -316,8 +332,8 @@ static void stats_print(struct stats_record *stats_rec,
>         int i;
>
>         /* Header */
> -       printf("\nRunning XDP on dev:%s (ifindex:%d) action:%s\n",
> -              ifname, ifindex, action2str(action));
> +       printf("\nRunning XDP on dev:%s (ifindex:%d) action:%s options:%s\n",
> +              ifname, ifindex, action2str(action), options2str(cfg_opt));
>
>         /* stats_global_map */
>         {
> @@ -399,7 +415,7 @@ static inline void swap(struct stats_record **a, struct stats_record **b)
>         *b = tmp;
>  }
>
> -static void stats_poll(int interval, int action)
> +static void stats_poll(int interval, int action, __u32 cfg_opt)
>  {
>         struct stats_record *record, *prev;
>
> @@ -410,7 +426,7 @@ static void stats_poll(int interval, int action)
>         while (1) {
>                 swap(&prev, &record);
>                 stats_collect(record);
> -               stats_print(record, prev, action);
> +               stats_print(record, prev, action, cfg_opt);
>                 sleep(interval);
>         }
>
> @@ -421,6 +437,7 @@ static void stats_poll(int interval, int action)
>
>  int main(int argc, char **argv)
>  {
> +       __u32 cfg_options= NO_TOUCH ; /* Default: Don't touch packet memory */
>         struct rlimit r = {10 * 1024 * 1024, RLIM_INFINITY};
>         struct bpf_prog_load_attr prog_load_attr = {
>                 .prog_type      = BPF_PROG_TYPE_XDP,
> @@ -435,6 +452,7 @@ int main(int argc, char **argv)
>         int interval = 2;
>         __u32 key = 0;
>
> +
>         char action_str_buf[XDP_ACTION_MAX_STRLEN + 1 /* for \0 */] = { 0 };
>         int action = XDP_PASS; /* Default action */
>         char *action_str = NULL;
> @@ -496,6 +514,9 @@ int main(int argc, char **argv)
>                         action_str = (char *)&action_str_buf;
>                         strncpy(action_str, optarg, XDP_ACTION_MAX_STRLEN);
>                         break;
> +               case 'r':
> +                       cfg_options |= READ_MEM;
> +                       break;
>                 case 'h':
>                 error:
>                 default:
> @@ -522,6 +543,7 @@ int main(int argc, char **argv)
>                 }
>         }
>         cfg.action = action;
> +       cfg.options = cfg_options;
>
>         /* Trick to pretty printf with thousands separators use %' */
>         if (use_separators)
> @@ -542,6 +564,6 @@ int main(int argc, char **argv)
>                 return EXIT_FAIL_XDP;
>         }
>
> -       stats_poll(interval, action);
> +       stats_poll(interval, action, cfg_options);
>         return EXIT_OK;
>  }
>

^ permalink raw reply

* Re: Re: [Qemu-devel] [PATCH] qemu: Introduce VIRTIO_NET_F_STANDBY feature bit to virtio_net
From: Siwei Liu @ 2018-06-26 23:38 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Samudrala, Sridhar, Cornelia Huck, Alexander Duyck, virtio-dev,
	aaron.f.brown, Jiri Pirko, Jakub Kicinski, Netdev, qemu-devel,
	virtualization, konrad.wilk, boris.ostrovsky, Joao Martins,
	Venu Busireddy, vijay.balakrishna
In-Reply-To: <20180626044650-mutt-send-email-mst@kernel.org>

On Mon, Jun 25, 2018 at 6:50 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Mon, Jun 25, 2018 at 10:54:09AM -0700, Samudrala, Sridhar wrote:
>> > > > > Might not neccessarily be something wrong, but it's very limited to
>> > > > > prohibit the MAC of VF from changing when enslaved by failover.
>> > > > You mean guest changing MAC? I'm not sure why we prohibit that.
>> > > I think Sridhar and Jiri might be better person to answer it. My
>> > > impression was that sync'ing the MAC address change between all 3
>> > > devices is challenging, as the failover driver uses MAC address to
>> > > match net_device internally.
>>
>> Yes. The MAC address is assigned by the hypervisor and it needs to manage the movement
>> of the MAC between the PF and VF.  Allowing the guest to change the MAC will require
>> synchronization between the hypervisor and the PF/VF drivers. Most of the VF drivers
>> don't allow changing guest MAC unless it is a trusted VF.
>
> OK but it's a policy thing. Maybe it's a trusted VF. Who knows?
> For example I can see host just
> failing VIRTIO_NET_CTRL_MAC_ADDR_SET if it wants to block it.
> I'm not sure why VIRTIO_NET_F_STANDBY has to block it in the guest.

That's why I think pairing using MAC is fragile IMHO. When VF's MAC
got changed before virtio attempts to match and pair the device, it
ends up with no pairing found out at all. UUID is better.

-Siwei

>
> --
> MST

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox