Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
firewire.h File Reference
#include <linux/completion.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/sysfs.h>
#include <linux/timer.h>
#include <linux/types.h>
#include <linux/workqueue.h>
#include <linux/atomic.h>
#include <asm/byteorder.h>

Go to the source code of this file.

Data Structures

struct  fw_csr_iterator
 
struct  fw_card
 
struct  fw_attribute_group
 
struct  fw_device
 
struct  fw_unit
 
struct  fw_driver
 
struct  fw_packet
 
struct  fw_transaction
 
struct  fw_address_handler
 
struct  fw_address_region
 
struct  fw_descriptor
 
struct  fw_iso_packet
 
struct  fw_iso_buffer
 
struct  fw_iso_context
 

Macros

#define CSR_REGISTER_BASE   0xfffff0000000ULL
 
#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_PRIORITY_BUDGET   0x218
 
#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_MAINT_UTILITY   0x230
 
#define CSR_BROADCAST_CHANNEL   0x234
 
#define CSR_CONFIG_ROM   0x400
 
#define CSR_CONFIG_ROM_END   0x800
 
#define CSR_OMPR   0x900
 
#define CSR_OPCR(i)   (0x904 + (i) * 4)
 
#define CSR_IMPR   0x980
 
#define CSR_IPCR(i)   (0x984 + (i) * 4)
 
#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
 
#define CSR_OFFSET   0x40
 
#define CSR_LEAF   0x80
 
#define CSR_DIRECTORY   0xc0
 
#define CSR_DESCRIPTOR   0x01
 
#define CSR_VENDOR   0x03
 
#define CSR_HARDWARE_VERSION   0x04
 
#define CSR_UNIT   0x11
 
#define CSR_SPECIFIER_ID   0x12
 
#define CSR_VERSION   0x13
 
#define CSR_DEPENDENT_INFO   0x14
 
#define CSR_MODEL   0x17
 
#define CSR_DIRECTORY_ID   0x20
 
#define FW_ISO_CONTEXT_TRANSMIT   0
 
#define FW_ISO_CONTEXT_RECEIVE   1
 
#define FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL   2
 
#define FW_ISO_CONTEXT_MATCH_TAG0   1
 
#define FW_ISO_CONTEXT_MATCH_TAG1   2
 
#define FW_ISO_CONTEXT_MATCH_TAG2   4
 
#define FW_ISO_CONTEXT_MATCH_TAG3   8
 
#define FW_ISO_CONTEXT_MATCH_ALL_TAGS   15
 

Typedefs

typedef void(* fw_packet_callback_t )(struct fw_packet *packet, struct fw_card *card, int status)
 
typedef void(* fw_transaction_callback_t )(struct fw_card *card, int rcode, void *data, size_t length, void *callback_data)
 
typedef void(* fw_address_callback_t )(struct fw_card *card, struct fw_request *request, int tcode, int destination, int source, int generation, unsigned long long offset, void *data, size_t length, void *callback_data)
 
typedef void(* fw_iso_callback_t )(struct fw_iso_context *context, u32 cycle, size_t header_length, void *header, void *data)
 
typedef void(* fw_iso_mc_callback_t )(struct fw_iso_context *context, dma_addr_t completed, void *data)
 

Enumerations

enum  fw_device_state { FW_DEVICE_INITIALIZING, FW_DEVICE_RUNNING, FW_DEVICE_GONE, FW_DEVICE_SHUTDOWN }
 

Functions

void fw_csr_iterator_init (struct fw_csr_iterator *ci, const u32 *p)
 
int fw_csr_iterator_next (struct fw_csr_iterator *ci, int *key, int *value)
 
int fw_csr_string (const u32 *directory, int key, char *buf, size_t size)
 
void fw_card_release (struct kref *kref)
 
int fw_device_enable_phys_dma (struct fw_device *device)
 
int fw_core_add_address_handler (struct fw_address_handler *handler, const struct fw_address_region *region)
 
void fw_core_remove_address_handler (struct fw_address_handler *handler)
 
void fw_send_response (struct fw_card *card, struct fw_request *request, int rcode)
 
int fw_get_request_speed (struct fw_request *request)
 
