MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / ieee1394 / nodemgr.h
blobf27ea3a257509346da6b6bfac37d716afcd861db
1 /*
2 * Copyright (C) 2000 Andreas E. Bombe
3 * 2001 Ben Collins <bcollins@debian.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef _IEEE1394_NODEMGR_H
21 #define _IEEE1394_NODEMGR_H
23 #include <linux/device.h>
24 #include "csr1212.h"
25 #include "ieee1394_core.h"
26 #include "ieee1394_hotplug.h"
28 /* '1' '3' '9' '4' in ASCII */
29 #define IEEE1394_BUSID_MAGIC __constant_cpu_to_be32(0x31333934)
31 /* This is the start of a Node entry structure. It should be a stable API
32 * for which to gather info from the Node Manager about devices attached
33 * to the bus. */
34 struct bus_options {
35 u8 irmc; /* Iso Resource Manager Capable */
36 u8 cmc; /* Cycle Master Capable */
37 u8 isc; /* Iso Capable */
38 u8 bmc; /* Bus Master Capable */
39 u8 pmc; /* Power Manager Capable (PNP spec) */
40 u8 cyc_clk_acc; /* Cycle clock accuracy */
41 u8 max_rom; /* Maximum block read supported in the CSR */
42 u8 generation; /* Incremented when configrom changes */
43 u8 lnkspd; /* Link speed */
44 u16 max_rec; /* Maximum packet size node can receive */
48 #define UNIT_DIRECTORY_VENDOR_ID 0x01
49 #define UNIT_DIRECTORY_MODEL_ID 0x02
50 #define UNIT_DIRECTORY_SPECIFIER_ID 0x04
51 #define UNIT_DIRECTORY_VERSION 0x08
52 #define UNIT_DIRECTORY_HAS_LUN_DIRECTORY 0x10
53 #define UNIT_DIRECTORY_LUN_DIRECTORY 0x20
56 * A unit directory corresponds to a protocol supported by the
57 * node. If a node supports eg. IP/1394 and AV/C, its config rom has a
58 * unit directory for each of these protocols.
60 struct unit_directory {
61 struct node_entry *ne; /* The node which this directory belongs to */
62 octlet_t address; /* Address of the unit directory on the node */
63 u8 flags; /* Indicates which entries were read */
65 quadlet_t vendor_id;
66 struct csr1212_keyval *vendor_name_kv;
67 const char *vendor_oui;
69 quadlet_t model_id;
70 struct csr1212_keyval *model_name_kv;
71 quadlet_t specifier_id;
72 quadlet_t version;
74 unsigned int id;
76 int ignore_driver;
78 int length; /* Number of quadlets */
80 struct device device;
82 struct class_device class_dev;
84 struct csr1212_keyval *ud_kv;
87 struct node_entry {
88 u64 guid; /* GUID of this node */
89 u32 guid_vendor_id; /* Top 24bits of guid */
90 const char *guid_vendor_oui; /* OUI name of guid vendor id */
92 struct hpsb_host *host; /* Host this node is attached to */
93 nodeid_t nodeid; /* NodeID */
94 struct bus_options busopt; /* Bus Options */
95 int needs_probe;
96 unsigned int generation; /* Synced with hpsb generation */
98 /* The following is read from the config rom */
99 u32 vendor_id;
100 struct csr1212_keyval *vendor_name_kv;
101 const char *vendor_oui;
103 u32 capabilities;
104 struct hpsb_tlabel_pool *tpool;
106 struct device device;
108 struct class_device class_dev;
110 /* Means this node is not attached anymore */
111 int in_limbo;
113 struct csr1212_csr *csr;
116 struct hpsb_protocol_driver {
117 /* The name of the driver, e.g. SBP2 or IP1394 */
118 const char *name;
121 * The device id table describing the protocols and/or devices
122 * supported by this driver. This is used by the nodemgr to
123 * decide if a driver could support a given node, but the
124 * probe function below can implement further protocol
125 * dependent or vendor dependent checking.
127 struct ieee1394_device_id *id_table;
130 * The update function is called when the node has just
131 * survived a bus reset, i.e. it is still present on the bus.
132 * However, it may be necessary to reestablish the connection
133 * or login into the node again, depending on the protocol. If the
134 * probe fails (returns non-zero), we unbind the driver from this
135 * device.
137 int (*update)(struct unit_directory *ud);
139 /* Our LDM structure */
140 struct device_driver driver;
143 int hpsb_register_protocol(struct hpsb_protocol_driver *driver);
144 void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver);
146 static inline int hpsb_node_entry_valid(struct node_entry *ne)
148 return ne->generation == get_hpsb_generation(ne->host);
152 * Returns a node entry (which has its reference count incremented) or NULL if
153 * the GUID in question is not known. Getting a valid entry does not mean that
154 * the node with this GUID is currently accessible (might be powered down).
156 struct node_entry *hpsb_guid_get_entry(u64 guid);
158 /* Same as above, but use the nodeid to get an node entry. This is not
159 * fool-proof by itself, since the nodeid can change. */
160 struct node_entry *hpsb_nodeid_get_entry(struct hpsb_host *host, nodeid_t nodeid);
163 * If the entry refers to a local host, this function will return the pointer
164 * to the hpsb_host structure. It will return NULL otherwise. Once you have
165 * established it is a local host, you can use that knowledge from then on (the
166 * GUID won't wander to an external node). */
167 struct hpsb_host *hpsb_get_host_by_ne(struct node_entry *ne);
170 * This will fill in the given, pre-initialised hpsb_packet with the current
171 * information from the node entry (host, node ID, generation number). It will
172 * return false if the node owning the GUID is not accessible (and not modify the
173 * hpsb_packet) and return true otherwise.
175 * Note that packet sending may still fail in hpsb_send_packet if a bus reset
176 * happens while you are trying to set up the packet (due to obsolete generation
177 * number). It will at least reliably fail so that you don't accidentally and
178 * unknowingly send your packet to the wrong node.
180 void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *pkt);
182 int hpsb_node_read(struct node_entry *ne, u64 addr,
183 quadlet_t *buffer, size_t length);
184 int hpsb_node_write(struct node_entry *ne, u64 addr,
185 quadlet_t *buffer, size_t length);
186 int hpsb_node_lock(struct node_entry *ne, u64 addr,
187 int extcode, quadlet_t *data, quadlet_t arg);
190 /* Iterate the hosts, calling a given function with supplied data for each
191 * host. */
192 int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *));
195 int init_ieee1394_nodemgr(void);
196 void cleanup_ieee1394_nodemgr(void);
199 /* The template for a host device */
200 extern struct device nodemgr_dev_template_host;
202 /* Bus attributes we export */
203 extern struct bus_attribute *const fw_bus_attrs[];
205 #endif /* _IEEE1394_NODEMGR_H */