Commit e8ac9c55 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

xpnet: convert devices to new API

Convert to net_device_ops and internal net_device_stats
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4805fc76
...@@ -95,11 +95,6 @@ struct xpnet_pending_msg { ...@@ -95,11 +95,6 @@ struct xpnet_pending_msg {
atomic_t use_count; atomic_t use_count;
}; };
/* driver specific structure pointed to by the device structure */
struct xpnet_dev_private {
struct net_device_stats stats;
};
struct net_device *xpnet_device; struct net_device *xpnet_device;
/* /*
...@@ -153,7 +148,6 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg) ...@@ -153,7 +148,6 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg)
struct sk_buff *skb; struct sk_buff *skb;
void *dst; void *dst;
enum xp_retval ret; enum xp_retval ret;
struct xpnet_dev_private *priv = netdev_priv(xpnet_device);
if (!XPNET_VALID_MSG(msg)) { if (!XPNET_VALID_MSG(msg)) {
/* /*
...@@ -161,7 +155,7 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg) ...@@ -161,7 +155,7 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg)
*/ */
xpc_received(partid, channel, (void *)msg); xpc_received(partid, channel, (void *)msg);
priv->stats.rx_errors++; xpnet_device->stats.rx_errors++;
return; return;
} }
...@@ -176,7 +170,7 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg) ...@@ -176,7 +170,7 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg)
xpc_received(partid, channel, (void *)msg); xpc_received(partid, channel, (void *)msg);
priv->stats.rx_errors++; xpnet_device->stats.rx_errors++;
return; return;
} }
...@@ -226,7 +220,7 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg) ...@@ -226,7 +220,7 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg)
xpc_received(partid, channel, (void *)msg); xpc_received(partid, channel, (void *)msg);
priv->stats.rx_errors++; xpnet_device->stats.rx_errors++;
return; return;
} }
...@@ -247,8 +241,8 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg) ...@@ -247,8 +241,8 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg)
skb_end_pointer(skb), skb->len); skb_end_pointer(skb), skb->len);
xpnet_device->last_rx = jiffies; xpnet_device->last_rx = jiffies;
priv->stats.rx_packets++; xpnet_device->stats.rx_packets++;
priv->stats.rx_bytes += skb->len + ETH_HLEN; xpnet_device->stats.rx_bytes += skb->len + ETH_HLEN;
netif_rx_ni(skb); netif_rx_ni(skb);
xpc_received(partid, channel, (void *)msg); xpc_received(partid, channel, (void *)msg);
...@@ -352,26 +346,6 @@ xpnet_dev_change_mtu(struct net_device *dev, int new_mtu) ...@@ -352,26 +346,6 @@ xpnet_dev_change_mtu(struct net_device *dev, int new_mtu)
return 0; return 0;
} }
/*
* Required for the net_device structure.
*/
static int
xpnet_dev_set_config(struct net_device *dev, struct ifmap *new_map)
{
return 0;
}
/*
* Return statistics to the caller.
*/
static struct net_device_stats *
xpnet_dev_get_stats(struct net_device *dev)
{
struct xpnet_dev_private *priv = netdev_priv(dev);
return &priv->stats;
}
/* /*
* Notification that the other end has received the message and * Notification that the other end has received the message and
* DMA'd the skb information. At this point, they are done with * DMA'd the skb information. At this point, they are done with
...@@ -453,7 +427,6 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -453,7 +427,6 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
struct xpnet_pending_msg *queued_msg; struct xpnet_pending_msg *queued_msg;
u64 start_addr, end_addr; u64 start_addr, end_addr;
short dest_partid; short dest_partid;
struct xpnet_dev_private *priv = netdev_priv(dev);
u16 embedded_bytes = 0; u16 embedded_bytes = 0;
dev_dbg(xpnet, ">skb->head=0x%p skb->data=0x%p skb->tail=0x%p " dev_dbg(xpnet, ">skb->head=0x%p skb->data=0x%p skb->tail=0x%p "
...@@ -476,7 +449,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -476,7 +449,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
dev_warn(xpnet, "failed to kmalloc %ld bytes; dropping " dev_warn(xpnet, "failed to kmalloc %ld bytes; dropping "
"packet\n", sizeof(struct xpnet_pending_msg)); "packet\n", sizeof(struct xpnet_pending_msg));
priv->stats.tx_errors++; dev->stats.tx_errors++;
return -ENOMEM; return -ENOMEM;
} }
...@@ -526,8 +499,8 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -526,8 +499,8 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
kfree(queued_msg); kfree(queued_msg);
} }
priv->stats.tx_packets++; dev->stats.tx_packets++;
priv->stats.tx_bytes += skb->len; dev->stats.tx_bytes += skb->len;
return 0; return 0;
} }
...@@ -538,12 +511,19 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -538,12 +511,19 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
static void static void
xpnet_dev_tx_timeout(struct net_device *dev) xpnet_dev_tx_timeout(struct net_device *dev)
{ {
struct xpnet_dev_private *priv = netdev_priv(dev); dev->stats.tx_errors++;
priv->stats.tx_errors++;
return;
} }
static const struct net_device_ops xpnet_netdev_ops = {
.ndo_open = xpnet_dev_open,
.ndo_stop = xpnet_dev_stop,
.ndo_start_xmit = xpnet_dev_hard_start_xmit,
.ndo_change_mtu = xpnet_dev_change_mtu,
.ndo_tx_timeout = xpnet_dev_tx_timeout,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};
static int __init static int __init
xpnet_init(void) xpnet_init(void)
{ {
...@@ -563,8 +543,7 @@ xpnet_init(void) ...@@ -563,8 +543,7 @@ xpnet_init(void)
* use ether_setup() to init the majority of our device * use ether_setup() to init the majority of our device
* structure and then override the necessary pieces. * structure and then override the necessary pieces.
*/ */
xpnet_device = alloc_netdev(sizeof(struct xpnet_dev_private), xpnet_device = alloc_netdev(0, XPNET_DEVICE_NAME, ether_setup);
XPNET_DEVICE_NAME, ether_setup);
if (xpnet_device == NULL) { if (xpnet_device == NULL) {
kfree(xpnet_broadcast_partitions); kfree(xpnet_broadcast_partitions);
return -ENOMEM; return -ENOMEM;
...@@ -573,13 +552,6 @@ xpnet_init(void) ...@@ -573,13 +552,6 @@ xpnet_init(void)
netif_carrier_off(xpnet_device); netif_carrier_off(xpnet_device);
xpnet_device->mtu = XPNET_DEF_MTU; xpnet_device->mtu = XPNET_DEF_MTU;
xpnet_device->change_mtu = xpnet_dev_change_mtu;
xpnet_device->open = xpnet_dev_open;
xpnet_device->get_stats = xpnet_dev_get_stats;
xpnet_device->stop = xpnet_dev_stop;
xpnet_device->hard_start_xmit = xpnet_dev_hard_start_xmit;
xpnet_device->tx_timeout = xpnet_dev_tx_timeout;
xpnet_device->set_config = xpnet_dev_set_config;
/* /*
* Multicast assumes the LSB of the first octet is set for multicast * Multicast assumes the LSB of the first octet is set for multicast
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment