All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] OpenCores 10/100 MAC ethtool operations
@ 2014-01-29 19:56 Max Filippov
  2014-01-29 19:56 ` [PATCH 1/4] net: ethoc: implement basic " Max Filippov
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Max Filippov @ 2014-01-29 19:56 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: David S. Miller, Florian Fainelli, Marc Gauthier, Max Filippov

Hello David, Florian and everybody,

this series implements ethtool callbacks for the ethoc driver as was
requested by Florian.

Max Filippov (4):
  net: ethoc: implement basic ethtool operations
  net: ethoc: implement ethtool get/set settings
  net: ethoc: implement ethtool get registers
  net: ethoc: implement ethtool get/set ring parameters

 drivers/net/ethernet/ethoc.c | 85 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

-- 
1.8.1.4


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

* [PATCH 1/4] net: ethoc: implement basic ethtool operations
  2014-01-29 19:56 [PATCH 0/4] OpenCores 10/100 MAC ethtool operations Max Filippov
@ 2014-01-29 19:56 ` Max Filippov
  2014-01-30 13:59   ` Ben Hutchings
  2014-01-29 19:56 ` [PATCH 2/4] net: ethoc: implement ethtool get/set settings Max Filippov
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Max Filippov @ 2014-01-29 19:56 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: David S. Miller, Florian Fainelli, Marc Gauthier, Max Filippov

The following methods are implemented:
- get link state (standard implementation);
- get timestamping info (standard implementation).

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 drivers/net/ethernet/ethoc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 5854d41..6de6352 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -900,6 +900,11 @@ out:
 	return NETDEV_TX_OK;
 }
 
