Kristian Høgsberg | c781c06 | 2007-05-07 20:33:32 -0400 | [diff] [blame] | 1 | /* |
Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 2 | * 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 | |
| 22 | enum { |
Kristian Høgsberg | 83db801 | 2007-01-26 00:37:50 -0500 | [diff] [blame] | 23 | FW_TOPOLOGY_A = 0x01, |
| 24 | FW_TOPOLOGY_B = 0x02, |
| 25 | FW_TOPOLOGY_MIXED = 0x03, |
| 26 | }; |
| 27 | |
| 28 | enum { |
Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 29 | FW_NODE_CREATED = 0x00, |
| 30 | FW_NODE_UPDATED = 0x01, |
| 31 | FW_NODE_DESTROYED = 0x02, |
| 32 | FW_NODE_LINK_ON = 0x03, |
Stefan Richter | 5af4e5e | 2007-01-21 20:45:32 +0100 | [diff] [blame] | 33 | FW_NODE_LINK_OFF = 0x04, |
Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | struct fw_port { |
| 37 | struct fw_node *node; |
| 38 | unsigned speed : 3; /* S100, S200, ... S3200 */ |
| 39 | }; |
| 40 | |
| 41 | struct fw_node { |
| 42 | u16 node_id; |
Stefan Richter | 5e20c28 | 2007-01-21 20:44:09 +0100 | [diff] [blame] | 43 | u8 color; |
Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 44 | u8 port_count; |
| 45 | unsigned link_on : 1; |
| 46 | unsigned initiated_reset : 1; |
| 47 | unsigned b_path : 1; |
Kristian Høgsberg | 83db801 | 2007-01-26 00:37:50 -0500 | [diff] [blame] | 48 | u8 phy_speed : 3; /* As in the self ID packet. */ |
| 49 | u8 max_speed : 5; /* Minimum of all phy-speeds and port speeds on |
| 50 | * the path from the local node to this node. */ |
| 51 | u8 max_depth : 4; /* Maximum depth to any leaf node */ |
| 52 | u8 max_hops : 4; /* Max hops in this sub tree */ |
Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 53 | atomic_t ref_count; |
| 54 | |
Stefan Richter | 5e20c28 | 2007-01-21 20:44:09 +0100 | [diff] [blame] | 55 | /* For serializing node topology into a list. */ |
Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 56 | struct list_head link; |
| 57 | |
| 58 | /* Upper layer specific data. */ |
| 59 | void *data; |
| 60 | |
Stefan Richter | 5e20c28 | 2007-01-21 20:44:09 +0100 | [diff] [blame] | 61 | struct fw_port ports[0]; |
Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 62 | }; |
| 63 | |
Adrian Bunk | 95688e9 | 2007-01-22 19:17:37 +0100 | [diff] [blame] | 64 | static inline struct fw_node * |
Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 65 | fw_node(struct list_head *l) |
| 66 | { |
Kristian Høgsberg | a98e271 | 2007-05-07 20:33:34 -0400 | [diff] [blame] | 67 | return list_entry(l, struct fw_node, link); |
Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 68 | } |
| 69 | |
Adrian Bunk | 95688e9 | 2007-01-22 19:17:37 +0100 | [diff] [blame] | 70 | static inline struct fw_node * |
Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 71 | fw_node_get(struct fw_node *node) |
| 72 | { |
| 73 | atomic_inc(&node->ref_count); |
| 74 | |
| 75 | return node; |
| 76 | } |
| 77 | |
Adrian Bunk | 95688e9 | 2007-01-22 19:17:37 +0100 | [diff] [blame] | 78 | static inline void |
Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 79 | fw_node_put(struct fw_node *node) |
| 80 | { |
| 81 | if (atomic_dec_and_test(&node->ref_count)) |
| 82 | kfree(node); |
| 83 | } |
| 84 | |
| 85 | void |
| 86 | fw_destroy_nodes(struct fw_card *card); |
| 87 | |
Kristian Høgsberg | e175569 | 2007-05-07 20:33:31 -0400 | [diff] [blame] | 88 | int |
| 89 | fw_compute_block_crc(u32 *block); |
| 90 | |
Kristian Høgsberg | 473d28c | 2007-03-07 12:12:55 -0500 | [diff] [blame] | 91 | |
Stefan Richter | 687198b | 2006-12-28 16:20:00 +0100 | [diff] [blame] | 92 | #endif /* __fw_topology_h */ |