blob: addb9f8ea776f1196dd7f65b6f75cd3695d13425 [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 {
Stefan Richterc9755e12008-03-24 20:54:28 +010023 FW_NODE_CREATED,
24 FW_NODE_UPDATED,
25 FW_NODE_DESTROYED,
26 FW_NODE_LINK_ON,
27 FW_NODE_LINK_OFF,
28 FW_NODE_INITIATED_RESET,
Kristian Høgsberg3038e352006-12-19 19:58:27 -050029};
30
Kristian Høgsberg3038e352006-12-19 19:58:27 -050031struct fw_node {
32 u16 node_id;
Stefan Richter5e20c282007-01-21 20:44:09 +010033 u8 color;
Kristian Høgsberg3038e352006-12-19 19:58:27 -050034 u8 port_count;
Stefan Richterf1397492007-06-10 21:31:36 +020035 u8 link_on : 1;
36 u8 initiated_reset : 1;
37 u8 b_path : 1;
38 u8 phy_speed : 2; /* As in the self ID packet. */
39 u8 max_speed : 2; /* Minimum of all phy-speeds on the path from the
40 * local node to this node. */
Kristian Høgsberg83db8012007-01-26 00:37:50 -050041 u8 max_depth : 4; /* Maximum depth to any leaf node */
42 u8 max_hops : 4; /* Max hops in this sub tree */
Kristian Høgsberg3038e352006-12-19 19:58:27 -050043 atomic_t ref_count;
44
Stefan Richter5e20c282007-01-21 20:44:09 +010045 /* For serializing node topology into a list. */
Kristian Høgsberg3038e352006-12-19 19:58:27 -050046 struct list_head link;
47
48 /* Upper layer specific data. */
49 void *data;
50
Stefan Richterdae1a3a2007-06-17 23:39:58 +020051 struct fw_node *ports[0];
Kristian Høgsberg3038e352006-12-19 19:58:27 -050052};
53
Adrian Bunk95688e92007-01-22 19:17:37 +010054static inline struct fw_node *
Kristian Høgsberg3038e352006-12-19 19:58:27 -050055fw_node_get(struct fw_node *node)
56{
57 atomic_inc(&node->ref_count);
58
59 return node;
60}
61
Adrian Bunk95688e92007-01-22 19:17:37 +010062static inline void
Kristian Høgsberg3038e352006-12-19 19:58:27 -050063fw_node_put(struct fw_node *node)
64{
65 if (atomic_dec_and_test(&node->ref_count))
66 kfree(node);
67}
68
69void
70fw_destroy_nodes(struct fw_card *card);
71
Kristian Høgsberge1755692007-05-07 20:33:31 -040072int
73fw_compute_block_crc(u32 *block);
74
Kristian Høgsberg473d28c2007-03-07 12:12:55 -050075
Stefan Richter687198b2006-12-28 16:20:00 +010076#endif /* __fw_topology_h */