void fw_send_request (struct fw_card *card, struct fw_transaction *t, int tcode, int destination_id, int generation, int speed, unsigned long long offset, void *payload, size_t length, fw_transaction_callback_t callback, void *callback_data)
 
int fw_cancel_transaction (struct fw_card *card, struct fw_transaction *transaction)
 
int fw_run_transaction (struct fw_card *card, int tcode, int destination_id, int generation, int speed, unsigned long long offset, void *payload, size_t length)
 
const charfw_rcode_string (int rcode)
 
int fw_core_add_descriptor (struct fw_descriptor *desc)
 
void fw_core_remove_descriptor (struct fw_descriptor *desc)
 
int fw_iso_buffer_init (struct fw_iso_buffer *buffer, struct fw_card *card, int page_count, enum dma_data_direction direction)
 
void fw_iso_buffer_destroy (struct fw_iso_buffer *buffer, struct fw_card *card)
 
size_t fw_iso_buffer_lookup (struct fw_iso_buffer *buffer, dma_addr_t completed)
 
struct fw_iso_contextfw_iso_context_create (struct fw_card *card, int type, int channel, int speed, size_t header_size, fw_iso_callback_t callback, void *callback_data)
 
int fw_iso_context_set_channels (struct fw_iso_context *ctx, u64 *channels)
 
int fw_iso_context_queue (struct fw_iso_context *ctx, struct fw_iso_packet *packet, struct fw_iso_buffer *buffer, unsigned long payload)
 
void fw_iso_context_queue_flush (struct fw_iso_context *ctx)
 
int fw_iso_context_flush_completions (struct fw_iso_context *ctx)
 
int fw_iso_context_start (struct fw_iso_context *ctx, int cycle, int sync, int tags)
 
int fw_iso_context_stop (struct fw_iso_context *ctx)
 
void fw_iso_context_destroy (struct fw_iso_context *ctx)
 
void fw_iso_resource_manage (struct fw_card *card, int generation, u64 channels_mask, int *channel, int *bandwidth, bool allocate)
 

Variables

struct bus_type fw_bus_type
 
struct fw_address_region fw_high_memory_region
 
struct workqueue_structfw_workqueue
 

Macro Definition Documentation

#define CSR_BANDWIDTH_AVAILABLE   0x220

Definition at line 34 of file firewire.h.

#define CSR_BROADCAST_CHANNEL   0x234

Definition at line 39 of file firewire.h.

#define CSR_BUS_MANAGER_ID   0x21c

Definition at line 33 of file firewire.h.

#define CSR_BUS_TIME   0x204

Definition at line 30 of file firewire.h.

#define CSR_BUSY_TIMEOUT   0x210

Definition at line 31 of file firewire.h.

#define CSR_CHANNELS_AVAILABLE   0x224

Definition at line 35 of file firewire.h.

#define CSR_CHANNELS_AVAILABLE_HI   0x224

Definition at line 36 of file firewire.h.

#define CSR_CHANNELS_AVAILABLE_LO   0x228

Definition at line 37 of file firewire.h.

#define CSR_CONFIG_ROM   0x400

Definition at line 40 of file firewire.h.

#define CSR_CONFIG_ROM_END   0x800

Definition at line 41 of file firewire.h.

#define CSR_CYCLE_TIME   0x200

Definition at line 29 of file firewire.h.

#define CSR_DEPENDENT_INFO   0x14

Definition at line 64 of file firewire.h.

#define CSR_DESCRIPTOR   0x01

Definition at line 58 of file firewire.h.

#define CSR_DIRECTORY   0xc0

Definition at line 56 of file firewire.h.

#define CSR_DIRECTORY_ID   0x20

Definition at line 66 of file firewire.h.

#define CSR_FCP_COMMAND   0xB00

Definition at line 46 of file firewire.h.

#define CSR_FCP_END   0xF00

Definition at line 48 of file firewire.h.

#define CSR_FCP_RESPONSE   0xD00

Definition at line 47 of file firewire.h.

#define CSR_HARDWARE_VERSION   0x04

Definition at line 60 of file firewire.h.

#define CSR_IMPR   0x980

Definition at line 44 of file firewire.h.

#define CSR_IPCR (   i)    (0x984 + (i) * 4)

Definition at line 45 of file firewire.h.

