cregit-Linux how code gets into the kernel

Release 4.11 drivers/atm/fore200e.c

Directory: drivers/atm
/*
  A FORE Systems 200E-series driver for ATM on Linux.
  Christophe Lizzi (lizzi@cnam.fr), October 1999-March 2003.

  Based on the PCA-200E driver from Uwe Dannowski (Uwe.Dannowski@inf.tu-dresden.de).

  This driver simultaneously supports PCA-200E and SBA-200E adapters
  on i386, alpha (untested), powerpc, sparc and sparc64 architectures.

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/


#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/capability.h>
#include <linux/interrupt.h>
#include <linux/bitops.h>
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/atmdev.h>
#include <linux/sonet.h>
#include <linux/atm_suni.h>
#include <linux/dma-mapping.h>
#include <linux/delay.h>
#include <linux/firmware.h>
#include <asm/io.h>
#include <asm/string.h>
#include <asm/page.h>
#include <asm/irq.h>
#include <asm/dma.h>
#include <asm/byteorder.h>
#include <linux/uaccess.h>
#include <linux/atomic.h>

#ifdef CONFIG_SBUS
#include <linux/of.h>
#include <linux/of_device.h>
#include <asm/idprom.h>
#include <asm/openprom.h>
#include <asm/oplib.h>
#include <asm/pgtable.h>
#endif

#if defined(CONFIG_ATM_FORE200E_USE_TASKLET) /* defer interrupt work to a tasklet */

#define FORE200E_USE_TASKLET
#endif

#if 0 /* enable the debugging code of the buffer supply queues */
#define FORE200E_BSQ_DEBUG
#endif

#if 1 /* ensure correct handling of 52-byte AAL0 SDUs expected by atmdump-like apps */

#define FORE200E_52BYTE_AAL0_SDU
#endif

#include "fore200e.h"
#include "suni.h"


#define FORE200E_VERSION "0.3e"


#define FORE200E         "fore200e: "

#if 0 /* override .config */
#define CONFIG_ATM_FORE200E_DEBUG 1
#endif
#if defined(CONFIG_ATM_FORE200E_DEBUG) && (CONFIG_ATM_FORE200E_DEBUG > 0)

