| 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 |  | 
| Stefan Richter | b769bd1 | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 22 | #include <linux/list.h> | 
 | 23 | #include <linux/slab.h> | 
 | 24 |  | 
 | 25 | #include <asm/atomic.h> | 
 | 26 |  | 
| Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 27 | enum { | 
| Stefan Richter | c9755e1 | 2008-03-24 20:54:28 +0100 | [diff] [blame] | 28 | 	FW_NODE_CREATED, | 
 | 29 | 	FW_NODE_UPDATED, | 
 | 30 | 	FW_NODE_DESTROYED, | 
 | 31 | 	FW_NODE_LINK_ON, | 
 | 32 | 	FW_NODE_LINK_OFF, | 
 | 33 | 	FW_NODE_INITIATED_RESET, | 
| Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 34 | }; | 
 | 35 |  | 
| Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 36 | struct fw_node { | 
 | 37 | 	u16 node_id; | 
| Stefan Richter | 5e20c28 | 2007-01-21 20:44:09 +0100 | [diff] [blame] | 38 | 	u8 color; | 
| Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 39 | 	u8 port_count; | 
| Stefan Richter | f139749 | 2007-06-10 21:31:36 +0200 | [diff] [blame] | 40 | 	u8 link_on : 1; | 
 | 41 | 	u8 initiated_reset : 1; | 
 | 42 | 	u8 b_path : 1; | 
 | 43 | 	u8 phy_speed : 2; /* As in the self ID packet. */ | 
 | 44 | 	u8 max_speed : 2; /* Minimum of all phy-speeds on the path from the | 
 | 45 | 			   * local node to this node. */ | 
| Kristian Høgsberg | 83db801 | 2007-01-26 00:37:50 -0500 | [diff] [blame] | 46 | 	u8 max_depth : 4; /* Maximum depth to any leaf node */ | 
 | 47 | 	u8 max_hops : 4;  /* Max hops in this sub tree */ | 
| Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 48 | 	atomic_t ref_count; | 
 | 49 |  | 
| Stefan Richter | 5e20c28 | 2007-01-21 20:44:09 +0100 | [diff] [blame] | 50 | 	/* For serializing node topology into a list. */ | 
| Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 51 | 	struct list_head link; | 
 | 52 |  | 
 | 53 | 	/* Upper layer specific data. */ | 
 | 54 | 	void *data; | 
 | 55 |  | 
| Stefan Richter | dae1a3a | 2007-06-17 23:39:58 +0200 | [diff] [blame] | 56 | 	struct fw_node *ports[0]; | 
| Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 57 | }; | 
 | 58 |  | 
| Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame] | 59 | static inline struct fw_node *fw_node_get(struct fw_node *node) | 
| Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 60 | { | 
 | 61 | 	atomic_inc(&node->ref_count); | 
 | 62 |  | 
 | 63 | 	return node; | 
 | 64 | } | 
 | 65 |  | 
| Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame] | 66 | static inline void fw_node_put(struct fw_node *node) | 
| Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 67 | { | 
 | 68 | 	if (atomic_dec_and_test(&node->ref_count)) | 
 | 69 | 		kfree(node); | 
 | 70 | } | 
 | 71 |  | 
| Stefan Richter | b769bd1 | 2009-01-04 16:23:29 +0100 | [diff] [blame] | 72 | struct fw_card; | 
| Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame] | 73 | void fw_destroy_nodes(struct fw_card *card); | 
| Kristian Høgsberg | 3038e35 | 2006-12-19 19:58:27 -0500 | [diff] [blame] | 74 |  | 
| Stefan Richter | 53dca51 | 2008-12-14 21:47:04 +0100 | [diff] [blame] | 75 | int fw_compute_block_crc(u32 *block); | 
| Kristian Høgsberg | 473d28c | 2007-03-07 12:12:55 -0500 | [diff] [blame] | 76 |  | 
| Stefan Richter | 687198b | 2006-12-28 16:20:00 +0100 | [diff] [blame] | 77 | #endif /* __fw_topology_h */ |