#define CSR_LEAF   0x80

Definition at line 55 of file firewire.h.

#define CSR_MAINT_UTILITY   0x230

Definition at line 38 of file firewire.h.

#define CSR_MODEL   0x17

Definition at line 65 of file firewire.h.

#define CSR_NODE_IDS   0x8

Definition at line 25 of file firewire.h.

#define CSR_OFFSET   0x40

Definition at line 54 of file firewire.h.

#define CSR_OMPR   0x900

Definition at line 42 of file firewire.h.

#define CSR_OPCR (   i)    (0x904 + (i) * 4)

Definition at line 43 of file firewire.h.

#define CSR_PRIORITY_BUDGET   0x218

Definition at line 32 of file firewire.h.

#define CSR_REGISTER_BASE   0xfffff0000000ULL

Definition at line 20 of file firewire.h.

#define CSR_RESET_START   0xc

Definition at line 26 of file firewire.h.

#define CSR_SPECIFIER_ID   0x12

Definition at line 62 of file firewire.h.

#define CSR_SPEED_MAP   0x2000

Definition at line 51 of file firewire.h.

#define CSR_SPEED_MAP_END   0x3000

Definition at line 52 of file firewire.h.

#define CSR_SPLIT_TIMEOUT_HI   0x18

Definition at line 27 of file firewire.h.

#define CSR_SPLIT_TIMEOUT_LO   0x1c

Definition at line 28 of file firewire.h.

#define CSR_STATE_CLEAR   0x0

Definition at line 23 of file firewire.h.

#define CSR_STATE_SET   0x4

Definition at line 24 of file firewire.h.

#define CSR_TOPOLOGY_MAP   0x1000

Definition at line 49 of file firewire.h.

#define CSR_TOPOLOGY_MAP_END   0x1400

Definition at line 50 of file firewire.h.

#define CSR_UNIT   0x11

Definition at line 61 of file firewire.h.

#define CSR_VENDOR   0x03

Definition at line 59 of file firewire.h.

#define CSR_VERSION   0x13

Definition at line 63 of file firewire.h.

#define FW_ISO_CONTEXT_MATCH_ALL_TAGS   15

Definition at line 405 of file firewire.h.

#define FW_ISO_CONTEXT_MATCH_TAG0   1

Definition at line 401 of file firewire.h.

#define FW_ISO_CONTEXT_MATCH_TAG1   2

Definition at line 402 of file firewire.h.

#define FW_ISO_CONTEXT_MATCH_TAG2   4

Definition at line 403 of file firewire.h.

#define FW_ISO_CONTEXT_MATCH_TAG3   8

Definition at line 404 of file firewire.h.

#define FW_ISO_CONTEXT_RECEIVE   1

Definition at line 398 of file firewire.h.

#define FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL   2

Definition at line 399 of file firewire.h.

#define FW_ISO_CONTEXT_TRANSMIT   0

Definition at line 397 of file firewire.h.

Typedef Documentation

typedef void(* fw_address_callback_t)(struct fw_card *card, struct fw_request *request, int tcode, int destination, int source, int generation, unsigned long long offset, void *data, size_t length, void *callback_data)

Definition at line 279 of file firewire.h.

typedef void(* fw_iso_callback_t)(struct fw_iso_context *context, u32 cycle, size_t header_length, void *header, void *data)

Definition at line 427 of file firewire.h.

typedef void(* fw_iso_mc_callback_t)(struct fw_iso_context *context, dma_addr_t completed, void *data)

Definition at line 430 of file firewire.h.

typedef void(* fw_packet_callback_t)(struct fw_packet *packet, struct fw_card *card, int status)

Definition at line 262 of file firewire.h.

typedef void(* fw_transaction_callback_t)(struct fw_card *card, int rcode, void *data, size_t length, void *callback_data)

Definition at line 264 of file firewire.h.

Enumeration Type Documentation

Enumerator:
FW_DEVICE_INITIALIZING 
FW_DEVICE_RUNNING 
FW_DEVICE_GONE 
FW_DEVICE_SHUTDOWN 

Definition at line 158 of file firewire.h.

Function Documentation

int fw_cancel_transaction ( struct fw_card card,
struct fw_transaction transaction 
)

