netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: greth: convert to hw_features
@ 2011-04-17 10:15 Michał Mirosław
  2011-04-18  0:44 ` David Miller
  2011-04-18  8:11 ` Kristoffer Glembo
  0 siblings, 2 replies; 3+ messages in thread
From: Michał Mirosław @ 2011-04-17 10:15 UTC (permalink / raw)
  To: netdev; +Cc: Kristoffer Glembo

Note: Driver modifies its struct net_device_ops. This will break if used for
multiple devices that are not all the same (if that HW config is possible).

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/net/greth.c |   46 ++++------------------------------------------
 drivers/net/greth.h |    4 ----
 2 files changed, 4 insertions(+), 46 deletions(-)

diff --git a/drivers/net/greth.c b/drivers/net/greth.c
index 396ff7d..f181304 100644
--- a/drivers/net/greth.c
+++ b/drivers/net/greth.c
@@ -901,7 +901,7 @@ static int greth_rx_gbit(struct net_device *dev, int limit)
 
 				skb_put(skb, pkt_len);
 
-				if (greth->flags & GRETH_FLAG_RX_CSUM && hw_checksummed(status))
+				if (dev->features & NETIF_F_RXCSUM && hw_checksummed(status))
 					skb->ip_summed = CHECKSUM_UNNECESSARY;
 				else
 					skb_checksum_none_assert(skb);
@@ -1142,41 +1142,6 @@ static void greth_get_regs(struct net_device *dev, struct ethtool_regs *regs, vo
 		buff[i] = greth_read_bd(&greth_regs[i]);
 }
 
-static u32 greth_get_rx_csum(struct net_device *dev)
-{
-	struct greth_private *greth = netdev_priv(dev);
-	return (greth->flags & GRETH_FLAG_RX_CSUM) != 0;
-}
-
-static int greth_set_rx_csum(struct net_device *dev, u32 data)
-{
-	struct greth_private *greth = netdev_priv(dev);
-
-	spin_lock_bh(&greth->devlock);
-
-	if (data)
-		greth->flags |= GRETH_FLAG_RX_CSUM;
-	else
-		greth->flags &= ~GRETH_FLAG_RX_CSUM;
-
-	spin_unlock_bh(&greth->devlock);
-
-	return 0;
-}
-
-static u32 greth_get_tx_csum(struct net_device *dev)
-{
-	return (dev->features & NETIF_F_IP_CSUM) != 0;
-}
-
-static int greth_set_tx_csum(struct net_device *dev, u32 data)
-{
-	netif_tx_lock_bh(dev);
-	ethtool_op_set_tx_csum(dev, data);
-	netif_tx_unlock_bh(dev);
-	return 0;
-}
-
 static const struct ethtool_ops greth_ethtool_ops = {
 	.get_msglevel		= greth_get_msglevel,
 	.set_msglevel		= greth_set_msglevel,
@@ -1185,10 +1150,6 @@ static const struct ethtool_ops greth_ethtool_ops = {
 	.get_drvinfo		= greth_get_drvinfo,
 	.get_regs_len           = greth_get_regs_len,
 	.get_regs               = greth_get_regs,
-	.get_rx_csum		= greth_get_rx_csum,
-	.set_rx_csum		= greth_set_rx_csum,
-	.get_tx_csum		= greth_get_tx_csum,
-	.set_tx_csum		= greth_set_tx_csum,
 	.get_link		= ethtool_op_get_link,
 };
 
@@ -1570,9 +1531,10 @@ static int __devinit greth_of_probe(struct platform_device *ofdev)
 	GRETH_REGSAVE(regs->status, 0xFF);
 
 	if (greth->gbit_mac) {
-		dev->features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_HIGHDMA;
+		dev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM |
+			NETIF_F_RXCSUM;
+		dev->features = dev->hw_features | NETIF_F_HIGHDMA;
 		greth_netdev_ops.ndo_start_xmit = greth_start_xmit_gbit;
-		greth->flags = GRETH_FLAG_RX_CSUM;
 	}
 
 	if (greth->multicast) {
diff --git a/drivers/net/greth.h b/drivers/net/greth.h
index be0f206..9a0040d 100644
--- a/drivers/net/greth.h
+++ b/drivers/net/greth.h
@@ -77,9 +77,6 @@
  */
 #define MAX_FRAME_SIZE		1520
 
-/* Flags */
-#define GRETH_FLAG_RX_CSUM 0x1
-
 /* GRETH APB registers */
 struct greth_regs {
 	u32 control;
@@ -133,7 +130,6 @@ struct greth_private {
 	unsigned int duplex;
 
 	u32 msg_enable;
-	u32 flags;
 
 	u8 phyaddr;
 	u8 multicast;
-- 
1.7.2.5


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

* Re: [PATCH] net: greth: convert to hw_features
  2011-04-17 10:15 [PATCH] net: greth: convert to hw_features Michał Mirosław
@ 2011-04-18  0:44 ` David Miller
  2011-04-18  8:11 ` Kristoffer Glembo
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2011-04-18  0:44 UTC (permalink / raw)
  To: mirq-linux; +Cc: netdev, kristoffer

From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: Sun, 17 Apr 2011 12:15:47 +0200 (CEST)

> Note: Driver modifies its struct net_device_ops. This will break if used for
> multiple devices that are not all the same (if that HW config is possible).
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

I guess for how this chip is used, this is OK for now.

Applied.

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

* Re: [PATCH] net: greth: convert to hw_features
  2011-04-17 10:15 [PATCH] net: greth: convert to hw_features Michał Mirosław
  2011-04-18  0:44 ` David Miller
@ 2011-04-18  8:11 ` Kristoffer Glembo
  1 sibling, 0 replies; 3+ messages in thread
From: Kristoffer Glembo @ 2011-04-18  8:11 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: netdev

Michał Mirosław wrote:
> Note: Driver modifies its struct net_device_ops. This will break if used for
> multiple devices that are not all the same (if that HW config is possible).
> 

True. I will fix this in the future. Not a big problem currently though, but thanks for the note and the patch!

Best regards,
Kristoffer Glembo
Aeroflex Gaisler

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

end of thread, other threads:[~2011-04-18  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-17 10:15 [PATCH] net: greth: convert to hw_features Michał Mirosław
2011-04-18  0:44 ` David Miller
2011-04-18  8:11 ` Kristoffer Glembo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).