linux/drivers/net/ethernet/dec/tulip/dmfe.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
    A Davicom DM9102/DM9102A/DM9102A+DM9801/DM9102A+DM9802 NIC fast
    ethernet driver for Linux.
    Copyright (C) 1997  Sten Wang


    DAVICOM Web-Site: www.davicom.com.tw

    Author: Sten Wang, 886-3-5798797-8517, E-mail: [email protected]
    Maintainer: Tobias Ringstrom <[email protected]>

    (C)Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.

    Marcelo Tosatti <[email protected]> :
    Made it compile in 2.3 (device to net_device)

    Alan Cox <[email protected]> :
    Cleaned up for kernel merge.
    Removed the back compatibility support
    Reformatted, fixing spelling etc as I went
    Removed IRQ 0-15 assumption

    Jeff Garzik <[email protected]> :
    Updated to use new PCI driver API.
    Resource usage cleanups.
    Report driver version to user.

    Tobias Ringstrom <[email protected]> :
    Cleaned up and added SMP safety.  Thanks go to Jeff Garzik,
    Andrew Morton and Frank Davis for the SMP safety fixes.

    Vojtech Pavlik <[email protected]> :
    Cleaned up pointer arithmetics.
    Fixed a lot of 64bit issues.
    Cleaned up printk()s a bit.
    Fixed some obvious big endian problems.

    Tobias Ringstrom <[email protected]> :
    Use time_after for jiffies calculation.  Added ethtool
    support.  Updated PCI resource allocation.  Do not
    forget to unmap PCI mapped skbs.

    Alan Cox <[email protected]>
    Added new PCI identifiers provided by Clear Zhang at ALi
    for their 1563 ethernet device.

    TODO

    Check on 64 bit boxes.
    Check and fix on big endian boxes.

    Test and make sure PCI latency is now correct for all cases.
*/

#define pr_fmt(fmt)

#define DRV_NAME

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/ptrace.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/skbuff.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/crc32.h>
#include <linux/bitops.h>

#include <asm/processor.h>
#include <asm/io.h>
#include <asm/dma.h>
#include <linux/uaccess.h>
#include <asm/irq.h>

#ifdef CONFIG_TULIP_DM910X
#include <linux/of.h>
#endif


/* Board/System/Debug information/definition ---------------- */
#define PCI_DM9132_ID
#define PCI_DM9102_ID
#define PCI_DM9100_ID
#define PCI_DM9009_ID

#define DM9102_IO_SIZE
#define DM9102A_IO_SIZE
#define TX_MAX_SEND_CNT
#define TX_DESC_CNT
#define RX_DESC_CNT
#define TX_FREE_DESC_CNT
#define TX_WAKE_DESC_CNT
#define DESC_ALL_CNT
#define TX_BUF_ALLOC
#define RX_ALLOC_SIZE
#define DM910X_RESET
#define CR0_DEFAULT
#define CR6_DEFAULT
#define CR7_DEFAULT
#define CR15_DEFAULT
#define TDES0_ERR_MASK
#define MAX_PACKET_SIZE
#define DMFE_MAX_MULTICAST
#define RX_COPY_SIZE
#define MAX_CHECK_PACKET
#define DM9801_NOISE_FLOOR
#define DM9802_NOISE_FLOOR

#define DMFE_WOL_LINKCHANGE
#define DMFE_WOL_SAMPLEPACKET
#define DMFE_WOL_MAGICPACKET


#define DMFE_10MHF
#define DMFE_100MHF
#define DMFE_10MFD
#define DMFE_100MFD
#define DMFE_AUTO
#define DMFE_1M_HPNA

#define DMFE_TXTH_72
#define DMFE_TXTH_96
#define DMFE_TXTH_128
#define DMFE_TXTH_256
#define DMFE_TXTH_512
#define DMFE_TXTH_1K

#define DMFE_TIMER_WUT
#define DMFE_TX_TIMEOUT
#define DMFE_TX_KICK

