blob: 0778077e9d800f05f52070a415d0aa7d53d68585 [file] [log] [blame]
Kristian Høgsberg3038e352006-12-19 19:58:27 -05001/* -*- c-basic-offset: 8 -*-
2 *
3 * fw-topology.h -- Incremental bus scan, based on bus topology
4 *
5 * Copyright (C) 2003-2006 Kristian Hoegsberg <krh@bitplanet.net>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22#ifndef __fw_topology_h
23#define __fw_topology_h
24
25enum {
Kristian Høgsberg83db8012007-01-26 00:37:50 -050026 FW_TOPOLOGY_A = 0x01,
27 FW_TOPOLOGY_B = 0x02,
28 FW_TOPOLOGY_MIXED = 0x03,
29};
30
31enum {
Kristian Høgsberg3038e352006-12-19 19:58:27 -050032 FW_NODE_CREATED = 0x00,
33 FW_NODE_UPDATED = 0x01,
34 FW_NODE_DESTROYED = 0x02,
35 FW_NODE_LINK_ON = 0x03,
Stefan Richter5af4e5e2007-01-21 20:45:32 +010036 FW_NODE_LINK_OFF = 0x04,
Kristian Høgsberg3038e352006-12-19 19:58:27 -050037};
38
39struct fw_port {
40 struct fw_node *node;
41 unsigned speed : 3; /* S100, S200, ... S3200 */
42};
43
44struct fw_node {
45 u16 node_id;
Stefan Richter5e20c282007-01-21 20:44:09 +010046 u8 color;
Kristian Høgsberg3038e352006-12-19 19:58:27 -050047 u8 port_count;
48 unsigned link_on : 1;
49 unsigned initiated_reset : 1;
50 unsigned b_path : 1;
Kristian Høgsberg83db8012007-01-26 00:37:50 -050051 u8 phy_speed : 3; /* As in the self ID packet. */
52 u8 max_speed : 5; /* Minimum of all phy-speeds and port speeds on
53 * the path from the local node to this node. */
54 u8 max_depth : 4; /* Maximum depth to any leaf node */
55 u8 max_hops : 4; /* Max hops in this sub tree */
Kristian Høgsberg3038e352006-12-19 19:58:27 -050056 atomic_t ref_count;
57
Stefan Richter5e20c282007-01-21 20:44:09 +010058 /* For serializing node topology into a list. */
Kristian Høgsberg3038e352006-12-19 19:58:27 -050059 struct list_head link;
60
61 /* Upper layer specific data. */
62 void *data;
63
Stefan Richter5e20c282007-01-21 20:44:09 +010064 struct fw_port ports[0];
Kristian Høgsberg3038e352006-12-19 19:58:27 -050065};
66
Adrian Bunk95688e92007-01-22 19:17:37 +010067static inline struct fw_node *
Kristian Høgsberg3038e352006-12-19 19:58:27 -050068fw_node(struct list_head *l)
69{
Stefan Richter5e20c282007-01-21 20:44:09 +010070 return list_entry (l, struct fw_node, link);
Kristian Høgsberg3038e352006-12-19 19:58:27 -050071}
72
Adrian Bunk95688e92007-01-22 19:17:37 +010073static inline struct fw_node *
Kristian Høgsberg3038e352006-12-19 19:58:27 -050074fw_node_get(struct fw_node *node)
75{
76 atomic_inc(&node->ref_count);
77
78 return node;
79}
80
Adrian Bunk95688e92007-01-22 19:17:37 +010081static inline void
Kristian Høgsberg3038e352006-12-19 19:58:27 -050082fw_node_put(struct fw_node *node)
83{
84 if (atomic_dec_and_test(&node->ref_count))
85 kfree(node);
86}
87
88void
89fw_destroy_nodes(struct fw_card *card);
90
Kristian Høgsberge1755692007-05-07 20:33:31 -040091int
92fw_compute_block_crc(u32 *block);
93
Kristian Høgsberg473d28c2007-03-07 12:12:55 -050094
Stefan Richter687198b2006-12-28 16:20:00 +010095#endif /* __fw_topology_h */