blob: aced9f7db35805f25d8220a6cc44f53a29ba0ce1 [file] [log] [blame]
Kristian Høgsbergc781c062007-05-07 20:33:32 -04001/*
Kristian Høgsberg3038e352006-12-19 19:58:27 -05002 * Copyright (C) 2003-2006 Kristian Hoegsberg <krh@bitplanet.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#ifndef __fw_topology_h
20#define __fw_topology_h
21
22enum {
23 FW_NODE_CREATED = 0x00,
24 FW_NODE_UPDATED = 0x01,
25 FW_NODE_DESTROYED = 0x02,
26 FW_NODE_LINK_ON = 0x03,
Stefan Richter5af4e5e2007-01-21 20:45:32 +010027 FW_NODE_LINK_OFF = 0x04,
Kristian Høgsberg3038e352006-12-19 19:58:27 -050028};
29
30struct fw_port {
31 struct fw_node *node;
32 unsigned speed : 3; /* S100, S200, ... S3200 */
33};
34
35struct fw_node {
36 u16 node_id;
Stefan Richter5e20c282007-01-21 20:44:09 +010037 u8 color;
Kristian Høgsberg3038e352006-12-19 19:58:27 -050038 u8 port_count;
39 unsigned link_on : 1;
40 unsigned initiated_reset : 1;
41 unsigned b_path : 1;
Kristian Høgsberg83db8012007-01-26 00:37:50 -050042 u8 phy_speed : 3; /* As in the self ID packet. */
43 u8 max_speed : 5; /* Minimum of all phy-speeds and port speeds on
44 * the path from the local node to this node. */
45 u8 max_depth : 4; /* Maximum depth to any leaf node */
46 u8 max_hops : 4; /* Max hops in this sub tree */
Kristian Høgsberg3038e352006-12-19 19:58:27 -050047 atomic_t ref_count;
48
Stefan Richter5e20c282007-01-21 20:44:09 +010049 /* For serializing node topology into a list. */
Kristian Høgsberg3038e352006-12-19 19:58:27 -050050 struct list_head link;
51
52 /* Upper layer specific data. */
53 void *data;
54
Stefan Richter5e20c282007-01-21 20:44:09 +010055 struct fw_port ports[0];
Kristian Høgsberg3038e352006-12-19 19:58:27 -050056};
57
Adrian Bunk95688e92007-01-22 19:17:37 +010058static inline struct fw_node *
Kristian Høgsberg3038e352006-12-19 19:58:27 -050059fw_node(struct list_head *l)
60{
Kristian Høgsberga98e2712007-05-07 20:33:34 -040061 return list_entry(l, struct fw_node, link);
Kristian Høgsberg3038e352006-12-19 19:58:27 -050062}
63
Adrian Bunk95688e92007-01-22 19:17:37 +010064static inline struct fw_node *
Kristian Høgsberg3038e352006-12-19 19:58:27 -050065fw_node_get(struct fw_node *node)
66{
67 atomic_inc(&node->ref_count);
68
69 return node;
70}
71
Adrian Bunk95688e92007-01-22 19:17:37 +010072static inline void
Kristian Høgsberg3038e352006-12-19 19:58:27 -050073fw_node_put(struct fw_node *node)
74{
75 if (atomic_dec_and_test(&node->ref_count))
76 kfree(node);
77}
78
79void
80fw_destroy_nodes(struct fw_card *card);
81
Kristian Høgsberge1755692007-05-07 20:33:31 -040082int
83fw_compute_block_crc(u32 *block);
84
Kristian Høgsberg473d28c2007-03-07 12:12:55 -050085
Stefan Richter687198b2006-12-28 16:20:00 +010086#endif /* __fw_topology_h */