#include <linux/mii.h>
#include <linux/of_device.h>
#include <linux/of_platform.h>
+#include <linux/slab.h>
#include <asm/cacheflush.h>
#include <asm/byteorder.h>
MODULE_PARM_DESC(greth_edcl, "GRETH EDCL usage indicator. Set to 1 if EDCL is used.");
static int greth_open(struct net_device *dev);
-static int greth_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static int greth_start_xmit_gbit(struct sk_buff *skb, struct net_device *dev);
+static netdev_tx_t greth_start_xmit(struct sk_buff *skb,
+ struct net_device *dev);
+static netdev_tx_t greth_start_xmit_gbit(struct sk_buff *skb,
+ struct net_device *dev);
static int greth_rx(struct net_device *dev, int limit);
static int greth_rx_gbit(struct net_device *dev, int limit);
static void greth_clean_tx(struct net_device *dev);
return 0;
}
-static int greth_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t
+greth_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct greth_private *greth = netdev_priv(dev);
struct greth_bd *bdp;
}
-static int greth_start_xmit_gbit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t
+greth_start_xmit_gbit(struct sk_buff *skb, struct net_device *dev)
{
struct greth_private *greth = netdev_priv(dev);
struct greth_bd *bdp;
if (net_ratelimit())
dev_warn(greth->dev, "Could not create TX DMA mapping\n");
dev_kfree_skb(skb);
- return NETDEV_TX_OK;
-
out:
return err;
}
else
skb->ip_summed = CHECKSUM_NONE;
- skb->dev = dev;
skb->protocol = eth_type_trans(skb, dev);
dev->stats.rx_packets++;
netif_receive_skb(skb);
struct greth_private *greth;
struct greth_regs *regs;
- greth = (struct greth_private *) netdev_priv(dev);
+ greth = netdev_priv(dev);
regs = (struct greth_regs *) greth->regs;
if (!is_valid_ether_addr(addr->sa_data))
static void greth_set_hash_filter(struct net_device *dev)
{
- struct dev_mc_list *curr;
- struct greth_private *greth = (struct greth_private *) netdev_priv(dev);
+ struct netdev_hw_addr *ha;
+ struct greth_private *greth = netdev_priv(dev);
struct greth_regs *regs = (struct greth_regs *) greth->regs;
u32 mc_filter[2];
- unsigned int i, bitnr;
+ unsigned int bitnr;
mc_filter[0] = mc_filter[1] = 0;
- curr = dev->mc_list;
-
- for (i = 0; i < dev->mc_count; i++, curr = curr->next) {
-
- if (!curr)
- break; /* unexpected end of list */
-
- bitnr = greth_hash_get_index(curr->dmi_addr);
+ netdev_for_each_mc_addr(ha, dev) {
+ bitnr = greth_hash_get_index(ha->addr);
mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
}
return;
}
- if (dev->mc_count == 0) {
+ if (netdev_mc_empty(dev)) {
cfg &= ~GRETH_CTRL_MCEN;
GRETH_REGSAVE(regs->control, cfg);
return;
.ndo_stop = greth_close,
.ndo_start_xmit = greth_start_xmit,
.ndo_set_mac_address = greth_set_mac_add,
+ .ndo_validate_addr = eth_validate_addr,
};
static inline int wait_for_mdio(struct greth_private *greth)
{
struct greth_private *greth = netdev_priv(dev);
struct phy_device *phy = NULL;
- u32 interface;
- int i;
+ int ret;
/* Find the first PHY */
- for (i = 0; i < PHY_MAX_ADDR; i++) {
- if (greth->mdio->phy_map[i]) {
- phy = greth->mdio->phy_map[i];
- break;
- }
- }
+ phy = phy_find_first(greth->mdio);
+
if (!phy) {
if (netif_msg_probe(greth))
dev_err(&dev->dev, "no PHY found\n");
return -ENXIO;
}
- if (greth->gbit_mac)
- interface = PHY_INTERFACE_MODE_GMII;
- else
- interface = PHY_INTERFACE_MODE_MII;
-
- phy = phy_connect(dev, dev_name(&phy->dev), &greth_link_change, 0, interface);
+ ret = phy_connect_direct(dev, phy, &greth_link_change,
+ 0, greth->gbit_mac ?
+ PHY_INTERFACE_MODE_GMII :
+ PHY_INTERFACE_MODE_MII);
+ if (ret) {
+ if (netif_msg_ifup(greth))
+ dev_err(&dev->dev, "could not attach to PHY\n");
+ return ret;
+ }
if (greth->gbit_mac)
phy->supported &= PHY_GBIT_FEATURES;
phy->advertising = phy->supported;
- if (IS_ERR(phy)) {
- if (netif_msg_ifup(greth))
- dev_err(&dev->dev, "could not attach to PHY\n");
- return PTR_ERR(phy);
- }
-
greth->link = 0;
greth->speed = 0;
greth->duplex = -1;