#define dw32(reg, val)
#define dw16(reg, val)
#define dr32(reg)
#define dr16(reg)
#define dr8(reg)

#define DMFE_DBUG(dbug_now, msg, value)

#define SHOW_MEDIA_TYPE(mode)


/* CR9 definition: SROM/MII */
#define CR9_SROM_READ
#define CR9_SRCS
#define CR9_SRCLK
#define CR9_CRDOUT
#define SROM_DATA_0
#define SROM_DATA_1
#define PHY_DATA_1
#define PHY_DATA_0
#define MDCLKH

#define PHY_POWER_DOWN

#define SROM_V41_CODE

#define __CHK_IO_SIZE(pci_id, dev_rev)

#define CHK_IO_SIZE(pci_dev)

/* Structure/enum declaration ------------------------------- */
struct tx_desc {} __attribute__(( aligned ));

struct rx_desc {} __attribute__(( aligned ));

struct dmfe_board_info {};

enum dmfe_offsets {};

enum dmfe_CR6_bits {};

/* Global variable declaration ----------------------------- */
static int dmfe_debug;
static unsigned char dmfe_media_mode =;
static u32 dmfe_cr6_user_set;

/* For module input parameter */
static int debug;
static u32 cr6set;
static unsigned char mode =;
static u8 chkmode =;
static u8 HPNA_mode;		/* Default: Low Power/High Speed */
static u8 HPNA_rx_cmd;		/* Default: Disable Rx remote command */
static u8 HPNA_tx_cmd;		/* Default: Don't issue remote command */
static u8 HPNA_NoiseFloor;	/* Default: HPNA NoiseFloor */
static u8 SF_mode;		/* Special Function: 1:VLAN, 2:RX Flow Control
				   4: TX pause packet */


/* function declaration ------------------------------------- */
static int dmfe_open(struct net_device *);
static netdev_tx_t dmfe_start_xmit(struct sk_buff *, struct net_device *);
static int dmfe_stop(struct net_device *);
static void dmfe_set_filter_mode(struct net_device *);
static const struct ethtool_ops netdev_ethtool_ops;
static u16 read_srom_word(void __iomem *, int);
static irqreturn_t dmfe_interrupt(int , void *);
#ifdef CONFIG_NET_POLL_CONTROLLER
static void poll_dmfe (struct net_device *dev);
#endif
static void dmfe_descriptor_init(struct net_device *);
static void allocate_rx_buffer(struct net_device *);
static void update_cr6(u32, void __iomem *);
static void send_filter_frame(struct net_device *);
static void dm9132_id_table(struct net_device *);
static u16 dmfe_phy_read(void __iomem *, u8, u8, u32);
static void dmfe_phy_write(void __iomem *, u8, u8, u16, u32);
static void dmfe_phy_write_1bit(void __iomem *, u32);
static u16 dmfe_phy_read_1bit(void __iomem *);
static u8 dmfe_sense_speed(struct dmfe_board_info *);
static void dmfe_process_mode(struct dmfe_board_info *);
static void dmfe_timer(struct timer_list *);
static inline u32 cal_CRC(unsigned char *, unsigned int, u8);
static void dmfe_rx_packet(struct net_device *, struct dmfe_board_info *);
static void dmfe_free_tx_pkt(struct net_device *, struct dmfe_board_info *);
static void dmfe_reuse_skb(struct dmfe_board_info *, struct sk_buff *);
static void dmfe_dynamic_reset(struct net_device *);
static void dmfe_free_rxbuffer(struct dmfe_board_info *);
static void dmfe_init_dm910x(struct net_device *);
static void dmfe_parse_srom(struct dmfe_board_info *);
static void dmfe_program_DM9801(struct dmfe_board_info *, int);
static void dmfe_program_DM9802(struct dmfe_board_info *);
static void dmfe_HPNA_remote_cmd_chk(struct dmfe_board_info * );
static void dmfe_set_phyxcer(struct dmfe_board_info *);

