net: gianfar: convert to hw_features
Note: I bet that gfar_set_features() don't really need a full reset. Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
c8c64cff2c
commit
8b3afe95e3
@@ -365,7 +365,7 @@ static void gfar_init_mac(struct net_device *ndev)
|
|||||||
gfar_write(®s->rir0, DEFAULT_RIR0);
|
gfar_write(®s->rir0, DEFAULT_RIR0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->rx_csum_enable)
|
if (ndev->features & NETIF_F_RXCSUM)
|
||||||
rctrl |= RCTRL_CHECKSUMMING;
|
rctrl |= RCTRL_CHECKSUMMING;
|
||||||
|
|
||||||
if (priv->extended_hash) {
|
if (priv->extended_hash) {
|
||||||
@@ -463,6 +463,7 @@ static const struct net_device_ops gfar_netdev_ops = {
|
|||||||
.ndo_start_xmit = gfar_start_xmit,
|
.ndo_start_xmit = gfar_start_xmit,
|
||||||
.ndo_stop = gfar_close,
|
.ndo_stop = gfar_close,
|
||||||
.ndo_change_mtu = gfar_change_mtu,
|
.ndo_change_mtu = gfar_change_mtu,
|
||||||
|
.ndo_set_features = gfar_set_features,
|
||||||
.ndo_set_multicast_list = gfar_set_multi,
|
.ndo_set_multicast_list = gfar_set_multi,
|
||||||
.ndo_tx_timeout = gfar_timeout,
|
.ndo_tx_timeout = gfar_timeout,
|
||||||
.ndo_do_ioctl = gfar_ioctl,
|
.ndo_do_ioctl = gfar_ioctl,
|
||||||
@@ -513,7 +514,7 @@ void unlock_tx_qs(struct gfar_private *priv)
|
|||||||
/* Returns 1 if incoming frames use an FCB */
|
/* Returns 1 if incoming frames use an FCB */
|
||||||
static inline int gfar_uses_fcb(struct gfar_private *priv)
|
static inline int gfar_uses_fcb(struct gfar_private *priv)
|
||||||
{
|
{
|
||||||
return priv->vlgrp || priv->rx_csum_enable ||
|
return priv->vlgrp || (priv->ndev->features & NETIF_F_RXCSUM) ||
|
||||||
(priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER);
|
(priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1030,10 +1031,11 @@ static int gfar_probe(struct platform_device *ofdev)
|
|||||||
netif_napi_add(dev, &priv->gfargrp[i].napi, gfar_poll, GFAR_DEV_WEIGHT);
|
netif_napi_add(dev, &priv->gfargrp[i].napi, gfar_poll, GFAR_DEV_WEIGHT);
|
||||||
|
|
||||||
if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) {
|
if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) {
|
||||||
priv->rx_csum_enable = 1;
|
dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG |
|
||||||
dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_HIGHDMA;
|
NETIF_F_RXCSUM;
|
||||||
} else
|
dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG |
|
||||||
priv->rx_csum_enable = 0;
|
NETIF_F_RXCSUM | NETIF_F_HIGHDMA;
|
||||||
|
}
|
||||||
|
|
||||||
priv->vlgrp = NULL;
|
priv->vlgrp = NULL;
|
||||||
|
|
||||||
@@ -2697,7 +2699,7 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
|
|||||||
if (priv->padding)
|
if (priv->padding)
|
||||||
skb_pull(skb, priv->padding);
|
skb_pull(skb, priv->padding);
|
||||||
|
|
||||||
if (priv->rx_csum_enable)
|
if (dev->features & NETIF_F_RXCSUM)
|
||||||
gfar_rx_checksum(skb, fcb);
|
gfar_rx_checksum(skb, fcb);
|
||||||
|
|
||||||
/* Tell the skb what kind of packet this is */
|
/* Tell the skb what kind of packet this is */
|
||||||
|
@@ -1083,7 +1083,7 @@ struct gfar_private {
|
|||||||
struct device_node *phy_node;
|
struct device_node *phy_node;
|
||||||
struct device_node *tbi_node;
|
struct device_node *tbi_node;
|
||||||
u32 device_flags;
|
u32 device_flags;
|
||||||
unsigned char rx_csum_enable:1,
|
unsigned char
|
||||||
extended_hash:1,
|
extended_hash:1,
|
||||||
bd_stash_en:1,
|
bd_stash_en:1,
|
||||||
rx_filer_enable:1,
|
rx_filer_enable:1,
|
||||||
@@ -1153,6 +1153,7 @@ extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev,
|
|||||||
extern void gfar_configure_coalescing(struct gfar_private *priv,
|
extern void gfar_configure_coalescing(struct gfar_private *priv,
|
||||||
unsigned long tx_mask, unsigned long rx_mask);
|
unsigned long tx_mask, unsigned long rx_mask);
|
||||||
void gfar_init_sysfs(struct net_device *dev);
|
void gfar_init_sysfs(struct net_device *dev);
|
||||||
|
int gfar_set_features(struct net_device *dev, u32 features);
|
||||||
|
|
||||||
extern const struct ethtool_ops gfar_ethtool_ops;
|
extern const struct ethtool_ops gfar_ethtool_ops;
|
||||||
|
|
||||||
|
@@ -517,15 +517,15 @@ static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rva
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gfar_set_rx_csum(struct net_device *dev, uint32_t data)
|
int gfar_set_features(struct net_device *dev, u32 features)
|
||||||
{
|
{
|
||||||
struct gfar_private *priv = netdev_priv(dev);
|
struct gfar_private *priv = netdev_priv(dev);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int err = 0, i = 0;
|
int err = 0, i = 0;
|
||||||
|
u32 changed = dev->features ^ features;
|
||||||
|
|
||||||
if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
|
if (!(changed & NETIF_F_RXCSUM))
|
||||||
return -EOPNOTSUPP;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
if (dev->flags & IFF_UP) {
|
if (dev->flags & IFF_UP) {
|
||||||
/* Halt TX and RX, and process the frames which
|
/* Halt TX and RX, and process the frames which
|
||||||
@@ -546,58 +546,15 @@ static int gfar_set_rx_csum(struct net_device *dev, uint32_t data)
|
|||||||
|
|
||||||
/* Now we take down the rings to rebuild them */
|
/* Now we take down the rings to rebuild them */
|
||||||
stop_gfar(dev);
|
stop_gfar(dev);
|
||||||
}
|
|
||||||
|
|
||||||
spin_lock_irqsave(&priv->bflock, flags);
|
dev->features = features;
|
||||||
priv->rx_csum_enable = data;
|
|
||||||
spin_unlock_irqrestore(&priv->bflock, flags);
|
|
||||||
|
|
||||||
if (dev->flags & IFF_UP) {
|
|
||||||
err = startup_gfar(dev);
|
err = startup_gfar(dev);
|
||||||
netif_tx_wake_all_queues(dev);
|
netif_tx_wake_all_queues(dev);
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t gfar_get_rx_csum(struct net_device *dev)
|
|
||||||
{
|
|
||||||
struct gfar_private *priv = netdev_priv(dev);
|
|
||||||
|
|
||||||
if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return priv->rx_csum_enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int gfar_set_tx_csum(struct net_device *dev, uint32_t data)
|
|
||||||
{
|
|
||||||
struct gfar_private *priv = netdev_priv(dev);
|
|
||||||
|
|
||||||
if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
|
|
||||||
netif_tx_lock_bh(dev);
|
|
||||||
|
|
||||||
if (data)
|
|
||||||
dev->features |= NETIF_F_IP_CSUM;
|
|
||||||
else
|
|
||||||
dev->features &= ~NETIF_F_IP_CSUM;
|
|
||||||
|
|
||||||
netif_tx_unlock_bh(dev);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t gfar_get_tx_csum(struct net_device *dev)
|
|
||||||
{
|
|
||||||
struct gfar_private *priv = netdev_priv(dev);
|
|
||||||
|
|
||||||
if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return (dev->features & NETIF_F_IP_CSUM) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t gfar_get_msglevel(struct net_device *dev)
|
static uint32_t gfar_get_msglevel(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct gfar_private *priv = netdev_priv(dev);
|
struct gfar_private *priv = netdev_priv(dev);
|
||||||
@@ -844,11 +801,6 @@ const struct ethtool_ops gfar_ethtool_ops = {
|
|||||||
.get_strings = gfar_gstrings,
|
.get_strings = gfar_gstrings,
|
||||||
.get_sset_count = gfar_sset_count,
|
.get_sset_count = gfar_sset_count,
|
||||||
.get_ethtool_stats = gfar_fill_stats,
|
.get_ethtool_stats = gfar_fill_stats,
|
||||||
.get_rx_csum = gfar_get_rx_csum,
|
|
||||||
.get_tx_csum = gfar_get_tx_csum,
|
|
||||||
.set_rx_csum = gfar_set_rx_csum,
|
|
||||||
.set_tx_csum = gfar_set_tx_csum,
|
|
||||||
.set_sg = ethtool_op_set_sg,
|
|
||||||
.get_msglevel = gfar_get_msglevel,
|
.get_msglevel = gfar_get_msglevel,
|
||||||
.set_msglevel = gfar_set_msglevel,
|
.set_msglevel = gfar_set_msglevel,
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
|
Reference in New Issue
Block a user