2019-06-04 08:11:33 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2021-08-03 17:25:24 +00:00
|
|
|
* Copyright (c) 1999-2021 Petko Manolov (petkan@nucleusys.com)
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/mii.h>
|
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <asm/byteorder.h>
|
2016-12-24 19:46:01 +00:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "pegasus.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Version Information
|
|
|
|
*/
|
2013-04-25 22:41:50 +00:00
|
|
|
#define DRIVER_AUTHOR "Petko Manolov <petkan@nucleusys.com>"
|
2005-04-16 22:20:36 +00:00
|
|
|
#define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver"
|
|
|
|
|
|
|
|
static const char driver_name[] = "pegasus";
|
|
|
|
|
|
|
|
#undef PEGASUS_WRITE_EEPROM
|
|
|
|
#define BMSR_MEDIA (BMSR_10HALF | BMSR_10FULL | BMSR_100HALF | \
|
|
|
|
BMSR_100FULL | BMSR_ANEGCAPABLE)
|
2020-04-02 14:33:29 +00:00
|
|
|
#define CARRIER_CHECK_DELAY (2 * HZ)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-12-19 14:08:01 +00:00
|
|
|
static bool loopback;
|
|
|
|
static bool mii_mode;
|
2010-06-26 06:58:54 +00:00
|
|
|
static char *devid;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static struct usb_eth_dev usb_dev_id[] = {
|
|
|
|
#define PEGASUS_DEV(pn, vid, pid, flags) \
|
|
|
|
{.name = pn, .vendor = vid, .device = pid, .private = flags},
|
2009-10-13 07:32:02 +00:00
|
|
|
#define PEGASUS_DEV_CLASS(pn, vid, pid, dclass, flags) \
|
|
|
|
PEGASUS_DEV(pn, vid, pid, flags)
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "pegasus.h"
|
|
|
|
#undef PEGASUS_DEV
|
2009-10-13 07:32:02 +00:00
|
|
|
#undef PEGASUS_DEV_CLASS
|
2005-11-15 07:55:18 +00:00
|
|
|
{NULL, 0, 0, 0},
|
2005-04-16 22:20:36 +00:00
|
|
|
{NULL, 0, 0, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct usb_device_id pegasus_ids[] = {
|
|
|
|
#define PEGASUS_DEV(pn, vid, pid, flags) \
|
|
|
|
{.match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = vid, .idProduct = pid},
|
2009-10-13 07:32:02 +00:00
|
|
|
/*
|
|
|
|
* The Belkin F8T012xx1 bluetooth adaptor has the same vendor and product
|
|
|
|
* IDs as the Belkin F5D5050, so we need to teach the pegasus driver to
|
|
|
|
* ignore adaptors belonging to the "Wireless" class 0xE0. For this one
|
|
|
|
* case anyway, seeing as the pegasus is for "Wired" adaptors.
|
|
|
|
*/
|
|
|
|
#define PEGASUS_DEV_CLASS(pn, vid, pid, dclass, flags) \
|
|
|
|
{.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_CLASS), \
|
|
|
|
.idVendor = vid, .idProduct = pid, .bDeviceClass = dclass},
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "pegasus.h"
|
|
|
|
#undef PEGASUS_DEV
|
2009-10-13 07:32:02 +00:00
|
|
|
#undef PEGASUS_DEV_CLASS
|
2005-11-15 07:55:18 +00:00
|
|
|
{},
|
2005-04-16 22:20:36 +00:00
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
module_param(loopback, bool, 0);
|
|
|
|
module_param(mii_mode, bool, 0);
|
2005-11-15 07:55:18 +00:00
|
|
|
module_param(devid, charp, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
MODULE_PARM_DESC(loopback, "Enable MAC loopback mode (bit 0)");
|
|
|
|
MODULE_PARM_DESC(mii_mode, "Enable HomePNA mode (bit 0),default=MII mode = 0");
|
2005-11-15 07:55:18 +00:00
|
|
|
MODULE_PARM_DESC(devid, "The format is: 'DEV_name:VendorID:DeviceID:Flags'");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* use ethtool to change the level for any given device */
|
|
|
|
static int msg_level = -1;
|
2010-06-26 06:58:54 +00:00
|
|
|
module_param(msg_level, int, 0);
|
|
|
|
MODULE_PARM_DESC(msg_level, "Override default message level");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(usb, pegasus_ids);
|
2009-01-08 19:22:25 +00:00
|
|
|
static const struct net_device_ops pegasus_netdev_ops;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-04-25 22:41:50 +00:00
|
|
|
/*****/
|
|
|
|
|
|
|
|
static void async_ctrl_callback(struct urb *urb)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-04-25 22:41:50 +00:00
|
|
|
struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
|
2008-12-19 07:00:59 +00:00
|
|
|
int status = urb->status;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-04-25 22:41:50 +00:00
|
|
|
if (status < 0)
|
|
|
|
dev_dbg(&urb->dev->dev, "%s failed with %d", __func__, status);
|
|
|
|
kfree(req);
|
|
|
|
usb_free_urb(urb);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2013-04-25 22:41:50 +00:00
|
|
|
static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2020-09-27 12:49:08 +00:00
|
|
|
return usb_control_msg_recv(pegasus->usb, 0, PEGASUS_REQ_GET_REGS,
|
|
|
|
PEGASUS_REQT_READ, 0, indx, data, size,
|
|
|
|
1000, GFP_NOIO);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2017-02-04 16:56:03 +00:00
|
|
|
static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size,
|
|
|
|
const void *data)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2021-08-03 17:25:23 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = usb_control_msg_send(pegasus->usb, 0, PEGASUS_REQ_SET_REGS,
|
2020-09-27 12:49:08 +00:00
|
|
|
PEGASUS_REQT_WRITE, 0, indx, data, size,
|
|
|
|
1000, GFP_NOIO);
|
2021-08-03 17:25:23 +00:00
|
|
|
if (ret < 0)
|
|
|
|
netif_dbg(pegasus, drv, pegasus->net, "%s failed with %d\n", __func__, ret);
|
|
|
|
|
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2020-09-27 12:49:08 +00:00
|
|
|
/*
|
|
|
|
* There is only one way to write to a single ADM8511 register and this is via
|
|
|
|
* specific control request. 'data' is ignored by the device, but it is here to
|
|
|
|
* not break the API.
|
|
|
|
*/
|
2010-06-26 06:58:54 +00:00
|
|
|
static int set_register(pegasus_t *pegasus, __u16 indx, __u8 data)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2020-09-27 12:49:08 +00:00
|
|
|
void *buf = &data;
|
2021-08-03 17:25:23 +00:00
|
|
|
int ret;
|
2020-09-27 12:49:08 +00:00
|
|
|
|
2021-08-03 17:25:23 +00:00
|
|
|
ret = usb_control_msg_send(pegasus->usb, 0, PEGASUS_REQ_SET_REG,
|
2020-09-27 12:49:08 +00:00
|
|
|
PEGASUS_REQT_WRITE, data, indx, buf, 1,
|
|
|
|
1000, GFP_NOIO);
|
2021-08-03 17:25:23 +00:00
|
|
|
if (ret < 0)
|
|
|
|
netif_dbg(pegasus, drv, pegasus->net, "%s failed with %d\n", __func__, ret);
|
|
|
|
|
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static int update_eth_regs_async(pegasus_t *pegasus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-04-25 22:41:50 +00:00
|
|
|
int ret = -ENOMEM;
|
|
|
|
struct urb *async_urb;
|
|
|
|
struct usb_ctrlrequest *req;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-04-25 22:41:50 +00:00
|
|
|
req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
|
|
|
|
if (req == NULL)
|
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-04-25 22:41:50 +00:00
|
|
|
async_urb = usb_alloc_urb(0, GFP_ATOMIC);
|
|
|
|
if (async_urb == NULL) {
|
|
|
|
kfree(req);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
req->bRequestType = PEGASUS_REQT_WRITE;
|
|
|
|
req->bRequest = PEGASUS_REQ_SET_REGS;
|
|
|
|
req->wValue = cpu_to_le16(0);
|
|
|
|
req->wIndex = cpu_to_le16(EthCtrl0);
|
|
|
|
req->wLength = cpu_to_le16(3);
|
|
|
|
|
|
|
|
usb_fill_control_urb(async_urb, pegasus->usb,
|
|
|
|
usb_sndctrlpipe(pegasus->usb, 0), (void *)req,
|
|
|
|
pegasus->eth_regs, 3, async_ctrl_callback, req);
|
|
|
|
|
|
|
|
ret = usb_submit_urb(async_urb, GFP_ATOMIC);
|
|
|
|
if (ret) {
|
2006-05-26 17:17:03 +00:00
|
|
|
if (ret == -ENODEV)
|
|
|
|
netif_device_detach(pegasus->net);
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_err(pegasus, drv, pegasus->net,
|
2013-04-25 22:41:50 +00:00
|
|
|
"%s returned %d\n", __func__, ret);
|
2006-05-26 17:17:03 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-04-25 22:41:36 +00:00
|
|
|
static int __mii_op(pegasus_t *p, __u8 phy, __u8 indx, __u16 *regd, __u8 cmd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2021-08-03 17:25:23 +00:00
|
|
|
int i, ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
__le16 regdi;
|
2021-08-03 17:25:23 +00:00
|
|
|
__u8 data[4] = { phy, 0, 0, indx };
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-04-25 22:41:36 +00:00
|
|
|
if (cmd & PHY_WRITE) {
|
|
|
|
__le16 *t = (__le16 *) & data[1];
|
|
|
|
*t = cpu_to_le16(*regd);
|
|
|
|
}
|
|
|
|
set_register(p, PhyCtrl, 0);
|
|
|
|
set_registers(p, PhyAddr, sizeof(data), data);
|
|
|
|
set_register(p, PhyCtrl, (indx | cmd));
|
2005-04-16 22:20:36 +00:00
|
|
|
for (i = 0; i < REG_TIMEOUT; i++) {
|
2013-04-25 22:41:36 +00:00
|
|
|
ret = get_registers(p, PhyCtrl, 1, data);
|
|
|
|
if (ret < 0)
|
2006-05-01 21:02:45 +00:00
|
|
|
goto fail;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (data[0] & PHY_DONE)
|
|
|
|
break;
|
|
|
|
}
|
2021-08-03 17:25:23 +00:00
|
|
|
if (i >= REG_TIMEOUT) {
|
|
|
|
ret = -ETIMEDOUT;
|
2010-02-17 10:30:24 +00:00
|
|
|
goto fail;
|
2021-08-03 17:25:23 +00:00
|
|
|
}
|
2013-04-25 22:41:36 +00:00
|
|
|
if (cmd & PHY_READ) {
|
|
|
|
ret = get_registers(p, PhyData, 2, ®di);
|
2021-08-03 17:25:23 +00:00
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2013-04-25 22:41:36 +00:00
|
|
|
*regd = le16_to_cpu(regdi);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
fail:
|
|
|
|
netif_dbg(p, drv, p->net, "%s failed\n", __func__);
|
2010-02-17 10:30:24 +00:00
|
|
|
return ret;
|
2013-04-25 22:41:36 +00:00
|
|
|
}
|
2010-02-17 10:30:24 +00:00
|
|
|
|
2013-04-25 22:41:36 +00:00
|
|
|
/* Returns non-negative int on success, error on failure */
|
|
|
|
static int read_mii_word(pegasus_t *pegasus, __u8 phy, __u8 indx, __u16 *regd)
|
|
|
|
{
|
|
|
|
return __mii_op(pegasus, phy, indx, regd, PHY_READ);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-04-25 22:41:36 +00:00
|
|
|
/* Returns zero on success, error on failure */
|
|
|
|
static int write_mii_word(pegasus_t *pegasus, __u8 phy, __u8 indx, __u16 *regd)
|
|
|
|
{
|
|
|
|
return __mii_op(pegasus, phy, indx, regd, PHY_WRITE);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mdio_read(struct net_device *dev, int phy_id, int loc)
|
|
|
|
{
|
2010-11-15 11:12:29 +00:00
|
|
|
pegasus_t *pegasus = netdev_priv(dev);
|
2021-08-03 17:25:23 +00:00
|
|
|
int ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
u16 res;
|
|
|
|
|
2021-08-03 17:25:23 +00:00
|
|
|
ret = read_mii_word(pegasus, phy_id, loc, &res);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return (int)res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void mdio_write(struct net_device *dev, int phy_id, int loc, int val)
|
|
|
|
{
|
2010-11-15 11:12:29 +00:00
|
|
|
pegasus_t *pegasus = netdev_priv(dev);
|
2013-05-02 20:44:20 +00:00
|
|
|
u16 data = val;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-05-02 20:44:20 +00:00
|
|
|
write_mii_word(pegasus, phy_id, loc, &data);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static int read_eprom_word(pegasus_t *pegasus, __u8 index, __u16 *retdata)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2021-08-03 17:25:23 +00:00
|
|
|
int ret, i;
|
2005-04-16 22:20:36 +00:00
|
|
|
__le16 retdatai;
|
2021-08-03 17:25:23 +00:00
|
|
|
__u8 tmp = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, EpromCtrl, 0);
|
|
|
|
set_register(pegasus, EpromOffset, index);
|
|
|
|
set_register(pegasus, EpromCtrl, EPROM_READ);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
for (i = 0; i < REG_TIMEOUT; i++) {
|
|
|
|
ret = get_registers(pegasus, EpromCtrl, 1, &tmp);
|
2021-08-03 17:25:23 +00:00
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (tmp & EPROM_DONE)
|
|
|
|
break;
|
|
|
|
}
|
2021-08-03 17:25:23 +00:00
|
|
|
if (i >= REG_TIMEOUT) {
|
|
|
|
ret = -ETIMEDOUT;
|
2010-02-17 10:30:24 +00:00
|
|
|
goto fail;
|
2021-08-03 17:25:23 +00:00
|
|
|
}
|
2010-02-17 10:30:24 +00:00
|
|
|
|
|
|
|
ret = get_registers(pegasus, EpromData, 2, &retdatai);
|
2021-08-03 17:25:23 +00:00
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2010-02-17 10:30:24 +00:00
|
|
|
*retdata = le16_to_cpu(retdatai);
|
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-05-01 21:02:45 +00:00
|
|
|
fail:
|
2021-08-03 17:25:23 +00:00
|
|
|
netif_dbg(pegasus, drv, pegasus->net, "%s failed\n", __func__);
|
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PEGASUS_WRITE_EEPROM
|
2010-06-26 06:58:54 +00:00
|
|
|
static inline void enable_eprom_write(pegasus_t *pegasus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
__u8 tmp;
|
|
|
|
|
2005-11-15 07:48:23 +00:00
|
|
|
get_registers(pegasus, EthCtrl2, 1, &tmp);
|
|
|
|
set_register(pegasus, EthCtrl2, tmp | EPROM_WR_ENABLE);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static inline void disable_eprom_write(pegasus_t *pegasus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
__u8 tmp;
|
|
|
|
|
2005-11-15 07:48:23 +00:00
|
|
|
get_registers(pegasus, EthCtrl2, 1, &tmp);
|
|
|
|
set_register(pegasus, EpromCtrl, 0);
|
|
|
|
set_register(pegasus, EthCtrl2, tmp & ~EPROM_WR_ENABLE);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static int write_eprom_word(pegasus_t *pegasus, __u8 index, __u16 data)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
__u8 tmp, d[4] = { 0x3f, 0, 0, EPROM_WRITE };
|
|
|
|
int ret;
|
2009-06-18 07:03:47 +00:00
|
|
|
__le16 le_data = cpu_to_le16(data);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-15 07:48:23 +00:00
|
|
|
set_registers(pegasus, EpromOffset, 4, d);
|
2005-04-16 22:20:36 +00:00
|
|
|
enable_eprom_write(pegasus);
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, EpromOffset, index);
|
2009-06-18 07:03:47 +00:00
|
|
|
set_registers(pegasus, EpromData, 2, &le_data);
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, EpromCtrl, EPROM_WRITE);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
for (i = 0; i < REG_TIMEOUT; i++) {
|
|
|
|
ret = get_registers(pegasus, EpromCtrl, 1, &tmp);
|
2006-05-01 21:02:45 +00:00
|
|
|
if (ret == -ESHUTDOWN)
|
|
|
|
goto fail;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (tmp & EPROM_DONE)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
disable_eprom_write(pegasus);
|
2010-02-17 10:30:24 +00:00
|
|
|
if (i >= REG_TIMEOUT)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
2006-05-01 21:02:45 +00:00
|
|
|
fail:
|
2021-08-03 17:25:23 +00:00
|
|
|
netif_dbg(pegasus, drv, pegasus->net, "%s failed\n", __func__);
|
2005-11-15 07:48:23 +00:00
|
|
|
return -ETIMEDOUT;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2021-08-03 17:25:23 +00:00
|
|
|
#endif /* PEGASUS_WRITE_EEPROM */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-02 07:56:04 +00:00
|
|
|
static inline int get_node_id(pegasus_t *pegasus, u8 *id)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2020-10-02 07:56:04 +00:00
|
|
|
int i, ret;
|
|
|
|
u16 w16;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
2020-10-02 07:56:04 +00:00
|
|
|
ret = read_eprom_word(pegasus, i, &w16);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-10-29 21:25:51 +00:00
|
|
|
((__le16 *) id)[i] = cpu_to_le16(w16);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2020-10-02 07:56:04 +00:00
|
|
|
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static void set_ethernet_addr(pegasus_t *pegasus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2020-10-02 07:56:04 +00:00
|
|
|
int ret;
|
|
|
|
u8 node_id[6];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-09-27 21:25:37 +00:00
|
|
|
if (pegasus->features & PEGASUS_II) {
|
2020-10-02 07:56:04 +00:00
|
|
|
ret = get_registers(pegasus, 0x10, sizeof(node_id), node_id);
|
|
|
|
if (ret < 0)
|
|
|
|
goto err;
|
2006-09-27 21:25:37 +00:00
|
|
|
} else {
|
2020-10-02 07:56:04 +00:00
|
|
|
ret = get_node_id(pegasus, node_id);
|
|
|
|
if (ret < 0)
|
|
|
|
goto err;
|
|
|
|
ret = set_registers(pegasus, EthID, sizeof(node_id), node_id);
|
|
|
|
if (ret < 0)
|
|
|
|
goto err;
|
2006-09-27 21:25:37 +00:00
|
|
|
}
|
2020-10-02 07:56:04 +00:00
|
|
|
|
2021-10-13 20:44:32 +00:00
|
|
|
eth_hw_addr_set(pegasus->net, node_id);
|
2020-10-02 07:56:04 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
err:
|
|
|
|
eth_hw_addr_random(pegasus->net);
|
2021-08-03 17:25:23 +00:00
|
|
|
netif_dbg(pegasus, drv, pegasus->net, "software assigned MAC address.\n");
|
2020-10-02 07:56:04 +00:00
|
|
|
|
|
|
|
return;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static inline int reset_mac(pegasus_t *pegasus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2021-08-03 17:25:23 +00:00
|
|
|
int ret, i;
|
2005-04-16 22:20:36 +00:00
|
|
|
__u8 data = 0x8;
|
|
|
|
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, EthCtrl1, data);
|
2005-04-16 22:20:36 +00:00
|
|
|
for (i = 0; i < REG_TIMEOUT; i++) {
|
2021-08-03 17:25:23 +00:00
|
|
|
ret = get_registers(pegasus, EthCtrl1, 1, &data);
|
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (~data & 0x08) {
|
2011-12-23 00:44:36 +00:00
|
|
|
if (loopback)
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
if (mii_mode && (pegasus->features & HAS_HOME_PNA))
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, Gpio1, 0x34);
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, Gpio1, 0x26);
|
|
|
|
set_register(pegasus, Gpio0, pegasus->features);
|
|
|
|
set_register(pegasus, Gpio0, DEFAULT_GPIO_SET);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == REG_TIMEOUT)
|
2005-11-15 07:48:23 +00:00
|
|
|
return -ETIMEDOUT;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS ||
|
|
|
|
usb_dev_id[pegasus->dev_index].vendor == VENDOR_DLINK) {
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, Gpio0, 0x24);
|
|
|
|
set_register(pegasus, Gpio0, 0x26);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_ELCON) {
|
|
|
|
__u16 auxmode;
|
2021-08-03 17:25:23 +00:00
|
|
|
ret = read_mii_word(pegasus, 3, 0x1b, &auxmode);
|
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2013-04-25 22:41:36 +00:00
|
|
|
auxmode |= 4;
|
|
|
|
write_mii_word(pegasus, 3, 0x1b, &auxmode);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2021-08-03 17:25:23 +00:00
|
|
|
fail:
|
|
|
|
netif_dbg(pegasus, drv, pegasus->net, "%s failed\n", __func__);
|
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int enable_net_traffic(struct net_device *dev, struct usb_device *usb)
|
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(dev);
|
|
|
|
int ret;
|
2021-08-03 17:25:23 +00:00
|
|
|
__u16 linkpart;
|
|
|
|
__u8 data[4];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2021-08-03 17:25:23 +00:00
|
|
|
ret = read_mii_word(pegasus, pegasus->phy, MII_LPA, &linkpart);
|
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2016-04-27 11:24:50 +00:00
|
|
|
data[0] = 0xc8; /* TX & RX enable, append status, no CRC */
|
2005-04-16 22:20:36 +00:00
|
|
|
data[1] = 0;
|
|
|
|
if (linkpart & (ADVERTISE_100FULL | ADVERTISE_10FULL))
|
|
|
|
data[1] |= 0x20; /* set full duplex */
|
|
|
|
if (linkpart & (ADVERTISE_100FULL | ADVERTISE_100HALF))
|
|
|
|
data[1] |= 0x10; /* set 100 Mbps */
|
|
|
|
if (mii_mode)
|
|
|
|
data[1] = 0;
|
2011-12-23 00:44:36 +00:00
|
|
|
data[2] = loopback ? 0x09 : 0x01;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
memcpy(pegasus->eth_regs, data, sizeof(data));
|
2005-04-16 22:20:36 +00:00
|
|
|
ret = set_registers(pegasus, EthCtrl0, 3, data);
|
|
|
|
|
|
|
|
if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS ||
|
2006-01-28 16:48:33 +00:00
|
|
|
usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS2 ||
|
2005-04-16 22:20:36 +00:00
|
|
|
usb_dev_id[pegasus->dev_index].vendor == VENDOR_DLINK) {
|
|
|
|
u16 auxmode;
|
2021-08-03 17:25:23 +00:00
|
|
|
ret = read_mii_word(pegasus, 0, 0x1b, &auxmode);
|
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2013-04-25 22:41:36 +00:00
|
|
|
auxmode |= 4;
|
|
|
|
write_mii_word(pegasus, 0, 0x1b, &auxmode);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2021-08-20 06:57:53 +00:00
|
|
|
return ret;
|
2021-08-03 17:25:23 +00:00
|
|
|
fail:
|
|
|
|
netif_dbg(pegasus, drv, pegasus->net, "%s failed\n", __func__);
|
2005-11-15 07:48:23 +00:00
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static void read_bulk_callback(struct urb *urb)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
pegasus_t *pegasus = urb->context;
|
|
|
|
struct net_device *net;
|
2021-08-03 17:25:23 +00:00
|
|
|
u8 *buf = urb->transfer_buffer;
|
2005-04-16 22:20:36 +00:00
|
|
|
int rx_status, count = urb->actual_length;
|
2008-12-19 07:00:59 +00:00
|
|
|
int status = urb->status;
|
2005-04-16 22:20:36 +00:00
|
|
|
__u16 pkt_len;
|
|
|
|
|
|
|
|
if (!pegasus)
|
|
|
|
return;
|
|
|
|
|
|
|
|
net = pegasus->net;
|
|
|
|
if (!netif_device_present(net) || !netif_running(net))
|
|
|
|
return;
|
|
|
|
|
2008-12-19 07:00:59 +00:00
|
|
|
switch (status) {
|
2005-04-16 22:20:36 +00:00
|
|
|
case 0:
|
|
|
|
break;
|
2006-09-19 05:49:02 +00:00
|
|
|
case -ETIME:
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_dbg(pegasus, rx_err, net, "reset MAC\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
pegasus->flags &= ~PEGASUS_RX_BUSY;
|
|
|
|
break;
|
|
|
|
case -EPIPE: /* stall, or disconnect from TT */
|
|
|
|
/* FIXME schedule work to clear the halt */
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_warn(pegasus, rx_err, net, "no rx stall recovery\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
case -ENOENT:
|
|
|
|
case -ECONNRESET:
|
|
|
|
case -ESHUTDOWN:
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_dbg(pegasus, ifdown, net, "rx unlink, %d\n", status);
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
default:
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_dbg(pegasus, rx_err, net, "RX status %d\n", status);
|
2005-04-16 22:20:36 +00:00
|
|
|
goto goon;
|
|
|
|
}
|
|
|
|
|
2016-05-18 18:40:51 +00:00
|
|
|
if (count < 4)
|
2005-04-16 22:20:36 +00:00
|
|
|
goto goon;
|
|
|
|
|
|
|
|
rx_status = buf[count - 2];
|
2021-12-26 22:12:08 +00:00
|
|
|
if (rx_status & 0x1c) {
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_dbg(pegasus, rx_err, net,
|
|
|
|
"RX packet error %x\n", rx_status);
|
2017-04-07 08:17:39 +00:00
|
|
|
net->stats.rx_errors++;
|
2021-12-26 22:12:08 +00:00
|
|
|
if (rx_status & 0x04) /* runt */
|
2017-04-07 08:17:39 +00:00
|
|
|
net->stats.rx_length_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (rx_status & 0x08)
|
2017-04-07 08:17:39 +00:00
|
|
|
net->stats.rx_crc_errors++;
|
2010-06-26 06:58:54 +00:00
|
|
|
if (rx_status & 0x10) /* extra bits */
|
2017-04-07 08:17:39 +00:00
|
|
|
net->stats.rx_frame_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
goto goon;
|
|
|
|
}
|
|
|
|
if (pegasus->chip == 0x8513) {
|
|
|
|
pkt_len = le32_to_cpu(*(__le32 *)urb->transfer_buffer);
|
|
|
|
pkt_len &= 0x0fff;
|
|
|
|
pegasus->rx_skb->data += 2;
|
|
|
|
} else {
|
|
|
|
pkt_len = buf[count - 3] << 8;
|
|
|
|
pkt_len += buf[count - 4];
|
|
|
|
pkt_len &= 0xfff;
|
2016-04-27 11:24:50 +00:00
|
|
|
pkt_len -= 4;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-09-22 07:49:24 +00:00
|
|
|
/*
|
|
|
|
* If the packet is unreasonably long, quietly drop it rather than
|
|
|
|
* kernel panicing by calling skb_put.
|
|
|
|
*/
|
|
|
|
if (pkt_len > PEGASUS_MTU)
|
|
|
|
goto goon;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* at this point we are sure pegasus->rx_skb != NULL
|
|
|
|
* so we go ahead and pass up the packet.
|
|
|
|
*/
|
|
|
|
skb_put(pegasus->rx_skb, pkt_len);
|
|
|
|
pegasus->rx_skb->protocol = eth_type_trans(pegasus->rx_skb, net);
|
|
|
|
netif_rx(pegasus->rx_skb);
|
2017-04-07 08:17:39 +00:00
|
|
|
net->stats.rx_packets++;
|
|
|
|
net->stats.rx_bytes += pkt_len;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (pegasus->flags & PEGASUS_UNPLUG)
|
|
|
|
return;
|
|
|
|
|
2013-04-25 22:41:21 +00:00
|
|
|
pegasus->rx_skb = __netdev_alloc_skb_ip_align(pegasus->net, PEGASUS_MTU,
|
|
|
|
GFP_ATOMIC);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (pegasus->rx_skb == NULL)
|
|
|
|
goto tl_sched;
|
|
|
|
goon:
|
|
|
|
usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb,
|
|
|
|
usb_rcvbulkpipe(pegasus->usb, 1),
|
2016-04-27 11:24:49 +00:00
|
|
|
pegasus->rx_skb->data, PEGASUS_MTU,
|
2005-04-16 22:20:36 +00:00
|
|
|
read_bulk_callback, pegasus);
|
2006-05-26 17:17:03 +00:00
|
|
|
rx_status = usb_submit_urb(pegasus->rx_urb, GFP_ATOMIC);
|
|
|
|
if (rx_status == -ENODEV)
|
|
|
|
netif_device_detach(pegasus->net);
|
|
|
|
else if (rx_status) {
|
2005-04-16 22:20:36 +00:00
|
|
|
pegasus->flags |= PEGASUS_RX_URB_FAIL;
|
|
|
|
goto tl_sched;
|
|
|
|
} else {
|
|
|
|
pegasus->flags &= ~PEGASUS_RX_URB_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
tl_sched:
|
|
|
|
tasklet_schedule(&pegasus->rx_tl);
|
|
|
|
}
|
|
|
|
|
2021-01-30 23:47:28 +00:00
|
|
|
static void rx_fixup(struct tasklet_struct *t)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2021-01-30 23:47:28 +00:00
|
|
|
pegasus_t *pegasus = from_tasklet(pegasus, t, rx_tl);
|
2006-05-26 17:17:03 +00:00
|
|
|
int status;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (pegasus->flags & PEGASUS_UNPLUG)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (pegasus->flags & PEGASUS_RX_URB_FAIL)
|
|
|
|
if (pegasus->rx_skb)
|
|
|
|
goto try_again;
|
2010-06-26 06:58:54 +00:00
|
|
|
if (pegasus->rx_skb == NULL)
|
2013-04-25 22:41:21 +00:00
|
|
|
pegasus->rx_skb = __netdev_alloc_skb_ip_align(pegasus->net,
|
|
|
|
PEGASUS_MTU,
|
|
|
|
GFP_ATOMIC);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (pegasus->rx_skb == NULL) {
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_warn(pegasus, rx_err, pegasus->net, "low on memory\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
tasklet_schedule(&pegasus->rx_tl);
|
2013-04-25 22:41:21 +00:00
|
|
|
return;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb,
|
|
|
|
usb_rcvbulkpipe(pegasus->usb, 1),
|
2016-04-27 11:24:49 +00:00
|
|
|
pegasus->rx_skb->data, PEGASUS_MTU,
|
2005-04-16 22:20:36 +00:00
|
|
|
read_bulk_callback, pegasus);
|
|
|
|
try_again:
|
2006-05-26 17:17:03 +00:00
|
|
|
status = usb_submit_urb(pegasus->rx_urb, GFP_ATOMIC);
|
|
|
|
if (status == -ENODEV)
|
|
|
|
netif_device_detach(pegasus->net);
|
|
|
|
else if (status) {
|
2005-04-16 22:20:36 +00:00
|
|
|
pegasus->flags |= PEGASUS_RX_URB_FAIL;
|
|
|
|
tasklet_schedule(&pegasus->rx_tl);
|
|
|
|
} else {
|
|
|
|
pegasus->flags &= ~PEGASUS_RX_URB_FAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static void write_bulk_callback(struct urb *urb)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
pegasus_t *pegasus = urb->context;
|
2007-07-23 08:05:52 +00:00
|
|
|
struct net_device *net;
|
2008-12-19 07:00:59 +00:00
|
|
|
int status = urb->status;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (!pegasus)
|
|
|
|
return;
|
|
|
|
|
2007-07-23 08:05:52 +00:00
|
|
|
net = pegasus->net;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!netif_device_present(net) || !netif_running(net))
|
|
|
|
return;
|
|
|
|
|
2008-12-19 07:00:59 +00:00
|
|
|
switch (status) {
|
2005-04-16 22:20:36 +00:00
|
|
|
case -EPIPE:
|
|
|
|
/* FIXME schedule_work() to clear the tx halt */
|
|
|
|
netif_stop_queue(net);
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_warn(pegasus, tx_err, net, "no tx stall recovery\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
case -ENOENT:
|
|
|
|
case -ECONNRESET:
|
|
|
|
case -ESHUTDOWN:
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_dbg(pegasus, ifdown, net, "tx unlink, %d\n", status);
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
default:
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_info(pegasus, tx_err, net, "TX status %d\n", status);
|
2020-08-23 22:36:59 +00:00
|
|
|
fallthrough;
|
2005-04-16 22:20:36 +00:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-05-03 14:33:13 +00:00
|
|
|
netif_trans_update(net); /* prevent tx timeout */
|
2005-04-16 22:20:36 +00:00
|
|
|
netif_wake_queue(net);
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static void intr_callback(struct urb *urb)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
pegasus_t *pegasus = urb->context;
|
|
|
|
struct net_device *net;
|
2008-12-19 07:00:59 +00:00
|
|
|
int res, status = urb->status;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (!pegasus)
|
|
|
|
return;
|
|
|
|
net = pegasus->net;
|
|
|
|
|
2008-12-19 07:00:59 +00:00
|
|
|
switch (status) {
|
2005-04-16 22:20:36 +00:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case -ECONNRESET: /* unlink */
|
|
|
|
case -ENOENT:
|
|
|
|
case -ESHUTDOWN:
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
/* some Pegasus-I products report LOTS of data
|
|
|
|
* toggle errors... avoid log spamming
|
|
|
|
*/
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_dbg(pegasus, timer, net, "intr status %d\n", status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (urb->actual_length >= 6) {
|
2010-06-26 06:58:54 +00:00
|
|
|
u8 *d = urb->transfer_buffer;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* byte 0 == tx_status1, reg 2B */
|
|
|
|
if (d[0] & (TX_UNDERRUN|EXCESSIVE_COL
|
|
|
|
|LATE_COL|JABBER_TIMEOUT)) {
|
2017-04-07 08:17:39 +00:00
|
|
|
net->stats.tx_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (d[0] & TX_UNDERRUN)
|
2017-04-07 08:17:39 +00:00
|
|
|
net->stats.tx_fifo_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (d[0] & (EXCESSIVE_COL | JABBER_TIMEOUT))
|
2017-04-07 08:17:39 +00:00
|
|
|
net->stats.tx_aborted_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (d[0] & LATE_COL)
|
2017-04-07 08:17:39 +00:00
|
|
|
net->stats.tx_window_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* d[5].LINK_STATUS lies on some adapters.
|
|
|
|
* d[0].NO_CARRIER kicks in only with failed TX.
|
|
|
|
* ... so monitoring with MII may be safest.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* bytes 3-4 == rx_lostpkt, reg 2E/2F */
|
2017-04-07 08:17:39 +00:00
|
|
|
net->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4];
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-12-19 07:00:59 +00:00
|
|
|
res = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (res == -ENODEV)
|
2006-05-26 17:17:03 +00:00
|
|
|
netif_device_detach(pegasus->net);
|
2010-02-17 10:30:24 +00:00
|
|
|
if (res)
|
|
|
|
netif_err(pegasus, timer, net,
|
|
|
|
"can't resubmit interrupt urb, %d\n", res);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
netdev: pass the stuck queue to the timeout handler
This allows incrementing the correct timeout statistic without any mess.
Down the road, devices can learn to reset just the specific queue.
The patch was generated with the following script:
use strict;
use warnings;
our $^I = '.bak';
my @work = (
["arch/m68k/emu/nfeth.c", "nfeth_tx_timeout"],
["arch/um/drivers/net_kern.c", "uml_net_tx_timeout"],
["arch/um/drivers/vector_kern.c", "vector_net_tx_timeout"],
["arch/xtensa/platforms/iss/network.c", "iss_net_tx_timeout"],
["drivers/char/pcmcia/synclink_cs.c", "hdlcdev_tx_timeout"],
["drivers/infiniband/ulp/ipoib/ipoib_main.c", "ipoib_timeout"],
["drivers/infiniband/ulp/ipoib/ipoib_main.c", "ipoib_timeout"],
["drivers/message/fusion/mptlan.c", "mpt_lan_tx_timeout"],
["drivers/misc/sgi-xp/xpnet.c", "xpnet_dev_tx_timeout"],
["drivers/net/appletalk/cops.c", "cops_timeout"],
["drivers/net/arcnet/arcdevice.h", "arcnet_timeout"],
["drivers/net/arcnet/arcnet.c", "arcnet_timeout"],
["drivers/net/arcnet/com20020.c", "arcnet_timeout"],
["drivers/net/ethernet/3com/3c509.c", "el3_tx_timeout"],
["drivers/net/ethernet/3com/3c515.c", "corkscrew_timeout"],
["drivers/net/ethernet/3com/3c574_cs.c", "el3_tx_timeout"],
["drivers/net/ethernet/3com/3c589_cs.c", "el3_tx_timeout"],
["drivers/net/ethernet/3com/3c59x.c", "vortex_tx_timeout"],
["drivers/net/ethernet/3com/3c59x.c", "vortex_tx_timeout"],
["drivers/net/ethernet/3com/typhoon.c", "typhoon_tx_timeout"],
["drivers/net/ethernet/8390/8390.h", "ei_tx_timeout"],
["drivers/net/ethernet/8390/8390.h", "eip_tx_timeout"],
["drivers/net/ethernet/8390/8390.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/8390p.c", "eip_tx_timeout"],
["drivers/net/ethernet/8390/ax88796.c", "ax_ei_tx_timeout"],
["drivers/net/ethernet/8390/axnet_cs.c", "axnet_tx_timeout"],
["drivers/net/ethernet/8390/etherh.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/hydra.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/mac8390.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/mcf8390.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/lib8390.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/ne2k-pci.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/pcnet_cs.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/smc-ultra.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/wd.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/zorro8390.c", "__ei_tx_timeout"],
["drivers/net/ethernet/adaptec/starfire.c", "tx_timeout"],
["drivers/net/ethernet/agere/et131x.c", "et131x_tx_timeout"],
["drivers/net/ethernet/allwinner/sun4i-emac.c", "emac_timeout"],
["drivers/net/ethernet/alteon/acenic.c", "ace_watchdog"],
["drivers/net/ethernet/amazon/ena/ena_netdev.c", "ena_tx_timeout"],
["drivers/net/ethernet/amd/7990.h", "lance_tx_timeout"],
["drivers/net/ethernet/amd/7990.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/a2065.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/am79c961a.c", "am79c961_timeout"],
["drivers/net/ethernet/amd/amd8111e.c", "amd8111e_tx_timeout"],
["drivers/net/ethernet/amd/ariadne.c", "ariadne_tx_timeout"],
["drivers/net/ethernet/amd/atarilance.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/au1000_eth.c", "au1000_tx_timeout"],
["drivers/net/ethernet/amd/declance.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/lance.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/mvme147.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/ni65.c", "ni65_timeout"],
["drivers/net/ethernet/amd/nmclan_cs.c", "mace_tx_timeout"],
["drivers/net/ethernet/amd/pcnet32.c", "pcnet32_tx_timeout"],
["drivers/net/ethernet/amd/sunlance.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/xgbe/xgbe-drv.c", "xgbe_tx_timeout"],
["drivers/net/ethernet/apm/xgene-v2/main.c", "xge_timeout"],
["drivers/net/ethernet/apm/xgene/xgene_enet_main.c", "xgene_enet_timeout"],
["drivers/net/ethernet/apple/macmace.c", "mace_tx_timeout"],
["drivers/net/ethernet/atheros/ag71xx.c", "ag71xx_tx_timeout"],
["drivers/net/ethernet/atheros/alx/main.c", "alx_tx_timeout"],
["drivers/net/ethernet/atheros/atl1c/atl1c_main.c", "atl1c_tx_timeout"],
["drivers/net/ethernet/atheros/atl1e/atl1e_main.c", "atl1e_tx_timeout"],
["drivers/net/ethernet/atheros/atlx/atl.c", "atlx_tx_timeout"],
["drivers/net/ethernet/atheros/atlx/atl1.c", "atlx_tx_timeout"],
["drivers/net/ethernet/atheros/atlx/atl2.c", "atl2_tx_timeout"],
["drivers/net/ethernet/broadcom/b44.c", "b44_tx_timeout"],
["drivers/net/ethernet/broadcom/bcmsysport.c", "bcm_sysport_tx_timeout"],
["drivers/net/ethernet/broadcom/bnx2.c", "bnx2_tx_timeout"],
["drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h", "bnx2x_tx_timeout"],
["drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c", "bnx2x_tx_timeout"],
["drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c", "bnx2x_tx_timeout"],
["drivers/net/ethernet/broadcom/bnxt/bnxt.c", "bnxt_tx_timeout"],
["drivers/net/ethernet/broadcom/genet/bcmgenet.c", "bcmgenet_timeout"],
["drivers/net/ethernet/broadcom/sb1250-mac.c", "sbmac_tx_timeout"],
["drivers/net/ethernet/broadcom/tg3.c", "tg3_tx_timeout"],
["drivers/net/ethernet/calxeda/xgmac.c", "xgmac_tx_timeout"],
["drivers/net/ethernet/cavium/liquidio/lio_main.c", "liquidio_tx_timeout"],
["drivers/net/ethernet/cavium/liquidio/lio_vf_main.c", "liquidio_tx_timeout"],
["drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c", "lio_vf_rep_tx_timeout"],
["drivers/net/ethernet/cavium/thunder/nicvf_main.c", "nicvf_tx_timeout"],
["drivers/net/ethernet/cirrus/cs89x0.c", "net_timeout"],
["drivers/net/ethernet/cisco/enic/enic_main.c", "enic_tx_timeout"],
["drivers/net/ethernet/cisco/enic/enic_main.c", "enic_tx_timeout"],
["drivers/net/ethernet/cortina/gemini.c", "gmac_tx_timeout"],
["drivers/net/ethernet/davicom/dm9000.c", "dm9000_timeout"],
["drivers/net/ethernet/dec/tulip/de2104x.c", "de_tx_timeout"],
["drivers/net/ethernet/dec/tulip/tulip_core.c", "tulip_tx_timeout"],
["drivers/net/ethernet/dec/tulip/winbond-840.c", "tx_timeout"],
["drivers/net/ethernet/dlink/dl2k.c", "rio_tx_timeout"],
["drivers/net/ethernet/dlink/sundance.c", "tx_timeout"],
["drivers/net/ethernet/emulex/benet/be_main.c", "be_tx_timeout"],
["drivers/net/ethernet/ethoc.c", "ethoc_tx_timeout"],
["drivers/net/ethernet/faraday/ftgmac100.c", "ftgmac100_tx_timeout"],
["drivers/net/ethernet/fealnx.c", "fealnx_tx_timeout"],
["drivers/net/ethernet/freescale/dpaa/dpaa_eth.c", "dpaa_tx_timeout"],
["drivers/net/ethernet/freescale/fec_main.c", "fec_timeout"],
["drivers/net/ethernet/freescale/fec_mpc52xx.c", "mpc52xx_fec_tx_timeout"],
["drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c", "fs_timeout"],
["drivers/net/ethernet/freescale/gianfar.c", "gfar_timeout"],
["drivers/net/ethernet/freescale/ucc_geth.c", "ucc_geth_timeout"],
["drivers/net/ethernet/fujitsu/fmvj18x_cs.c", "fjn_tx_timeout"],
["drivers/net/ethernet/google/gve/gve_main.c", "gve_tx_timeout"],
["drivers/net/ethernet/hisilicon/hip04_eth.c", "hip04_timeout"],
["drivers/net/ethernet/hisilicon/hix5hd2_gmac.c", "hix5hd2_net_timeout"],
["drivers/net/ethernet/hisilicon/hns/hns_enet.c", "hns_nic_net_timeout"],
["drivers/net/ethernet/hisilicon/hns3/hns3_enet.c", "hns3_nic_net_timeout"],
["drivers/net/ethernet/huawei/hinic/hinic_main.c", "hinic_tx_timeout"],
["drivers/net/ethernet/i825xx/82596.c", "i596_tx_timeout"],
["drivers/net/ethernet/i825xx/ether1.c", "ether1_timeout"],
["drivers/net/ethernet/i825xx/lib82596.c", "i596_tx_timeout"],
["drivers/net/ethernet/i825xx/sun3_82586.c", "sun3_82586_timeout"],
["drivers/net/ethernet/ibm/ehea/ehea_main.c", "ehea_tx_watchdog"],
["drivers/net/ethernet/ibm/emac/core.c", "emac_tx_timeout"],
["drivers/net/ethernet/ibm/emac/core.c", "emac_tx_timeout"],
["drivers/net/ethernet/ibm/ibmvnic.c", "ibmvnic_tx_timeout"],
["drivers/net/ethernet/intel/e100.c", "e100_tx_timeout"],
["drivers/net/ethernet/intel/e1000/e1000_main.c", "e1000_tx_timeout"],
["drivers/net/ethernet/intel/e1000e/netdev.c", "e1000_tx_timeout"],
["drivers/net/ethernet/intel/fm10k/fm10k_netdev.c", "fm10k_tx_timeout"],
["drivers/net/ethernet/intel/i40e/i40e_main.c", "i40e_tx_timeout"],
["drivers/net/ethernet/intel/iavf/iavf_main.c", "iavf_tx_timeout"],
["drivers/net/ethernet/intel/ice/ice_main.c", "ice_tx_timeout"],
["drivers/net/ethernet/intel/ice/ice_main.c", "ice_tx_timeout"],
["drivers/net/ethernet/intel/igb/igb_main.c", "igb_tx_timeout"],
["drivers/net/ethernet/intel/igbvf/netdev.c", "igbvf_tx_timeout"],
["drivers/net/ethernet/intel/ixgb/ixgb_main.c", "ixgb_tx_timeout"],
["drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c", "adapter->netdev->netdev_ops->ndo_tx_timeout(adapter->netdev);"],
["drivers/net/ethernet/intel/ixgbe/ixgbe_main.c", "ixgbe_tx_timeout"],
["drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c", "ixgbevf_tx_timeout"],
["drivers/net/ethernet/jme.c", "jme_tx_timeout"],
["drivers/net/ethernet/korina.c", "korina_tx_timeout"],
["drivers/net/ethernet/lantiq_etop.c", "ltq_etop_tx_timeout"],
["drivers/net/ethernet/marvell/mv643xx_eth.c", "mv643xx_eth_tx_timeout"],
["drivers/net/ethernet/marvell/pxa168_eth.c", "pxa168_eth_tx_timeout"],
["drivers/net/ethernet/marvell/skge.c", "skge_tx_timeout"],
["drivers/net/ethernet/marvell/sky2.c", "sky2_tx_timeout"],
["drivers/net/ethernet/marvell/sky2.c", "sky2_tx_timeout"],
["drivers/net/ethernet/mediatek/mtk_eth_soc.c", "mtk_tx_timeout"],
["drivers/net/ethernet/mellanox/mlx4/en_netdev.c", "mlx4_en_tx_timeout"],
["drivers/net/ethernet/mellanox/mlx4/en_netdev.c", "mlx4_en_tx_timeout"],
["drivers/net/ethernet/mellanox/mlx5/core/en_main.c", "mlx5e_tx_timeout"],
["drivers/net/ethernet/micrel/ks8842.c", "ks8842_tx_timeout"],
["drivers/net/ethernet/micrel/ksz884x.c", "netdev_tx_timeout"],
["drivers/net/ethernet/microchip/enc28j60.c", "enc28j60_tx_timeout"],
["drivers/net/ethernet/microchip/encx24j600.c", "encx24j600_tx_timeout"],
["drivers/net/ethernet/natsemi/sonic.h", "sonic_tx_timeout"],
["drivers/net/ethernet/natsemi/sonic.c", "sonic_tx_timeout"],
["drivers/net/ethernet/natsemi/jazzsonic.c", "sonic_tx_timeout"],
["drivers/net/ethernet/natsemi/macsonic.c", "sonic_tx_timeout"],
["drivers/net/ethernet/natsemi/natsemi.c", "ns_tx_timeout"],
["drivers/net/ethernet/natsemi/ns83820.c", "ns83820_tx_timeout"],
["drivers/net/ethernet/natsemi/xtsonic.c", "sonic_tx_timeout"],
["drivers/net/ethernet/neterion/s2io.h", "s2io_tx_watchdog"],
["drivers/net/ethernet/neterion/s2io.c", "s2io_tx_watchdog"],
["drivers/net/ethernet/neterion/vxge/vxge-main.c", "vxge_tx_watchdog"],
["drivers/net/ethernet/netronome/nfp/nfp_net_common.c", "nfp_net_tx_timeout"],
["drivers/net/ethernet/nvidia/forcedeth.c", "nv_tx_timeout"],
["drivers/net/ethernet/nvidia/forcedeth.c", "nv_tx_timeout"],
["drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c", "pch_gbe_tx_timeout"],
["drivers/net/ethernet/packetengines/hamachi.c", "hamachi_tx_timeout"],
["drivers/net/ethernet/packetengines/yellowfin.c", "yellowfin_tx_timeout"],
["drivers/net/ethernet/pensando/ionic/ionic_lif.c", "ionic_tx_timeout"],
["drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c", "netxen_tx_timeout"],
["drivers/net/ethernet/qlogic/qla3xxx.c", "ql3xxx_tx_timeout"],
["drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c", "qlcnic_tx_timeout"],
["drivers/net/ethernet/qualcomm/emac/emac.c", "emac_tx_timeout"],
["drivers/net/ethernet/qualcomm/qca_spi.c", "qcaspi_netdev_tx_timeout"],
["drivers/net/ethernet/qualcomm/qca_uart.c", "qcauart_netdev_tx_timeout"],
["drivers/net/ethernet/rdc/r6040.c", "r6040_tx_timeout"],
["drivers/net/ethernet/realtek/8139cp.c", "cp_tx_timeout"],
["drivers/net/ethernet/realtek/8139too.c", "rtl8139_tx_timeout"],
["drivers/net/ethernet/realtek/atp.c", "tx_timeout"],
["drivers/net/ethernet/realtek/r8169_main.c", "rtl8169_tx_timeout"],
["drivers/net/ethernet/renesas/ravb_main.c", "ravb_tx_timeout"],
["drivers/net/ethernet/renesas/sh_eth.c", "sh_eth_tx_timeout"],
["drivers/net/ethernet/renesas/sh_eth.c", "sh_eth_tx_timeout"],
["drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c", "sxgbe_tx_timeout"],
["drivers/net/ethernet/seeq/ether3.c", "ether3_timeout"],
["drivers/net/ethernet/seeq/sgiseeq.c", "timeout"],
["drivers/net/ethernet/sfc/efx.c", "efx_watchdog"],
["drivers/net/ethernet/sfc/falcon/efx.c", "ef4_watchdog"],
["drivers/net/ethernet/sgi/ioc3-eth.c", "ioc3_timeout"],
["drivers/net/ethernet/sgi/meth.c", "meth_tx_timeout"],
["drivers/net/ethernet/silan/sc92031.c", "sc92031_tx_timeout"],
["drivers/net/ethernet/sis/sis190.c", "sis190_tx_timeout"],
["drivers/net/ethernet/sis/sis900.c", "sis900_tx_timeout"],
["drivers/net/ethernet/smsc/epic100.c", "epic_tx_timeout"],
["drivers/net/ethernet/smsc/smc911x.c", "smc911x_timeout"],
["drivers/net/ethernet/smsc/smc9194.c", "smc_timeout"],
["drivers/net/ethernet/smsc/smc91c92_cs.c", "smc_tx_timeout"],
["drivers/net/ethernet/smsc/smc91x.c", "smc_timeout"],
["drivers/net/ethernet/stmicro/stmmac/stmmac_main.c", "stmmac_tx_timeout"],
["drivers/net/ethernet/sun/cassini.c", "cas_tx_timeout"],
["drivers/net/ethernet/sun/ldmvsw.c", "sunvnet_tx_timeout_common"],
["drivers/net/ethernet/sun/niu.c", "niu_tx_timeout"],
["drivers/net/ethernet/sun/sunbmac.c", "bigmac_tx_timeout"],
["drivers/net/ethernet/sun/sungem.c", "gem_tx_timeout"],
["drivers/net/ethernet/sun/sunhme.c", "happy_meal_tx_timeout"],
["drivers/net/ethernet/sun/sunqe.c", "qe_tx_timeout"],
["drivers/net/ethernet/sun/sunvnet.c", "sunvnet_tx_timeout_common"],
["drivers/net/ethernet/sun/sunvnet_common.c", "sunvnet_tx_timeout_common"],
["drivers/net/ethernet/sun/sunvnet_common.h", "sunvnet_tx_timeout_common"],
["drivers/net/ethernet/synopsys/dwc-xlgmac-net.c", "xlgmac_tx_timeout"],
["drivers/net/ethernet/ti/cpmac.c", "cpmac_tx_timeout"],
["drivers/net/ethernet/ti/cpsw.c", "cpsw_ndo_tx_timeout"],
["drivers/net/ethernet/ti/cpsw_priv.c", "cpsw_ndo_tx_timeout"],
["drivers/net/ethernet/ti/cpsw_priv.h", "cpsw_ndo_tx_timeout"],
["drivers/net/ethernet/ti/davinci_emac.c", "emac_dev_tx_timeout"],
["drivers/net/ethernet/ti/netcp_core.c", "netcp_ndo_tx_timeout"],
["drivers/net/ethernet/ti/tlan.c", "tlan_tx_timeout"],
["drivers/net/ethernet/toshiba/ps3_gelic_net.h", "gelic_net_tx_timeout"],
["drivers/net/ethernet/toshiba/ps3_gelic_net.c", "gelic_net_tx_timeout"],
["drivers/net/ethernet/toshiba/ps3_gelic_wireless.c", "gelic_net_tx_timeout"],
["drivers/net/ethernet/toshiba/spider_net.c", "spider_net_tx_timeout"],
["drivers/net/ethernet/toshiba/tc35815.c", "tc35815_tx_timeout"],
["drivers/net/ethernet/via/via-rhine.c", "rhine_tx_timeout"],
["drivers/net/ethernet/wiznet/w5100.c", "w5100_tx_timeout"],
["drivers/net/ethernet/wiznet/w5300.c", "w5300_tx_timeout"],
["drivers/net/ethernet/xilinx/xilinx_emaclite.c", "xemaclite_tx_timeout"],
["drivers/net/ethernet/xircom/xirc2ps_cs.c", "xirc_tx_timeout"],
["drivers/net/fjes/fjes_main.c", "fjes_tx_retry"],
["drivers/net/slip/slip.c", "sl_tx_timeout"],
["include/linux/usb/usbnet.h", "usbnet_tx_timeout"],
["drivers/net/usb/aqc111.c", "usbnet_tx_timeout"],
["drivers/net/usb/asix_devices.c", "usbnet_tx_timeout"],
["drivers/net/usb/asix_devices.c", "usbnet_tx_timeout"],
["drivers/net/usb/asix_devices.c", "usbnet_tx_timeout"],
["drivers/net/usb/ax88172a.c", "usbnet_tx_timeout"],
["drivers/net/usb/ax88179_178a.c", "usbnet_tx_timeout"],
["drivers/net/usb/catc.c", "catc_tx_timeout"],
["drivers/net/usb/cdc_mbim.c", "usbnet_tx_timeout"],
["drivers/net/usb/cdc_ncm.c", "usbnet_tx_timeout"],
["drivers/net/usb/dm9601.c", "usbnet_tx_timeout"],
["drivers/net/usb/hso.c", "hso_net_tx_timeout"],
["drivers/net/usb/int51x1.c", "usbnet_tx_timeout"],
["drivers/net/usb/ipheth.c", "ipheth_tx_timeout"],
["drivers/net/usb/kaweth.c", "kaweth_tx_timeout"],
["drivers/net/usb/lan78xx.c", "lan78xx_tx_timeout"],
["drivers/net/usb/mcs7830.c", "usbnet_tx_timeout"],
["drivers/net/usb/pegasus.c", "pegasus_tx_timeout"],
["drivers/net/usb/qmi_wwan.c", "usbnet_tx_timeout"],
["drivers/net/usb/r8152.c", "rtl8152_tx_timeout"],
["drivers/net/usb/rndis_host.c", "usbnet_tx_timeout"],
["drivers/net/usb/rtl8150.c", "rtl8150_tx_timeout"],
["drivers/net/usb/sierra_net.c", "usbnet_tx_timeout"],
["drivers/net/usb/smsc75xx.c", "usbnet_tx_timeout"],
["drivers/net/usb/smsc95xx.c", "usbnet_tx_timeout"],
["drivers/net/usb/sr9700.c", "usbnet_tx_timeout"],
["drivers/net/usb/sr9800.c", "usbnet_tx_timeout"],
["drivers/net/usb/usbnet.c", "usbnet_tx_timeout"],
["drivers/net/vmxnet3/vmxnet3_drv.c", "vmxnet3_tx_timeout"],
["drivers/net/wan/cosa.c", "cosa_net_timeout"],
["drivers/net/wan/farsync.c", "fst_tx_timeout"],
["drivers/net/wan/fsl_ucc_hdlc.c", "uhdlc_tx_timeout"],
["drivers/net/wan/lmc/lmc_main.c", "lmc_driver_timeout"],
["drivers/net/wan/x25_asy.c", "x25_asy_timeout"],
["drivers/net/wimax/i2400m/netdev.c", "i2400m_tx_timeout"],
["drivers/net/wireless/intel/ipw2x00/ipw2100.c", "ipw2100_tx_timeout"],
["drivers/net/wireless/intersil/hostap/hostap_main.c", "prism2_tx_timeout"],
["drivers/net/wireless/intersil/hostap/hostap_main.c", "prism2_tx_timeout"],
["drivers/net/wireless/intersil/hostap/hostap_main.c", "prism2_tx_timeout"],
["drivers/net/wireless/intersil/orinoco/main.c", "orinoco_tx_timeout"],
["drivers/net/wireless/intersil/orinoco/orinoco_usb.c", "orinoco_tx_timeout"],
["drivers/net/wireless/intersil/orinoco/orinoco.h", "orinoco_tx_timeout"],
["drivers/net/wireless/intersil/prism54/islpci_dev.c", "islpci_eth_tx_timeout"],
["drivers/net/wireless/intersil/prism54/islpci_eth.c", "islpci_eth_tx_timeout"],
["drivers/net/wireless/intersil/prism54/islpci_eth.h", "islpci_eth_tx_timeout"],
["drivers/net/wireless/marvell/mwifiex/main.c", "mwifiex_tx_timeout"],
["drivers/net/wireless/quantenna/qtnfmac/core.c", "qtnf_netdev_tx_timeout"],
["drivers/net/wireless/quantenna/qtnfmac/core.h", "qtnf_netdev_tx_timeout"],
["drivers/net/wireless/rndis_wlan.c", "usbnet_tx_timeout"],
["drivers/net/wireless/wl3501_cs.c", "wl3501_tx_timeout"],
["drivers/net/wireless/zydas/zd1201.c", "zd1201_tx_timeout"],
["drivers/s390/net/qeth_core.h", "qeth_tx_timeout"],
["drivers/s390/net/qeth_core_main.c", "qeth_tx_timeout"],
["drivers/s390/net/qeth_l2_main.c", "qeth_tx_timeout"],
["drivers/s390/net/qeth_l2_main.c", "qeth_tx_timeout"],
["drivers/s390/net/qeth_l3_main.c", "qeth_tx_timeout"],
["drivers/s390/net/qeth_l3_main.c", "qeth_tx_timeout"],
["drivers/staging/ks7010/ks_wlan_net.c", "ks_wlan_tx_timeout"],
["drivers/staging/qlge/qlge_main.c", "qlge_tx_timeout"],
["drivers/staging/rtl8192e/rtl8192e/rtl_core.c", "_rtl92e_tx_timeout"],
["drivers/staging/rtl8192u/r8192U_core.c", "tx_timeout"],
["drivers/staging/unisys/visornic/visornic_main.c", "visornic_xmit_timeout"],
["drivers/staging/wlan-ng/p80211netdev.c", "p80211knetdev_tx_timeout"],
["drivers/tty/n_gsm.c", "gsm_mux_net_tx_timeout"],
["drivers/tty/synclink.c", "hdlcdev_tx_timeout"],
["drivers/tty/synclink_gt.c", "hdlcdev_tx_timeout"],
["drivers/tty/synclinkmp.c", "hdlcdev_tx_timeout"],
["net/atm/lec.c", "lec_tx_timeout"],
["net/bluetooth/bnep/netdev.c", "bnep_net_timeout"]
);
for my $p (@work) {
my @pair = @$p;
my $file = $pair[0];
my $func = $pair[1];
print STDERR $file , ": ", $func,"\n";
our @ARGV = ($file);
while (<ARGV>) {
if (m/($func\s*\(struct\s+net_device\s+\*[A-Za-z_]?[A-Za-z-0-9_]*)(\))/) {
print STDERR "found $1+$2 in $file\n";
}
if (s/($func\s*\(struct\s+net_device\s+\*[A-Za-z_]?[A-Za-z-0-9_]*)(\))/$1, unsigned int txqueue$2/) {
print STDERR "$func found in $file\n";
}
print;
}
}
where the list of files and functions is simply from:
git grep ndo_tx_timeout, with manual addition of headers
in the rare cases where the function is from a header,
then manually changing the few places which actually
call ndo_tx_timeout.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Shannon Nelson <snelson@pensando.io>
Reviewed-by: Martin Habets <mhabets@solarflare.com>
changes from v9:
fixup a forward declaration
changes from v9:
more leftovers from v3 change
changes from v8:
fix up a missing direct call to timeout
rebased on net-next
changes from v7:
fixup leftovers from v3 change
changes from v6:
fix typo in rtl driver
changes from v5:
add missing files (allow any net device argument name)
changes from v4:
add a missing driver header
changes from v3:
change queue # to unsigned
Changes from v2:
added headers
Changes from v1:
Fix errors found by kbuild:
generalize the pattern a bit, to pick up
a couple of instances missed by the previous
version.
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-12-10 14:23:51 +00:00
|
|
|
static void pegasus_tx_timeout(struct net_device *net, unsigned int txqueue)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(net);
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_warn(pegasus, timer, net, "tx timeout\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
usb_unlink_urb(pegasus->tx_urb);
|
2017-04-07 08:17:39 +00:00
|
|
|
net->stats.tx_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-08-31 19:50:45 +00:00
|
|
|
static netdev_tx_t pegasus_start_xmit(struct sk_buff *skb,
|
|
|
|
struct net_device *net)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(net);
|
|
|
|
int count = ((skb->len + 2) & 0x3f) ? skb->len + 2 : skb->len + 3;
|
|
|
|
int res;
|
|
|
|
__u16 l16 = skb->len;
|
|
|
|
|
|
|
|
netif_stop_queue(net);
|
|
|
|
|
|
|
|
((__le16 *) pegasus->tx_buff)[0] = cpu_to_le16(l16);
|
2007-03-27 21:55:52 +00:00
|
|
|
skb_copy_from_linear_data(skb, pegasus->tx_buff + 2, skb->len);
|
2005-04-16 22:20:36 +00:00
|
|
|
usb_fill_bulk_urb(pegasus->tx_urb, pegasus->usb,
|
|
|
|
usb_sndbulkpipe(pegasus->usb, 2),
|
|
|
|
pegasus->tx_buff, count,
|
|
|
|
write_bulk_callback, pegasus);
|
|
|
|
if ((res = usb_submit_urb(pegasus->tx_urb, GFP_ATOMIC))) {
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_warn(pegasus, tx_err, net, "fail tx, %d\n", res);
|
2005-04-16 22:20:36 +00:00
|
|
|
switch (res) {
|
|
|
|
case -EPIPE: /* stall, or disconnect from TT */
|
|
|
|
/* cleanup should already have been scheduled */
|
|
|
|
break;
|
|
|
|
case -ENODEV: /* disconnect() upcoming */
|
2009-04-17 08:40:19 +00:00
|
|
|
case -EPERM:
|
2006-05-26 17:17:03 +00:00
|
|
|
netif_device_detach(pegasus->net);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
default:
|
2017-04-07 08:17:39 +00:00
|
|
|
net->stats.tx_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
netif_start_queue(net);
|
|
|
|
}
|
|
|
|
} else {
|
2017-04-07 08:17:39 +00:00
|
|
|
net->stats.tx_packets++;
|
|
|
|
net->stats.tx_bytes += skb->len;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
|
2009-06-23 06:03:08 +00:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static inline void disable_net_traffic(pegasus_t *pegasus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-06-18 07:03:47 +00:00
|
|
|
__le16 tmp = cpu_to_le16(0);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-06-18 07:03:47 +00:00
|
|
|
set_registers(pegasus, EthCtrl0, sizeof(tmp), &tmp);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2021-08-04 14:30:05 +00:00
|
|
|
static inline int get_interrupt_interval(pegasus_t *pegasus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-06-18 07:03:47 +00:00
|
|
|
u16 data;
|
|
|
|
u8 interval;
|
2021-08-04 14:30:05 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = read_eprom_word(pegasus, 4, &data);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-06-18 07:03:47 +00:00
|
|
|
interval = data >> 8;
|
2005-09-22 07:49:24 +00:00
|
|
|
if (pegasus->usb->speed != USB_SPEED_HIGH) {
|
2009-06-18 07:03:47 +00:00
|
|
|
if (interval < 0x80) {
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_info(pegasus, timer, pegasus->net,
|
|
|
|
"intr interval changed from %ums to %ums\n",
|
|
|
|
interval, 0x80);
|
2009-06-18 07:03:47 +00:00
|
|
|
interval = 0x80;
|
|
|
|
data = (data & 0x00FF) | ((u16)interval << 8);
|
2005-09-22 07:49:24 +00:00
|
|
|
#ifdef PEGASUS_WRITE_EEPROM
|
2009-06-18 07:03:47 +00:00
|
|
|
write_eprom_word(pegasus, 4, data);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
2005-09-22 07:49:24 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-06-18 07:03:47 +00:00
|
|
|
pegasus->intr_interval = interval;
|
2021-08-04 14:30:05 +00:00
|
|
|
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void set_carrier(struct net_device *net)
|
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(net);
|
|
|
|
u16 tmp;
|
|
|
|
|
2007-04-24 14:20:06 +00:00
|
|
|
if (read_mii_word(pegasus, pegasus->phy, MII_BMSR, &tmp))
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
2005-09-22 07:49:24 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (tmp & BMSR_LSTATUS)
|
|
|
|
netif_carrier_on(net);
|
|
|
|
else
|
|
|
|
netif_carrier_off(net);
|
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static void free_all_urbs(pegasus_t *pegasus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
usb_free_urb(pegasus->intr_urb);
|
|
|
|
usb_free_urb(pegasus->tx_urb);
|
|
|
|
usb_free_urb(pegasus->rx_urb);
|
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static void unlink_all_urbs(pegasus_t *pegasus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
usb_kill_urb(pegasus->intr_urb);
|
|
|
|
usb_kill_urb(pegasus->tx_urb);
|
|
|
|
usb_kill_urb(pegasus->rx_urb);
|
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static int alloc_urbs(pegasus_t *pegasus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-04-25 22:41:50 +00:00
|
|
|
int res = -ENOMEM;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
pegasus->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
if (!pegasus->rx_urb) {
|
2013-04-25 22:41:50 +00:00
|
|
|
return res;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
pegasus->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
if (!pegasus->tx_urb) {
|
|
|
|
usb_free_urb(pegasus->rx_urb);
|
2013-04-25 22:41:50 +00:00
|
|
|
return res;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
pegasus->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
if (!pegasus->intr_urb) {
|
|
|
|
usb_free_urb(pegasus->tx_urb);
|
|
|
|
usb_free_urb(pegasus->rx_urb);
|
2013-04-25 22:41:50 +00:00
|
|
|
return res;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2013-04-25 22:41:50 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int pegasus_open(struct net_device *net)
|
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(net);
|
2013-04-25 22:41:50 +00:00
|
|
|
int res=-ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (pegasus->rx_skb == NULL)
|
2013-04-25 22:41:21 +00:00
|
|
|
pegasus->rx_skb = __netdev_alloc_skb_ip_align(pegasus->net,
|
|
|
|
PEGASUS_MTU,
|
|
|
|
GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!pegasus->rx_skb)
|
2013-04-25 22:41:50 +00:00
|
|
|
goto exit;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2021-08-20 06:57:53 +00:00
|
|
|
set_registers(pegasus, EthID, 6, net->dev_addr);
|
2010-06-26 06:58:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb,
|
|
|
|
usb_rcvbulkpipe(pegasus->usb, 1),
|
2016-04-27 11:24:49 +00:00
|
|
|
pegasus->rx_skb->data, PEGASUS_MTU,
|
2005-04-16 22:20:36 +00:00
|
|
|
read_bulk_callback, pegasus);
|
|
|
|
if ((res = usb_submit_urb(pegasus->rx_urb, GFP_KERNEL))) {
|
2006-05-26 17:17:03 +00:00
|
|
|
if (res == -ENODEV)
|
|
|
|
netif_device_detach(pegasus->net);
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_dbg(pegasus, ifup, net, "failed rx_urb, %d\n", res);
|
2005-04-16 22:20:36 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
usb_fill_int_urb(pegasus->intr_urb, pegasus->usb,
|
|
|
|
usb_rcvintpipe(pegasus->usb, 3),
|
2010-06-26 06:58:54 +00:00
|
|
|
pegasus->intr_buff, sizeof(pegasus->intr_buff),
|
2005-04-16 22:20:36 +00:00
|
|
|
intr_callback, pegasus, pegasus->intr_interval);
|
|
|
|
if ((res = usb_submit_urb(pegasus->intr_urb, GFP_KERNEL))) {
|
2006-05-26 17:17:03 +00:00
|
|
|
if (res == -ENODEV)
|
|
|
|
netif_device_detach(pegasus->net);
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_dbg(pegasus, ifup, net, "failed intr_urb, %d\n", res);
|
2005-04-16 22:20:36 +00:00
|
|
|
usb_kill_urb(pegasus->rx_urb);
|
|
|
|
goto exit;
|
|
|
|
}
|
2013-04-25 22:41:50 +00:00
|
|
|
res = enable_net_traffic(net, pegasus->usb);
|
|
|
|
if (res < 0) {
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_dbg(pegasus, ifup, net,
|
|
|
|
"can't enable_net_traffic() - %d\n", res);
|
2005-04-16 22:20:36 +00:00
|
|
|
res = -EIO;
|
|
|
|
usb_kill_urb(pegasus->rx_urb);
|
|
|
|
usb_kill_urb(pegasus->intr_urb);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
set_carrier(net);
|
|
|
|
netif_start_queue(net);
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_dbg(pegasus, ifup, net, "open\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
res = 0;
|
|
|
|
exit:
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pegasus_close(struct net_device *net)
|
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(net);
|
|
|
|
|
|
|
|
netif_stop_queue(net);
|
|
|
|
if (!(pegasus->flags & PEGASUS_UNPLUG))
|
|
|
|
disable_net_traffic(pegasus);
|
|
|
|
tasklet_kill(&pegasus->rx_tl);
|
|
|
|
unlink_all_urbs(pegasus);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pegasus_get_drvinfo(struct net_device *dev,
|
|
|
|
struct ethtool_drvinfo *info)
|
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(dev);
|
2013-01-06 00:44:26 +00:00
|
|
|
|
2022-08-30 20:14:52 +00:00
|
|
|
strscpy(info->driver, driver_name, sizeof(info->driver));
|
2010-06-26 06:58:54 +00:00
|
|
|
usb_make_path(pegasus->usb, info->bus_info, sizeof(info->bus_info));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* also handles three patterns of some kind in hardware */
|
|
|
|
#define WOL_SUPPORTED (WAKE_MAGIC|WAKE_PHY)
|
|
|
|
|
|
|
|
static void
|
|
|
|
pegasus_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
|
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(dev);
|
|
|
|
|
|
|
|
wol->supported = WAKE_MAGIC | WAKE_PHY;
|
|
|
|
wol->wolopts = pegasus->wolopts;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pegasus_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
|
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(dev);
|
|
|
|
u8 reg78 = 0x04;
|
2013-01-19 01:32:01 +00:00
|
|
|
int ret;
|
2010-06-26 06:58:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (wol->wolopts & ~WOL_SUPPORTED)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (wol->wolopts & WAKE_MAGIC)
|
|
|
|
reg78 |= 0x80;
|
|
|
|
if (wol->wolopts & WAKE_PHY)
|
|
|
|
reg78 |= 0x40;
|
|
|
|
/* FIXME this 0x10 bit still needs to get set in the chip... */
|
|
|
|
if (wol->wolopts)
|
|
|
|
pegasus->eth_regs[0] |= 0x10;
|
|
|
|
else
|
|
|
|
pegasus->eth_regs[0] &= ~0x10;
|
|
|
|
pegasus->wolopts = wol->wolopts;
|
2013-01-19 01:32:01 +00:00
|
|
|
|
|
|
|
ret = set_register(pegasus, WakeupControl, reg78);
|
|
|
|
if (!ret)
|
|
|
|
ret = device_set_wakeup_enable(&pegasus->usb->dev,
|
|
|
|
wol->wolopts);
|
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void pegasus_reset_wol(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct ethtool_wolinfo wol;
|
2010-06-26 06:58:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
memset(&wol, 0, sizeof wol);
|
|
|
|
(void) pegasus_set_wol(dev, &wol);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2017-03-17 22:34:04 +00:00
|
|
|
pegasus_get_link_ksettings(struct net_device *dev,
|
|
|
|
struct ethtool_link_ksettings *ecmd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
pegasus_t *pegasus;
|
|
|
|
|
|
|
|
pegasus = netdev_priv(dev);
|
2017-03-17 22:34:04 +00:00
|
|
|
mii_ethtool_get_link_ksettings(&pegasus->mii, ecmd);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2017-03-17 22:34:04 +00:00
|
|
|
pegasus_set_link_ksettings(struct net_device *dev,
|
|
|
|
const struct ethtool_link_ksettings *ecmd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(dev);
|
2017-03-17 22:34:04 +00:00
|
|
|
return mii_ethtool_set_link_ksettings(&pegasus->mii, ecmd);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int pegasus_nway_reset(struct net_device *dev)
|
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(dev);
|
|
|
|
return mii_nway_restart(&pegasus->mii);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 pegasus_get_link(struct net_device *dev)
|
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(dev);
|
|
|
|
return mii_link_ok(&pegasus->mii);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 pegasus_get_msglevel(struct net_device *dev)
|
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(dev);
|
|
|
|
return pegasus->msg_enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pegasus_set_msglevel(struct net_device *dev, u32 v)
|
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(dev);
|
|
|
|
pegasus->msg_enable = v;
|
|
|
|
}
|
|
|
|
|
2009-09-02 08:03:33 +00:00
|
|
|
static const struct ethtool_ops ops = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.get_drvinfo = pegasus_get_drvinfo,
|
|
|
|
.nway_reset = pegasus_nway_reset,
|
|
|
|
.get_link = pegasus_get_link,
|
|
|
|
.get_msglevel = pegasus_get_msglevel,
|
|
|
|
.set_msglevel = pegasus_set_msglevel,
|
|
|
|
.get_wol = pegasus_get_wol,
|
|
|
|
.set_wol = pegasus_set_wol,
|
2017-03-17 22:34:04 +00:00
|
|
|
.get_link_ksettings = pegasus_get_link_ksettings,
|
|
|
|
.set_link_ksettings = pegasus_set_link_ksettings,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2021-07-27 13:45:00 +00:00
|
|
|
static int pegasus_siocdevprivate(struct net_device *net, struct ifreq *rq,
|
|
|
|
void __user *udata, int cmd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-06-26 06:58:54 +00:00
|
|
|
__u16 *data = (__u16 *) &rq->ifr_ifru;
|
2005-04-16 22:20:36 +00:00
|
|
|
pegasus_t *pegasus = netdev_priv(net);
|
|
|
|
int res;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case SIOCDEVPRIVATE:
|
|
|
|
data[0] = pegasus->phy;
|
2020-08-23 22:36:59 +00:00
|
|
|
fallthrough;
|
2005-04-16 22:20:36 +00:00
|
|
|
case SIOCDEVPRIVATE + 1:
|
2021-08-03 17:25:23 +00:00
|
|
|
res = read_mii_word(pegasus, data[0], data[1] & 0x1f, &data[3]);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case SIOCDEVPRIVATE + 2:
|
|
|
|
if (!capable(CAP_NET_ADMIN))
|
|
|
|
return -EPERM;
|
2013-04-25 22:41:36 +00:00
|
|
|
write_mii_word(pegasus, pegasus->phy, data[1] & 0x1f, &data[2]);
|
2005-04-16 22:20:36 +00:00
|
|
|
res = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
res = -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pegasus_set_multicast(struct net_device *net)
|
|
|
|
{
|
|
|
|
pegasus_t *pegasus = netdev_priv(net);
|
|
|
|
|
|
|
|
if (net->flags & IFF_PROMISC) {
|
|
|
|
pegasus->eth_regs[EthCtrl2] |= RX_PROMISCUOUS;
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_info(pegasus, link, net, "Promiscuous mode enabled\n");
|
2010-02-08 04:30:35 +00:00
|
|
|
} else if (!netdev_mc_empty(net) || (net->flags & IFF_ALLMULTI)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
pegasus->eth_regs[EthCtrl0] |= RX_MULTICAST;
|
|
|
|
pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS;
|
2010-02-17 10:30:24 +00:00
|
|
|
netif_dbg(pegasus, link, net, "set allmulti\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
|
|
|
pegasus->eth_regs[EthCtrl0] &= ~RX_MULTICAST;
|
|
|
|
pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS;
|
|
|
|
}
|
2013-04-25 22:41:50 +00:00
|
|
|
update_eth_regs_async(pegasus);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static __u8 mii_phy_probe(pegasus_t *pegasus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2021-08-03 17:25:23 +00:00
|
|
|
int i, ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
__u16 tmp;
|
|
|
|
|
|
|
|
for (i = 0; i < 32; i++) {
|
2021-08-03 17:25:23 +00:00
|
|
|
ret = read_mii_word(pegasus, i, MII_BMSR, &tmp);
|
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (tmp == 0 || tmp == 0xffff || (tmp & BMSR_MEDIA) == 0)
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
return i;
|
|
|
|
}
|
2021-08-03 17:25:23 +00:00
|
|
|
fail:
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0xff;
|
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static inline void setup_pegasus_II(pegasus_t *pegasus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2021-08-03 17:25:23 +00:00
|
|
|
int ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
__u8 data = 0xa5;
|
2010-06-26 06:58:54 +00:00
|
|
|
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, Reg1d, 0);
|
|
|
|
set_register(pegasus, Reg7b, 1);
|
2018-07-27 08:36:29 +00:00
|
|
|
msleep(100);
|
2005-04-16 22:20:36 +00:00
|
|
|
if ((pegasus->features & HAS_HOME_PNA) && mii_mode)
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, Reg7b, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, Reg7b, 2);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, 0x83, data);
|
2021-08-03 17:25:23 +00:00
|
|
|
ret = get_registers(pegasus, 0x83, 1, &data);
|
|
|
|
if (ret < 0)
|
|
|
|
goto fail;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
if (data == 0xa5)
|
2005-04-16 22:20:36 +00:00
|
|
|
pegasus->chip = 0x8513;
|
2010-06-26 06:58:54 +00:00
|
|
|
else
|
2005-04-16 22:20:36 +00:00
|
|
|
pegasus->chip = 0;
|
|
|
|
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, 0x80, 0xc0);
|
|
|
|
set_register(pegasus, 0x83, 0xff);
|
|
|
|
set_register(pegasus, 0x84, 0x01);
|
2010-06-26 06:58:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (pegasus->features & HAS_HOME_PNA && mii_mode)
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, Reg81, 6);
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
2005-11-15 07:48:23 +00:00
|
|
|
set_register(pegasus, Reg81, 2);
|
2021-08-03 17:25:23 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
fail:
|
|
|
|
netif_dbg(pegasus, drv, pegasus->net, "%s failed\n", __func__);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-11-22 14:57:56 +00:00
|
|
|
static void check_carrier(struct work_struct *work)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-11-22 14:57:56 +00:00
|
|
|
pegasus_t *pegasus = container_of(work, pegasus_t, carrier_check.work);
|
2005-04-16 22:20:36 +00:00
|
|
|
set_carrier(pegasus->net);
|
|
|
|
if (!(pegasus->flags & PEGASUS_UNPLUG)) {
|
2020-04-02 14:33:29 +00:00
|
|
|
queue_delayed_work(system_long_wq, &pegasus->carrier_check,
|
2005-04-16 22:20:36 +00:00
|
|
|
CARRIER_CHECK_DELAY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-30 19:39:02 +00:00
|
|
|
static int pegasus_blacklisted(struct usb_device *udev)
|
|
|
|
{
|
|
|
|
struct usb_device_descriptor *udd = &udev->descriptor;
|
|
|
|
|
|
|
|
/* Special quirk to keep the driver from handling the Belkin Bluetooth
|
|
|
|
* dongle which happens to have the same ID.
|
|
|
|
*/
|
2009-06-18 07:03:47 +00:00
|
|
|
if ((udd->idVendor == cpu_to_le16(VENDOR_BELKIN)) &&
|
|
|
|
(udd->idProduct == cpu_to_le16(0x0121)) &&
|
2008-07-30 19:39:02 +00:00
|
|
|
(udd->bDeviceClass == USB_CLASS_WIRELESS_CONTROLLER) &&
|
|
|
|
(udd->bDeviceProtocol == 1))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int pegasus_probe(struct usb_interface *intf,
|
|
|
|
const struct usb_device_id *id)
|
|
|
|
{
|
|
|
|
struct usb_device *dev = interface_to_usbdev(intf);
|
|
|
|
struct net_device *net;
|
|
|
|
pegasus_t *pegasus;
|
|
|
|
int dev_index = id - pegasus_ids;
|
|
|
|
int res = -ENOMEM;
|
|
|
|
|
2008-11-16 08:36:08 +00:00
|
|
|
if (pegasus_blacklisted(dev))
|
|
|
|
return -ENODEV;
|
2008-07-30 19:39:02 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
net = alloc_etherdev(sizeof(struct pegasus));
|
2012-01-29 13:47:52 +00:00
|
|
|
if (!net)
|
2005-04-16 22:20:36 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
pegasus = netdev_priv(net);
|
|
|
|
pegasus->dev_index = dev_index;
|
|
|
|
|
2013-04-25 22:41:50 +00:00
|
|
|
res = alloc_urbs(pegasus);
|
|
|
|
if (res < 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
dev_err(&intf->dev, "can't allocate %s\n", "urbs");
|
|
|
|
goto out1;
|
|
|
|
}
|
|
|
|
|
2021-01-30 23:47:28 +00:00
|
|
|
tasklet_setup(&pegasus->rx_tl, rx_fixup);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-11-22 14:57:56 +00:00
|
|
|
INIT_DELAYED_WORK(&pegasus->carrier_check, check_carrier);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
pegasus->intf = intf;
|
|
|
|
pegasus->usb = dev;
|
|
|
|
pegasus->net = net;
|
2009-01-08 19:22:25 +00:00
|
|
|
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
net->watchdog_timeo = PEGASUS_TX_TIMEOUT;
|
2009-01-08 19:22:25 +00:00
|
|
|
net->netdev_ops = &pegasus_netdev_ops;
|
2014-05-11 00:12:32 +00:00
|
|
|
net->ethtool_ops = &ops;
|
2005-04-16 22:20:36 +00:00
|
|
|
pegasus->mii.dev = net;
|
|
|
|
pegasus->mii.mdio_read = mdio_read;
|
|
|
|
pegasus->mii.mdio_write = mdio_write;
|
|
|
|
pegasus->mii.phy_id_mask = 0x1f;
|
|
|
|
pegasus->mii.reg_num_mask = 0x1f;
|
2010-06-26 06:58:54 +00:00
|
|
|
pegasus->msg_enable = netif_msg_init(msg_level, NETIF_MSG_DRV
|
2005-04-16 22:20:36 +00:00
|
|
|
| NETIF_MSG_PROBE | NETIF_MSG_LINK);
|
|
|
|
|
|
|
|
pegasus->features = usb_dev_id[dev_index].private;
|
2021-08-04 14:30:05 +00:00
|
|
|
res = get_interrupt_interval(pegasus);
|
|
|
|
if (res)
|
|
|
|
goto out2;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (reset_mac(pegasus)) {
|
|
|
|
dev_err(&intf->dev, "can't reset MAC\n");
|
|
|
|
res = -EIO;
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
set_ethernet_addr(pegasus);
|
|
|
|
if (pegasus->features & PEGASUS_II) {
|
|
|
|
dev_info(&intf->dev, "setup Pegasus II specific registers\n");
|
|
|
|
setup_pegasus_II(pegasus);
|
|
|
|
}
|
|
|
|
pegasus->phy = mii_phy_probe(pegasus);
|
|
|
|
if (pegasus->phy == 0xff) {
|
|
|
|
dev_warn(&intf->dev, "can't locate MII phy, using default\n");
|
|
|
|
pegasus->phy = 1;
|
|
|
|
}
|
|
|
|
pegasus->mii.phy_id = pegasus->phy;
|
|
|
|
usb_set_intfdata(intf, pegasus);
|
|
|
|
SET_NETDEV_DEV(net, &intf->dev);
|
|
|
|
pegasus_reset_wol(net);
|
|
|
|
res = register_netdev(net);
|
|
|
|
if (res)
|
|
|
|
goto out3;
|
2020-04-02 14:33:29 +00:00
|
|
|
queue_delayed_work(system_long_wq, &pegasus->carrier_check,
|
2013-04-25 22:41:50 +00:00
|
|
|
CARRIER_CHECK_DELAY);
|
|
|
|
dev_info(&intf->dev, "%s, %s, %pM\n", net->name,
|
|
|
|
usb_dev_id[dev_index].name, net->dev_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
out3:
|
|
|
|
usb_set_intfdata(intf, NULL);
|
|
|
|
out2:
|
|
|
|
free_all_urbs(pegasus);
|
|
|
|
out1:
|
|
|
|
free_netdev(net);
|
|
|
|
out:
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pegasus_disconnect(struct usb_interface *intf)
|
|
|
|
{
|
|
|
|
struct pegasus *pegasus = usb_get_intfdata(intf);
|
|
|
|
|
|
|
|
usb_set_intfdata(intf, NULL);
|
|
|
|
if (!pegasus) {
|
|
|
|
dev_dbg(&intf->dev, "unregistering non-bound device?\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pegasus->flags |= PEGASUS_UNPLUG;
|
2020-04-02 14:33:29 +00:00
|
|
|
cancel_delayed_work_sync(&pegasus->carrier_check);
|
2005-04-16 22:20:36 +00:00
|
|
|
unregister_netdev(pegasus->net);
|
2005-09-22 07:49:24 +00:00
|
|
|
unlink_all_urbs(pegasus);
|
2005-04-16 22:20:36 +00:00
|
|
|
free_all_urbs(pegasus);
|
2007-04-26 00:40:23 +00:00
|
|
|
if (pegasus->rx_skb != NULL) {
|
2005-04-16 22:20:36 +00:00
|
|
|
dev_kfree_skb(pegasus->rx_skb);
|
2007-04-26 00:40:23 +00:00
|
|
|
pegasus->rx_skb = NULL;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
free_netdev(pegasus->net);
|
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static int pegasus_suspend(struct usb_interface *intf, pm_message_t message)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct pegasus *pegasus = usb_get_intfdata(intf);
|
2010-06-26 06:58:54 +00:00
|
|
|
|
|
|
|
netif_device_detach(pegasus->net);
|
2020-04-02 14:33:29 +00:00
|
|
|
cancel_delayed_work_sync(&pegasus->carrier_check);
|
2005-04-19 00:39:22 +00:00
|
|
|
if (netif_running(pegasus->net)) {
|
|
|
|
usb_kill_urb(pegasus->rx_urb);
|
|
|
|
usb_kill_urb(pegasus->intr_urb);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
static int pegasus_resume(struct usb_interface *intf)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct pegasus *pegasus = usb_get_intfdata(intf);
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
netif_device_attach(pegasus->net);
|
2005-04-19 00:39:22 +00:00
|
|
|
if (netif_running(pegasus->net)) {
|
|
|
|
pegasus->rx_urb->status = 0;
|
|
|
|
pegasus->rx_urb->actual_length = 0;
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
read_bulk_callback(pegasus->rx_urb);
|
2005-04-19 00:39:22 +00:00
|
|
|
|
|
|
|
pegasus->intr_urb->status = 0;
|
|
|
|
pegasus->intr_urb->actual_length = 0;
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
intr_callback(pegasus->intr_urb);
|
2005-04-19 00:39:22 +00:00
|
|
|
}
|
2020-04-02 14:33:29 +00:00
|
|
|
queue_delayed_work(system_long_wq, &pegasus->carrier_check,
|
2006-05-01 21:02:45 +00:00
|
|
|
CARRIER_CHECK_DELAY);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-08 19:22:25 +00:00
|
|
|
static const struct net_device_ops pegasus_netdev_ops = {
|
|
|
|
.ndo_open = pegasus_open,
|
|
|
|
.ndo_stop = pegasus_close,
|
2021-07-27 13:45:00 +00:00
|
|
|
.ndo_siocdevprivate = pegasus_siocdevprivate,
|
2009-01-08 19:22:25 +00:00
|
|
|
.ndo_start_xmit = pegasus_start_xmit,
|
2011-08-16 06:29:01 +00:00
|
|
|
.ndo_set_rx_mode = pegasus_set_multicast,
|
2009-01-08 19:22:25 +00:00
|
|
|
.ndo_tx_timeout = pegasus_tx_timeout,
|
2009-07-09 17:54:35 +00:00
|
|
|
.ndo_set_mac_address = eth_mac_addr,
|
|
|
|
.ndo_validate_addr = eth_validate_addr,
|
2009-01-08 19:22:25 +00:00
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static struct usb_driver pegasus_driver = {
|
|
|
|
.name = driver_name,
|
|
|
|
.probe = pegasus_probe,
|
|
|
|
.disconnect = pegasus_disconnect,
|
|
|
|
.id_table = pegasus_ids,
|
|
|
|
.suspend = pegasus_suspend,
|
|
|
|
.resume = pegasus_resume,
|
2012-04-23 17:08:51 +00:00
|
|
|
.disable_hub_initiated_lpm = 1,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2008-11-16 08:36:08 +00:00
|
|
|
static void __init parse_id(char *id)
|
2005-11-15 07:55:18 +00:00
|
|
|
{
|
2010-06-26 06:58:54 +00:00
|
|
|
unsigned int vendor_id = 0, device_id = 0, flags = 0, i = 0;
|
|
|
|
char *token, *name = NULL;
|
2005-11-15 07:55:18 +00:00
|
|
|
|
|
|
|
if ((token = strsep(&id, ":")) != NULL)
|
|
|
|
name = token;
|
|
|
|
/* name now points to a null terminated string*/
|
|
|
|
if ((token = strsep(&id, ":")) != NULL)
|
|
|
|
vendor_id = simple_strtoul(token, NULL, 16);
|
|
|
|
if ((token = strsep(&id, ":")) != NULL)
|
|
|
|
device_id = simple_strtoul(token, NULL, 16);
|
|
|
|
flags = simple_strtoul(id, NULL, 16);
|
|
|
|
pr_info("%s: new device %s, vendor ID 0x%04x, device ID 0x%04x, flags: 0x%x\n",
|
2010-06-26 06:58:54 +00:00
|
|
|
driver_name, name, vendor_id, device_id, flags);
|
2005-11-15 07:55:18 +00:00
|
|
|
|
|
|
|
if (vendor_id > 0x10000 || vendor_id == 0)
|
|
|
|
return;
|
|
|
|
if (device_id > 0x10000 || device_id == 0)
|
|
|
|
return;
|
|
|
|
|
2010-06-26 06:58:54 +00:00
|
|
|
for (i = 0; usb_dev_id[i].name; i++);
|
2005-11-15 07:55:18 +00:00
|
|
|
usb_dev_id[i].name = name;
|
|
|
|
usb_dev_id[i].vendor = vendor_id;
|
|
|
|
usb_dev_id[i].device = device_id;
|
|
|
|
usb_dev_id[i].private = flags;
|
|
|
|
pegasus_ids[i].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
|
|
|
|
pegasus_ids[i].idVendor = vendor_id;
|
|
|
|
pegasus_ids[i].idProduct = device_id;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int __init pegasus_init(void)
|
|
|
|
{
|
2021-08-03 17:25:24 +00:00
|
|
|
pr_info("%s: " DRIVER_DESC "\n", driver_name);
|
2005-11-15 07:55:18 +00:00
|
|
|
if (devid)
|
|
|
|
parse_id(devid);
|
2005-04-16 22:20:36 +00:00
|
|
|
return usb_register(&pegasus_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit pegasus_exit(void)
|
|
|
|
{
|
|
|
|
usb_deregister(&pegasus_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(pegasus_init);
|
|
|
|
module_exit(pegasus_exit);
|