/* DM910X network board routine ---------------------------- */

static const struct net_device_ops netdev_ops =;

/*
 *	Search DM910X board ,allocate space and register it
 */

static int dmfe_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{}


static void dmfe_remove_one(struct pci_dev *pdev)
{}


/*
 *	Open the interface.
 *	The interface is opened whenever "ifconfig" actives it.
 */

static int dmfe_open(struct net_device *dev)
{}


/*	Initialize DM910X board
 *	Reset DM910X board
 *	Initialize TX/Rx descriptor chain structure
 *	Send the set-up frame
 *	Enable Tx/Rx machine
 */

static void dmfe_init_dm910x(struct net_device *dev)
{}


/*
 *	Hardware start transmission.
 *	Send a packet to media from the upper layer.
 */

static netdev_tx_t dmfe_start_xmit(struct sk_buff *skb,
					 struct net_device *dev)
{}


/*
 *	Stop the interface.
 *	The interface is stopped when it is brought.
 */

static int dmfe_stop(struct net_device *dev)
{}


/*
 *	DM9102 insterrupt handler
 *	receive the packet to upper layer, free the transmitted packet
 */

static irqreturn_t dmfe_interrupt(int irq, void *dev_id)
{}


#ifdef CONFIG_NET_POLL_CONTROLLER
/*
 * Polling 'interrupt' - used by things like netconsole to send skbs
 * without having to re-enable interrupts. It's not called while
 * the interrupt routine is executing.
 */

static void poll_dmfe (struct net_device *dev)
{}
#endif

/*
 *	Free TX resource after TX complete
 */

static void dmfe_free_tx_pkt(struct net_device *dev, struct dmfe_board_info *db)
{}


/*
 *	Calculate the CRC valude of the Rx packet
 *	flag = 	1 : return the reverse CRC (for the received packet CRC)
 *		0 : return the normal CRC (for Hash Table index)
 */

static inline u32 cal_CRC(unsigned char * Data, unsigned int Len, u8 flag)
{}


/*
 *	Receive the come packet and pass to upper layer
 */

static void dmfe_rx_packet(struct net_device *dev, struct dmfe_board_info *db)
{}

/*
 * Set DM910X multicast address
 */

static void dmfe_set_filter_mode(struct net_device *dev)
{}

/*
 * 	Ethtool interace
 */

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

static int dmfe_ethtool_set_wol(struct net_device *dev,
				struct ethtool_wolinfo *wolinfo)
{}

static void dmfe_ethtool_get_wol(struct net_device *dev,
				 struct ethtool_wolinfo *wolinfo)
{}


static const struct ethtool_ops netdev_ethtool_ops =;

/*
 *	A periodic timer routine
 *	Dynamic media sense, allocate Rx buffer...
 */

static void dmfe_timer(struct timer_list *t)
{}


/*
 *	Dynamic reset the DM910X board
 *	Stop DM910X board
 *	Free Tx/Rx allocated memory
 *	Reset DM910X board
 *	Re-initialize DM910X board
 */

static void dmfe_dynamic_reset(struct net_device *dev)
{}


/*
 *	free all allocated rx buffer
 */

static void dmfe_free_rxbuffer(struct dmfe_board_info * db)
{}


/*
 *	Reuse the SK buffer
 */

static void dmfe_reuse_skb(struct dmfe_board_info *db, struct sk_buff * skb)
{}


/*
 *	Initialize transmit/Receive descriptor
 *	Using Chain structure, and allocate Tx/Rx buffer
 */

static void dmfe_descriptor_init(struct net_device *dev)
{}


/*
 *	Update CR6 value
 *	Firstly stop DM910X , then written value and start
 */

static void update_cr6(u32 cr6_data, void __iomem *ioaddr)
{}


/*
 *	Send a setup frame for DM9132
 *	This setup frame initialize DM910X address filter mode
*/

static void dm9132_id_table(struct net_device *dev)
{}


