clean
[linux-2.4.21-pre4.git] / drivers / ieee1394 / ieee1394_transactions.h
1 #ifndef _IEEE1394_TRANSACTIONS_H
2 #define _IEEE1394_TRANSACTIONS_H
3
4 #include "ieee1394_core.h"
5
6
7 /*
8  * Utility functions to fill out packet headers.
9  */
10 void fill_async_readquad(struct hpsb_packet *packet, u64 addr);
11 void fill_async_readquad_resp(struct hpsb_packet *packet, int rcode, 
12                               quadlet_t data);
13 void fill_async_readblock(struct hpsb_packet *packet, u64 addr, int length);
14 void fill_async_readblock_resp(struct hpsb_packet *packet, int rcode, 
15                                int length);
16 void fill_async_writequad(struct hpsb_packet *packet, u64 addr, quadlet_t data);
17 void fill_async_writeblock(struct hpsb_packet *packet, u64 addr, int length);
18 void fill_async_write_resp(struct hpsb_packet *packet, int rcode);
19 void fill_async_lock(struct hpsb_packet *packet, u64 addr, int extcode, 
20                      int length);
21 void fill_async_lock_resp(struct hpsb_packet *packet, int rcode, int extcode, 
22                           int length);
23 void fill_iso_packet(struct hpsb_packet *packet, int length, int channel,
24                      int tag, int sync);
25 void fill_phy_packet(struct hpsb_packet *packet, quadlet_t data);
26
27 /*
28  * Get and free transaction labels.
29  */
30 int get_tlabel(struct hpsb_host *host, nodeid_t nodeid, int wait);
31 void free_tlabel(struct hpsb_host *host, nodeid_t nodeid, int tlabel);
32
33 struct hpsb_packet *hpsb_make_readqpacket(struct hpsb_host *host, nodeid_t node,
34                                           u64 addr);
35 struct hpsb_packet *hpsb_make_readbpacket(struct hpsb_host *host, nodeid_t node,
36                                           u64 addr, size_t length);
37 struct hpsb_packet *hpsb_make_writeqpacket(struct hpsb_host *host,
38                                            nodeid_t node, u64 addr,
39                                            quadlet_t data);
40 struct hpsb_packet *hpsb_make_writebpacket(struct hpsb_host *host,
41                                            nodeid_t node, u64 addr,
42                                            size_t length);
43 struct hpsb_packet *hpsb_make_lockpacket(struct hpsb_host *host, nodeid_t node,
44                                          u64 addr, int extcode);
45 struct hpsb_packet *hpsb_make_lock64packet(struct hpsb_host *host, nodeid_t node,
46                                           u64 addr, int extcode);
47 struct hpsb_packet *hpsb_make_phypacket(struct hpsb_host *host,
48                                         quadlet_t data) ;
49
50
51 /*
52  * hpsb_packet_success - Make sense of the ack and reply codes and
53  * return more convenient error codes:
54  * 0           success
55  * -EBUSY      node is busy, try again
56  * -EAGAIN     error which can probably resolved by retry
57  * -EREMOTEIO  node suffers from an internal error
58  * -EACCES     this transaction is not allowed on requested address
59  * -EINVAL     invalid address at node
60  */
61 int hpsb_packet_success(struct hpsb_packet *packet);
62
63
64 /*
65  * The generic read, write and lock functions.  All recognize the local node ID
66  * and act accordingly.  Read and write automatically use quadlet commands if
67  * length == 4 and and block commands otherwise (however, they do not yet
68  * support lengths that are not a multiple of 4).  You must explicitly specifiy
69  * the generation for which the node ID is valid, to avoid sending packets to
70  * the wrong nodes when we race with a bus reset.
71  */
72 int hpsb_read(struct hpsb_host *host, nodeid_t node, unsigned int generation,
73               u64 addr, quadlet_t *buffer, size_t length);
74 int hpsb_write(struct hpsb_host *host, nodeid_t node, unsigned int generation,
75                u64 addr, quadlet_t *buffer, size_t length);
76 int hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation,
77               u64 addr, int extcode, quadlet_t *data, quadlet_t arg);
78
79 /* Generic packet creation. Used by hpsb_write. Also useful for protocol
80  * drivers that want to implement their own hpsb_write replacement.  */
81 struct hpsb_packet *hpsb_make_packet (struct hpsb_host *host, nodeid_t node,
82                                       u64 addr, quadlet_t *buffer, size_t length);
83
84 #endif /* _IEEE1394_TRANSACTIONS_H */