You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
This commit is contained in:
@@ -0,0 +1,188 @@
|
||||
# -*- shell-script -*-
|
||||
|
||||
menu "IEEE 1394 (FireWire) support"
|
||||
|
||||
config IEEE1394
|
||||
tristate "IEEE 1394 (FireWire) support"
|
||||
depends on PCI || BROKEN
|
||||
select NET
|
||||
help
|
||||
IEEE 1394 describes a high performance serial bus, which is also
|
||||
known as FireWire(tm) or i.Link(tm) and is used for connecting all
|
||||
sorts of devices (most notably digital video cameras) to your
|
||||
computer.
|
||||
|
||||
If you have FireWire hardware and want to use it, say Y here. This
|
||||
is the core support only, you will also need to select a driver for
|
||||
your IEEE 1394 adapter.
|
||||
|
||||
To compile this driver as a module, say M here: the
|
||||
module will be called ieee1394.
|
||||
|
||||
comment "Subsystem Options"
|
||||
depends on IEEE1394
|
||||
|
||||
config IEEE1394_VERBOSEDEBUG
|
||||
bool "Excessive debugging output"
|
||||
depends on IEEE1394
|
||||
help
|
||||
If you say Y here, you will get very verbose debugging logs from
|
||||
the subsystem which includes a dump of the header of every sent
|
||||
and received packet. This can amount to a high amount of data
|
||||
collected in a very short time which is usually also saved to
|
||||
disk by the system logging daemons.
|
||||
|
||||
Say Y if you really want or need the debugging output, everyone
|
||||
else says N.
|
||||
|
||||
config IEEE1394_OUI_DB
|
||||
bool "OUI Database built-in"
|
||||
depends on IEEE1394
|
||||
help
|
||||
If you say Y here, then an OUI list (vendor unique ID's) will be
|
||||
compiled into the ieee1394 module. This doesn't really do much
|
||||
except being able to display the vendor of a hardware node. The
|
||||
downside is that it adds about 300k to the size of the module,
|
||||
or kernel (depending on whether you compile ieee1394 as a
|
||||
module, or static in the kernel).
|
||||
|
||||
This option is not needed for userspace programs like gscanbus
|
||||
to show this information.
|
||||
|
||||
config IEEE1394_EXTRA_CONFIG_ROMS
|
||||
bool "Build in extra config rom entries for certain functionality"
|
||||
depends on IEEE1394
|
||||
help
|
||||
Some IEEE1394 functionality depends on extra config rom entries
|
||||
being available in the host adapters CSR. These options will
|
||||
allow you to choose which ones.
|
||||
|
||||
config IEEE1394_CONFIG_ROM_IP1394
|
||||
bool "IP-1394 Entry"
|
||||
depends on IEEE1394_EXTRA_CONFIG_ROMS && IEEE1394
|
||||
help
|
||||
Adds an entry for using IP-over-1394. If you want to use your
|
||||
IEEE1394 bus as a network for IP systems (including interacting
|
||||
with MacOSX and WinXP IP-over-1394), enable this option and the
|
||||
eth1394 option below.
|
||||
|
||||
comment "Device Drivers"
|
||||
depends on IEEE1394
|
||||
|
||||
comment "Texas Instruments PCILynx requires I2C"
|
||||
depends on IEEE1394 && I2C=n
|
||||
|
||||
config IEEE1394_PCILYNX
|
||||
tristate "Texas Instruments PCILynx support"
|
||||
depends on PCI && IEEE1394 && I2C
|
||||
select I2C_ALGOBIT
|
||||
help
|
||||
Say Y here if you have an IEEE-1394 controller with the Texas
|
||||
Instruments PCILynx chip. Note: this driver is written for revision
|
||||
2 of this chip and may not work with revision 0.
|
||||
|
||||
To compile this driver as a module, say M here: the
|
||||
module will be called pcilynx.
|
||||
|
||||
# Non-maintained pcilynx options
|
||||
# if [ "$CONFIG_IEEE1394_PCILYNX" != "n" ]; then
|
||||
# bool ' Use PCILynx local RAM' CONFIG_IEEE1394_PCILYNX_LOCALRAM
|
||||
# bool ' Support for non-IEEE1394 local ports' CONFIG_IEEE1394_PCILYNX_PORTS
|
||||
# fi
|
||||
config IEEE1394_OHCI1394
|
||||
tristate "OHCI-1394 support"
|
||||
depends on PCI && IEEE1394
|
||||
help
|
||||
Enable this driver if you have an IEEE 1394 controller based on the
|
||||
OHCI-1394 specification. The current driver is only tested with OHCI
|
||||
chipsets made by Texas Instruments and NEC. Most third-party vendors
|
||||
use one of these chipsets. It should work with any OHCI-1394
|
||||
compliant card, however.
|
||||
|
||||
To compile this driver as a module, say M here: the
|
||||
module will be called ohci1394.
|
||||
|
||||
comment "Protocol Drivers"
|
||||
depends on IEEE1394
|
||||
|
||||
config IEEE1394_VIDEO1394
|
||||
tristate "OHCI-1394 Video support"
|
||||
depends on IEEE1394 && IEEE1394_OHCI1394
|
||||
help
|
||||
This option enables video device usage for OHCI-1394 cards. Enable
|
||||
this option only if you have an IEEE 1394 video device connected to
|
||||
an OHCI-1394 card.
|
||||
|
||||
config IEEE1394_SBP2
|
||||
tristate "SBP-2 support (Harddisks etc.)"
|
||||
depends on IEEE1394 && SCSI && (PCI || BROKEN)
|
||||
help
|
||||
This option enables you to use SBP-2 devices connected to your IEEE
|
||||
1394 bus. SBP-2 devices include harddrives and DVD devices.
|
||||
|
||||
config IEEE1394_SBP2_PHYS_DMA
|
||||
bool "Enable Phys DMA support for SBP2 (Debug)"
|
||||
depends on IEEE1394 && IEEE1394_SBP2
|
||||
|
||||
config IEEE1394_ETH1394
|
||||
tristate "Ethernet over 1394"
|
||||
depends on IEEE1394 && EXPERIMENTAL && INET
|
||||
select IEEE1394_CONFIG_ROM_IP1394
|
||||
select IEEE1394_EXTRA_CONFIG_ROMS
|
||||
help
|
||||
This driver implements a functional majority of RFC 2734: IPv4 over
|
||||
1394. It will provide IP connectivity with implementations of RFC
|
||||
2734 found on other operating systems. It will not communicate with
|
||||
older versions of this driver found in stock kernels prior to 2.6.3.
|
||||
This driver is still considered experimental. It does not yet support
|
||||
MCAP, therefore multicast support is significantly limited.
|
||||
|
||||
config IEEE1394_DV1394
|
||||
tristate "OHCI-DV I/O support"
|
||||
depends on IEEE1394 && IEEE1394_OHCI1394
|
||||
help
|
||||
This driver allows you to transmit and receive DV (digital video)
|
||||
streams on an OHCI-1394 card using a simple frame-oriented
|
||||
interface.
|
||||
|
||||
The user-space API for dv1394 is documented in dv1394.h.
|
||||
|
||||
To compile this driver as a module, say M here: the
|
||||
module will be called dv1394.
|
||||
|
||||
config IEEE1394_RAWIO
|
||||
tristate "Raw IEEE1394 I/O support"
|
||||
depends on IEEE1394
|
||||
help
|
||||
Say Y here if you want support for the raw device. This is generally
|
||||
a good idea, so you should say Y here. The raw device enables
|
||||
direct communication of user programs with the IEEE 1394 bus and
|
||||
thus with the attached peripherals.
|
||||
|
||||
To compile this driver as a module, say M here: the
|
||||
module will be called raw1394.
|
||||
|
||||
config IEEE1394_CMP
|
||||
tristate "IEC61883-1 Plug support"
|
||||
depends on IEEE1394
|
||||
help
|
||||
This option enables the Connection Management Procedures
|
||||
(IEC61883-1) driver, which implements input and output plugs.
|
||||
|
||||
To compile this driver as a module, say M here: the
|
||||
module will be called cmp.
|
||||
|
||||
config IEEE1394_AMDTP
|
||||
tristate "IEC61883-6 (Audio transmission) support"
|
||||
depends on IEEE1394 && IEEE1394_OHCI1394 && IEEE1394_CMP
|
||||
help
|
||||
This option enables the Audio & Music Data Transmission Protocol
|
||||
(IEC61883-6) driver, which implements audio transmission over
|
||||
IEEE1394.
|
||||
|
||||
The userspace interface is documented in amdtp.h.
|
||||
|
||||
To compile this driver as a module, say M here: the
|
||||
module will be called amdtp.
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Makefile for the Linux IEEE 1394 implementation
|
||||
#
|
||||
|
||||
ieee1394-objs := ieee1394_core.o ieee1394_transactions.o hosts.o \
|
||||
highlevel.o csr.o nodemgr.o oui.o dma.o iso.o \
|
||||
csr1212.o config_roms.o
|
||||
|
||||
obj-$(CONFIG_IEEE1394) += ieee1394.o
|
||||
obj-$(CONFIG_IEEE1394_PCILYNX) += pcilynx.o
|
||||
obj-$(CONFIG_IEEE1394_OHCI1394) += ohci1394.o
|
||||
obj-$(CONFIG_IEEE1394_VIDEO1394) += video1394.o
|
||||
obj-$(CONFIG_IEEE1394_RAWIO) += raw1394.o
|
||||
obj-$(CONFIG_IEEE1394_SBP2) += sbp2.o
|
||||
obj-$(CONFIG_IEEE1394_DV1394) += dv1394.o
|
||||
obj-$(CONFIG_IEEE1394_ETH1394) += eth1394.o
|
||||
obj-$(CONFIG_IEEE1394_AMDTP) += amdtp.o
|
||||
obj-$(CONFIG_IEEE1394_CMP) += cmp.o
|
||||
|
||||
quiet_cmd_oui2c = OUI2C $@
|
||||
cmd_oui2c = $(CONFIG_SHELL) $(srctree)/$(src)/oui2c.sh < $< > $@
|
||||
|
||||
targets := oui.c
|
||||
$(obj)/oui.o: $(obj)/oui.c
|
||||
$(obj)/oui.c: $(src)/oui.db $(src)/oui2c.sh FORCE
|
||||
$(call if_changed,oui2c)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,84 @@
|
||||
/* -*- c-basic-offset: 8 -*- */
|
||||
|
||||
#ifndef __AMDTP_H
|
||||
#define __AMDTP_H
|
||||
|
||||
#include <asm/types.h>
|
||||
#include "ieee1394-ioctl.h"
|
||||
|
||||
/* The userspace interface for the Audio & Music Data Transmission
|
||||
* Protocol driver is really simple. First, open /dev/amdtp, use the
|
||||
* ioctl to configure format, rate, dimension and either plug or
|
||||
* channel, then start writing samples.
|
||||
*
|
||||
* The formats supported by the driver are listed below.
|
||||
* AMDTP_FORMAT_RAW corresponds to the AM824 raw format, which can
|
||||
* carry any number of channels, so use this if you're streaming
|
||||
* multichannel audio. The AMDTP_FORMAT_IEC958_PCM corresponds to the
|
||||
* AM824 IEC958 encapsulation without the IEC958 data bit set, using
|
||||
* AMDTP_FORMAT_IEC958_AC3 will transmit the samples with the data bit
|
||||
* set, suitable for transmitting compressed AC-3 audio.
|
||||
*
|
||||
* The rate field specifies the transmission rate; supported values
|
||||
* are 32000, 44100, 48000, 88200, 96000, 176400 and 192000.
|
||||
*
|
||||
* The dimension field specifies the dimension of the signal, that is,
|
||||
* the number of audio channels. Only AMDTP_FORMAT_RAW supports
|
||||
* settings greater than 2.
|
||||
*
|
||||
* The mode field specifies which transmission mode to use. The AMDTP
|
||||
* specifies two different transmission modes: blocking and
|
||||
* non-blocking. The blocking transmission mode always send a fixed
|
||||
* number of samples, typically 8, 16 or 32. To exactly match the
|
||||
* transmission rate, the driver alternates between sending empty and
|
||||
* non-empty packets. In non-blocking mode, the driver transmits as
|
||||
* small packets as possible. For example, for a transmission rate of
|
||||
* 44100Hz, the driver should send 5 41/80 samples in every cycle, but
|
||||
* this is not possible so instead the driver alternates between
|
||||
* sending 5 and 6 samples.
|
||||
*
|
||||
* The last thing to specify is either the isochronous channel to use
|
||||
* or the output plug to connect to. If you know what channel the
|
||||
* destination device will listen on, you can specify the channel
|
||||
* directly and use the AMDTP_IOC_CHANNEL ioctl. However, if the
|
||||
* destination device chooses the channel and uses the IEC61883-1 plug
|
||||
* mechanism, you can specify an output plug to connect to. The
|
||||
* driver will pick up the channel number from the plug once the
|
||||
* destination device locks the output plug control register. In this
|
||||
* case set the plug field and use the AMDTP_IOC_PLUG ioctl.
|
||||
*
|
||||
* Having configured the interface, the driver now accepts writes of
|
||||
* regular 16 bit signed little endian samples, with the channels
|
||||
* interleaved. For example, 4 channels would look like:
|
||||
*
|
||||
* | sample 0 | sample 1 ...
|
||||
* | ch. 0 | ch. 1 | ch. 2 | ch. 3 | ch. 0 | ...
|
||||
* | lsb | msb | lsb | msb | lsb | msb | lsb | msb | lsb | msb | ...
|
||||
*
|
||||
*/
|
||||
|
||||
enum {
|
||||
AMDTP_FORMAT_RAW,
|
||||
AMDTP_FORMAT_IEC958_PCM,
|
||||
AMDTP_FORMAT_IEC958_AC3
|
||||
};
|
||||
|
||||
enum {
|
||||
AMDTP_MODE_BLOCKING,
|
||||
AMDTP_MODE_NON_BLOCKING,
|
||||
};
|
||||
|
||||
enum {
|
||||
AMDTP_INPUT_LE16,
|
||||
AMDTP_INPUT_BE16,
|
||||
};
|
||||
|
||||
struct amdtp_ioctl {
|
||||
__u32 format;
|
||||
__u32 rate;
|
||||
__u32 dimension;
|
||||
__u32 mode;
|
||||
union { __u32 channel; __u32 plug; } u;
|
||||
};
|
||||
|
||||
#endif /* __AMDTP_H */
|
||||
@@ -0,0 +1,311 @@
|
||||
/* -*- c-basic-offset: 8 -*-
|
||||
*
|
||||
* cmp.c - Connection Management Procedures
|
||||
* Copyright (C) 2001 Kristian Høgsberg
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* TODO
|
||||
* ----
|
||||
*
|
||||
* - Implement IEC61883-1 output plugs and connection management.
|
||||
* This should probably be part of the general subsystem, as it could
|
||||
* be shared with dv1394.
|
||||
*
|
||||
* - Add IEC61883 unit directory when loading this module. This
|
||||
* requires a run-time changeable config rom.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/wait.h>
|
||||
#include <linux/interrupt.h>
|
||||
|
||||
#include "hosts.h"
|
||||
#include "highlevel.h"
|
||||
#include "ieee1394.h"
|
||||
#include "ieee1394_core.h"
|
||||
#include "cmp.h"
|
||||
|
||||
struct plug {
|
||||
union {
|
||||
struct cmp_pcr pcr;
|
||||
quadlet_t quadlet;
|
||||
} u;
|
||||
void (*update)(struct cmp_pcr *plug, void *data);
|
||||
void *data;
|
||||
};
|
||||
|
||||
struct cmp_host {
|
||||
struct hpsb_host *host;
|
||||
|
||||
union {
|
||||
struct cmp_mpr ompr;
|
||||
quadlet_t ompr_quadlet;
|
||||
} u;
|
||||
struct plug opcr[2];
|
||||
|
||||
union {
|
||||
struct cmp_mpr impr;
|
||||
quadlet_t impr_quadlet;
|
||||
} v;
|
||||
struct plug ipcr[2];
|
||||
};
|
||||
|
||||
enum {
|
||||
CMP_P2P_CONNECTION,
|
||||
CMP_BC_CONNECTION
|
||||
};
|
||||
|
||||
#define CSR_PCR_MAP 0x900
|
||||
#define CSR_PCR_MAP_END 0x9fc
|
||||
|
||||
static struct hpsb_highlevel cmp_highlevel;
|
||||
|
||||
static void cmp_add_host(struct hpsb_host *host);
|
||||
static void cmp_host_reset(struct hpsb_host *host);
|
||||
static int pcr_read(struct hpsb_host *host, int nodeid, quadlet_t *buf,
|
||||
u64 addr, size_t length, u16 flags);
|
||||
static int pcr_lock(struct hpsb_host *host, int nodeid, quadlet_t *store,
|
||||
u64 addr, quadlet_t data, quadlet_t arg, int extcode, u16 flags);
|
||||
|
||||
static struct hpsb_highlevel cmp_highlevel = {
|
||||
.name = "cmp",
|
||||
.add_host = cmp_add_host,
|
||||
.host_reset = cmp_host_reset,
|
||||
};
|
||||
|
||||
static struct hpsb_address_ops pcr_ops = {
|
||||
.read = pcr_read,
|
||||
.lock = pcr_lock,
|
||||
};
|
||||
|
||||
|
||||
struct cmp_pcr *
|
||||
cmp_register_opcr(struct hpsb_host *host, int opcr_number, int payload,
|
||||
void (*update)(struct cmp_pcr *pcr, void *data),
|
||||
void *data)
|
||||
{
|
||||
struct cmp_host *ch;
|
||||
struct plug *plug;
|
||||
|
||||
ch = hpsb_get_hostinfo(&cmp_highlevel, host);
|
||||
|
||||
if (opcr_number >= ch->u.ompr.nplugs ||
|
||||
ch->opcr[opcr_number].update != NULL)
|
||||
return NULL;
|
||||
|
||||
plug = &ch->opcr[opcr_number];
|
||||
plug->u.pcr.online = 1;
|
||||
plug->u.pcr.bcast_count = 0;
|
||||
plug->u.pcr.p2p_count = 0;
|
||||
plug->u.pcr.overhead = 0;
|
||||
plug->u.pcr.payload = payload;
|
||||
plug->update = update;
|
||||
plug->data = data;
|
||||
|
||||
return &plug->u.pcr;
|
||||
}
|
||||
|
||||
void cmp_unregister_opcr(struct hpsb_host *host, struct cmp_pcr *opcr)
|
||||
{
|
||||
struct cmp_host *ch;
|
||||
struct plug *plug;
|
||||
|
||||
ch = hpsb_get_hostinfo(&cmp_highlevel, host);
|
||||
plug = (struct plug *)opcr;
|
||||
if (plug - ch->opcr >= ch->u.ompr.nplugs) BUG();
|
||||
|
||||
plug->u.pcr.online = 0;
|
||||
plug->update = NULL;
|
||||
}
|
||||
|
||||
static void reset_plugs(struct cmp_host *ch)
|
||||
{
|
||||
int i;
|
||||
|
||||
ch->u.ompr.non_persistent_ext = 0xff;
|
||||
for (i = 0; i < ch->u.ompr.nplugs; i++) {
|
||||
ch->opcr[i].u.pcr.bcast_count = 0;
|
||||
ch->opcr[i].u.pcr.p2p_count = 0;
|
||||
ch->opcr[i].u.pcr.overhead = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void cmp_add_host(struct hpsb_host *host)
|
||||
{
|
||||
struct cmp_host *ch = hpsb_create_hostinfo(&cmp_highlevel, host, sizeof (*ch));
|
||||
|
||||
if (ch == NULL) {
|
||||
HPSB_ERR("Failed to allocate cmp_host");
|
||||
return;
|
||||
}
|
||||
|
||||
hpsb_register_addrspace(&cmp_highlevel, host, &pcr_ops,
|
||||
CSR_REGISTER_BASE + CSR_PCR_MAP,
|
||||
CSR_REGISTER_BASE + CSR_PCR_MAP_END);
|
||||
|
||||
ch->host = host;
|
||||
ch->u.ompr.rate = IEEE1394_SPEED_100;
|
||||
ch->u.ompr.bcast_channel_base = 63;
|
||||
ch->u.ompr.nplugs = 2;
|
||||
|
||||
reset_plugs(ch);
|
||||
}
|
||||
|
||||
static void cmp_host_reset(struct hpsb_host *host)
|
||||
{
|
||||
struct cmp_host *ch;
|
||||
|
||||
ch = hpsb_get_hostinfo(&cmp_highlevel, host);
|
||||
if (ch == NULL) {
|
||||
HPSB_ERR("cmp: Tried to reset unknown host");
|
||||
return;
|
||||
}
|
||||
|
||||
reset_plugs(ch);
|
||||
}
|
||||
|
||||
static int pcr_read(struct hpsb_host *host, int nodeid, quadlet_t *buf,
|
||||
u64 addr, size_t length, u16 flags)
|
||||
{
|
||||
int csraddr = addr - CSR_REGISTER_BASE;
|
||||
int plug;
|
||||
struct cmp_host *ch;
|
||||
|
||||
if (length != 4)
|
||||
return RCODE_TYPE_ERROR;
|
||||
|
||||
ch = hpsb_get_hostinfo(&cmp_highlevel, host);
|
||||
if (csraddr == 0x900) {
|
||||
*buf = cpu_to_be32(ch->u.ompr_quadlet);
|
||||
return RCODE_COMPLETE;
|
||||
}
|
||||
else if (csraddr < 0x904 + ch->u.ompr.nplugs * 4) {
|
||||
plug = (csraddr - 0x904) / 4;
|
||||
*buf = cpu_to_be32(ch->opcr[plug].u.quadlet);
|
||||
return RCODE_COMPLETE;
|
||||
}
|
||||
else if (csraddr < 0x980) {
|
||||
return RCODE_ADDRESS_ERROR;
|
||||
}
|
||||
else if (csraddr == 0x980) {
|
||||
*buf = cpu_to_be32(ch->v.impr_quadlet);
|
||||
return RCODE_COMPLETE;
|
||||
}
|
||||
else if (csraddr < 0x984 + ch->v.impr.nplugs * 4) {
|
||||
plug = (csraddr - 0x984) / 4;
|
||||
*buf = cpu_to_be32(ch->ipcr[plug].u.quadlet);
|
||||
return RCODE_COMPLETE;
|
||||
}
|
||||
else
|
||||
return RCODE_ADDRESS_ERROR;
|
||||
}
|
||||
|
||||
static int pcr_lock(struct hpsb_host *host, int nodeid, quadlet_t *store,
|
||||
u64 addr, quadlet_t data, quadlet_t arg, int extcode, u16 flags)
|
||||
{
|
||||
int csraddr = addr - CSR_REGISTER_BASE;
|
||||
int plug;
|
||||
struct cmp_host *ch;
|
||||
|
||||
ch = hpsb_get_hostinfo(&cmp_highlevel, host);
|
||||
|
||||
if (extcode != EXTCODE_COMPARE_SWAP)
|
||||
return RCODE_TYPE_ERROR;
|
||||
|
||||
if (csraddr == 0x900) {
|
||||
/* FIXME: Ignore writes to bits 30-31 and 0-7 */
|
||||
*store = cpu_to_be32(ch->u.ompr_quadlet);
|
||||
if (arg == cpu_to_be32(ch->u.ompr_quadlet))
|
||||
ch->u.ompr_quadlet = be32_to_cpu(data);
|
||||
|
||||
return RCODE_COMPLETE;
|
||||
}
|
||||
if (csraddr < 0x904 + ch->u.ompr.nplugs * 4) {
|
||||
plug = (csraddr - 0x904) / 4;
|
||||
*store = cpu_to_be32(ch->opcr[plug].u.quadlet);
|
||||
|
||||
if (arg == *store)
|
||||
ch->opcr[plug].u.quadlet = be32_to_cpu(data);
|
||||
|
||||
if (be32_to_cpu(*store) != ch->opcr[plug].u.quadlet &&
|
||||
ch->opcr[plug].update != NULL)
|
||||
ch->opcr[plug].update(&ch->opcr[plug].u.pcr,
|
||||
ch->opcr[plug].data);
|
||||
|
||||
return RCODE_COMPLETE;
|
||||
}
|
||||
else if (csraddr < 0x980) {
|
||||
return RCODE_ADDRESS_ERROR;
|
||||
}
|
||||
else if (csraddr == 0x980) {
|
||||
/* FIXME: Ignore writes to bits 24-31 and 0-7 */
|
||||
*store = cpu_to_be32(ch->u.ompr_quadlet);
|
||||
if (arg == cpu_to_be32(ch->u.ompr_quadlet))
|
||||
ch->u.ompr_quadlet = be32_to_cpu(data);
|
||||
|
||||
return RCODE_COMPLETE;
|
||||
}
|
||||
else if (csraddr < 0x984 + ch->v.impr.nplugs * 4) {
|
||||
plug = (csraddr - 0x984) / 4;
|
||||
*store = cpu_to_be32(ch->ipcr[plug].u.quadlet);
|
||||
|
||||
if (arg == *store)
|
||||
ch->ipcr[plug].u.quadlet = be32_to_cpu(data);
|
||||
|
||||
if (be32_to_cpu(*store) != ch->ipcr[plug].u.quadlet &&
|
||||
ch->ipcr[plug].update != NULL)
|
||||
ch->ipcr[plug].update(&ch->ipcr[plug].u.pcr,
|
||||
ch->ipcr[plug].data);
|
||||
|
||||
return RCODE_COMPLETE;
|
||||
}
|
||||
else
|
||||
return RCODE_ADDRESS_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/* Module interface */
|
||||
|
||||
MODULE_AUTHOR("Kristian Hogsberg <hogsberg@users.sf.net>");
|
||||
MODULE_DESCRIPTION("Connection Management Procedures (CMP)");
|
||||
MODULE_SUPPORTED_DEVICE("cmp");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
EXPORT_SYMBOL(cmp_register_opcr);
|
||||
EXPORT_SYMBOL(cmp_unregister_opcr);
|
||||
|
||||
static int __init cmp_init_module (void)
|
||||
{
|
||||
hpsb_register_highlevel (&cmp_highlevel);
|
||||
|
||||
HPSB_INFO("Loaded CMP driver");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit cmp_exit_module (void)
|
||||
{
|
||||
hpsb_unregister_highlevel(&cmp_highlevel);
|
||||
|
||||
HPSB_INFO("Unloaded CMP driver");
|
||||
}
|
||||
|
||||
module_init(cmp_init_module);
|
||||
module_exit(cmp_exit_module);
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef __CMP_H
|
||||
#define __CMP_H
|
||||
|
||||
struct cmp_mpr {
|
||||
u32 nplugs:5;
|
||||
u32 reserved:3;
|
||||
u32 persistent_ext:8;
|
||||
u32 non_persistent_ext:8;
|
||||
u32 bcast_channel_base:6;
|
||||
u32 rate:2;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct cmp_pcr {
|
||||
u32 payload:10;
|
||||
u32 overhead:4;
|
||||
u32 speed:2;
|
||||
u32 channel:6;
|
||||
u32 reserved:2;
|
||||
u32 p2p_count:6;
|
||||
u32 bcast_count:1;
|
||||
u32 online:1;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct cmp_pcr *cmp_register_opcr(struct hpsb_host *host, int plug,
|
||||
int payload,
|
||||
void (*update)(struct cmp_pcr *plug,
|
||||
void *data),
|
||||
void *data);
|
||||
void cmp_unregister_opcr(struct hpsb_host *host, struct cmp_pcr *plug);
|
||||
|
||||
#endif /* __CMP_H */
|
||||
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* IEEE 1394 for Linux
|
||||
*
|
||||
* ConfigROM entries
|
||||
*
|
||||
* Copyright (C) 2004 Ben Collins
|
||||
*
|
||||
* This code is licensed under the GPL. See the file COPYING in the root
|
||||
* directory of the kernel sources for details.
|
||||
*/
|
||||
|
||||
#include <linux/config.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#include "csr1212.h"
|
||||
#include "ieee1394.h"
|
||||
#include "ieee1394_types.h"
|
||||
#include "hosts.h"
|
||||
#include "ieee1394_core.h"
|
||||
#include "highlevel.h"
|
||||
#include "csr.h"
|
||||
#include "config_roms.h"
|
||||
|
||||
struct hpsb_config_rom_entry {
|
||||
const char *name;
|
||||
|
||||
/* Base initialization, called at module load */
|
||||
int (*init)(void);
|
||||
|
||||
/* Add entry to specified host */
|
||||
int (*add)(struct hpsb_host *host);
|
||||
|
||||
/* Remove entry from specified host */
|
||||
void (*remove)(struct hpsb_host *host);
|
||||
|
||||
/* Cleanup called at module exit */
|
||||
void (*cleanup)(void);
|
||||
|
||||
/* The flag added to host->config_roms */
|
||||
unsigned int flag;
|
||||
};
|
||||
|
||||
|
||||
int hpsb_default_host_entry(struct hpsb_host *host)
|
||||
{
|
||||
struct csr1212_keyval *root;
|
||||
struct csr1212_keyval *vend_id = NULL;
|
||||
struct csr1212_keyval *text = NULL;
|
||||
char csr_name[128];
|
||||
int ret;
|
||||
|
||||
sprintf(csr_name, "Linux - %s", host->driver->name);
|
||||
root = host->csr.rom->root_kv;
|
||||
|
||||
vend_id = csr1212_new_immediate(CSR1212_KV_ID_VENDOR, host->csr.guid_hi >> 8);
|
||||
text = csr1212_new_string_descriptor_leaf(csr_name);
|
||||
|
||||
if (!vend_id || !text) {
|
||||
if (vend_id)
|
||||
csr1212_release_keyval(vend_id);
|
||||
if (text)
|
||||
csr1212_release_keyval(text);
|
||||
csr1212_destroy_csr(host->csr.rom);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = csr1212_associate_keyval(vend_id, text);
|
||||
csr1212_release_keyval(text);
|
||||
ret |= csr1212_attach_keyval_to_directory(root, vend_id);
|
||||
csr1212_release_keyval(vend_id);
|
||||
if (ret != CSR1212_SUCCESS) {
|
||||
csr1212_destroy_csr(host->csr.rom);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
host->update_config_rom = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_IEEE1394_CONFIG_ROM_IP1394
|
||||
#include "eth1394.h"
|
||||
|
||||
static struct csr1212_keyval *ip1394_ud;
|
||||
|
||||
static int config_rom_ip1394_init(void)
|
||||
{
|
||||
struct csr1212_keyval *spec_id = NULL;
|
||||
struct csr1212_keyval *spec_desc = NULL;
|
||||
struct csr1212_keyval *ver = NULL;
|
||||
struct csr1212_keyval *ver_desc = NULL;
|
||||
int ret = -ENOMEM;
|
||||
|
||||
ip1394_ud = csr1212_new_directory(CSR1212_KV_ID_UNIT);
|
||||
|
||||
spec_id = csr1212_new_immediate(CSR1212_KV_ID_SPECIFIER_ID,
|
||||
ETHER1394_GASP_SPECIFIER_ID);
|
||||
spec_desc = csr1212_new_string_descriptor_leaf("IANA");
|
||||
ver = csr1212_new_immediate(CSR1212_KV_ID_VERSION,
|
||||
ETHER1394_GASP_VERSION);
|
||||
ver_desc = csr1212_new_string_descriptor_leaf("IPv4");
|
||||
|
||||
if (!ip1394_ud || !spec_id || !spec_desc || !ver || !ver_desc)
|
||||
goto ip1394_fail;
|
||||
|
||||
if (csr1212_associate_keyval(spec_id, spec_desc) == CSR1212_SUCCESS &&
|
||||
csr1212_associate_keyval(ver, ver_desc) == CSR1212_SUCCESS &&
|
||||
csr1212_attach_keyval_to_directory(ip1394_ud, spec_id) == CSR1212_SUCCESS &&
|
||||
csr1212_attach_keyval_to_directory(ip1394_ud, ver) == CSR1212_SUCCESS)
|
||||
ret = 0;
|
||||
|
||||
ip1394_fail:
|
||||
if (ret && ip1394_ud) {
|
||||
csr1212_release_keyval(ip1394_ud);
|
||||
ip1394_ud = NULL;
|
||||
}
|
||||
|
||||
if (spec_id)
|
||||
csr1212_release_keyval(spec_id);
|
||||
if (spec_desc)
|
||||
csr1212_release_keyval(spec_desc);
|
||||
if (ver)
|
||||
csr1212_release_keyval(ver);
|
||||
if (ver_desc)
|
||||
csr1212_release_keyval(ver_desc);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void config_rom_ip1394_cleanup(void)
|
||||
{
|
||||
if (ip1394_ud) {
|
||||
csr1212_release_keyval(ip1394_ud);
|
||||
ip1394_ud = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int config_rom_ip1394_add(struct hpsb_host *host)
|
||||
{
|
||||
if (!ip1394_ud)
|
||||
return -ENODEV;
|
||||
|
||||
if (csr1212_attach_keyval_to_directory(host->csr.rom->root_kv,
|
||||
ip1394_ud) != CSR1212_SUCCESS)
|
||||
return -ENOMEM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void config_rom_ip1394_remove(struct hpsb_host *host)
|
||||
{
|
||||
csr1212_detach_keyval_from_directory(host->csr.rom->root_kv, ip1394_ud);
|
||||
}
|
||||
|
||||
static struct hpsb_config_rom_entry ip1394_entry = {
|
||||
.name = "ip1394",
|
||||
.init = config_rom_ip1394_init,
|
||||
.add = config_rom_ip1394_add,
|
||||
.remove = config_rom_ip1394_remove,
|
||||
.cleanup = config_rom_ip1394_cleanup,
|
||||
.flag = HPSB_CONFIG_ROM_ENTRY_IP1394,
|
||||
};
|
||||
#endif /* CONFIG_IEEE1394_CONFIG_ROM_IP1394 */
|
||||
|
||||
|
||||
static struct hpsb_config_rom_entry *const config_rom_entries[] = {
|
||||
#ifdef CONFIG_IEEE1394_CONFIG_ROM_IP1394
|
||||
&ip1394_entry,
|
||||
#endif
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
int hpsb_init_config_roms(void)
|
||||
{
|
||||
int i, error = 0;
|
||||
|
||||
for (i = 0; config_rom_entries[i]; i++) {
|
||||
if (!config_rom_entries[i]->init)
|
||||
continue;
|
||||
|
||||
if (config_rom_entries[i]->init()) {
|
||||
HPSB_ERR("Failed to initialize config rom entry `%s'",
|
||||
config_rom_entries[i]->name);
|
||||
error = -1;
|
||||
} else
|
||||
HPSB_DEBUG("Initialized config rom entry `%s'",
|
||||
config_rom_entries[i]->name);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
void hpsb_cleanup_config_roms(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; config_rom_entries[i]; i++) {
|
||||
if (config_rom_entries[i]->cleanup)
|
||||
config_rom_entries[i]->cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
int hpsb_add_extra_config_roms(struct hpsb_host *host)
|
||||
{
|
||||
int i, error = 0;
|
||||
|
||||
for (i = 0; config_rom_entries[i]; i++) {
|
||||
if (config_rom_entries[i]->add(host)) {
|
||||
HPSB_ERR("fw-host%d: Failed to attach config rom entry `%s'",
|
||||
host->id, config_rom_entries[i]->name);
|
||||
error = -1;
|
||||
} else {
|
||||
host->config_roms |= config_rom_entries[i]->flag;
|
||||
host->update_config_rom = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
void hpsb_remove_extra_config_roms(struct hpsb_host *host)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; config_rom_entries[i]; i++) {
|
||||
if (!(host->config_roms & config_rom_entries[i]->flag))
|
||||
continue;
|
||||
|
||||
config_rom_entries[i]->remove(host);
|
||||
|
||||
host->config_roms &= ~config_rom_entries[i]->flag;
|
||||
host->update_config_rom = 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef _IEEE1394_CONFIG_ROMS_H
|
||||
#define _IEEE1394_CONFIG_ROMS_H
|
||||
|
||||
#include "ieee1394_types.h"
|
||||
#include "hosts.h"
|
||||
|
||||
/* The default host entry. This must succeed. */
|
||||
int hpsb_default_host_entry(struct hpsb_host *host);
|
||||
|
||||
/* Initialize all config roms */
|
||||
int hpsb_init_config_roms(void);
|
||||
|
||||
/* Cleanup all config roms */
|
||||
void hpsb_cleanup_config_roms(void);
|
||||
|
||||
/* Add extra config roms to specified host */
|
||||
int hpsb_add_extra_config_roms(struct hpsb_host *host);
|
||||
|
||||
/* Remove extra config roms from specified host */
|
||||
void hpsb_remove_extra_config_roms(struct hpsb_host *host);
|
||||
|
||||
|
||||
/* List of flags to check if a host contains a certain extra config rom
|
||||
* entry. Available in the host->config_roms member. */
|
||||
#define HPSB_CONFIG_ROM_ENTRY_IP1394 0x00000001
|
||||
|
||||
#endif /* _IEEE1394_CONFIG_ROMS_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,96 @@
|
||||
|
||||
#ifndef _IEEE1394_CSR_H
|
||||
#define _IEEE1394_CSR_H
|
||||
|
||||
#ifdef CONFIG_PREEMPT
|
||||
#include <linux/sched.h>
|
||||
#endif
|
||||
|
||||
#include "csr1212.h"
|
||||
|
||||
#define CSR_REGISTER_BASE 0xfffff0000000ULL
|
||||
|
||||
/* register offsets relative to CSR_REGISTER_BASE */
|
||||
#define CSR_STATE_CLEAR 0x0
|
||||
#define CSR_STATE_SET 0x4
|
||||
#define CSR_NODE_IDS 0x8
|
||||
#define CSR_RESET_START 0xc
|
||||
#define CSR_SPLIT_TIMEOUT_HI 0x18
|
||||
#define CSR_SPLIT_TIMEOUT_LO 0x1c
|
||||
#define CSR_CYCLE_TIME 0x200
|
||||
#define CSR_BUS_TIME 0x204
|
||||
#define CSR_BUSY_TIMEOUT 0x210
|
||||
#define CSR_BUS_MANAGER_ID 0x21c
|
||||
#define CSR_BANDWIDTH_AVAILABLE 0x220
|
||||
#define CSR_CHANNELS_AVAILABLE 0x224
|
||||
#define CSR_CHANNELS_AVAILABLE_HI 0x224
|
||||
#define CSR_CHANNELS_AVAILABLE_LO 0x228
|
||||
#define CSR_BROADCAST_CHANNEL 0x234
|
||||
#define CSR_CONFIG_ROM 0x400
|
||||
#define CSR_CONFIG_ROM_END 0x800
|
||||
#define CSR_FCP_COMMAND 0xB00
|
||||
#define CSR_FCP_RESPONSE 0xD00
|
||||
#define CSR_FCP_END 0xF00
|
||||
#define CSR_TOPOLOGY_MAP 0x1000
|
||||
#define CSR_TOPOLOGY_MAP_END 0x1400
|
||||
#define CSR_SPEED_MAP 0x2000
|
||||
#define CSR_SPEED_MAP_END 0x3000
|
||||
|
||||
/* IEEE 1394 bus specific Configuration ROM Key IDs */
|
||||
#define IEEE1394_KV_ID_POWER_REQUIREMENTS (0x30)
|
||||
|
||||
/* IEEE 1394 Bus Inforamation Block specifics */
|
||||
#define CSR_BUS_INFO_SIZE (5 * sizeof(quadlet_t))
|
||||
|
||||
#define CSR_IRMC_SHIFT 31
|
||||
#define CSR_CMC_SHIFT 30
|
||||
#define CSR_ISC_SHIFT 29
|
||||
#define CSR_BMC_SHIFT 28
|
||||
#define CSR_PMC_SHIFT 27
|
||||
#define CSR_CYC_CLK_ACC_SHIFT 16
|
||||
#define CSR_MAX_REC_SHIFT 12
|
||||
#define CSR_MAX_ROM_SHIFT 8
|
||||
#define CSR_GENERATION_SHIFT 4
|
||||
|
||||
#define CSR_SET_BUS_INFO_GENERATION(csr, gen) \
|
||||
((csr)->bus_info_data[2] = \
|
||||
cpu_to_be32((be32_to_cpu((csr)->bus_info_data[2]) & \
|
||||
~(0xf << CSR_GENERATION_SHIFT)) | \
|
||||
(gen) << CSR_GENERATION_SHIFT))
|
||||
|
||||
struct csr_control {
|
||||
spinlock_t lock;
|
||||
|
||||
quadlet_t state;
|
||||
quadlet_t node_ids;
|
||||
quadlet_t split_timeout_hi, split_timeout_lo;
|
||||
unsigned long expire; // Calculated from split_timeout
|
||||
quadlet_t cycle_time;
|
||||
quadlet_t bus_time;
|
||||
quadlet_t bus_manager_id;
|
||||
quadlet_t bandwidth_available;
|
||||
quadlet_t channels_available_hi, channels_available_lo;
|
||||
quadlet_t broadcast_channel;
|
||||
|
||||
/* Bus Info */
|
||||
quadlet_t guid_hi, guid_lo;
|
||||
u8 cyc_clk_acc;
|
||||
u8 max_rec;
|
||||
u8 max_rom;
|
||||
u8 generation; /* Only use values between 0x2 and 0xf */
|
||||
u8 lnk_spd;
|
||||
|
||||
unsigned long gen_timestamp[16];
|
||||
|
||||
struct csr1212_csr *rom;
|
||||
|
||||
quadlet_t topology_map[256];
|
||||
quadlet_t speed_map[1024];
|
||||
};
|
||||
|
||||
extern struct csr1212_bus_ops csr_bus_ops;
|
||||
|
||||
int init_csr(void);
|
||||
void cleanup_csr(void);
|
||||
|
||||
#endif /* _IEEE1394_CSR_H */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,260 @@
|
||||
/*
|
||||
* DMA region bookkeeping routines
|
||||
*
|
||||
* Copyright (C) 2002 Maas Digital LLC
|
||||
*
|
||||
* This code is licensed under the GPL. See the file COPYING in the root
|
||||
* directory of the kernel sources for details.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/mm.h>
|
||||
#include "dma.h"
|
||||
|
||||
/* dma_prog_region */
|
||||
|
||||
void dma_prog_region_init(struct dma_prog_region *prog)
|
||||
{
|
||||
prog->kvirt = NULL;
|
||||
prog->dev = NULL;
|
||||
prog->n_pages = 0;
|
||||
prog->bus_addr = 0;
|
||||
}
|
||||
|
||||
int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes, struct pci_dev *dev)
|
||||
{
|
||||
/* round up to page size */
|
||||
n_bytes = PAGE_ALIGN(n_bytes);
|
||||
|
||||
prog->n_pages = n_bytes >> PAGE_SHIFT;
|
||||
|
||||
prog->kvirt = pci_alloc_consistent(dev, n_bytes, &prog->bus_addr);
|
||||
if (!prog->kvirt) {
|
||||
printk(KERN_ERR "dma_prog_region_alloc: pci_alloc_consistent() failed\n");
|
||||
dma_prog_region_free(prog);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
prog->dev = dev;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dma_prog_region_free(struct dma_prog_region *prog)
|
||||
{
|
||||
if (prog->kvirt) {
|
||||
pci_free_consistent(prog->dev, prog->n_pages << PAGE_SHIFT, prog->kvirt, prog->bus_addr);
|
||||
}
|
||||
|
||||
prog->kvirt = NULL;
|
||||
prog->dev = NULL;
|
||||
prog->n_pages = 0;
|
||||
prog->bus_addr = 0;
|
||||
}
|
||||
|
||||
/* dma_region */
|
||||
|
||||
void dma_region_init(struct dma_region *dma)
|
||||
{
|
||||
dma->kvirt = NULL;
|
||||
dma->dev = NULL;
|
||||
dma->n_pages = 0;
|
||||
dma->n_dma_pages = 0;
|
||||
dma->sglist = NULL;
|
||||
}
|
||||
|
||||
int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_dev *dev, int direction)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
/* round up to page size */
|
||||
n_bytes = PAGE_ALIGN(n_bytes);
|
||||
|
||||
dma->n_pages = n_bytes >> PAGE_SHIFT;
|
||||
|
||||
dma->kvirt = vmalloc_32(n_bytes);
|
||||
if (!dma->kvirt) {
|
||||
printk(KERN_ERR "dma_region_alloc: vmalloc_32() failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Clear the ram out, no junk to the user */
|
||||
memset(dma->kvirt, 0, n_bytes);
|
||||
|
||||
/* allocate scatter/gather list */
|
||||
dma->sglist = vmalloc(dma->n_pages * sizeof(*dma->sglist));
|
||||
if (!dma->sglist) {
|
||||
printk(KERN_ERR "dma_region_alloc: vmalloc(sglist) failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* just to be safe - this will become unnecessary once sglist->address goes away */
|
||||
memset(dma->sglist, 0, dma->n_pages * sizeof(*dma->sglist));
|
||||
|
||||
/* fill scatter/gather list with pages */
|
||||
for (i = 0; i < dma->n_pages; i++) {
|
||||
unsigned long va = (unsigned long) dma->kvirt + (i << PAGE_SHIFT);
|
||||
|
||||
dma->sglist[i].page = vmalloc_to_page((void *)va);
|
||||
dma->sglist[i].length = PAGE_SIZE;
|
||||
}
|
||||
|
||||
/* map sglist to the IOMMU */
|
||||
dma->n_dma_pages = pci_map_sg(dev, dma->sglist, dma->n_pages, direction);
|
||||
|
||||
if (dma->n_dma_pages == 0) {
|
||||
printk(KERN_ERR "dma_region_alloc: pci_map_sg() failed\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
dma->dev = dev;
|
||||
dma->direction = direction;
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
dma_region_free(dma);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
void dma_region_free(struct dma_region *dma)
|
||||
{
|
||||
if (dma->n_dma_pages) {
|
||||
pci_unmap_sg(dma->dev, dma->sglist, dma->n_pages, dma->direction);
|
||||
dma->n_dma_pages = 0;
|
||||
dma->dev = NULL;
|
||||
}
|
||||
|
||||
vfree(dma->sglist);
|
||||
dma->sglist = NULL;
|
||||
|
||||
vfree(dma->kvirt);
|
||||
dma->kvirt = NULL;
|
||||
dma->n_pages = 0;
|
||||
}
|
||||
|
||||
/* find the scatterlist index and remaining offset corresponding to a
|
||||
given offset from the beginning of the buffer */
|
||||
static inline int dma_region_find(struct dma_region *dma, unsigned long offset, unsigned long *rem)
|
||||
{
|
||||
int i;
|
||||
unsigned long off = offset;
|
||||
|
||||
for (i = 0; i < dma->n_dma_pages; i++) {
|
||||
if (off < sg_dma_len(&dma->sglist[i])) {
|
||||
*rem = off;
|
||||
break;
|
||||
}
|
||||
|
||||
off -= sg_dma_len(&dma->sglist[i]);
|
||||
}
|
||||
|
||||
BUG_ON(i >= dma->n_dma_pages);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
dma_addr_t dma_region_offset_to_bus(struct dma_region *dma, unsigned long offset)
|
||||
{
|
||||
unsigned long rem;
|
||||
|
||||
struct scatterlist *sg = &dma->sglist[dma_region_find(dma, offset, &rem)];
|
||||
return sg_dma_address(sg) + rem;
|
||||
}
|
||||
|
||||
void dma_region_sync_for_cpu(struct dma_region *dma, unsigned long offset, unsigned long len)
|
||||
{
|
||||
int first, last;
|
||||
unsigned long rem;
|
||||
|
||||
if (!len)
|
||||
len = 1;
|
||||
|
||||
first = dma_region_find(dma, offset, &rem);
|
||||
last = dma_region_find(dma, offset + len - 1, &rem);
|
||||
|
||||
pci_dma_sync_sg_for_cpu(dma->dev, &dma->sglist[first], last - first + 1, dma->direction);
|
||||
}
|
||||
|
||||
void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset, unsigned long len)
|
||||
{
|
||||
int first, last;
|
||||
unsigned long rem;
|
||||
|
||||
if (!len)
|
||||
len = 1;
|
||||
|
||||
first = dma_region_find(dma, offset, &rem);
|
||||
last = dma_region_find(dma, offset + len - 1, &rem);
|
||||
|
||||
pci_dma_sync_sg_for_device(dma->dev, &dma->sglist[first], last - first + 1, dma->direction);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MMU
|
||||
|
||||
/* nopage() handler for mmap access */
|
||||
|
||||
static struct page*
|
||||
dma_region_pagefault(struct vm_area_struct *area, unsigned long address, int *type)
|
||||
{
|
||||
unsigned long offset;
|
||||
unsigned long kernel_virt_addr;
|
||||
struct page *ret = NOPAGE_SIGBUS;
|
||||
|
||||
struct dma_region *dma = (struct dma_region*) area->vm_private_data;
|
||||
|
||||
if (!dma->kvirt)
|
||||
goto out;
|
||||
|
||||
if ( (address < (unsigned long) area->vm_start) ||
|
||||
(address > (unsigned long) area->vm_start + (dma->n_pages << PAGE_SHIFT)) )
|
||||
goto out;
|
||||
|
||||
if (type)
|
||||
*type = VM_FAULT_MINOR;
|
||||
offset = address - area->vm_start;
|
||||
kernel_virt_addr = (unsigned long) dma->kvirt + offset;
|
||||
ret = vmalloc_to_page((void*) kernel_virt_addr);
|
||||
get_page(ret);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct vm_operations_struct dma_region_vm_ops = {
|
||||
.nopage = dma_region_pagefault,
|
||||
};
|
||||
|
||||
int dma_region_mmap(struct dma_region *dma, struct file *file, struct vm_area_struct *vma)
|
||||
{
|
||||
unsigned long size;
|
||||
|
||||
if (!dma->kvirt)
|
||||
return -EINVAL;
|
||||
|
||||
/* must be page-aligned */
|
||||
if (vma->vm_pgoff != 0)
|
||||
return -EINVAL;
|
||||
|
||||
/* check the length */
|
||||
size = vma->vm_end - vma->vm_start;
|
||||
if (size > (dma->n_pages << PAGE_SHIFT))
|
||||
return -EINVAL;
|
||||
|
||||
vma->vm_ops = &dma_region_vm_ops;
|
||||
vma->vm_private_data = dma;
|
||||
vma->vm_file = file;
|
||||
vma->vm_flags |= VM_RESERVED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* CONFIG_MMU */
|
||||
|
||||
int dma_region_mmap(struct dma_region *dma, struct file *file, struct vm_area_struct *vma)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_MMU */
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* DMA region bookkeeping routines
|
||||
*
|
||||
* Copyright (C) 2002 Maas Digital LLC
|
||||
*
|
||||
* This code is licensed under the GPL. See the file COPYING in the root
|
||||
* directory of the kernel sources for details.
|
||||
*/
|
||||
|
||||
#ifndef IEEE1394_DMA_H
|
||||
#define IEEE1394_DMA_H
|
||||
|
||||
#include <linux/pci.h>
|
||||
#include <asm/scatterlist.h>
|
||||
|
||||
/* struct dma_prog_region
|
||||
|
||||
a small, physically-contiguous DMA buffer with random-access,
|
||||
synchronous usage characteristics
|
||||
*/
|
||||
|
||||
struct dma_prog_region {
|
||||
unsigned char *kvirt; /* kernel virtual address */
|
||||
struct pci_dev *dev; /* PCI device */
|
||||
unsigned int n_pages; /* # of kernel pages */
|
||||
dma_addr_t bus_addr; /* base bus address */
|
||||
};
|
||||
|
||||
/* clear out all fields but do not allocate any memory */
|
||||
void dma_prog_region_init(struct dma_prog_region *prog);
|
||||
int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes, struct pci_dev *dev);
|
||||
void dma_prog_region_free(struct dma_prog_region *prog);
|
||||
|
||||
static inline dma_addr_t dma_prog_region_offset_to_bus(struct dma_prog_region *prog, unsigned long offset)
|
||||
{
|
||||
return prog->bus_addr + offset;
|
||||
}
|
||||
|
||||
/* struct dma_region
|
||||
|
||||
a large, non-physically-contiguous DMA buffer with streaming,
|
||||
asynchronous usage characteristics
|
||||
*/
|
||||
|
||||
struct dma_region {
|
||||
unsigned char *kvirt; /* kernel virtual address */
|
||||
struct pci_dev *dev; /* PCI device */
|
||||
unsigned int n_pages; /* # of kernel pages */
|
||||
unsigned int n_dma_pages; /* # of IOMMU pages */
|
||||
struct scatterlist *sglist; /* IOMMU mapping */
|
||||
int direction; /* PCI_DMA_TODEVICE, etc */
|
||||
};
|
||||
|
||||
/* clear out all fields but do not allocate anything */
|
||||
void dma_region_init(struct dma_region *dma);
|
||||
|
||||
/* allocate the buffer and map it to the IOMMU */
|
||||
int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_dev *dev, int direction);
|
||||
|
||||
/* unmap and free the buffer */
|
||||
void dma_region_free(struct dma_region *dma);
|
||||
|
||||
/* sync the CPU's view of the buffer */
|
||||
void dma_region_sync_for_cpu(struct dma_region *dma, unsigned long offset, unsigned long len);
|
||||
/* sync the IO bus' view of the buffer */
|
||||
void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset, unsigned long len);
|
||||
|
||||
/* map the buffer into a user space process */
|
||||
int dma_region_mmap(struct dma_region *dma, struct file *file, struct vm_area_struct *vma);
|
||||
|
||||
/* macro to index into a DMA region (or dma_prog_region) */
|
||||
#define dma_region_i(_dma, _type, _index) ( ((_type*) ((_dma)->kvirt)) + (_index) )
|
||||
|
||||
/* return the DMA bus address of the byte with the given offset
|
||||
relative to the beginning of the dma_region */
|
||||
dma_addr_t dma_region_offset_to_bus(struct dma_region *dma, unsigned long offset);
|
||||
|
||||
#endif /* IEEE1394_DMA_H */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,305 @@
|
||||
/*
|
||||
* dv1394.h - DV input/output over IEEE 1394 on OHCI chips
|
||||
* Copyright (C)2001 Daniel Maas <dmaas@dcine.com>
|
||||
* receive by Dan Dennedy <dan@dennedy.org>
|
||||
*
|
||||
* based on:
|
||||
* video1394.h - driver for OHCI 1394 boards
|
||||
* Copyright (C)1999,2000 Sebastien Rougeaux <sebastien.rougeaux@anu.edu.au>
|
||||
* Peter Schlaile <udbz@rz.uni-karlsruhe.de>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _DV_1394_H
|
||||
#define _DV_1394_H
|
||||
|
||||
/* This is the public user-space interface. Try not to break it. */
|
||||
|
||||
#define DV1394_API_VERSION 0x20011127
|
||||
|
||||
/* ********************
|
||||
** **
|
||||
** DV1394 API **
|
||||
** **
|
||||
********************
|
||||
|
||||
There are two methods of operating the DV1394 DV output device.
|
||||
|
||||
1)
|
||||
|
||||
The simplest is an interface based on write(): simply write
|
||||
full DV frames of data to the device, and they will be transmitted
|
||||
as quickly as possible. The FD may be set for non-blocking I/O,
|
||||
in which case you can use select() or poll() to wait for output
|
||||
buffer space.
|
||||
|
||||
To set the DV output parameters (e.g. whether you want NTSC or PAL
|
||||
video), use the DV1394_INIT ioctl, passing in the parameters you
|
||||
want in a struct dv1394_init.
|
||||
|
||||
Example 1:
|
||||
To play a raw .DV file: cat foo.DV > /dev/dv1394
|
||||
(cat will use write() internally)
|
||||
|
||||
Example 2:
|
||||
static struct dv1394_init init = {
|
||||
0x63, (broadcast channel)
|
||||
4, (four-frame ringbuffer)
|
||||
DV1394_NTSC, (send NTSC video)
|
||||
0, 0 (default empty packet rate)
|
||||
}
|
||||
|
||||
ioctl(fd, DV1394_INIT, &init);
|
||||
|
||||
while (1) {
|
||||
read( <a raw DV file>, buf, DV1394_NTSC_FRAME_SIZE );
|
||||
write( <the dv1394 FD>, buf, DV1394_NTSC_FRAME_SIZE );
|
||||
}
|
||||
|
||||
2)
|
||||
|
||||
For more control over buffering, and to avoid unnecessary copies
|
||||
of the DV data, you can use the more sophisticated the mmap() interface.
|
||||
First, call the DV1394_INIT ioctl to specify your parameters,
|
||||
including the number of frames in the ringbuffer. Then, calling mmap()
|
||||
on the dv1394 device will give you direct access to the ringbuffer
|
||||
from which the DV card reads your frame data.
|
||||
|
||||
The ringbuffer is simply one large, contiguous region of memory
|
||||
containing two or more frames of packed DV data. Each frame of DV data
|
||||
is 120000 bytes (NTSC) or 144000 bytes (PAL).
|
||||
|
||||
Fill one or more frames in the ringbuffer, then use the DV1394_SUBMIT_FRAMES
|
||||
ioctl to begin I/O. You can use either the DV1394_WAIT_FRAMES ioctl
|
||||
or select()/poll() to wait until the frames are transmitted. Next, you'll
|
||||
need to call the DV1394_GET_STATUS ioctl to determine which ringbuffer
|
||||
frames are clear (ready to be filled with new DV data). Finally, use
|
||||
DV1394_SUBMIT_FRAMES again to send the new data to the DV output.
|
||||
|
||||
|
||||
Example: here is what a four-frame ringbuffer might look like
|
||||
during DV transmission:
|
||||
|
||||
|
||||
frame 0 frame 1 frame 2 frame 3
|
||||
|
||||
*--------------------------------------*
|
||||
| CLEAR | DV data | DV data | CLEAR |
|
||||
*--------------------------------------*
|
||||
<ACTIVE>
|
||||
|
||||
transmission goes in this direction --->>>
|
||||
|
||||
|
||||
The DV hardware is currently transmitting the data in frame 1.
|
||||
Once frame 1 is finished, it will automatically transmit frame 2.
|
||||
(if frame 2 finishes before frame 3 is submitted, the device
|
||||
will continue to transmit frame 2, and will increase the dropped_frames
|
||||
counter each time it repeats the transmission).
|
||||
|
||||
|
||||
If you called DV1394_GET_STATUS at this instant, you would
|
||||
receive the following values:
|
||||
|
||||
n_frames = 4
|
||||
active_frame = 1
|
||||
first_clear_frame = 3
|
||||
n_clear_frames = 2
|
||||
|
||||
At this point, you should write new DV data into frame 3 and optionally
|
||||
frame 0. Then call DV1394_SUBMIT_FRAMES to inform the device that
|
||||
it may transmit the new frames.
|
||||
|
||||
ERROR HANDLING
|
||||
|
||||
An error (buffer underflow/overflow or a break in the DV stream due
|
||||
to a 1394 bus reset) can be detected by checking the dropped_frames
|
||||
field of struct dv1394_status (obtained through the
|
||||
DV1394_GET_STATUS ioctl).
|
||||
|
||||
The best way to recover from such an error is to re-initialize
|
||||
dv1394, either by using the DV1394_INIT ioctl call, or closing the
|
||||
file descriptor and opening it again. (note that you must unmap all
|
||||
ringbuffer mappings when closing the file descriptor, or else
|
||||
dv1394 will still be considered 'in use').
|
||||
|
||||
MAIN LOOP
|
||||
|
||||
For maximum efficiency and robustness against bus errors, you are
|
||||
advised to model the main loop of your application after the
|
||||
following pseudo-code example:
|
||||
|
||||
(checks of system call return values omitted for brevity; always
|
||||
check return values in your code!)
|
||||
|
||||
while ( frames left ) {
|
||||
|
||||
struct pollfd *pfd = ...;
|
||||
|
||||
pfd->fd = dv1394_fd;
|
||||
pfd->revents = 0;
|
||||
pfd->events = POLLOUT | POLLIN; (OUT for transmit, IN for receive)
|
||||
|
||||
(add other sources of I/O here)
|
||||
|
||||
poll(pfd, 1, -1); (or select(); add a timeout if you want)
|
||||
|
||||
if (pfd->revents) {
|
||||
struct dv1394_status status;
|
||||
|
||||
ioctl(dv1394_fd, DV1394_GET_STATUS, &status);
|
||||
|
||||
if (status.dropped_frames > 0) {
|
||||
reset_dv1394();
|
||||
} else {
|
||||
for (int i = 0; i < status.n_clear_frames; i++) {
|
||||
copy_DV_frame();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
where copy_DV_frame() reads or writes on the dv1394 file descriptor
|
||||
(read/write mode) or copies data to/from the mmap ringbuffer and
|
||||
then calls ioctl(DV1394_SUBMIT_FRAMES) to notify dv1394 that new
|
||||
frames are availble (mmap mode).
|
||||
|
||||
reset_dv1394() is called in the event of a buffer
|
||||
underflow/overflow or a halt in the DV stream (e.g. due to a 1394
|
||||
bus reset). To guarantee recovery from the error, this function
|
||||
should close the dv1394 file descriptor (and munmap() all
|
||||
ringbuffer mappings, if you are using them), then re-open the
|
||||
dv1394 device (and re-map the ringbuffer).
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* maximum number of frames in the ringbuffer */
|
||||
#define DV1394_MAX_FRAMES 32
|
||||
|
||||
/* number of *full* isochronous packets per DV frame */
|
||||
#define DV1394_NTSC_PACKETS_PER_FRAME 250
|
||||
#define DV1394_PAL_PACKETS_PER_FRAME 300
|
||||
|
||||
/* size of one frame's worth of DV data, in bytes */
|
||||
#define DV1394_NTSC_FRAME_SIZE (480 * DV1394_NTSC_PACKETS_PER_FRAME)
|
||||
#define DV1394_PAL_FRAME_SIZE (480 * DV1394_PAL_PACKETS_PER_FRAME)
|
||||
|
||||
|
||||
/* ioctl() commands */
|
||||
#include "ieee1394-ioctl.h"
|
||||
|
||||
|
||||
enum pal_or_ntsc {
|
||||
DV1394_NTSC = 0,
|
||||
DV1394_PAL
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/* this is the argument to DV1394_INIT */
|
||||
struct dv1394_init {
|
||||
/* DV1394_API_VERSION */
|
||||
unsigned int api_version;
|
||||
|
||||
/* isochronous transmission channel to use */
|
||||
unsigned int channel;
|
||||
|
||||
/* number of frames in the ringbuffer. Must be at least 2
|
||||
and at most DV1394_MAX_FRAMES. */
|
||||
unsigned int n_frames;
|
||||
|
||||
/* send/receive PAL or NTSC video format */
|
||||
enum pal_or_ntsc format;
|
||||
|
||||
/* the following are used only for transmission */
|
||||
|
||||
/* set these to zero unless you want a
|
||||
non-default empty packet rate (see below) */
|
||||
unsigned long cip_n;
|
||||
unsigned long cip_d;
|
||||
|
||||
/* set this to zero unless you want a
|
||||
non-default SYT cycle offset (default = 3 cycles) */
|
||||
unsigned int syt_offset;
|
||||
};
|
||||
|
||||
/* NOTE: you may only allocate the DV frame ringbuffer once each time
|
||||
you open the dv1394 device. DV1394_INIT will fail if you call it a
|
||||
second time with different 'n_frames' or 'format' arguments (which
|
||||
would imply a different size for the ringbuffer). If you need a
|
||||
different buffer size, simply close and re-open the device, then
|
||||
initialize it with your new settings. */
|
||||
|
||||
/* Q: What are cip_n and cip_d? */
|
||||
|
||||
/*
|
||||
A: DV video streams do not utilize 100% of the potential bandwidth offered
|
||||
by IEEE 1394 (FireWire). To achieve the correct rate of data transmission,
|
||||
DV devices must periodically insert empty packets into the 1394 data stream.
|
||||
Typically there is one empty packet per 14-16 data-carrying packets.
|
||||
|
||||
Some DV devices will accept a wide range of empty packet rates, while others
|
||||
require a precise rate. If the dv1394 driver produces empty packets at
|
||||
a rate that your device does not accept, you may see ugly patterns on the
|
||||
DV output, or even no output at all.
|
||||
|
||||
The default empty packet insertion rate seems to work for many people; if
|
||||
your DV output is stable, you can simply ignore this discussion. However,
|
||||
we have exposed the empty packet rate as a parameter to support devices that
|
||||
do not work with the default rate.
|
||||
|
||||
The decision to insert an empty packet is made with a numerator/denominator
|
||||
algorithm. Empty packets are produced at an average rate of CIP_N / CIP_D.
|
||||
You can alter the empty packet rate by passing non-zero values for cip_n
|
||||
and cip_d to the INIT ioctl.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
struct dv1394_status {
|
||||
/* this embedded init struct returns the current dv1394
|
||||
parameters in use */
|
||||
struct dv1394_init init;
|
||||
|
||||
/* the ringbuffer frame that is currently being
|
||||
displayed. (-1 if the device is not transmitting anything) */
|
||||
int active_frame;
|
||||
|
||||
/* index of the first buffer (ahead of active_frame) that
|
||||
is ready to be filled with data */
|
||||
unsigned int first_clear_frame;
|
||||
|
||||
/* how many buffers, including first_clear_buffer, are
|
||||
ready to be filled with data */
|
||||
unsigned int n_clear_frames;
|
||||
|
||||
/* how many times the DV stream has underflowed, overflowed,
|
||||
or otherwise encountered an error, since the previous call
|
||||
to DV1394_GET_STATUS */
|
||||
unsigned int dropped_frames;
|
||||
|
||||
/* N.B. The dropped_frames counter is only a lower bound on the actual
|
||||
number of dropped frames, with the special case that if dropped_frames
|
||||
is zero, then it is guaranteed that NO frames have been dropped
|
||||
since the last call to DV1394_GET_STATUS.
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
#endif /* _DV_1394_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* eth1394.h -- Ethernet driver for Linux IEEE-1394 Subsystem
|
||||
*
|
||||
* Copyright (C) 2000 Bonin Franck <boninf@free.fr>
|
||||
* (C) 2001 Ben Collins <bcollins@debian.org>
|
||||
*
|
||||
* Mainly based on work by Emanuel Pirker and Andreas E. Bombe
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __ETH1394_H
|
||||
#define __ETH1394_H
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
#include "ieee1394.h"
|
||||
|
||||
/* Register for incoming packets. This is 4096 bytes, which supports up to
|
||||
* S3200 (per Table 16-3 of IEEE 1394b-2002). */
|
||||
#define ETHER1394_REGION_ADDR_LEN 4096
|
||||
|
||||
#define ETHER1394_INVALID_ADDR ~0ULL
|
||||
|
||||
/* GASP identifier numbers for IPv4 over IEEE 1394 */
|
||||
#define ETHER1394_GASP_SPECIFIER_ID 0x00005E
|
||||
#define ETHER1394_GASP_SPECIFIER_ID_HI ((ETHER1394_GASP_SPECIFIER_ID >> 8) & 0xffff)
|
||||
#define ETHER1394_GASP_SPECIFIER_ID_LO (ETHER1394_GASP_SPECIFIER_ID & 0xff)
|
||||
#define ETHER1394_GASP_VERSION 1
|
||||
|
||||
#define ETHER1394_GASP_OVERHEAD (2 * sizeof(quadlet_t)) /* GASP header overhead */
|
||||
|
||||
#define ETHER1394_GASP_BUFFERS 16
|
||||
|
||||
/* Node set == 64 */
|
||||
#define NODE_SET (ALL_NODES + 1)
|
||||
|
||||
enum eth1394_bc_states { ETHER1394_BC_ERROR,
|
||||
ETHER1394_BC_RUNNING,
|
||||
ETHER1394_BC_STOPPED };
|
||||
|
||||
|
||||
/* Private structure for our ethernet driver */
|
||||
struct eth1394_priv {
|
||||
struct net_device_stats stats; /* Device stats */
|
||||
struct hpsb_host *host; /* The card for this dev */
|
||||
u16 bc_maxpayload; /* Max broadcast payload */
|
||||
u8 bc_sspd; /* Max broadcast speed */
|
||||
u64 local_fifo; /* Local FIFO Address */
|
||||
spinlock_t lock; /* Private lock */
|
||||
int broadcast_channel; /* Async stream Broadcast Channel */
|
||||
enum eth1394_bc_states bc_state; /* broadcast channel state */
|
||||
struct hpsb_iso *iso; /* Async stream recv handle */
|
||||
int bc_dgl; /* Outgoing broadcast datagram label */
|
||||
struct list_head ip_node_list; /* List of IP capable nodes */
|
||||
struct unit_directory *ud_list[ALL_NODES]; /* Cached unit dir list */
|
||||
};
|
||||
|
||||
|
||||
/* Define a fake hardware header format for the networking core. Note that
|
||||
* header size cannot exceed 16 bytes as that is the size of the header cache.
|
||||
* Also, we do not need the source address in the header so we omit it and
|
||||
* keep the header to under 16 bytes */
|
||||
#define ETH1394_ALEN (8)
|
||||
#define ETH1394_HLEN (10)
|
||||
|
||||
struct eth1394hdr {
|
||||
unsigned char h_dest[ETH1394_ALEN]; /* destination eth1394 addr */
|
||||
unsigned short h_proto; /* packet type ID field */
|
||||
} __attribute__((packed));
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/skbuff.h>
|
||||
|
||||
static inline struct eth1394hdr *eth1394_hdr(const struct sk_buff *skb)
|
||||
{
|
||||
return (struct eth1394hdr *)skb->mac.raw;
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type;
|
||||
|
||||
/* IP1394 headers */
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
/* Unfragmented */
|
||||
#if defined __BIG_ENDIAN_BITFIELD
|
||||
struct eth1394_uf_hdr {
|
||||
u16 lf:2;
|
||||
u16 res:14;
|
||||
u16 ether_type; /* Ethernet packet type */
|
||||
} __attribute__((packed));
|
||||
#elif defined __LITTLE_ENDIAN_BITFIELD
|
||||
struct eth1394_uf_hdr {
|
||||
u16 res:14;
|
||||
u16 lf:2;
|
||||
u16 ether_type;
|
||||
} __attribute__((packed));
|
||||
#else
|
||||
#error Unknown bit field type
|
||||
#endif
|
||||
|
||||
/* First fragment */
|
||||
#if defined __BIG_ENDIAN_BITFIELD
|
||||
struct eth1394_ff_hdr {
|
||||
u16 lf:2;
|
||||
u16 res1:2;
|
||||
u16 dg_size:12; /* Datagram size */
|
||||
u16 ether_type; /* Ethernet packet type */
|
||||
u16 dgl; /* Datagram label */
|
||||
u16 res2;
|
||||
} __attribute__((packed));
|
||||
#elif defined __LITTLE_ENDIAN_BITFIELD
|
||||
struct eth1394_ff_hdr {
|
||||
u16 dg_size:12;
|
||||
u16 res1:2;
|
||||
u16 lf:2;
|
||||
u16 ether_type;
|
||||
u16 dgl;
|
||||
u16 res2;
|
||||
} __attribute__((packed));
|
||||
#else
|
||||
#error Unknown bit field type
|
||||
#endif
|
||||
|
||||
/* XXX: Subsequent fragments, including last */
|
||||
#if defined __BIG_ENDIAN_BITFIELD
|
||||
struct eth1394_sf_hdr {
|
||||
u16 lf:2;
|
||||
u16 res1:2;
|
||||
u16 dg_size:12; /* Datagram size */
|
||||
u16 res2:4;
|
||||
u16 fg_off:12; /* Fragment offset */
|
||||
u16 dgl; /* Datagram label */
|
||||
u16 res3;
|
||||
} __attribute__((packed));
|
||||
#elif defined __LITTLE_ENDIAN_BITFIELD
|
||||
struct eth1394_sf_hdr {
|
||||
u16 dg_size:12;
|
||||
u16 res1:2;
|
||||
u16 lf:2;
|
||||
u16 fg_off:12;
|
||||
u16 res2:4;
|
||||
u16 dgl;
|
||||
u16 res3;
|
||||
} __attribute__((packed));
|
||||
#else
|
||||
#error Unknown bit field type
|
||||
#endif
|
||||
|
||||
#if defined __BIG_ENDIAN_BITFIELD
|
||||
struct eth1394_common_hdr {
|
||||
u16 lf:2;
|
||||
u16 pad1:14;
|
||||
} __attribute__((packed));
|
||||
#elif defined __LITTLE_ENDIAN_BITFIELD
|
||||
struct eth1394_common_hdr {
|
||||
u16 pad1:14;
|
||||
u16 lf:2;
|
||||
} __attribute__((packed));
|
||||
#else
|
||||
#error Unknown bit field type
|
||||
#endif
|
||||
|
||||
struct eth1394_hdr_words {
|
||||
u16 word1;
|
||||
u16 word2;
|
||||
u16 word3;
|
||||
u16 word4;
|
||||
};
|
||||
|
||||
union eth1394_hdr {
|
||||
struct eth1394_common_hdr common;
|
||||
struct eth1394_uf_hdr uf;
|
||||
struct eth1394_ff_hdr ff;
|
||||
struct eth1394_sf_hdr sf;
|
||||
struct eth1394_hdr_words words;
|
||||
};
|
||||
|
||||
/* End of IP1394 headers */
|
||||
|
||||
/* Fragment types */
|
||||
#define ETH1394_HDR_LF_UF 0 /* unfragmented */
|
||||
#define ETH1394_HDR_LF_FF 1 /* first fragment */
|
||||
#define ETH1394_HDR_LF_LF 2 /* last fragment */
|
||||
#define ETH1394_HDR_LF_IF 3 /* interior fragment */
|
||||
|
||||
#define IP1394_HW_ADDR_LEN 16 /* As per RFC */
|
||||
|
||||
/* Our arp packet (ARPHRD_IEEE1394) */
|
||||
struct eth1394_arp {
|
||||
u16 hw_type; /* 0x0018 */
|
||||
u16 proto_type; /* 0x0806 */
|
||||
u8 hw_addr_len; /* 16 */
|
||||
u8 ip_addr_len; /* 4 */
|
||||
u16 opcode; /* ARP Opcode */
|
||||
/* Above is exactly the same format as struct arphdr */
|
||||
|
||||
u64 s_uniq_id; /* Sender's 64bit EUI */
|
||||
u8 max_rec; /* Sender's max packet size */
|
||||
u8 sspd; /* Sender's max speed */
|
||||
u16 fifo_hi; /* hi 16bits of sender's FIFO addr */
|
||||
u32 fifo_lo; /* lo 32bits of sender's FIFO addr */
|
||||
u32 sip; /* Sender's IP Address */
|
||||
u32 tip; /* IP Address of requested hw addr */
|
||||
};
|
||||
|
||||
/* Network timeout */
|
||||
#define ETHER1394_TIMEOUT 100000
|
||||
|
||||
/* This is our task struct. It's used for the packet complete callback. */
|
||||
struct packet_task {
|
||||
struct sk_buff *skb;
|
||||
int outstanding_pkts;
|
||||
eth1394_tx_type tx_type;
|
||||
int max_payload;
|
||||
struct hpsb_packet *packet;
|
||||
struct eth1394_priv *priv;
|
||||
union eth1394_hdr hdr;
|
||||
u64 addr;
|
||||
u16 dest_node;
|
||||
};
|
||||
|
||||
#endif /* __ETH1394_H */
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user