linux/drivers/atm/nicstar.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * nicstar.c
 *
 * Device driver supporting CBR for IDT 77201/77211 "NICStAR" based cards.
 *
 * IMPORTANT: The included file nicstarmac.c was NOT WRITTEN BY ME.
 *            It was taken from the frle-0.22 device driver.
 *            As the file doesn't have a copyright notice, in the file
 *            nicstarmac.copyright I put the copyright notice from the
 *            frle-0.22 device driver.
 *            Some code is based on the nicstar driver by M. Welsh.
 *
 * Author: Rui Prior ([email protected])
 * PowerPC support by Jay Talbott ([email protected]) April 1999
 *
 *
 * (C) INESC 1999
 */

/*
 * IMPORTANT INFORMATION
 *
 * There are currently three types of spinlocks:
 *
 * 1 - Per card interrupt spinlock (to protect structures and such)
 * 2 - Per SCQ scq spinlock
 * 3 - Per card resource spinlock (to access registers, etc.)
 *
 * These must NEVER be grabbed in reverse order.
 *
 */

/* Header files */

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/skbuff.h>
#include <linux/atmdev.h>
#include <linux/atm.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/types.h>
#include <linux/string.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/timer.h>
#include <linux/interrupt.h>
#include <linux/bitops.h>
#include <linux/slab.h>
#include <linux/idr.h>
#include <asm/io.h>
#include <linux/uaccess.h>
#include <linux/atomic.h>
#include <linux/etherdevice.h>
#include "nicstar.h"
#ifdef CONFIG_ATM_NICSTAR_USE_SUNI
#include "suni.h"
#endif /* CONFIG_ATM_NICSTAR_USE_SUNI */
#ifdef CONFIG_ATM_NICSTAR_USE_IDT77105
#include "idt77105.h"
#endif /* CONFIG_ATM_NICSTAR_USE_IDT77105 */

/* Additional code */

#include "nicstarmac.c"

/* Configurable parameters */

#undef PHY_LOOPBACK
#undef TX_DEBUG
#undef RX_DEBUG
#undef GENERAL_DEBUG
#undef EXTRA_DEBUG

/* Do not touch these */

#ifdef TX_DEBUG
#define TXPRINTK
#else
#define TXPRINTK(args...)
#endif /* TX_DEBUG */

#ifdef RX_DEBUG
#define RXPRINTK
#else
#define RXPRINTK(args...)
#endif /* RX_DEBUG */

#ifdef GENERAL_DEBUG
#define PRINTK
#else
#define PRINTK(args...)
#endif /* GENERAL_DEBUG */

#ifdef EXTRA_DEBUG
#define XPRINTK
#else
#define XPRINTK(args...)
#endif /* EXTRA_DEBUG */

/* Macros */

#define CMD_BUSY(card)

#define NS_DELAY

#define PTR_DIFF(a, b)

#ifndef ATM_SKB
#define ATM_SKB
#endif

#define scq_virt_to_bus(scq, p)

/* Function declarations */

static u32 ns_read_sram(ns_dev * card, u32 sram_address);
static void ns_write_sram(ns_dev * card, u32 sram_address, u32 * value,
			  int count);
static int ns_init_card(int i, struct pci_dev *pcidev);
static void ns_init_card_error(ns_dev * card, int error);
static scq_info *get_scq(ns_dev *card, int size, u32 scd);
static void free_scq(ns_dev *card, scq_info * scq, struct atm_vcc *vcc);
static void push_rxbufs(ns_dev *, struct sk_buff *);
static irqreturn_t ns_irq_handler(int irq, void *dev_id);
static int ns_open(struct atm_vcc *vcc);
static void ns_close(struct atm_vcc *vcc);
static void fill_tst(ns_dev * card, int n, vc_map * vc);
static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb);
static int ns_send_bh(struct atm_vcc *vcc, struct sk_buff *skb);
static int push_scqe(ns_dev * card, vc_map * vc, scq_info * scq, ns_scqe * tbd,
		     struct sk_buff *skb, bool may_sleep);
