[PATCH 4/4] ibmveth: General cleanups
Stephen Rothwell
sfr at canb.auug.org.au
Wed Sep 7 13:50:35 EST 2005
There are no semantic changes here.
- remove an unused define
- remove lionb from struct ibmveth_adapter
it was only used for a proc file and could be obtained
from other available data
- rearrange some functions to get rid of forward declarations
Signed-off-by: Stephen Rothwell <sfr at canb.auug.org.au>
---
drivers/net/ibmveth.c | 318 ++++++++++++++++++++-----------------------------
1 files changed, 133 insertions(+), 185 deletions(-)
--
Cheers,
Stephen Rothwell sfr at canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
d53d2f190a0cad40f593cb03e110b1a4c3204a5e
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -46,6 +46,7 @@
#include <linux/mm.h>
#include <linux/ethtool.h>
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <asm/semaphore.h>
#include <asm/hvcall.h>
@@ -53,7 +54,6 @@
#include <asm/iommu.h>
#include <asm/vio.h>
#include <asm/uaccess.h>
-#include <linux/seq_file.h>
#define IbmVethMaxSendFrags 6
@@ -74,7 +74,6 @@
#define IbmVethMcastClearFilterTable 0x3UL
/* hcall numbers */
-#define H_VIO_SIGNAL 0x104
#define H_REGISTER_LOGICAL_LAN 0x114
#define H_FREE_LOGICAL_LAN 0x118
#define H_ADD_LOGICAL_LAN_BUFFER 0x11C
@@ -142,7 +141,6 @@ struct ibmveth_adapter {
struct net_device_stats stats;
unsigned int mcastFilterSize;
unsigned long mac_addr;
- unsigned long liobn;
void *buffer_list_addr;
void *filter_list_addr;
dma_addr_t buffer_list_dma;
@@ -218,27 +216,6 @@ struct ibmveth_rx_q_entry {
#define ibmveth_assert(expr)
#endif
-static int ibmveth_open(struct net_device *dev);
-static int ibmveth_close(struct net_device *dev);
-static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
-static int ibmveth_poll(struct net_device *dev, int *budget);
-static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *dev);
-static struct net_device_stats *ibmveth_get_stats(struct net_device *dev);
-static void ibmveth_set_multicast_list(struct net_device *dev);
-static int ibmveth_change_mtu(struct net_device *dev, int new_mtu);
-static void ibmveth_proc_register_driver(void);
-static void ibmveth_proc_unregister_driver(void);
-static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter);
-static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter);
-static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance,
- struct pt_regs *regs);
-static inline void ibmveth_schedule_replenishing(struct ibmveth_adapter*);
-
-#ifdef CONFIG_PROC_FS
-#define IBMVETH_PROC_DIR "ibmveth"
-static struct proc_dir_entry *ibmveth_proc_dir;
-#endif
-
static const char ibmveth_driver_name[] = "ibmveth";
static const char ibmveth_driver_string[] =
"IBM i/pSeries Virtual Ethernet Driver";
@@ -428,7 +405,7 @@ static void ibmveth_replenish_task(struc
ibmveth_replenish_buffer_pool(adapter, &adapter->rx_buff_pool[1]);
ibmveth_replenish_buffer_pool(adapter, &adapter->rx_buff_pool[2]);
- adapter->rx_no_buffer = *(u64*)(((char*)adapter->buffer_list_addr)
+ adapter->rx_no_buffer = *(u64 *)(((char *)adapter->buffer_list_addr)
+ 4096 - 8);
atomic_inc(&adapter->not_replenishing);
@@ -436,7 +413,7 @@ static void ibmveth_replenish_task(struc
ibmveth_schedule_replenishing(adapter);
}
-/* empty and free ana buffer pool - also used to do cleanup in error paths */
+/* empty and free a buffer pool - also used to do cleanup in error paths */
static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter,
struct ibmveth_buff_pool *pool)
{
@@ -604,6 +581,21 @@ static void ibmveth_cleanup(struct ibmve
ibmveth_free_buffer_pool(adapter, &adapter->rx_buff_pool[2]);
}
+static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance,
+ struct pt_regs *regs)
+{
+ struct net_device *netdev = dev_instance;
+ struct ibmveth_adapter *adapter = netdev->priv;
+ unsigned long lpar_rc;
+
+ if (netif_rx_schedule_prep(netdev)) {
+ lpar_rc = vio_disable_interrupts(adapter->vdev);
+ ibmveth_assert(lpar_rc == H_Success);
+ __netif_rx_schedule(netdev);
+ }
+ return IRQ_HANDLED;
+}
+
static int ibmveth_open(struct net_device *netdev)
{
struct ibmveth_adapter *adapter = netdev->priv;
@@ -985,21 +977,6 @@ restart_poll:
return 0;
}
-static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance,
- struct pt_regs *regs)
-{
- struct net_device *netdev = dev_instance;
- struct ibmveth_adapter *adapter = netdev->priv;
- unsigned long lpar_rc;
-
- if (netif_rx_schedule_prep(netdev)) {
- lpar_rc = vio_disable_interrupts(adapter->vdev);
- ibmveth_assert(lpar_rc == H_Success);
- __netif_rx_schedule(netdev);
- }
- return IRQ_HANDLED;
-}
-
static struct net_device_stats *ibmveth_get_stats(struct net_device *dev)
{
struct ibmveth_adapter *adapter = dev->priv;
@@ -1065,6 +1042,121 @@ static int ibmveth_change_mtu(struct net
return 0;
}
+#ifdef CONFIG_PROC_FS
+
+#define IBMVETH_PROC_DIR "ibmveth"
+static struct proc_dir_entry *ibmveth_proc_dir;
+
+static void ibmveth_proc_register_driver(void)
+{
+ ibmveth_proc_dir = create_proc_entry(IBMVETH_PROC_DIR, S_IFDIR,
+ proc_net);
+ if (ibmveth_proc_dir)
+ SET_MODULE_OWNER(ibmveth_proc_dir);
+}
+
+static void ibmveth_proc_unregister_driver(void)
+{
+ remove_proc_entry(IBMVETH_PROC_DIR, proc_net);
+}
+
+static int ibmveth_seq_show(struct seq_file *seq, void *v)
+{
+ struct ibmveth_adapter *adapter = seq->private;
+ char *current_mac = (char *)&adapter->netdev->dev_addr;
+ char *firmware_mac = (char *)&adapter->mac_addr;
+
+ seq_printf(seq, "%s %s\n\n", ibmveth_driver_string,
+ ibmveth_driver_version);
+ seq_printf(seq, "Unit Address: 0x%x\n", adapter->vdev->unit_address);
+ seq_printf(seq, "LIOBN: 0x%lx\n",
+ adapter->vdev->iommu_table->it_index);
+ seq_printf(seq, "Current MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
+ current_mac[0], current_mac[1], current_mac[2],
+ current_mac[3], current_mac[4], current_mac[5]);
+ seq_printf(seq, "Firmware MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
+ firmware_mac[0], firmware_mac[1], firmware_mac[2],
+ firmware_mac[3], firmware_mac[4], firmware_mac[5]);
+ seq_printf(seq, "\nAdapter Statistics:\n");
+ seq_printf(seq, " TX: skbuffs linearized: %ld\n",
+ adapter->tx_linearized);
+ seq_printf(seq, " multi-descriptor sends: %ld\n",
+ adapter->tx_multidesc_send);
+ seq_printf(seq, " skb_linearize failures: %ld\n",
+ adapter->tx_linearize_failed);
+ seq_printf(seq, " vio_map_single failres: %ld\n",
+ adapter->tx_map_failed);
+ seq_printf(seq, " send failures: %ld\n",
+ adapter->tx_send_failed);
+ seq_printf(seq, " RX: replenish task cycles: %ld\n",
+ adapter->replenish_task_cycles);
+ seq_printf(seq, " alloc_skb_failures: %ld\n",
+ adapter->replenish_no_mem);
+ seq_printf(seq, " add buffer failures: %ld\n",
+ adapter->replenish_add_buff_failure);
+ seq_printf(seq, " invalid buffers: %ld\n",
+ adapter->rx_invalid_buffer);
+ seq_printf(seq, " no buffers: %ld\n",
+ adapter->rx_no_buffer);
+ return 0;
+}
+
+static int ibmveth_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, ibmveth_seq_show, PDE(inode)->data);
+}
+
+static struct file_operations ibmveth_proc_fops = {
+ .owner = THIS_MODULE,
+ .open = ibmveth_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter)
+{
+ struct proc_dir_entry *entry;
+
+ if (ibmveth_proc_dir) {
+ entry = create_proc_entry(adapter->netdev->name, S_IFREG,
+ ibmveth_proc_dir);
+ if (!entry)
+ ibmveth_error_printk("Cannot create adapter proc entry");
+ else {
+ entry->data = adapter;
+ entry->proc_fops = &ibmveth_proc_fops;
+ SET_MODULE_OWNER(entry);
+ }
+ }
+}
+
+static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter)
+{
+ if (ibmveth_proc_dir)
+ remove_proc_entry(adapter->netdev->name, ibmveth_proc_dir);
+}
+
+#else /* CONFIG_PROC_FS */
+
+static void ibmveth_proc_register_driver(void)
+{
+}
+
+static void ibmveth_proc_unregister_driver(void)
+{
+}
+
+static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter)
+{
+}
+
+static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter)
+{
+}
+
+#endif /* CONFIG_PROC_FS */
+
static int __devinit ibmveth_probe(struct vio_dev *dev,
const struct vio_device_id *id)
{
@@ -1122,8 +1214,6 @@ static int __devinit ibmveth_probe(struc
adapter->mac_addr = 0;
memcpy(&adapter->mac_addr, mac_addr_p, 6);
- adapter->liobn = dev->iommu_table->it_index;
-
netdev->irq = dev->irq;
netdev->open = ibmveth_open;
netdev->poll = ibmveth_poll;
@@ -1180,148 +1270,6 @@ static int __devexit ibmveth_remove(stru
return 0;
}
-#ifdef CONFIG_PROC_FS
-static void ibmveth_proc_register_driver(void)
-{
- ibmveth_proc_dir = create_proc_entry(IBMVETH_PROC_DIR, S_IFDIR,
- proc_net);
- if (ibmveth_proc_dir)
- SET_MODULE_OWNER(ibmveth_proc_dir);
-}
-
-static void ibmveth_proc_unregister_driver(void)
-{
- remove_proc_entry(IBMVETH_PROC_DIR, proc_net);
-}
-
-static void *ibmveth_seq_start(struct seq_file *seq, loff_t *pos)
-{
- if (*pos == 0)
- return (void *)1;
- else
- return NULL;
-}
-
-static void *ibmveth_seq_next(struct seq_file *seq, void *v, loff_t *pos)
-{
- ++*pos;
- return NULL;
-}
-
-static void ibmveth_seq_stop(struct seq_file *seq, void *v)
-{
-}
-
-static int ibmveth_seq_show(struct seq_file *seq, void *v)
-{
- struct ibmveth_adapter *adapter = seq->private;
- char *current_mac = (char *)&adapter->netdev->dev_addr;
- char *firmware_mac = (char *)&adapter->mac_addr;
-
- seq_printf(seq, "%s %s\n\n", ibmveth_driver_string,
- ibmveth_driver_version);
- seq_printf(seq, "Unit Address: 0x%x\n", adapter->vdev->unit_address);
- seq_printf(seq, "LIOBN: 0x%lx\n", adapter->liobn);
- seq_printf(seq, "Current MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
- current_mac[0], current_mac[1], current_mac[2],
- current_mac[3], current_mac[4], current_mac[5]);
- seq_printf(seq, "Firmware MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
- firmware_mac[0], firmware_mac[1], firmware_mac[2],
- firmware_mac[3], firmware_mac[4], firmware_mac[5]);
- seq_printf(seq, "\nAdapter Statistics:\n");
- seq_printf(seq, " TX: skbuffs linearized: %ld\n",
- adapter->tx_linearized);
- seq_printf(seq, " multi-descriptor sends: %ld\n",
- adapter->tx_multidesc_send);
- seq_printf(seq, " skb_linearize failures: %ld\n",
- adapter->tx_linearize_failed);
- seq_printf(seq, " vio_map_single failres: %ld\n",
- adapter->tx_map_failed);
- seq_printf(seq, " send failures: %ld\n",
- adapter->tx_send_failed);
- seq_printf(seq, " RX: replenish task cycles: %ld\n",
- adapter->replenish_task_cycles);
- seq_printf(seq, " alloc_skb_failures: %ld\n",
- adapter->replenish_no_mem);
- seq_printf(seq, " add buffer failures: %ld\n",
- adapter->replenish_add_buff_failure);
- seq_printf(seq, " invalid buffers: %ld\n",
- adapter->rx_invalid_buffer);
- seq_printf(seq, " no buffers: %ld\n",
- adapter->rx_no_buffer);
- return 0;
-}
-static struct seq_operations ibmveth_seq_ops = {
- .start = ibmveth_seq_start,
- .next = ibmveth_seq_next,
- .stop = ibmveth_seq_stop,
- .show = ibmveth_seq_show,
-};
-
-static int ibmveth_proc_open(struct inode *inode, struct file *file)
-{
- struct seq_file *seq;
- struct proc_dir_entry *proc;
- int rc;
-
- rc = seq_open(file, &ibmveth_seq_ops);
- if (!rc) {
- /* recover the pointer buried in proc_dir_entry data */
- seq = file->private_data;
- proc = PDE(inode);
- seq->private = proc->data;
- }
- return rc;
-}
-
-static struct file_operations ibmveth_proc_fops = {
- .owner = THIS_MODULE,
- .open = ibmveth_proc_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = seq_release,
-};
-
-static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter)
-{
- struct proc_dir_entry *entry;
-
- if (ibmveth_proc_dir) {
- entry = create_proc_entry(adapter->netdev->name, S_IFREG,
- ibmveth_proc_dir);
- if (!entry)
- ibmveth_error_printk("Cannot create adapter proc entry");
- else {
- entry->data = adapter;
- entry->proc_fops = &ibmveth_proc_fops;
- SET_MODULE_OWNER(entry);
- }
- }
-}
-
-static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter)
-{
- if (ibmveth_proc_dir)
- remove_proc_entry(adapter->netdev->name, ibmveth_proc_dir);
-}
-
-#else /* CONFIG_PROC_FS */
-static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter)
-{
-}
-
-static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter)
-{
-}
-static void ibmveth_proc_register_driver(void)
-{
-}
-
-static void ibmveth_proc_unregister_driver(void)
-{
-}
-#endif /* CONFIG_PROC_FS */
-
static struct vio_device_id ibmveth_device_table[] __devinitdata= {
{ "network", "IBM,l-lan"},
{ "", "" }
More information about the Linuxppc64-dev
mailing list