Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
core-transaction.c File Reference
#include <linux/bug.h>
#include <linux/completion.h>
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/firewire.h>
#include <linux/firewire-constants.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/idr.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/rculist.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/types.h>
#include <linux/workqueue.h>
#include <asm/byteorder.h>
#include "core.h"

Go to the source code of this file.

Data Structures

struct  transaction_callback_data
 
struct  fw_request
 

Macros

#define HEADER_PRI(pri)   ((pri) << 0)
 
#define HEADER_TCODE(tcode)   ((tcode) << 4)
 
#define HEADER_RETRY(retry)   ((retry) << 8)
 
#define HEADER_TLABEL(tlabel)   ((tlabel) << 10)
 
#define HEADER_DESTINATION(destination)   ((destination) << 16)
 
#define HEADER_SOURCE(source)   ((source) << 16)
 
#define HEADER_RCODE(rcode)   ((rcode) << 12)
 
#define HEADER_OFFSET_HIGH(offset_high)   ((offset_high) << 0)
 
#define HEADER_DATA_LENGTH(length)   ((length) << 16)
 
#define HEADER_EXTENDED_TCODE(tcode)   ((tcode) << 0)
 
#define HEADER_GET_TCODE(q)   (((q) >> 4) & 0x0f)
 
#define HEADER_GET_TLABEL(q)   (((q) >> 10) & 0x3f)
 
#define HEADER_GET_RCODE(q)   (((q) >> 12) & 0x0f)
 
#define HEADER_GET_DESTINATION(q)   (((q) >> 16) & 0xffff)
 
#define HEADER_GET_SOURCE(q)   (((q) >> 16) & 0xffff)
 
#define HEADER_GET_OFFSET_HIGH(q)   (((q) >> 0) & 0xffff)
 
#define HEADER_GET_DATA_LENGTH(q)   (((q) >> 16) & 0xffff)
 
#define HEADER_GET_EXTENDED_TCODE(q)   (((q) >> 0) & 0xffff)
 
#define HEADER_DESTINATION_IS_BROADCAST(q)   (((q) & HEADER_DESTINATION(0x3f)) == HEADER_DESTINATION(0x3f))
 
#define PHY_PACKET_CONFIG   0x0
 
#define PHY_PACKET_LINK_ON   0x1
 
#define PHY_PACKET_SELF_ID   0x2
 
#define PHY_CONFIG_GAP_COUNT(gap_count)   (((gap_count) << 16) | (1 << 22))
 
#define PHY_CONFIG_ROOT_ID(node_id)   ((((node_id) & 0x3f) << 24) | (1 << 23))
 
#define PHY_IDENTIFIER(id)   ((id) << 30)
 

Functions

int fw_cancel_transaction (struct fw_card *card, struct fw_transaction *transaction)
 
 EXPORT_SYMBOL (fw_cancel_transaction)
 
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)
 
 EXPORT_SYMBOL (fw_send_request)
 
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)
 
 EXPORT_SYMBOL (fw_run_transaction)
 
void fw_send_phy_config (struct fw_card *card, int node_id, int generation, int gap_count)
 
 EXPORT_SYMBOL (fw_high_memory_region)
 
int fw_core_add_address_handler (struct fw_address_handler *handler, const struct fw_address_region *region)
 
 EXPORT_SYMBOL (fw_core_add_address_handler)
 
void fw_core_remove_address_handler (struct fw_address_handler *handler)
 
 EXPORT_SYMBOL (fw_core_remove_address_handler)
 
int fw_get_response_length (struct fw_request *r)
 
void fw_fill_response (struct fw_packet *response, u32 *request_header, int rcode, void *payload, size_t length)
 
 EXPORT_SYMBOL (fw_fill_response)
 
void fw_send_response (struct fw_card *card, struct fw_request *request, int rcode)
 
 EXPORT_SYMBOL (fw_send_response)
 
int fw_get_request_speed (struct fw_request *request)
 
 EXPORT_SYMBOL (fw_get_request_speed)
 
void fw_core_handle_request (struct fw_card *card, struct fw_packet *p)
 
 EXPORT_SYMBOL (fw_core_handle_request)
 
void fw_core_handle_response (struct fw_card *card, struct fw_packet *p)
 
 EXPORT_SYMBOL (fw_core_handle_response)
 
const charfw_rcode_string (int rcode)
 
 EXPORT_SYMBOL (fw_rcode_string)
 
 MODULE_AUTHOR ("Kristian Hoegsberg <[email protected]>")
 
 MODULE_DESCRIPTION ("Core IEEE1394 transaction logic")
 
 MODULE_LICENSE ("GPL")
 
 module_init (fw_core_init)
 
 module_exit (fw_core_cleanup)
 

