linux/drivers/net/usb/pegasus.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *  Copyright (c) 1999-2021 Petko Manolov ([email protected])
 *
 */

#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>
#include <linux/uaccess.h>
#include "pegasus.h"

/*
 * Version Information
 */
#define DRIVER_AUTHOR
#define DRIVER_DESC

static const char driver_name[] =;

#undef	PEGASUS_WRITE_EEPROM
#define BMSR_MEDIA
#define CARRIER_CHECK_DELAY

static bool loopback;
static bool mii_mode;
static char *devid;

static struct usb_eth_dev usb_dev_id[] =;

static struct usb_device_id pegasus_ids[] =;

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();
module_param(loopback, bool, 0);
module_param(mii_mode, bool, 0);
module_param(devid, charp, 0);
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();

/* use ethtool to change the level for any given device */
static int msg_level =;
module_param(msg_level, int, 0);
MODULE_PARM_DESC();

MODULE_DEVICE_TABLE(usb, pegasus_ids);
static const struct net_device_ops pegasus_netdev_ops;

/*****/

static void async_ctrl_callback(struct urb *urb)
{}

static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data)
{}

static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size,
			 const void *data)
{}

/*
 * 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.
 */
static int set_register(pegasus_t *pegasus, __u16 indx, __u8 data)
{}

static int update_eth_regs_async(pegasus_t *pegasus)
{}

static int __mii_op(pegasus_t *p, __u8 phy, __u8 indx, __u16 *regd, __u8 cmd)
{}

/* Returns non-negative int on success, error on failure */
static int read_mii_word(pegasus_t *pegasus, __u8 phy, __u8 indx, __u16 *regd)
{}

/* Returns zero on success, error on failure */
static int write_mii_word(pegasus_t *pegasus, __u8 phy, __u8 indx, __u16 *regd)
{}

static int mdio_read(struct net_device *dev, int phy_id, int loc)
{}

static void mdio_write(struct net_device *dev, int phy_id, int loc, int val)
{}

static int read_eprom_word(pegasus_t *pegasus, __u8 index, __u16 *retdata)
{}

#ifdef	PEGASUS_WRITE_EEPROM
static inline void enable_eprom_write(pegasus_t *pegasus)
{
	__u8 tmp;

	get_registers(pegasus, EthCtrl2, 1, &tmp);
	set_register(pegasus, EthCtrl2, tmp | EPROM_WR_ENABLE);
}

static inline void disable_eprom_write(pegasus_t *pegasus)
{
	__u8 tmp;

	get_registers(pegasus, EthCtrl2, 1, &tmp);
	set_register(pegasus, EpromCtrl, 0);
	set_register(pegasus, EthCtrl2, tmp & ~EPROM_WR_ENABLE);
}

static int write_eprom_word(pegasus_t *pegasus, __u8 index, __u16 data)
{
	int i;
	__u8 tmp, d[4] = { 0x3f, 0, 0, EPROM_WRITE };
	int ret;
	__le16 le_data = cpu_to_le16(data);

	set_registers(pegasus, EpromOffset, 4, d);
	enable_eprom_write(pegasus);
	set_register(pegasus, EpromOffset, index);
	set_registers(pegasus, EpromData, 2, &le_data);
	set_register(pegasus, EpromCtrl, EPROM_WRITE);

	for (i = 0; i < REG_TIMEOUT; i++) {
		ret = get_registers(pegasus, EpromCtrl, 1, &tmp);
		if (ret == -ESHUTDOWN)
			goto fail;
		if (tmp & EPROM_DONE)
			break;
	}
	disable_eprom_write(pegasus);
	if (i >= REG_TIMEOUT)
		goto fail;

	return ret;

fail:
	netif_dbg(pegasus, drv, pegasus->net, "%s failed\n", __func__);
	return -ETIMEDOUT;
}
#endif	/* PEGASUS_WRITE_EEPROM */

static inline int get_node_id(pegasus_t *pegasus, u8 *id)
{}

static void set_ethernet_addr(pegasus_t *pegasus)
{}

static inline int reset_mac(pegasus_t *pegasus)
{}

static int enable_net_traffic(struct net_device *dev, struct usb_device *usb)
{}

static void read_bulk_callback(struct urb *urb)
{}

static void rx_fixup(struct tasklet_struct *t)
{}

static void write_bulk_callback(struct urb *urb)
{}

static void intr_callback(struct urb *urb)
{}

static void pegasus_tx_timeout(struct net_device *net, unsigned int txqueue)
{}

static netdev_tx_t pegasus_start_xmit(struct sk_buff *skb,
					    struct net_device *net)
{}

static inline void disable_net_traffic(pegasus_t *pegasus)
{}

static inline int get_interrupt_interval(pegasus_t *pegasus)
{}

static void set_carrier(struct net_device *net)
{}

static void free_all_urbs(pegasus_t *pegasus)
{}

static void unlink_all_urbs(pegasus_t *pegasus)
{}

static int alloc_urbs(pegasus_t *pegasus)
{}

static int pegasus_open(struct net_device *net)
{}

static int pegasus_close(struct net_device *net)
{}

static void pegasus_get_drvinfo(struct net_device *dev,
				struct ethtool_drvinfo *info)
{}

/* also handles three patterns of some kind in hardware */
#define WOL_SUPPORTED

static void
pegasus_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{}

static int
pegasus_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{}

static inline void pegasus_reset_wol(struct net_device *dev)
{}

static int
pegasus_get_link_ksettings(struct net_device *dev,
			   struct ethtool_link_ksettings *ecmd)
{}

static int
pegasus_set_link_ksettings(struct net_device *dev,
			   const struct ethtool_link_ksettings *ecmd)
{}

static int pegasus_nway_reset(struct net_device *dev)
{}

static u32 pegasus_get_link(struct net_device *dev)
{}

static u32 pegasus_get_msglevel(struct net_device *dev)
{}

static void pegasus_set_msglevel(struct net_device *dev, u32 v)
{}

static const struct ethtool_ops ops =;

static int pegasus_siocdevprivate(struct net_device *net, struct ifreq *rq,
				  void __user *udata, int cmd)
{}

static void pegasus_set_multicast(struct net_device *net)
{}

static __u8 mii_phy_probe(pegasus_t *pegasus)
{}

static inline void setup_pegasus_II(pegasus_t *pegasus)
{}

static void check_carrier(struct work_struct *work)
{}

static int pegasus_blacklisted(struct usb_device *udev)
{}

static int pegasus_probe(struct usb_interface *intf,
			 const struct usb_device_id *id)
{}

static void pegasus_disconnect(struct usb_interface *intf)
{}

static int pegasus_suspend(struct usb_interface *intf, pm_message_t message)
{}

static int pegasus_resume(struct usb_interface *intf)
{}

static const struct net_device_ops pegasus_netdev_ops =;

static struct usb_driver pegasus_driver =;

static void __init parse_id(char *id)
{}

static int __init pegasus_init(void)
{}

static void __exit pegasus_exit(void)
{}

module_init();
module_exit(pegasus_exit);