/*
 *	Send a setup frame for DM9102/DM9102A
 *	This setup frame initialize DM910X address filter mode
 */

static void send_filter_frame(struct net_device *dev)
{}


/*
 *	Allocate rx buffer,
 *	As possible as allocate maxiumn Rx buffer
 */

static void allocate_rx_buffer(struct net_device *dev)
{}

static void srom_clk_write(void __iomem *ioaddr, u32 data)
{}

/*
 *	Read one word data from the serial ROM
 */
static u16 read_srom_word(void __iomem *ioaddr, int offset)
{}


/*
 *	Auto sense the media mode
 */

static u8 dmfe_sense_speed(struct dmfe_board_info *db)
{}


/*
 *	Set 10/100 phyxcer capability
 *	AUTO mode : phyxcer register4 is NIC capability
 *	Force mode: phyxcer register4 is the force media
 */

static void dmfe_set_phyxcer(struct dmfe_board_info *db)
{}


/*
 *	Process op-mode
 *	AUTO mode : PHY controller in Auto-negotiation Mode
 *	Force mode: PHY controller in force mode with HUB
 *			N-way force capability with SWITCH
 */

static void dmfe_process_mode(struct dmfe_board_info *db)
{}


/*
 *	Write a word to Phy register
 */

static void dmfe_phy_write(void __iomem *ioaddr, u8 phy_addr, u8 offset,
			   u16 phy_data, u32 chip_id)
{}


/*
 *	Read a word data from phy register
 */

static u16 dmfe_phy_read(void __iomem *ioaddr, u8 phy_addr, u8 offset, u32 chip_id)
{}


/*
 *	Write one bit data to Phy Controller
 */

static void dmfe_phy_write_1bit(void __iomem *ioaddr, u32 phy_data)
{}


/*
 *	Read one bit phy data from PHY controller
 */

static u16 dmfe_phy_read_1bit(void __iomem *ioaddr)
{}


/*
 *	Parser SROM and media mode
 */

static void dmfe_parse_srom(struct dmfe_board_info * db)
{}


/*
 *	Init HomeRun DM9801
 */

static void dmfe_program_DM9801(struct dmfe_board_info * db, int HPNA_rev)
{}


/*
 *	Init HomeRun DM9802
 */

static void dmfe_program_DM9802(struct dmfe_board_info * db)
{}


/*
 *	Check remote HPNA power and speed status. If not correct,
 *	issue command again.
*/

static void dmfe_HPNA_remote_cmd_chk(struct dmfe_board_info * db)
{}



static const struct pci_device_id dmfe_pci_tbl[] =;
MODULE_DEVICE_TABLE(pci, dmfe_pci_tbl);

static int __maybe_unused dmfe_suspend(struct device *dev_d)
{}

static int __maybe_unused dmfe_resume(struct device *dev_d)
{}

static SIMPLE_DEV_PM_OPS(dmfe_pm_ops, dmfe_suspend, dmfe_resume);

static struct pci_driver dmfe_driver =;

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

module_param(debug, int, 0);
module_param(mode, byte, 0);
module_param(cr6set, int, 0);
module_param(chkmode, byte, 0);
module_param(HPNA_mode, byte, 0);
module_param(HPNA_rx_cmd, byte, 0);
module_param(HPNA_tx_cmd, byte, 0);
module_param(HPNA_NoiseFloor, byte, 0);
module_param(SF_mode, byte, 0);
MODULE_PARM_DESC();
MODULE_PARM_DESC();

MODULE_PARM_DESC();

/*	Description:
 *	when user used insmod to add module, system invoked init_module()
 *	to initialize and register.
 */

static int __init dmfe_init_module(void)
{}


/*
 *	Description:
 *	when user used rmmod to delete module, system invoked clean_module()
 *	to un-register all registered services.
 */

static void __exit dmfe_cleanup_module(void)
{}

module_init();
module_exit(dmfe_cleanup_module);