Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
Browse files Browse the repository at this point in the history
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (84 commits)
  wimax: fix kernel-doc for debufs_dentry member of struct wimax_dev
  net: convert pegasus driver to net_device_ops
  bnx2x: Prevent eeprom set when driver is down
  net: switch kaweth driver to netdevops
  pcnet32: round off carrier watch timer
  i2400m/usb: wrap USB power saving in #ifdef CONFIG_PM
  wimax: testing for rfkill support should also test for CONFIG_RFKILL_MODULE
  wimax: fix kconfig interactions with rfkill and input layers
  wimax: fix '#ifndef CONFIG_BUG' layout to avoid warning
  r6040: bump release number to 0.20
  r6040: warn about MAC address being unset
  r6040: check PHY status when bringing interface up
  r6040: make printks consistent with DRV_NAME
  gianfar: Fixup use of BUS_ID_SIZE
  mlx4_en: Returning real Max in get_ringparam
  mlx4_en: Consider inline packets on completion
  netdev: bfin_mac: enable bfin_mac net dev driver for BF51x
  qeth: convert to net_device_ops
  vlan: add neigh_setup
  dm9601: warn on invalid mac address
  ...
  • Loading branch information
Linus Torvalds committed Jan 8, 2009
2 parents ce279e6 + 56cf391 commit 5fbbf5f
Show file tree
Hide file tree
Showing 123 changed files with 1,826 additions and 10,910 deletions.
54 changes: 25 additions & 29 deletions drivers/ieee1394/eth1394.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,6 @@ static int ether1394_stop(struct net_device *dev)
return 0;
}

/* Return statistics to the caller */
static struct net_device_stats *ether1394_stats(struct net_device *dev)
{
return &(((struct eth1394_priv *)netdev_priv(dev))->stats);
}

/* FIXME: What to do if we timeout? I think a host reset is probably in order,
* so that's what we do. Should we increment the stat counters too? */
static void ether1394_tx_timeout(struct net_device *dev)
Expand Down Expand Up @@ -516,16 +510,19 @@ static const struct header_ops ether1394_header_ops = {
.parse = ether1394_header_parse,
};

static const struct net_device_ops ether1394_netdev_ops = {
.ndo_open = ether1394_open,
.ndo_stop = ether1394_stop,
.ndo_start_xmit = ether1394_tx,
.ndo_tx_timeout = ether1394_tx_timeout,
.ndo_change_mtu = ether1394_change_mtu,
};

static void ether1394_init_dev(struct net_device *dev)
{
dev->open = ether1394_open;
dev->stop = ether1394_stop;
dev->hard_start_xmit = ether1394_tx;
dev->get_stats = ether1394_stats;
dev->tx_timeout = ether1394_tx_timeout;
dev->change_mtu = ether1394_change_mtu;

dev->header_ops = &ether1394_header_ops;
dev->netdev_ops = &ether1394_netdev_ops;

SET_ETHTOOL_OPS(dev, &ethtool_ops);

Expand Down Expand Up @@ -1075,7 +1072,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
HPSB_PRINT(KERN_ERR, "ether1394 rx: sender nodeid "
"lookup failure: " NODE_BUS_FMT,
NODE_BUS_ARGS(priv->host, srcid));
priv->stats.rx_dropped++;
dev->stats.rx_dropped++;
return -1;
}
ud = node->ud;
Expand All @@ -1098,7 +1095,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
skb = dev_alloc_skb(len + dev->hard_header_len + 15);
if (unlikely(!skb)) {
ETH1394_PRINT_G(KERN_ERR, "Out of memory\n");
priv->stats.rx_dropped++;
dev->stats.rx_dropped++;
return -1;
}
skb_reserve(skb, (dev->hard_header_len + 15) & ~15);
Expand Down Expand Up @@ -1217,15 +1214,15 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
spin_lock_irqsave(&priv->lock, flags);