Variables

struct fw_address_region fw_high_memory_region
 

Macro Definition Documentation

#define HEADER_DATA_LENGTH (   length)    ((length) << 16)

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

#define HEADER_DESTINATION (   destination)    ((destination) << 16)

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

#define HEADER_DESTINATION_IS_BROADCAST (   q)    (((q) & HEADER_DESTINATION(0x3f)) == HEADER_DESTINATION(0x3f))

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

#define HEADER_EXTENDED_TCODE (   tcode)    ((tcode) << 0)

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

#define HEADER_GET_DATA_LENGTH (   q)    (((q) >> 16) & 0xffff)

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

#define HEADER_GET_DESTINATION (   q)    (((q) >> 16) & 0xffff)

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

#define HEADER_GET_EXTENDED_TCODE (   q)    (((q) >> 0) & 0xffff)

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

#define HEADER_GET_OFFSET_HIGH (   q)    (((q) >> 0) & 0xffff)

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

#define HEADER_GET_RCODE (   q)    (((q) >> 12) & 0x0f)

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

#define HEADER_GET_SOURCE (   q)    (((q) >> 16) & 0xffff)

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

#define HEADER_GET_TCODE (   q)    (((q) >> 4) & 0x0f)

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

#define HEADER_GET_TLABEL (   q)    (((q) >> 10) & 0x3f)

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

#define HEADER_OFFSET_HIGH (   offset_high)    ((offset_high) << 0)

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

#define HEADER_PRI (   pri)    ((pri) << 0)

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

#define HEADER_RCODE (   rcode)    ((rcode) << 12)

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

#define HEADER_RETRY (   retry)    ((retry) << 8)

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

#define HEADER_SOURCE (   source)    ((source) << 16)

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

#define HEADER_TCODE (   tcode)    ((tcode) << 4)

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

#define HEADER_TLABEL (   tlabel)    ((tlabel) << 10)

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

#define PHY_CONFIG_GAP_COUNT (   gap_count)    (((gap_count) << 16) | (1 << 22))

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

#define PHY_CONFIG_ROOT_ID (   node_id)    ((((node_id) & 0x3f) << 24) | (1 << 23))

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

#define PHY_IDENTIFIER (   id)    ((id) << 30)

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

#define PHY_PACKET_CONFIG   0x0

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

#define PHY_PACKET_LINK_ON   0x1

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

#define PHY_PACKET_SELF_ID   0x2

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

Function Documentation

EXPORT_SYMBOL ( fw_cancel_transaction  )
EXPORT_SYMBOL ( fw_send_request  )
EXPORT_SYMBOL ( fw_run_transaction  )
EXPORT_SYMBOL ( fw_high_memory_region  )
EXPORT_SYMBOL ( fw_core_add_address_handler  )
EXPORT_SYMBOL ( fw_core_remove_address_handler  )
EXPORT_SYMBOL ( fw_fill_response  )
EXPORT_SYMBOL ( fw_send_response  )
EXPORT_SYMBOL ( fw_get_request_speed  )
EXPORT_SYMBOL ( fw_core_handle_request  )
EXPORT_SYMBOL ( fw_core_handle_response  )
EXPORT_SYMBOL ( fw_rcode_string  )
int fw_cancel_transaction ( struct fw_card card,
struct fw_transaction transaction 
)

Definition at line 119 of file core-transaction.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.

void fw_core_handle_request ( struct fw_card card,
struct fw_packet p 
)

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

void fw_core_handle_response ( struct fw_card card,
struct fw_packet p 
)

Definition at line 939 of file core-transaction.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_fill_response ( struct fw_packet response,
u32 request_header,
int  rcode,
void payload,
size_t  length 
)

Definition at line 674 of file core-transaction.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.

int fw_get_response_length ( struct fw_request r)

Definition at line 639 of file core-transaction.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_phy_config ( struct fw_card card,
int  node_id,
int  generation,
int  gap_count 
)

Definition at line 455 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.

MODULE_AUTHOR ( "Kristian Hoegsberg <[email protected]>"  )
MODULE_DESCRIPTION ( "Core IEEE1394 transaction logic"  )
module_exit ( fw_core_cleanup  )
module_init ( fw_core_init  )
MODULE_LICENSE ( "GPL"  )

Variable Documentation

struct fw_address_region fw_high_memory_region
Initial value:
=
{ .start = 0x000100000000ULL, .end = 0xffffe0000000ULL, }

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