Definition at line 119 of file core-transaction.c.

void fw_card_release ( struct kref kref)

Definition at line 673 of file core-card.c.

int fw_core_add_address_handler ( struct fw_address_handler handler,
const struct fw_address_region region 
)

fw_core_add_address_handler() - register for incoming requests : callback : region in the IEEE 1212 node space address range

region->start, ->end, and handler->length have to be quadlet-aligned.

When a request is received that falls within the specified address range, the specified callback is invoked. The parameters passed to the callback give the details of the particular request.

To be called in process context. Return value: 0 on success, non-zero otherwise.

The start offset of the handler's address region is determined by fw_core_add_address_handler() and is returned in handler->offset.

Address allocations are exclusive, except for the FCP registers.

Definition at line 567 of file core-transaction.c.

int fw_core_add_descriptor ( struct fw_descriptor desc)

Definition at line 180 of file core-card.c.

void fw_core_remove_address_handler ( struct fw_address_handler handler)

fw_core_remove_address_handler() - unregister an address handler

To be called in process context.

When fw_core_remove_address_handler() returns, ->callback() is guaranteed to not run on any CPU anymore.

Definition at line 613 of file core-transaction.c.

void fw_core_remove_descriptor ( struct fw_descriptor desc)

Definition at line 217 of file core-card.c.

void fw_csr_iterator_init ( struct fw_csr_iterator ci,
const u32 p 
)

Definition at line 47 of file core-device.c.

int fw_csr_iterator_next ( struct fw_csr_iterator ci,
int key,
int value 
)

Definition at line 54 of file core-device.c.

int fw_csr_string ( const u32 directory,
int  key,
char buf,
size_t  size 
)

fw_csr_string() - reads a string from the configuration ROM : e.g. root directory or unit directory : the key of the preceding directory entry : where to put the string : size of , in bytes

The string is taken from a minimal ASCII text descriptor leaf after the immediate entry with . The string is zero-terminated. Returns strlen(buf) or a negative error code.

Definition at line 120 of file core-device.c.

int fw_device_enable_phys_dma ( struct fw_device device)

Definition at line 219 of file core-device.c.

int fw_get_request_speed ( struct fw_request request)

fw_get_request_speed() - returns speed at which the was received

Definition at line 832 of file core-transaction.c.

void fw_iso_buffer_destroy ( struct fw_iso_buffer buffer,
struct fw_card card 
)

Definition at line 125 of file core-iso.c.

int fw_iso_buffer_init ( struct fw_iso_buffer buffer,
struct fw_card card,
int  page_count,
enum dma_data_direction  direction 
)

Definition at line 90 of file core-iso.c.

size_t fw_iso_buffer_lookup ( struct fw_iso_buffer buffer,
dma_addr_t  completed 
)

Definition at line 147 of file core-iso.c.

struct fw_iso_context* fw_iso_context_create ( struct fw_card card,
int  type,
int  channel,
int  speed,
size_t  header_size,
fw_iso_callback_t  callback,
void callback_data 
)
read

Definition at line 163 of file core-iso.c.

void fw_iso_context_destroy ( struct fw_iso_context ctx)

Definition at line 186 of file core-iso.c.

int fw_iso_context_flush_completions ( struct fw_iso_context ctx)

Definition at line 219 of file core-iso.c.

int fw_iso_context_queue ( struct fw_iso_context ctx,
struct fw_iso_packet packet,
struct fw_iso_buffer buffer,
unsigned long  payload 
)

Definition at line 204 of file core-iso.c.

void fw_iso_context_queue_flush ( struct fw_iso_context ctx)

Definition at line 213 of file core-iso.c.

int fw_iso_context_set_channels ( struct fw_iso_context ctx,
u64 channels 
)

Definition at line 199 of file core-iso.c.

int fw_iso_context_start ( struct fw_iso_context ctx,
int  cycle,
int  sync,
int  tags 
)

Definition at line 192 of file core-iso.c.

int fw_iso_context_stop ( struct fw_iso_context ctx)

Definition at line 225 of file core-iso.c.

void fw_iso_resource_manage ( struct fw_card card,
int  generation,
u64  channels_mask,
int channel,
int bandwidth,
bool  allocate 
)

