2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2000 Andreas E. Bombe
|
|
|
|
* 2001 Ben Collins <bcollins@debian.org>
|
|
|
|
*
|
|
|
|
* 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 _IEEE1394_NODEMGR_H
|
|
|
|
#define _IEEE1394_NODEMGR_H
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
2008-08-27 19:40:02 +08:00
|
|
|
#include <asm/system.h>
|
2006-07-04 00:02:29 +08:00
|
|
|
#include <asm/types.h>
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "ieee1394_core.h"
|
2008-08-27 19:40:02 +08:00
|
|
|
#include "ieee1394_transactions.h"
|
2006-07-04 00:02:29 +08:00
|
|
|
#include "ieee1394_types.h"
|
|
|
|
|
|
|
|
struct csr1212_csr;
|
|
|
|
struct csr1212_keyval;
|
|
|
|
struct hpsb_host;
|
|
|
|
struct ieee1394_device_id;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* This is the start of a Node entry structure. It should be a stable API
|
|
|
|
* for which to gather info from the Node Manager about devices attached
|
|
|
|
* to the bus. */
|
|
|
|
struct bus_options {
|
|
|
|
u8 irmc; /* Iso Resource Manager Capable */
|
|
|
|
u8 cmc; /* Cycle Master Capable */
|
|
|
|
u8 isc; /* Iso Capable */
|
|
|
|
u8 bmc; /* Bus Master Capable */
|
|
|
|
u8 pmc; /* Power Manager Capable (PNP spec) */
|
|
|
|
u8 cyc_clk_acc; /* Cycle clock accuracy */
|
|
|
|
u8 max_rom; /* Maximum block read supported in the CSR */
|
|
|
|
u8 generation; /* Incremented when configrom changes */
|
|
|
|
u8 lnkspd; /* Link speed */
|
|
|
|
u16 max_rec; /* Maximum packet size node can receive */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define UNIT_DIRECTORY_VENDOR_ID 0x01
|
|
|
|
#define UNIT_DIRECTORY_MODEL_ID 0x02
|
|
|
|
#define UNIT_DIRECTORY_SPECIFIER_ID 0x04
|
|
|
|
#define UNIT_DIRECTORY_VERSION 0x08
|
|
|
|
#define UNIT_DIRECTORY_HAS_LUN_DIRECTORY 0x10
|
|
|
|
#define UNIT_DIRECTORY_LUN_DIRECTORY 0x20
|
|
|
|
#define UNIT_DIRECTORY_HAS_LUN 0x40
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A unit directory corresponds to a protocol supported by the
|
|
|
|
* node. If a node supports eg. IP/1394 and AV/C, its config rom has a
|
|
|
|
* unit directory for each of these protocols.
|
|
|
|
*/
|
|
|
|
struct unit_directory {
|
2006-07-04 00:02:28 +08:00
|
|
|
struct node_entry *ne; /* The node which this directory belongs to */
|
|
|
|
octlet_t address; /* Address of the unit directory on the node */
|
2005-04-17 06:20:36 +08:00
|
|
|
u8 flags; /* Indicates which entries were read */
|
|
|
|
|
|
|
|
quadlet_t vendor_id;
|
|
|
|
struct csr1212_keyval *vendor_name_kv;
|
|
|
|
|
|
|
|
quadlet_t model_id;
|
|
|
|
struct csr1212_keyval *model_name_kv;
|
|
|
|
quadlet_t specifier_id;
|
|
|
|
quadlet_t version;
|
2007-05-27 19:17:15 +08:00
|
|
|
quadlet_t directory_id;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
unsigned int id;
|
|
|
|
|
|
|
|
int ignore_driver;
|
|
|
|
|
|
|
|
int length; /* Number of quadlets */
|
|
|
|
|
|
|
|
struct device device;
|
2007-05-25 17:50:53 +08:00
|
|
|
struct device unit_dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct csr1212_keyval *ud_kv;
|
2006-07-04 00:02:28 +08:00
|
|
|
u32 lun; /* logical unit number immediate value */
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct node_entry {
|
|
|
|
u64 guid; /* GUID of this node */
|
|
|
|
u32 guid_vendor_id; /* Top 24bits of guid */
|
|
|
|
|
|
|
|
struct hpsb_host *host; /* Host this node is attached to */
|
|
|
|
nodeid_t nodeid; /* NodeID */
|
|
|
|
struct bus_options busopt; /* Bus Options */
|
2008-08-16 19:36:47 +08:00
|
|
|
bool needs_probe;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int generation; /* Synced with hpsb generation */
|
|
|
|
|
|
|
|
/* The following is read from the config rom */
|
|
|
|
u32 vendor_id;
|
|
|
|
struct csr1212_keyval *vendor_name_kv;
|
|
|
|
|
|
|
|
u32 capabilities;
|
|
|
|
|
|
|
|
struct device device;
|
2007-05-25 17:50:53 +08:00
|
|
|
struct device node_dev;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Means this node is not attached anymore */
|
ieee1394: survive a few seconds connection loss
There are situations when nodes vanish from the bus and come back in
quickly thereafter:
- When certain bus-powered hubs are plugged in,
- when certain disk enclosures are switched from self-power to bus
power or vice versa and break the daisy chain during the transition,
- when the user plugs a cable out and quickly plugs it back in, e.g.
to reorder a daisy chain (works on Mac OS X if done quickly enough),
- when certain hubs temporarily malfunction during high bus traffic.
The ieee1394 driver's nodemgr already contained a function to set
vanished nodes aside into "limbo"; i.e. they wouldn't actually be
deleted right away. (In fact, only unloading the driver or writing into
an obscure sysfs attribute would delete them eventually.) If nodes
reappeared later, they would be resurrected out of limbo.
Moving nodes into and out of limbo was accompanied with calling the
.suspend() and .resume() driver methods of the drivers which were bound
to a respective node's unit directories. Not only is this somewhat
strange due to the intended use of these driver methods for power
management, also the sbp2 driver in particular does not implement
.suspend() and .resume(). Hence sbp2 would be disconnected from devices
in situations as listed above.
We now:
- leave drivers bound when nodes go into limbo,
- call the drivers' .update() when nodes come out of limbo,
- automatically delete in-limbo nodes 3 seconds after the last
bus reset and bus rescan.
- Because of the automatic removal, the now obsolete bus attribute
/sys/bus/ieee1394/destroy_node is removed.
This especially lets sbp2 survive brief disconnections. You can for
example yank a disk's cable and plug it back in while reading the
respective disk with dd, but dd will happily continue as if nothing
happened.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2008-08-20 03:30:17 +08:00
|
|
|
bool in_limbo;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct csr1212_csr *csr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hpsb_protocol_driver {
|
|
|
|
/* The name of the driver, e.g. SBP2 or IP1394 */
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The device id table describing the protocols and/or devices
|
|
|
|
* supported by this driver. This is used by the nodemgr to
|
|
|
|
* decide if a driver could support a given node, but the
|
|
|
|
* probe function below can implement further protocol
|
|
|
|
* dependent or vendor dependent checking.
|
|
|
|
*/
|
2009-02-16 06:11:38 +08:00
|
|
|
const struct ieee1394_device_id *id_table;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The update function is called when the node has just
|
|
|
|
* survived a bus reset, i.e. it is still present on the bus.
|
|
|
|
* However, it may be necessary to reestablish the connection
|
|
|
|
* or login into the node again, depending on the protocol. If the
|
|
|
|
* probe fails (returns non-zero), we unbind the driver from this
|
|
|
|
* device.
|
|
|
|
*/
|
|
|
|
int (*update)(struct unit_directory *ud);
|
|
|
|
|
|
|
|
/* Our LDM structure */
|
|
|
|
struct device_driver driver;
|
|
|
|
};
|
|
|
|
|
2006-11-24 02:59:48 +08:00
|
|
|
int __hpsb_register_protocol(struct hpsb_protocol_driver *, struct module *);
|
|
|
|
static inline int hpsb_register_protocol(struct hpsb_protocol_driver *driver)
|
|
|
|
{
|
|
|
|
return __hpsb_register_protocol(driver, THIS_MODULE);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver);
|
|
|
|
|
|
|
|
static inline int hpsb_node_entry_valid(struct node_entry *ne)
|
|
|
|
{
|
|
|
|
return ne->generation == get_hpsb_generation(ne->host);
|
|
|
|
}
|
2007-03-05 10:06:23 +08:00
|
|
|
void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *packet);
|
2005-04-17 06:20:36 +08:00
|
|
|
int hpsb_node_write(struct node_entry *ne, u64 addr,
|
|
|
|
quadlet_t *buffer, size_t length);
|
2008-08-27 19:40:02 +08:00
|
|
|
static inline int hpsb_node_read(struct node_entry *ne, u64 addr,
|
|
|
|
quadlet_t *buffer, size_t length)
|
|
|
|
{
|
|
|
|
unsigned int g = ne->generation;
|
|
|
|
|
|
|
|
smp_rmb();
|
|
|
|
return hpsb_read(ne->host, ne->nodeid, g, addr, buffer, length);
|
|
|
|
}
|
|
|
|
static inline int hpsb_node_lock(struct node_entry *ne, u64 addr, int extcode,
|
|
|
|
quadlet_t *buffer, quadlet_t arg)
|
|
|
|
{
|
|
|
|
unsigned int g = ne->generation;
|
|
|
|
|
|
|
|
smp_rmb();
|
|
|
|
return hpsb_lock(ne->host, ne->nodeid, g, addr, extcode, buffer, arg);
|
|
|
|
}
|
2007-03-05 10:06:23 +08:00
|
|
|
int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
int init_ieee1394_nodemgr(void);
|
|
|
|
void cleanup_ieee1394_nodemgr(void);
|
|
|
|
|
|
|
|
/* The template for a host device */
|
|
|
|
extern struct device nodemgr_dev_template_host;
|
|
|
|
|
|
|
|
/* Bus attributes we export */
|
|
|
|
extern struct bus_attribute *const fw_bus_attrs[];
|
|
|
|
|
|
|
|
#endif /* _IEEE1394_NODEMGR_H */
|