#define DPRINTK(level, format, args...)  do { if (CONFIG_ATM_FORE200E_DEBUG >= (level)) \
                                                  printk(FORE200E format, ##args); } while (0)
#else

#define DPRINTK(level, format, args...)  do {} while (0)
#endif



#define FORE200E_ALIGN(addr, alignment) \
        ((((unsigned long)(addr) + (alignment - 1)) & ~(alignment - 1)) - (unsigned long)(addr))


#define FORE200E_DMA_INDEX(dma_addr, type, index)  ((dma_addr) + (index) * sizeof(type))


#define FORE200E_INDEX(virt_addr, type, index)     (&((type *)(virt_addr))[ index ])


#define FORE200E_NEXT_ENTRY(index, modulo)         (index = ((index) + 1) % (modulo))

#if 1

#define ASSERT(expr)     if (!(expr)) { \
                             printk(FORE200E "assertion failed! %s[%d]: %s\n", \
                                    __func__, __LINE__, #expr); \
                             panic(FORE200E "%s", __func__); \
                         }
#else

#define ASSERT(expr)     do {} while (0)
#endif



static const struct atmdev_ops   fore200e_ops;

static const struct fore200e_bus fore200e_bus[];

static LIST_HEAD(fore200e_boards);


MODULE_AUTHOR("Christophe Lizzi - credits to Uwe Dannowski and Heikki Vatiainen");
MODULE_DESCRIPTION("FORE Systems 200E-series ATM driver - version " FORE200E_VERSION);
MODULE_SUPPORTED_DEVICE("PCA-200E, SBA-200E");



static const int fore200e_rx_buf_nbr[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ] = {
    { BUFFER_S1_NBR, BUFFER_L1_NBR },
    { BUFFER_S2_NBR, BUFFER_L2_NBR }
};


static const int fore200e_rx_buf_size[ BUFFER_SCHEME_NBR ][ BUFFER_MAGN_NBR ] = {
    { BUFFER_S1_SIZE, BUFFER_L1_SIZE },
    { BUFFER_S2_SIZE, BUFFER_L2_SIZE }
};


#if defined(CONFIG_ATM_FORE200E_DEBUG) && (CONFIG_ATM_FORE200E_DEBUG > 0)

static const char* fore200e_traffic_class[] = { "NONE", "UBR", "CBR", "VBR", "ABR", "ANY" };
#endif


#if 0 /* currently unused */
static int 
fore200e_fore2atm_aal(enum fore200e_aal aal)
{
    switch(aal) {
    case FORE200E_AAL0:  return ATM_AAL0;
    case FORE200E_AAL34: return ATM_AAL34;
    case FORE200E_AAL5:  return ATM_AAL5;
    }

    return -EINVAL;
}
#endif



static enum fore200e_aal fore200e_atm2fore_aal(int aal) { switch(aal) { case ATM_AAL0: return FORE200E_AAL0; case ATM_AAL34: return FORE200E_AAL34; case ATM_AAL1: case ATM_AAL2: case ATM_AAL5: return FORE200E_AAL5; } return -EINVAL; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)44100.00%1100.00%
Total44100.00%1100.00%


static char* fore200e_irq_itoa(int irq) { static char str[8]; sprintf(str, "%d", irq); return str; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)29100.00%1100.00%
Total29100.00%1100.00%

/* allocate and align a chunk of memory intended to hold the data behing exchanged between the driver and the adapter (using streaming DVMA) */
static int fore200e_chunk_alloc(struct fore200e* fore200e, struct chunk* chunk, int size, int alignment, int direction) { unsigned long offset = 0; if (alignment <= sizeof(int)) alignment = 0; chunk->alloc_size = size + alignment; chunk->align_size = size; chunk->direction = direction; chunk->alloc_addr = kzalloc(chunk->alloc_size, GFP_KERNEL | GFP_DMA); if (chunk->alloc_addr == NULL) return -ENOMEM; if (alignment > 0) offset = FORE200E_ALIGN(chunk->alloc_addr, alignment); chunk->align_addr = chunk->alloc_addr + offset; chunk->dma_addr = fore200e->bus->dma_map(fore200e, chunk->align_addr, chunk->align_size, direction); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)14399.31%266.67%
Adrian Bunk10.69%133.33%
Total144100.00%3100.00%

/* free a chunk of memory */
static void fore200e_chunk_free(struct fore200e* fore200e, struct chunk* chunk) { fore200e->bus->dma_unmap(fore200e, chunk->dma_addr, chunk->dma_size, chunk->direction); kfree(chunk->alloc_addr); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4397.73%266.67%
Adrian Bunk12.27%133.33%
Total44100.00%3100.00%


static void fore200e_spin(int msecs) { unsigned long timeout = jiffies + msecs_to_jiffies(msecs); while (time_before(jiffies, timeout)); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2583.33%133.33%
Dave Jones413.33%133.33%
Chas Williams13.33%133.33%
Total30100.00%3100.00%


static int fore200e_poll(struct fore200e* fore200e, volatile u32* addr, u32 val, int msecs) { unsigned long timeout = jiffies + msecs_to_jiffies(msecs); int ok; mb(); do { if ((ok = (*addr == val)) || (*addr & STATUS_ERROR)) break; } while (time_before(jiffies, timeout)); #if 1 if (!ok) { printk(FORE200E "cmd polling failed, got status 0x%08x, expected 0x%08x\n", *addr, val); } #endif return ok; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)9494.95%133.33%
Dave Jones44.04%133.33%
Chas Williams11.01%133.33%
Total99100.00%3100.00%


static int fore200e_io_poll(struct fore200e* fore200e, volatile u32 __iomem *addr, u32 val, int msecs) { unsigned long timeout = jiffies + msecs_to_jiffies(msecs); int ok; do { if ((ok = (fore200e->bus->read(addr) == val))) break; } while (time_before(jiffies, timeout)); #if 1 if (!ok) { printk(FORE200E "I/O polling failed, got status 0x%08x, expected 0x%08x\n", fore200e->bus->read(addr), val); } #endif return ok; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)9694.12%125.00%
Dave Jones43.92%125.00%
Chas Williams10.98%125.00%
Al Viro10.98%125.00%
Total102100.00%4100.00%


static void fore200e_free_rx_buf(struct fore200e* fore200e) { int scheme, magn, nbr; struct buffer* buffer; for (scheme = 0; scheme < BUFFER_SCHEME_NBR; scheme++) { for (magn = 0; magn < BUFFER_MAGN_NBR; magn++) { if ((buffer = fore200e->host_bsq[ scheme ][ magn ].buffer) != NULL) { for (nbr = 0; nbr < fore200e_rx_buf_nbr[ scheme ][ magn ]; nbr++) { struct chunk* data = &buffer[ nbr ].data; if (data->alloc_addr != NULL) fore200e_chunk_free(fore200e, data); } } } } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)124100.00%1100.00%
Total124100.00%1100.00%


static void fore200e_uninit_bs_queue(struct fore200e* fore200e) { int scheme, magn; for (scheme = 0; scheme < BUFFER_SCHEME_NBR; scheme++) { for (magn = 0; magn < BUFFER_MAGN_NBR; magn++) { struct chunk* status = &fore200e->host_bsq[ scheme ][ magn ].status; struct chunk* rbd_block = &fore200e->host_bsq[ scheme ][ magn ].rbd_block; if (status->alloc_addr) fore200e->bus->dma_chunk_free(fore200e, status); if (rbd_block->alloc_addr) fore200e->bus->dma_chunk_free(fore200e, rbd_block); } } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)116100.00%1100.00%
Total116100.00%1100.00%


static int fore200e_reset(struct fore200e* fore200e, int diag) { int ok; fore200e->cp_monitor = fore200e->virt_base + FORE200E_CP_MONITOR_OFFSET; fore200e->bus->write(BSTAT_COLD_START, &fore200e->cp_monitor->bstat); fore200e->bus->reset(fore200e); if (diag) { ok = fore200e_io_poll(fore200e, &fore200e->cp_monitor->bstat, BSTAT_SELFTEST_OK, 1000); if (ok == 0) { printk(FORE200E "device %s self-test failed\n", fore200e->name); return -ENODEV; } printk(FORE200E "device %s self-test passed\n", fore200e->name); fore200e->state = FORE200E_STATE_RESET; } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)117100.00%1100.00%
Total117100.00%1100.00%


static void fore200e_shutdown(struct fore200e* fore200e) { printk(FORE200E "removing device %s at 0x%lx, IRQ %s\n", fore200e->name, fore200e->phys_base, fore200e_irq_itoa(fore200e->irq)); if (fore200e->state > FORE200E_STATE_RESET) { /* first, reset the board to prevent further interrupts or data transfers */ fore200e_reset(fore200e, 0); } /* then, release all allocated resources */ switch(fore200e->state) { case FORE200E_STATE_COMPLETE: kfree(fore200e->stats); case FORE200E_STATE_IRQ: free_irq(fore200e->irq, fore200e->atm_dev); case FORE200E_STATE_ALLOC_BUF: fore200e_free_rx_buf(fore200e); case FORE200E_STATE_INIT_BSQ: fore200e_uninit_bs_queue(fore200e); case FORE200E_STATE_INIT_RXQ: fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_rxq.status); fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_rxq.rpd); case FORE200E_STATE_INIT_TXQ: fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_txq.status); fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_txq.tpd); case FORE200E_STATE_INIT_CMDQ: fore200e->bus->dma_chunk_free(fore200e, &fore200e->host_cmdq.status); case FORE200E_STATE_INITIALIZE: /* nothing to do for that state */ case FORE200E_STATE_START_FW: /* nothing to do for that state */ case FORE200E_STATE_RESET: /* nothing to do for that state */ case FORE200E_STATE_MAP: fore200e->bus->unmap(fore200e); case FORE200E_STATE_CONFIGURE: /* nothing to do for that state */ case FORE200E_STATE_REGISTER: /* XXX shouldn't we *start* by deregistering the device? */ atm_dev_deregister(fore200e->atm_dev); case FORE200E_STATE_BLANK: /* nothing to do for that state */ break; } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)23199.57%150.00%
Linus Torvalds10.43%150.00%
Total232100.00%2100.00%

#ifdef CONFIG_PCI
static u32 fore200e_pca_read(volatile u32 __iomem *addr) { /* on big-endian hosts, the board is configured to convert the endianess of slave RAM accesses */ return le32_to_cpu(readl(addr)); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2195.45%150.00%
Al Viro14.55%150.00%
Total22100.00%2100.00%


static void fore200e_pca_write(u32 val, volatile u32 __iomem *addr) { /* on big-endian hosts, the board is configured to convert the endianess of slave RAM accesses */ writel(cpu_to_le32(val), addr); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2596.15%150.00%
Al Viro13.85%150.00%
Total26100.00%2100.00%


static u32 fore200e_pca_dma_map(struct fore200e* fore200e, void* virt_addr, int size, int direction) { u32 dma_addr = dma_map_single(&((struct pci_dev *) fore200e->bus_dev)->dev, virt_addr, size, direction); DPRINTK(3, "PCI DVMA mapping: virt_addr = 0x%p, size = %d, direction = %d, --> dma_addr = 0x%08x\n", virt_addr, size, direction, dma_addr); return dma_addr; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)5990.77%266.67%
Chas Williams69.23%133.33%
Total65100.00%3100.00%


static void fore200e_pca_dma_unmap(struct fore200e* fore200e, u32 dma_addr, int size, int direction) { DPRINTK(3, "PCI DVMA unmapping: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction); dma_unmap_single(&((struct pci_dev *) fore200e->bus_dev)->dev, dma_addr, size, direction); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)5089.29%266.67%
Chas Williams610.71%133.33%
Total56100.00%3100.00%


static void fore200e_pca_dma_sync_for_cpu(struct fore200e* fore200e, u32 dma_addr, int size, int direction) { DPRINTK(3, "PCI DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction); dma_sync_single_for_cpu(&((struct pci_dev *) fore200e->bus_dev)->dev, dma_addr, size, direction); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)3155.36%250.00%
Andrew Morton1933.93%125.00%
Chas Williams610.71%125.00%
Total56100.00%4100.00%


static void fore200e_pca_dma_sync_for_device(struct fore200e* fore200e, u32 dma_addr, int size, int direction) { DPRINTK(3, "PCI DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction); dma_sync_single_for_device(&((struct pci_dev *) fore200e->bus_dev)->dev, dma_addr, size, direction); }

Contributors

PersonTokensPropCommitsCommitProp
Andrew Morton3257.14%125.00%
Linus Torvalds (pre-git)1832.14%250.00%
Chas Williams610.71%125.00%
Total56100.00%4100.00%

/* allocate a DMA consistent chunk of memory intended to act as a communication mechanism (to hold descriptors, status, queues, etc.) shared by the driver and the adapter */
static int fore200e_pca_dma_chunk_alloc(struct fore200e* fore200e, struct chunk* chunk, int size, int nbr, int alignment) { /* returned chunks are page-aligned */ chunk->alloc_size = size * nbr; chunk->alloc_addr = dma_alloc_coherent(&((struct pci_dev *) fore200e->bus_dev)->dev, chunk->alloc_size, &chunk->dma_addr, GFP_KERNEL); if ((chunk->alloc_addr == NULL) || (chunk->dma_addr == 0)) return -ENOMEM; chunk->align_addr = chunk->alloc_addr; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)7979.80%133.33%
Chas Williams2020.20%266.67%
Total99100.00%3100.00%

/* free a DMA consistent chunk of memory */
static void fore200e_pca_dma_chunk_free(struct fore200e* fore200e, struct chunk* chunk) { dma_free_coherent(&((struct pci_dev *) fore200e->bus_dev)->dev, chunk->alloc_size, chunk->alloc_addr, chunk->dma_addr); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)3986.67%150.00%
Chas Williams613.33%150.00%
Total45100.00%2100.00%


static int fore200e_pca_irq_check(struct fore200e* fore200e) { /* this is a 1 bit register */ int irq_posted = readl(fore200e->regs.pca.psr); #if defined(CONFIG_ATM_FORE200E_DEBUG) && (CONFIG_ATM_FORE200E_DEBUG == 2) if (irq_posted && (readl(fore200e->regs.pca.hcr) & PCA200E_HCR_OUTFULL)) { DPRINTK(2,"FIFO OUT full, device %d\n", fore200e->atm_dev->number); } #endif return irq_posted; }

Contributors

PersonTokensPropCommitsCommitProp
Chas Williams5470.13%150.00%
Linus Torvalds (pre-git)2329.87%150.00%
Total77100.00%2100.00%


static void fore200e_pca_irq_ack(struct fore200e* fore200e) { writel(PCA200E_HCR_CLRINTR, fore200e->regs.pca.hcr); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)24100.00%1100.00%
Total24100.00%1100.00%


static void fore200e_pca_reset(struct fore200e* fore200e) { writel(PCA200E_HCR_RESET, fore200e->regs.pca.hcr); fore200e_spin(10); writel(0, fore200e->regs.pca.hcr); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)42100.00%1100.00%
Total42100.00%1100.00%


static int fore200e_pca_map(struct fore200e* fore200e) { DPRINTK(2, "device %s being mapped in memory\n", fore200e->name); fore200e->virt_base = ioremap(fore200e->phys_base, PCA200E_IOSPACE_LENGTH); if (fore200e->virt_base == NULL) { printk(FORE200E "can't map device %s\n", fore200e->name); return -EFAULT; } DPRINTK(1, "device %s mapped to 0x%p\n", fore200e->name, fore200e->virt_base); /* gain access to the PCA specific registers */ fore200e->regs.pca.hcr = fore200e->virt_base + PCA200E_HCR_OFFSET; fore200e->regs.pca.imr = fore200e->virt_base + PCA200E_IMR_OFFSET; fore200e->regs.pca.psr = fore200e->virt_base + PCA200E_PSR_OFFSET; fore200e->state = FORE200E_STATE_MAP; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)12599.21%150.00%
Chas Williams10.79%150.00%
Total126100.00%2100.00%


static void fore200e_pca_unmap(struct fore200e* fore200e) { DPRINTK(2, "device %s being unmapped from memory\n", fore200e->name); if (fore200e->virt_base != NULL) iounmap(fore200e->virt_base); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)37100.00%1100.00%
Total37100.00%1100.00%


static int fore200e_pca_configure(struct fore200e *fore200e) { struct pci_dev* pci_dev = (struct pci_dev*)fore200e->bus_dev; u8 master_ctrl, latency; DPRINTK(2, "device %s being configured\n", fore200e->name); if ((pci_dev->irq == 0) || (pci_dev->irq == 0xFF)) { printk(FORE200E "incorrect IRQ setting - misconfigured PCI-PCI bridge?\n"); return -EIO; } pci_read_config_byte(pci_dev, PCA200E_PCI_MASTER_CTRL, &master_ctrl); master_ctrl = master_ctrl #if defined(__BIG_ENDIAN) /* request the PCA board to convert the endianess of slave RAM accesses */ | PCA200E_CTRL_CONVERT_ENDIAN #endif #if 0 | PCA200E_CTRL_DIS_CACHE_RD | PCA200E_CTRL_DIS_WRT_INVAL | PCA200E_CTRL_ENA_CONT_REQ_MODE | PCA200E_CTRL_2_CACHE_WRT_INVAL #endif | PCA200E_CTRL_LARGE_PCI_BURSTS; pci_write_config_byte(pci_dev, PCA200E_PCI_MASTER_CTRL, master_ctrl); /* raise latency from 32 (default) to 192, as this seems to prevent NIC lockups (under heavy rx loads) due to continuous 'FIFO OUT full' condition. this may impact the performances of other PCI devices on the same bus, though */ latency = 192; pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, latency); fore200e->state = FORE200E_STATE_CONFIGURE; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)11483.82%150.00%
Chas Williams2216.18%150.00%
Total136100.00%2100.00%


static int __init fore200e_pca_prom_read(struct fore200e* fore200e, struct prom_data* prom) { struct host_cmdq* cmdq = &fore200e->host_cmdq; struct host_cmdq_entry* entry = &cmdq->host_entry[ cmdq->head ]; struct prom_opcode opcode; int ok; u32 prom_dma; FORE200E_NEXT_ENTRY(cmdq->head, QUEUE_SIZE_CMD); opcode.opcode = OPCODE_GET_PROM; opcode.pad = 0; prom_dma = fore200e->bus->dma_map(fore200e, prom, sizeof(struct prom_data), DMA_FROM_DEVICE); fore200e->bus->write(prom_dma, &entry->cp_entry->cmd.prom_block.prom_haddr); *entry->status = STATUS_PENDING; fore200e->bus->write(*(u32*)&opcode, (u32 __iomem *)&entry->cp_entry->cmd.prom_block.opcode); ok = fore200e_poll(fore200e, entry->status, STATUS_COMPLETE, 400); *entry->status = STATUS_FREE; fore200e->bus->dma_unmap(fore200e, prom_dma, sizeof(struct prom_data), DMA_FROM_DEVICE); if (ok == 0) { printk(FORE200E "unable to get PROM data from device %s\n", fore200e->name); return -EIO; } #if defined(__BIG_ENDIAN) #define swap_here(addr) (*((u32*)(addr)) = swab32( *((u32*)(addr)) )) /* MAC address is stored as little-endian */ swap_here(&prom->mac_addr[0]); swap_here(&prom->mac_addr[4]); #endif return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)25398.83%250.00%
Christoph Hellwig20.78%125.00%
Al Viro10.39%125.00%
Total256100.00%4100.00%


static int fore200e_pca_proc_read(struct fore200e* fore200e, char *page) { struct pci_dev* pci_dev = (struct pci_dev*)fore200e->bus_dev; return sprintf(page, " PCI bus/slot/function:\t%d/%d/%d\n", pci_dev->bus->number, PCI_SLOT(pci_dev->devfn), PCI_FUNC(pci_dev->devfn)); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)57100.00%1100.00%
Total57100.00%1100.00%

#endif /* CONFIG_PCI */ #ifdef CONFIG_SBUS
static u32 fore200e_sba_read(volatile u32 __iomem *addr) { return sbus_readl(addr); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1794.44%150.00%
Al Viro15.56%150.00%
Total18100.00%2100.00%


static void fore200e_sba_write(u32 val, volatile u32 __iomem *addr) { sbus_writel(val, addr); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)2195.45%150.00%
Al Viro14.55%150.00%
Total22100.00%2100.00%


static u32 fore200e_sba_dma_map(struct fore200e *fore200e, void* virt_addr, int size, int direction) { struct platform_device *op = fore200e->bus_dev; u32 dma_addr; dma_addr = dma_map_single(&op->dev, virt_addr, size, direction); DPRINTK(3, "SBUS DVMA mapping: virt_addr = 0x%p, size = %d, direction = %d --> dma_addr = 0x%08x\n", virt_addr, size, direction, dma_addr); return dma_addr; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4973.13%233.33%
David S. Miller1725.37%350.00%
Grant C. Likely11.49%116.67%
Total67100.00%6100.00%


static void fore200e_sba_dma_unmap(struct fore200e *fore200e, u32 dma_addr, int size, int direction) { struct platform_device *op = fore200e->bus_dev; DPRINTK(3, "SBUS DVMA unmapping: dma_addr = 0x%08x, size = %d, direction = %d,\n", dma_addr, size, direction); dma_unmap_single(&op->dev, dma_addr, size, direction); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4275.00%233.33%
David S. Miller1323.21%350.00%
Grant C. Likely11.79%116.67%
Total56100.00%6100.00%


static void fore200e_sba_dma_sync_for_cpu(struct fore200e *fore200e, u32 dma_addr, int size, int direction) { struct platform_device *op = fore200e->bus_dev; DPRINTK(3, "SBUS DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction); dma_sync_single_for_cpu(&op->dev, dma_addr, size, direction); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)3155.36%228.57%
David S. Miller1323.21%342.86%
Andrew Morton1119.64%114.29%
Grant C. Likely11.79%114.29%
Total56100.00%7100.00%


static void fore200e_sba_dma_sync_for_device(struct fore200e *fore200e, u32 dma_addr, int size, int direction) { struct platform_device *op = fore200e->bus_dev; DPRINTK(3, "SBUS DVMA sync: dma_addr = 0x%08x, size = %d, direction = %d\n", dma_addr, size, direction); dma_sync_single_for_device(&op->dev, dma_addr, size, direction); }

Contributors

PersonTokensPropCommitsCommitProp
Andrew Morton3257.14%114.29%
David S. Miller1323.21%342.86%
Linus Torvalds (pre-git)1017.86%228.57%
Grant C. Likely11.79%114.29%
Total56100.00%7100.00%

/* Allocate a DVMA consistent chunk of memory intended to act as a communication mechanism * (to hold descriptors, status, queues, etc.) shared by the driver and the adapter. */
static int fore200e_sba_dma_chunk_alloc(struct fore200e *fore200e, struct chunk *chunk, int size, int nbr, int alignment) { struct platform_device *op = fore200e->bus_dev; chunk->alloc_size = chunk->align_size = size * nbr; /* returned chunks are page-aligned */ chunk->alloc_addr = dma_alloc_coherent(&op->dev, chunk->alloc_size, &chunk->dma_addr, GFP_ATOMIC); if ((chunk->alloc_addr == NULL) || (chunk->dma_addr == 0)) return -ENOMEM; chunk->align_addr = chunk->alloc_addr; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)8380.58%116.67%
David S. Miller1514.56%350.00%
Chas Williams43.88%116.67%
Grant C. Likely10.97%116.67%
Total103100.00%6100.00%

/* free a DVMA consistent chunk of memory */
static void fore200e_sba_dma_chunk_free(struct fore200e *fore200e, struct chunk *chunk) { struct platform_device *op = fore200e->bus_dev; dma_free_coherent(&op->dev, chunk->alloc_size, chunk->alloc_addr, chunk->dma_addr)