fw_iso_resource_manage() - Allocate or deallocate a channel and/or bandwidth

In parameters: card, generation, channels_mask, bandwidth, allocate Out parameters: channel, bandwidth This function blocks (sleeps) during communication with the IRM.

Allocates or deallocates at most one channel out of channels_mask. channels_mask is a bitfield with MSB for channel 63 and LSB for channel 0. (Note, the IRM's CHANNELS_AVAILABLE is a big-endian bitfield with MSB for channel 0 and LSB for channel 63.) Allocates or deallocates as many bandwidth allocation units as specified.

Returns channel < 0 if no channel was allocated or deallocated. Returns bandwidth = 0 if no bandwidth was allocated or deallocated.

If generation is stale, deallocations succeed but allocations fail with channel = -EAGAIN.

If channel allocation fails, no bandwidth will be allocated either. If bandwidth allocation fails, no channel will be allocated either. But deallocations of channel and bandwidth are tried independently of each other's success.

Definition at line 362 of file core-iso.c.

const char* fw_rcode_string ( int  rcode)

fw_rcode_string - convert a firewire result code to an error description : the result code

Definition at line 1016 of file core-transaction.c.

int fw_run_transaction ( struct fw_card card,
int  tcode,
int  destination_id,
int  generation,
int  speed,
unsigned long long  offset,
void payload,
size_t  length 
)

fw_run_transaction() - send request and sleep until transaction is completed

Returns the RCODE. See fw_send_request() for parameter documentation. Unlike fw_send_request(), points to the payload of the request or/and to the payload of the response. DMA mapping restrictions apply to outbound request payloads of >= 8 bytes but not to inbound response payloads.

Definition at line 419 of file core-transaction.c.

void fw_send_request ( struct fw_card card,
struct fw_transaction t,
int  tcode,
int  destination_id,
int  generation,
int  speed,
unsigned long long  offset,
void payload,
size_t  length,
fw_transaction_callback_t  callback,
void callback_data 
)

fw_send_request() - submit a request packet for transmission : interface to send the request at : transaction instance to which the request belongs : transaction code : destination node ID, consisting of bus_ID and phy_ID : bus generation in which request and response are valid : transmission speed : 48bit wide offset into destination's address space : data payload for the request subaction : length of the payload, in bytes : function to be called when the transaction is completed : data to be passed to the transaction completion callback

Submit a request packet into the asynchronous request transmission queue. Can be called from atomic context. If you prefer a blocking API, use fw_run_transaction() in a context that can sleep.

In case of lock requests, specify one of the firewire-core specific TCODE_ constants instead of TCODE_LOCK_REQUEST in .

Make sure that the value in is not older than the one in . Otherwise the request is in danger to be sent to a wrong node.

In case of asynchronous stream packets i.e. TCODE_STREAM_DATA, the caller needs to synthesize with fw_stream_packet_destination_id(). It will contain tag, channel, and sy data instead of a node ID then.

The payload buffer at is going to be DMA-mapped except in case of <= 8 or of local (loopback) requests. Hence make sure that the buffer complies with the restrictions of the streaming DMA mapping API. must not be freed before the is called.

In case of request types without payload, is NULL and is 0.

After the transaction is completed successfully or unsuccessfully, the will be called. Among its parameters is the response code which is either one of the rcodes per IEEE 1394 or, in case of internal errors, the firewire-core specific RCODE_SEND_ERROR. The other firewire-core specific rcodes (RCODE_CANCELLED, RCODE_BUSY, RCODE_GENERATION, RCODE_NO_ACK) denote transaction timeout, busy responder, stale request generation, or missing ACK respectively.

Note some timing corner cases: fw_send_request() may complete much earlier than when the request packet actually hits the wire. On the other hand, transaction completion and hence execution of may happen even before fw_send_request() returns.

Definition at line 350 of file core-transaction.c.

void fw_send_response ( struct fw_card card,
struct fw_request request,
int  rcode 
)

Definition at line 804 of file core-transaction.c.

Variable Documentation

struct bus_type fw_bus_type

Definition at line 213 of file core-device.c.

struct fw_address_region fw_high_memory_region

Definition at line 525 of file core-transaction.c.

struct workqueue_struct* fw_workqueue

Definition at line 755 of file core-device.c.