linux/drivers/net/usb/net1080.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Net1080 based USB host-to-host cables
 * Copyright (C) 2000-2005 by David Brownell
 */

// #define	DEBUG			// error path messages, extra info
// #define	VERBOSE			// more; success messages

#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/workqueue.h>
#include <linux/mii.h>
#include <linux/usb.h>
#include <linux/usb/usbnet.h>
#include <linux/slab.h>

#include <linux/unaligned.h>


/*
 * Netchip 1080 driver ... http://www.netchip.com
 * (Sept 2004:  End-of-life announcement has been sent.)
 * Used in (some) LapLink cables
 */

#define frame_errors

/*
 * NetChip framing of ethernet packets, supporting additional error
 * checks for links that may drop bulk packets from inside messages.
 * Odd USB length == always short read for last usb packet.
 *	- nc_header
 *	- Ethernet header (14 bytes)
 *	- payload
 *	- (optional padding byte, if needed so length becomes odd)
 *	- nc_trailer
 *
 * This framing is to be avoided for non-NetChip devices.
 */

struct nc_header {} __packed;

#define PAD_BYTE

struct nc_trailer {} __packed;

// packets may use FLAG_FRAMING_NC and optional pad
#define FRAMED_SIZE(mtu)

#define MIN_FRAMED

/* packets _could_ be up to 64KB... */
#define NC_MAX_PACKET


/*
 * Zero means no timeout; else, how long a 64 byte bulk packet may be queued
 * before the hardware drops it.  If that's done, the driver will need to
 * frame network packets to guard against the dropped USB packets.  The win32
 * driver sets this for both sides of the link.
 */
#define NC_READ_TTL_MS

/*
 * We ignore most registers and EEPROM contents.
 */
#define REG_USBCTL
#define REG_TTL
#define REG_STATUS

/*
 * Vendor specific requests to read/write data
 */
#define REQUEST_REGISTER
#define REQUEST_EEPROM

static int
nc_vendor_read(struct usbnet *dev, u8 req, u8 regnum, u16 *retval_ptr)
{}

static inline int
nc_register_read(struct usbnet *dev, u8 regnum, u16 *retval_ptr)
{}

static void
nc_vendor_write(struct usbnet *dev, u8 req, u8 regnum, u16 value)
{}

static inline void
nc_register_write(struct usbnet *dev, u8 regnum, u16 value)
{}


#if 0
static void nc_dump_registers(struct usbnet *dev)
{
	u8	reg;
	u16	*vp = kmalloc(sizeof (u16));

	if (!vp)
		return;

	netdev_dbg(dev->net, "registers:\n");
	for (reg = 0; reg < 0x20; reg++) {
		int retval;

		// reading some registers is trouble
		if (reg >= 0x08 && reg <= 0xf)
			continue;
		if (reg >= 0x12 && reg <= 0x1e)
			continue;

		retval = nc_register_read(dev, reg, vp);
		if (retval < 0)
			netdev_dbg(dev->net, "reg [0x%x] ==> error %d\n",
				   reg, retval);
		else
			netdev_dbg(dev->net, "reg [0x%x] = 0x%x\n", reg, *vp);
	}
	kfree(vp);
}
#endif


/*-------------------------------------------------------------------------*/

/*
 * Control register
 */

#define USBCTL_WRITABLE_MASK
// bits 15-13 reserved, r/o
#define USBCTL_ENABLE_LANG
#define USBCTL_ENABLE_MFGR
#define USBCTL_ENABLE_PROD
#define USBCTL_ENABLE_SERIAL
#define USBCTL_ENABLE_DEFAULTS
// bits 7-4 reserved, r/o
#define USBCTL_FLUSH_OTHER
#define USBCTL_FLUSH_THIS
#define USBCTL_DISCONN_OTHER
#define USBCTL_DISCONN_THIS

static inline void nc_dump_usbctl(struct usbnet *dev, u16 usbctl)
{}

/*-------------------------------------------------------------------------*/

/*
 * Status register
 */

#define STATUS_PORT_A

#define STATUS_CONN_OTHER
#define STATUS_SUSPEND_OTHER
#define STATUS_MAILBOX_OTHER
#define STATUS_PACKETS_OTHER(n)

#define STATUS_CONN_THIS
#define STATUS_SUSPEND_THIS
#define STATUS_MAILBOX_THIS
#define STATUS_PACKETS_THIS(n)

#define STATUS_UNSPEC_MASK
#define STATUS_NOISE_MASK


static inline void nc_dump_status(struct usbnet *dev, u16 status)
{}

/*-------------------------------------------------------------------------*/

/*
 * TTL register
 */

#define TTL_OTHER(ttl)
#define MK_TTL(this,other)

/*-------------------------------------------------------------------------*/

static int net1080_reset(struct usbnet *dev)
{}

static int net1080_check_connect(struct usbnet *dev)
{}

static void nc_ensure_sync(struct usbnet *dev)
{}

static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
{}

static struct sk_buff *
net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
{}

static int net1080_bind(struct usbnet *dev, struct usb_interface *intf)
{}

static const struct driver_info	net1080_info =;

static const struct usb_device_id	products [] =;
MODULE_DEVICE_TABLE(usb, products);

static struct usb_driver net1080_driver =;

module_usb_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();