if (!skb->protocol) {
priv->stats.rx_errors++;
priv->stats.rx_dropped++;
dev->stats.rx_errors++;
dev->stats.rx_dropped++;
dev_kfree_skb_any(skb);
} else if (netif_rx(skb) == NET_RX_DROP) {
priv->stats.rx_errors++;
priv->stats.rx_dropped++;
dev->stats.rx_errors++;
dev->stats.rx_dropped++;
} else {
priv->stats.rx_packets++;
priv->stats.rx_bytes += skb->len;
dev->stats.rx_packets++;
dev->stats.rx_bytes += skb->len;
}

spin_unlock_irqrestore(&priv->lock, flags);
Expand All @@ -1234,8 +1231,6 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
if (netif_queue_stopped(dev))
netif_wake_queue(dev);

dev->last_rx = jiffies;

return 0;
}

Expand Down Expand Up @@ -1509,17 +1504,18 @@ static int ether1394_send_packet(struct packet_task *ptask, unsigned int tx_len)
static void ether1394_dg_complete(struct packet_task *ptask, int fail)
{
struct sk_buff *skb = ptask->skb;
struct eth1394_priv *priv = netdev_priv(skb->dev);
struct net_device *dev = skb->dev;
struct eth1394_priv *priv = netdev_priv(dev);
unsigned long flags;

/* Statistics */
spin_lock_irqsave(&priv->lock, flags);
if (fail) {
priv->stats.tx_dropped++;
priv->stats.tx_errors++;
dev->stats.tx_dropped++;
dev->stats.tx_errors++;
} else {
priv->stats.tx_bytes += skb->len;
priv->stats.tx_packets++;
dev->stats.tx_bytes += skb->len;
dev->stats.tx_packets++;
}
spin_unlock_irqrestore(&priv->lock, flags);

Expand Down Expand Up @@ -1696,8 +1692,8 @@ static int ether1394_tx(struct sk_buff *skb, struct net_device *dev)
dev_kfree_skb(skb);

spin_lock_irqsave(&priv->lock, flags);
priv->stats.tx_dropped++;
priv->stats.tx_errors++;
dev->stats.tx_dropped++;
dev->stats.tx_errors++;
spin_unlock_irqrestore(&priv->lock, flags);

/*
Expand Down
1 change: 0 additions & 1 deletion drivers/ieee1394/eth1394.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ enum eth1394_bc_states { ETHER1394_BC_ERROR,

/* Private structure for our ethernet driver */
struct eth1394_priv {
struct net_device_stats stats; /* Device stats */
struct hpsb_host *host; /* The card for this dev */
u16 bc_maxpayload; /* Max broadcast payload */
u8 bc_sspd; /* Max broadcast speed */
Expand Down
77 changes: 31 additions & 46 deletions drivers/isdn/hysdn/hysdn_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,19 @@ char *hysdn_net_revision = "$Revision: 1.8.6.4 $";
/* inside the definition. */
/****************************************************************************/
struct net_local {
struct net_device netdev; /* the network device */
struct net_device_stats stats;
/* additional vars may be added here */
char dev_name[9]; /* our own device name */

/* Tx control lock. This protects the transmit buffer ring
* state along with the "tx full" state of the driver. This
* means all netif_queue flow control actions are protected
* by this lock as well.
*/
struct net_device *dev;
spinlock_t lock;
struct sk_buff *skbs[MAX_SKB_BUFFERS]; /* pointers to tx-skbs */
int in_idx, out_idx; /* indexes to buffer ring */
int sk_count; /* number of buffers currently in ring */
}; /* net_local */


/*****************************************************/
/* Get the current statistics for this card. */
/* This may be called with the card open or closed ! */
/*****************************************************/
static struct net_device_stats *
net_get_stats(struct net_device *dev)
{
return (&((struct net_local *) dev)->stats);
} /* net_device_stats */

/*********************************************************************/
/* Open/initialize the board. This is called (in the current kernel) */
Expand Down Expand Up @@ -182,8 +169,8 @@ hysdn_tx_netack(hysdn_card * card)
if (!lp->sk_count)
return; /* error condition */

lp->stats.tx_packets++;
lp->stats.tx_bytes += lp->skbs[lp->out_idx]->len;
lp->dev->stats.tx_packets++;
lp->dev->stats.tx_bytes += lp->skbs[lp->out_idx]->len;

dev_kfree_skb(lp->skbs[lp->out_idx++]); /* free skb */
if (lp->out_idx >= MAX_SKB_BUFFERS)
Expand All @@ -200,29 +187,30 @@ void
hysdn_rx_netpkt(hysdn_card * card, unsigned char *buf, unsigned short len)
{
struct net_local *lp = card->netif;
struct net_device *dev = lp->dev;
struct sk_buff *skb;

if (!lp)
return; /* non existing device */

lp->stats.rx_bytes += len;
dev->stats.rx_bytes += len;

skb = dev_alloc_skb(len);
if (skb == NULL) {
printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n",
lp->netdev.name);
lp->stats.rx_dropped++;
dev->name);
dev->stats.rx_dropped++;
return;
}
/* copy the data */
memcpy(skb_put(skb, len), buf, len);

/* determine the used protocol */
skb->protocol = eth_type_trans(skb, &lp->netdev);
skb->protocol = eth_type_trans(skb, dev);

netif_rx(skb);
lp->stats.rx_packets++; /* adjust packet count */
dev->stats.rx_packets++; /* adjust packet count */

netif_rx(skb);
} /* hysdn_rx_netpkt */

