patch-2.4.22 linux-2.4.22/drivers/net/bmac.c
Next file: linux-2.4.22/drivers/net/bonding/Makefile
Previous file: linux-2.4.22/drivers/net/b44.h
Back to the patch index
Back to the overall index
- Lines: 136
- Date:
2003-08-25 04:44:42.000000000 -0700
- Orig file:
linux-2.4.21/drivers/net/bmac.c
- Orig date:
2003-06-13 07:51:34.000000000 -0700
diff -urN linux-2.4.21/drivers/net/bmac.c linux-2.4.22/drivers/net/bmac.c
@@ -18,6 +18,8 @@
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/crc32.h>
+#include <linux/ethtool.h>
+#include <asm/uaccess.h>
#include <asm/prom.h>
#include <asm/dbdma.h>
#include <asm/io.h>
@@ -67,7 +69,6 @@
volatile struct dbdma_cmd *tx_cmds; /* xmit dma command list */
volatile struct dbdma_cmd *rx_cmds; /* recv dma command list */
struct device_node *node;
- int is_bmac_plus;
struct sk_buff *rx_bufs[N_RX_RING];
int rx_fill;
int rx_empty;
@@ -80,6 +81,8 @@
int timeout_active;
int sleeping;
int opened;
+ int is_bmac_plus;
+ u32 device_id;
unsigned short hash_use_count[64];
unsigned short hash_table_mask[4];
struct net_device *next_bmac;
@@ -153,6 +156,7 @@
static int bmac_transmit_packet(struct sk_buff *skb, struct net_device *dev);
static struct net_device_stats *bmac_stats(struct net_device *dev);
static void bmac_set_multicast(struct net_device *dev);
+static int bmac_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
static void bmac_reset_and_enable(struct net_device *dev);
static void bmac_start_chip(struct net_device *dev);
static void bmac_init_chip(struct net_device *dev);
@@ -1053,7 +1057,7 @@
{
struct dev_mc_list *dmi = dev->mc_list;
char *addrs;
- int i, j, bit, byte;
+ int i;
unsigned short rx_cfg;
u32 crc;
@@ -1189,7 +1193,7 @@
read_srom(struct net_device *dev, unsigned int addr, unsigned int addr_len)
{
unsigned short data, val;
- int i;
+ unsigned int i;
/* send out the address we want to read from */
for (i = 0; i < addr_len; i++) {
@@ -1303,6 +1307,7 @@
struct bmac_data *bp;
unsigned char *addr;
struct net_device *dev;
+ u32 *deviceid;
if (bmac->n_addrs != 3 || bmac->n_intrs != 3) {
printk(KERN_ERR "can't use BMAC %s: need 3 addrs and 3 intrs\n",
@@ -1356,6 +1361,10 @@
goto err_out;
dev->irq = bmac->intrs[0].line;
+ deviceid = (u32 *)get_property(bmac, "device-id", NULL);
+ if (deviceid)
+ bp->device_id = *deviceid;
+
bmac_enable_and_reset_chip(dev);
bmwrite(dev, INTDISABLE, DisableAll);
@@ -1378,6 +1387,7 @@
dev->get_stats = bmac_stats;
dev->set_multicast_list = bmac_set_multicast;
dev->set_mac_address = bmac_set_address;
+ dev->do_ioctl = bmac_do_ioctl;
bmac_get_station_address(dev, addr);
if (bmac_verify_checksum(dev) != 0)
@@ -1451,6 +1461,56 @@
kfree(dev);
}
+static int bmac_ethtool_ioctl(struct net_device *dev, void *useraddr)
+{
+ struct bmac_data *bp = (struct bmac_data *) dev->priv;
+ u32 ethcmd;
+
+ if (get_user(ethcmd, (u32 *)useraddr))
+ return -EFAULT;
+
+ switch (ethcmd) {
+ case ETHTOOL_GDRVINFO: {
+ struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
+ strcpy (info.driver, "bmac");
+ info.version[0] = '\0';
+ snprintf(info.fw_version, 31, "chip id %x", bp->device_id);
+ if (copy_to_user (useraddr, &info, sizeof (info)))
+ return -EFAULT;
+ return 0;
+ }
+
+ case ETHTOOL_GSET:
+ case ETHTOOL_SSET:
+ case ETHTOOL_NWAY_RST:
+ case ETHTOOL_GLINK:
+ case ETHTOOL_GMSGLVL:
+ case ETHTOOL_SMSGLVL:
+ default:
+ ;
+ }
+
+ return -EOPNOTSUPP;
+}
+
+static int bmac_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+{
+ switch(cmd) {
+ case SIOCETHTOOL:
+ return bmac_ethtool_ioctl(dev, (void *) ifr->ifr_data);
+
+ case SIOCGMIIPHY:
+ case SIOCDEVPRIVATE:
+ case SIOCGMIIREG:
+ case SIOCDEVPRIVATE+1:
+ case SIOCSMIIREG:
+ case SIOCDEVPRIVATE+2:
+ default:
+ ;
+ }
+ return -EOPNOTSUPP;
+}
+
static int bmac_open(struct net_device *dev)
{
struct bmac_data *bp = (struct bmac_data *) dev->priv;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)