static void process_tsq(ns_dev * card);
static void drain_scq(ns_dev * card, scq_info * scq, int pos);
static void process_rsq(ns_dev * card);
static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe);
static void recycle_rx_buf(ns_dev * card, struct sk_buff *skb);
static void recycle_iovec_rx_bufs(ns_dev * card, struct iovec *iov, int count);
static void recycle_iov_buf(ns_dev * card, struct sk_buff *iovb);
static void dequeue_sm_buf(ns_dev * card, struct sk_buff *sb);
static void dequeue_lg_buf(ns_dev * card, struct sk_buff *lb);
static int ns_proc_read(struct atm_dev *dev, loff_t * pos, char *page);
static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user * arg);
#ifdef EXTRA_DEBUG
static void which_list(ns_dev * card, struct sk_buff *skb);
#endif
static void ns_poll(struct timer_list *unused);
static void ns_phy_put(struct atm_dev *dev, unsigned char value,
		       unsigned long addr);
static unsigned char ns_phy_get(struct atm_dev *dev, unsigned long addr);

/* Global variables */

static struct ns_dev *cards[NS_MAX_CARDS];
static unsigned num_cards;
static const struct atmdev_ops atm_ops =;

static struct timer_list ns_timer;
static char *mac[NS_MAX_CARDS];
module_param_array();
MODULE_DESCRIPTION();
MODULE_LICENSE();

/* Functions */

static int nicstar_init_one(struct pci_dev *pcidev,
			    const struct pci_device_id *ent)
{}

static void nicstar_remove_one(struct pci_dev *pcidev)
{}

static const struct pci_device_id nicstar_pci_tbl[] =;

MODULE_DEVICE_TABLE(pci, nicstar_pci_tbl);

static struct pci_driver nicstar_driver =;

static int __init nicstar_init(void)
{}

static void __exit nicstar_cleanup(void)
{}

static u32 ns_read_sram(ns_dev * card, u32 sram_address)
{}

static void ns_write_sram(ns_dev * card, u32 sram_address, u32 * value,
			  int count)
{}

static int ns_init_card(int i, struct pci_dev *pcidev)
{}

static void ns_init_card_error(ns_dev *card, int error)
{}

static scq_info *get_scq(ns_dev *card, int size, u32 scd)
{}

/* For variable rate SCQ vcc must be NULL */
static void free_scq(ns_dev *card, scq_info *scq, struct atm_vcc *vcc)
{}

/* The handles passed must be pointers to the sk_buff containing the small
   or large buffer(s) cast to u32. */
static void push_rxbufs(ns_dev * card, struct sk_buff *skb)
{}

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

static int ns_open(struct atm_vcc *vcc)
{}

static void ns_close(struct atm_vcc *vcc)
{}

static void fill_tst(ns_dev * card, int n, vc_map * vc)
{}

static int _ns_send(struct atm_vcc *vcc, struct sk_buff *skb, bool may_sleep)
{}

static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
{}

static int ns_send_bh(struct atm_vcc *vcc, struct sk_buff *skb)
{}

static int push_scqe(ns_dev * card, vc_map * vc, scq_info * scq, ns_scqe * tbd,
		     struct sk_buff *skb, bool may_sleep)
{}

static void process_tsq(ns_dev * card)
{}

static void drain_scq(ns_dev * card, scq_info * scq, int pos)
{}

static void process_rsq(ns_dev * card)
{}

static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
{}

static void recycle_rx_buf(ns_dev * card, struct sk_buff *skb)
{}

static void recycle_iovec_rx_bufs(ns_dev * card, struct iovec *iov, int count)
{}

static void recycle_iov_buf(ns_dev * card, struct sk_buff *iovb)
{}

static void dequeue_sm_buf(ns_dev * card, struct sk_buff *sb)
{}

static void dequeue_lg_buf(ns_dev * card, struct sk_buff *lb)
{}

static int ns_proc_read(struct atm_dev *dev, loff_t * pos, char *page)
{}

static int ns_ioctl(struct atm_dev *dev, unsigned int cmd, void __user * arg)
{}

#ifdef EXTRA_DEBUG
static void which_list(ns_dev * card, struct sk_buff *skb)
{
	printk("skb buf_type: 0x%08x\n", NS_PRV_BUFTYPE(skb));
}
#endif /* EXTRA_DEBUG */

static void ns_poll(struct timer_list *unused)
{}

static void ns_phy_put(struct atm_dev *dev, unsigned char value,
		       unsigned long addr)
{}

static unsigned char ns_phy_get(struct atm_dev *dev, unsigned long addr)
{}

module_init();
module_exit(nicstar_cleanup);