/*****************************************************/
Expand All @@ -242,24 +230,15 @@ hysdn_tx_netget(hysdn_card * card)
return (lp->skbs[lp->out_idx]); /* next packet to send */
} /* hysdn_tx_netget */

static const struct net_device_ops hysdn_netdev_ops = {
.ndo_open = net_open,
.ndo_stop = net_close,
.ndo_start_xmit = net_send_packet,
.ndo_change_mtu = eth_change_mtu,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};

/*******************************************/
/* init function called by register device */
/*******************************************/
static int
net_init(struct net_device *dev)
{
/* setup the function table */
dev->open = net_open;
dev->stop = net_close;
dev->hard_start_xmit = net_send_packet;
dev->get_stats = net_get_stats;

/* Fill in the fields of the device structure with ethernet values. */
ether_setup(dev);

return (0); /* success */
} /* net_init */

/*****************************************************************************/
/* hysdn_net_create creates a new net device for the given card. If a device */
Expand All @@ -271,28 +250,34 @@ hysdn_net_create(hysdn_card * card)
{
struct net_device *dev;
int i;
struct net_local *lp;

if(!card) {
printk(KERN_WARNING "No card-pt in hysdn_net_create!\n");
return (-ENOMEM);
}
hysdn_net_release(card); /* release an existing net device */
if ((dev = kzalloc(sizeof(struct net_local), GFP_KERNEL)) == NULL) {

dev = alloc_etherdev(sizeof(struct net_local));
if (!dev) {
printk(KERN_WARNING "HYSDN: unable to allocate mem\n");
return (-ENOMEM);
}

lp = netdev_priv(dev);
lp->dev = dev;

dev->netdev_ops = &hysdn_netdev_ops;
spin_lock_init(&((struct net_local *) dev)->lock);

/* initialise necessary or informing fields */
dev->base_addr = card->iobase; /* IO address */
dev->irq = card->irq; /* irq */
dev->init = net_init; /* the init function of the device */
if(dev->name) {
strcpy(dev->name, ((struct net_local *) dev)->dev_name);
}

dev->netdev_ops = &hysdn_netdev_ops;
if ((i = register_netdev(dev))) {
printk(KERN_WARNING "HYSDN: unable to create network device\n");
kfree(dev);
free_netdev(dev);
return (i);
}
dev->ml_priv = card; /* remember pointer to own data structure */
Expand All @@ -316,7 +301,7 @@ hysdn_net_release(hysdn_card * card)
return (0); /* non existing */

card->netif = NULL; /* clear out pointer */
dev->stop(dev); /* close the device */
net_close(dev);

flush_tx_buffers((struct net_local *) dev); /* empty buffers */

Expand Down
Loading

0 comments on commit 5fbbf5f

Please sign in to comment.