+const struct ethtool_ops ethoc_ethtool_ops = {
+	.get_link = ethtool_op_get_link,
+	.get_ts_info = ethtool_op_get_ts_info,
+};
+
 static const struct net_device_ops ethoc_netdev_ops = {
 	.ndo_open = ethoc_open,
 	.ndo_stop = ethoc_stop,
@@ -1148,6 +1153,7 @@ static int ethoc_probe(struct platform_device *pdev)
 	netdev->netdev_ops = &ethoc_netdev_ops;
 	netdev->watchdog_timeo = ETHOC_TIMEOUT;
 	netdev->features |= 0;
+	netdev->ethtool_ops = &ethoc_ethtool_ops;
 
 	/* setup NAPI */
 	netif_napi_add(netdev, &priv->napi, ethoc_poll, 64);
-- 
1.8.1.4


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

* [PATCH 2/4] net: ethoc: implement ethtool get/set settings
  2014-01-29 19:56 [PATCH 0/4] OpenCores 10/100 MAC ethtool operations Max Filippov
  2014-01-29 19:56 ` [PATCH 1/4] net: ethoc: implement basic " Max Filippov
@ 2014-01-29 19:56 ` Max Filippov
  2014-01-29 19:56 ` [PATCH 3/4] net: ethoc: implement ethtool get registers Max Filippov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Max Filippov @ 2014-01-29 19:56 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: David S. Miller, Florian Fainelli, Marc Gauthier, Max Filippov

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 drivers/net/ethernet/ethoc.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 6de6352..9518023 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -900,7 +900,31 @@ out:
 	return NETDEV_TX_OK;
 }
 
+static int ethoc_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+	struct ethoc *priv = netdev_priv(dev);
+	struct phy_device *phydev = priv->phy;
+
+	if (!phydev)
+		return -ENODEV;
+
+	return phy_ethtool_gset(phydev, cmd);
+}
+
+static int ethoc_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+	struct ethoc *priv = netdev_priv(dev);
+	struct phy_device *phydev = priv->phy;
+
+	if (!phydev)
+		return -ENODEV;
+
+	return phy_ethtool_sset(phydev, cmd);
+}
+
 const struct ethtool_ops ethoc_ethtool_ops = {
+	.get_settings = ethoc_get_settings,
+	.set_settings = ethoc_set_settings,
 	.get_link = ethtool_op_get_link,
 	.get_ts_info = ethtool_op_get_ts_info,
 };
-- 
1.8.1.4


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

* [PATCH 3/4] net: ethoc: implement ethtool get registers
  2014-01-29 19:56 [PATCH 0/4] OpenCores 10/100 MAC ethtool operations Max Filippov
  2014-01-29 19:56 ` [PATCH 1/4] net: ethoc: implement basic " Max Filippov
  2014-01-29 19:56 ` [PATCH 2/4] net: ethoc: implement ethtool get/set settings Max Filippov
@ 2014-01-29 19:56 ` Max Filippov
  2014-01-30 14:01   ` Ben Hutchings
  2014-01-29 19:56 ` [PATCH 4/4] net: ethoc: implement ethtool get/set ring parameters Max Filippov
  2014-01-29 20:01 ` [PATCH 0/4] OpenCores 10/100 MAC ethtool operations Florian Fainelli
  4 siblings, 1 reply; 8+ messages in thread
From: Max Filippov @ 2014-01-29 19:56 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: David S. Miller, Florian Fainelli, Marc Gauthier, Max Filippov

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 drivers/net/ethernet/ethoc.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 9518023..0bf297b 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -52,6 +52,7 @@ MODULE_PARM_DESC(buffer_size, "DMA buffer allocation size");
 #define	ETH_HASH0	0x48
 #define	ETH_HASH1	0x4c
 #define	ETH_TXCTRL	0x50
+#define	ETH_END		0x54
 
 /* mode register */
 #define	MODER_RXEN	(1 <<  0) /* receive enable */
@@ -922,9 +923,28 @@ static int ethoc_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 	return phy_ethtool_sset(phydev, cmd);
 }
 
+static int ethoc_get_regs_len(struct net_device *netdev)
+{
+	return ETH_END;
+}
+
+static void ethoc_get_regs(struct net_device *dev, struct ethtool_regs *regs,
+			   void *p)
+{
+	struct ethoc *priv = netdev_priv(dev);
+	u32 *regs_buff = p;
+	unsigned i;
+
+	regs->version = 0;
+	for (i = 0; i < ETH_END / sizeof(u32); ++i)
+		regs_buff[i] = ethoc_read(priv, i * sizeof(u32));
+}
+
 const struct ethtool_ops ethoc_ethtool_ops = {
 	.get_settings = ethoc_get_settings,
 	.set_settings = ethoc_set_settings,
+	.get_regs_len = ethoc_get_regs_len,
+	.get_regs = ethoc_get_regs,
 	.get_link = ethtool_op_get_link,
 	.get_ts_info = ethtool_op_get_ts_info,
 };
-- 
1.8.1.4


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

* [PATCH 4/4] net: ethoc: implement ethtool get/set ring parameters
  2014-01-29 19:56 [PATCH 0/4] OpenCores 10/100 MAC ethtool operations Max Filippov
                   ` (2 preceding siblings ...)
  2014-01-29 19:56 ` [PATCH 3/4] net: ethoc: implement ethtool get registers Max Filippov
@ 2014-01-29 19:56 ` Max Filippov
  2014-01-29 20:01 ` [PATCH 0/4] OpenCores 10/100 MAC ethtool operations Florian Fainelli
  4 siblings, 0 replies; 8+ messages in thread
From: Max Filippov @ 2014-01-29 19:56 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: David S. Miller, Florian Fainelli, Marc Gauthier, Max Filippov

TX and RX rings share memory and descriptors. Maximal number of
descriptors reported is one less than the total available nuber of
descriptors. For the set operation the requested number of TX descriptors
is rounded down to the nearest power of two (driver logic requirement), the
rest are RX descriptors. If less RX descriptors is requested the rest is
left unused.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 drivers/net/ethernet/ethoc.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 0bf297b..c873946 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -181,6 +181,7 @@ MODULE_PARM_DESC(buffer_size, "DMA buffer allocation size");
  * @membase:	pointer to buffer memory region
  * @dma_alloc:	dma allocated buffer size
  * @io_region_size:	I/O memory region size
+ * @num_bd:	number of buffer descriptors
  * @num_tx:	number of send buffers
  * @cur_tx:	last send buffer written
  * @dty_tx:	last buffer actually sent
@@ -201,6 +202,7 @@ struct ethoc {
 	int dma_alloc;
 	resource_size_t io_region_size;
 
+	unsigned int num_bd;
 	unsigned int num_tx;
 	unsigned int cur_tx;
 	unsigned int dty_tx;
@@ -940,12 +942,44 @@ static void ethoc_get_regs(struct net_device *dev, struct ethtool_regs *regs,
 		regs_buff[i] = ethoc_read(priv, i * sizeof(u32));
 }
 
+static void ethoc_get_ringparam(struct net_device *dev,
+				struct ethtool_ringparam *ring)
+{
+	struct ethoc *priv = netdev_priv(dev);
+
+	ring->rx_max_pending = priv->num_bd - 1;
+	ring->rx_mini_max_pending = 0;
+	ring->rx_jumbo_max_pending = 0;
+	ring->tx_max_pending = priv->num_bd - 1;
+
+	ring->rx_pending = priv->num_rx;
+	ring->rx_mini_pending = 0;
+	ring->rx_jumbo_pending = 0;
+	ring->tx_pending = priv->num_tx;
+}
+
+static int ethoc_set_ringparam(struct net_device *dev,
+			       struct ethtool_ringparam *ring)
+{
+	struct ethoc *priv = netdev_priv(dev);
+
+	if (netif_running(dev))
+		return -EBUSY;
+	priv->num_tx = rounddown_pow_of_two(ring->tx_pending);
+	priv->num_rx = priv->num_bd - priv->num_tx;
+	if (priv->num_rx > ring->rx_pending)
+		priv->num_rx = ring->rx_pending;
+	return 0;
+}
+
 const struct ethtool_ops ethoc_ethtool_ops = {
 	.get_settings = ethoc_get_settings,
 	.set_settings = ethoc_set_settings,
 	.get_regs_len = ethoc_get_regs_len,
 	.get_regs = ethoc_get_regs,
 	.get_link = ethtool_op_get_link,
+	.get_ringparam = ethoc_get_ringparam,
+	.set_ringparam = ethoc_set_ringparam,
 	.get_ts_info = ethtool_op_get_ts_info,
 };
 
@@ -1077,6 +1111,7 @@ static int ethoc_probe(struct platform_device *pdev)
 		ret = -ENODEV;
 		goto error;
 	}
+	priv->num_bd = num_bd;
 	/* num_tx must be a power of two */
 	priv->num_tx = rounddown_pow_of_two(num_bd >> 1);
 	priv->num_rx = num_bd - priv->num_tx;
-- 
1.8.1.4


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

* Re: [PATCH 0/4] OpenCores 10/100 MAC ethtool operations
  2014-01-29 19:56 [PATCH 0/4] OpenCores 10/100 MAC ethtool operations Max Filippov
                   ` (3 preceding siblings ...)
  2014-01-29 19:56 ` [PATCH 4/4] net: ethoc: implement ethtool get/set ring parameters Max Filippov
@ 2014-01-29 20:01 ` Florian Fainelli
  4 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2014-01-29 20:01 UTC (permalink / raw)
  To: Max Filippov; +Cc: netdev, linux-kernel, David S. Miller, Marc Gauthier

2014-01-29 Max Filippov <jcmvbkbc@gmail.com>:
> Hello David, Florian and everybody,
>
> this series implements ethtool callbacks for the ethoc driver as was
> requested by Florian.

Thanks Max, this does look good to me now:

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

>
> Max Filippov (4):
>   net: ethoc: implement basic ethtool operations
>   net: ethoc: implement ethtool get/set settings
>   net: ethoc: implement ethtool get registers
>   net: ethoc: implement ethtool get/set ring parameters
>
>  drivers/net/ethernet/ethoc.c | 85 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 85 insertions(+)
>
> --
> 1.8.1.4
>



-- 
Florian

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

* Re: [PATCH 1/4] net: ethoc: implement basic ethtool operations
  2014-01-29 19:56 ` [PATCH 1/4] net: ethoc: implement basic " Max Filippov
@ 2014-01-30 13:59   ` Ben Hutchings
  0 siblings, 0 replies; 8+ messages in thread
From: Ben Hutchings @ 2014-01-30 13:59 UTC (permalink / raw)
  To: Max Filippov
  Cc: netdev, linux-kernel, David S. Miller, Florian Fainelli, Marc Gauthier

[-- Attachment #1: Type: text/plain, Size: 1341 bytes --]

On Wed, 2014-01-29 at 23:56 +0400, Max Filippov wrote:
> The following methods are implemented:
> - get link state (standard implementation);
> - get timestamping info (standard implementation).
> 
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>

Reviewed-by: Ben Hutchings <ben@decadent.org.uk>

> ---
>  drivers/net/ethernet/ethoc.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
> index 5854d41..6de6352 100644
> --- a/drivers/net/ethernet/ethoc.c
> +++ b/drivers/net/ethernet/ethoc.c
> @@ -900,6 +900,11 @@ out:
>  	return NETDEV_TX_OK;
>  }
>  
> +const struct ethtool_ops ethoc_ethtool_ops = {
> +	.get_link = ethtool_op_get_link,
> +	.get_ts_info = ethtool_op_get_ts_info,
> +};
> +
>  static const struct net_device_ops ethoc_netdev_ops = {
>  	.ndo_open = ethoc_open,
>  	.ndo_stop = ethoc_stop,
> @@ -1148,6 +1153,7 @@ static int ethoc_probe(struct platform_device *pdev)
>  	netdev->netdev_ops = &ethoc_netdev_ops;
>  	netdev->watchdog_timeo = ETHOC_TIMEOUT;
>  	netdev->features |= 0;
> +	netdev->ethtool_ops = &ethoc_ethtool_ops;
>  
>  	/* setup NAPI */
>  	netif_napi_add(netdev, &priv->napi, ethoc_poll, 64);

-- 
Ben Hutchings
It is a miracle that curiosity survives formal education. - Albert Einstein

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

* Re: [PATCH 3/4] net: ethoc: implement ethtool get registers
  2014-01-29 19:56 ` [PATCH 3/4] net: ethoc: implement ethtool get registers Max Filippov
@ 2014-01-30 14:01   ` Ben Hutchings
  0 siblings, 0 replies; 8+ messages in thread
From: Ben Hutchings @ 2014-01-30 14:01 UTC (permalink / raw)
  To: Max Filippov
  Cc: netdev, linux-kernel, David S. Miller, Florian Fainelli, Marc Gauthier

[-- Attachment #1: Type: text/plain, Size: 1716 bytes --]

On Wed, 2014-01-29 at 23:56 +0400, Max Filippov wrote:
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>

Reviewed-by: Ben Hutchings <ben@decadent.org.uk>

> ---
>  drivers/net/ethernet/ethoc.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
> index 9518023..0bf297b 100644
> --- a/drivers/net/ethernet/ethoc.c
> +++ b/drivers/net/ethernet/ethoc.c
> @@ -52,6 +52,7 @@ MODULE_PARM_DESC(buffer_size, "DMA buffer allocation size");
>  #define	ETH_HASH0	0x48
>  #define	ETH_HASH1	0x4c
>  #define	ETH_TXCTRL	0x50
> +#define	ETH_END		0x54
>  
>  /* mode register */
>  #define	MODER_RXEN	(1 <<  0) /* receive enable */
> @@ -922,9 +923,28 @@ static int ethoc_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
>  	return phy_ethtool_sset(phydev, cmd);
>  }
>  
> +static int ethoc_get_regs_len(struct net_device *netdev)
> +{
> +	return ETH_END;
> +}
> +
> +static void ethoc_get_regs(struct net_device *dev, struct ethtool_regs *regs,
> +			   void *p)
> +{
> +	struct ethoc *priv = netdev_priv(dev);
> +	u32 *regs_buff = p;
> +	unsigned i;
> +
> +	regs->version = 0;
> +	for (i = 0; i < ETH_END / sizeof(u32); ++i)
> +		regs_buff[i] = ethoc_read(priv, i * sizeof(u32));
> +}
> +
>  const struct ethtool_ops ethoc_ethtool_ops = {
>  	.get_settings = ethoc_get_settings,
>  	.set_settings = ethoc_set_settings,
> +	.get_regs_len = ethoc_get_regs_len,
> +	.get_regs = ethoc_get_regs,
>  	.get_link = ethtool_op_get_link,
>  	.get_ts_info = ethtool_op_get_ts_info,
>  };

-- 
Ben Hutchings
It is a miracle that curiosity survives formal education. - Albert Einstein

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

end of thread, other threads:[~2014-01-30 14:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-29 19:56 [PATCH 0/4] OpenCores 10/100 MAC ethtool operations Max Filippov
2014-01-29 19:56 ` [PATCH 1/4] net: ethoc: implement basic " Max Filippov
2014-01-30 13:59   ` Ben Hutchings
2014-01-29 19:56 ` [PATCH 2/4] net: ethoc: implement ethtool get/set settings Max Filippov
2014-01-29 19:56 ` [PATCH 3/4] net: ethoc: implement ethtool get registers Max Filippov
2014-01-30 14:01   ` Ben Hutchings
2014-01-29 19:56 ` [PATCH 4/4] net: ethoc: implement ethtool get/set ring parameters Max Filippov
2014-01-29 20:01 ` [PATCH 0/4] OpenCores 10/100 MAC ethtool operations Florian Fainelli

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