Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
I comment all the calls to used_routing, in order to use global routing.
[simgrid.git] / src / surf / surf_private.h
1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef _SURF_SURF_PRIVATE_H
7 #define _SURF_SURF_PRIVATE_H
8
9 #include "surf/surf.h"
10 #include "surf/maxmin.h"
11 #include "surf/trace_mgr.h"
12 #include "xbt/log.h"
13 #include "surf/surfxml_parse_private.h"
14 #include "surf/random_mgr.h"
15 #include "instr/private.h"
16
17 #define NO_MAX_DURATION -1.0
18
19 /* user-visible parameters */
20 extern double sg_tcp_gamma;
21 extern double sg_latency_factor;
22 extern double sg_bandwidth_factor;
23 extern double sg_weight_S_parameter;
24 extern int sg_maxmin_selective_update;
25 extern int sg_network_fullduplex;
26 #ifdef HAVE_GTNETS
27   extern double sg_gtnets_jitter;
28   extern int sg_gtnets_jitter_seed;
29 #endif
30
31
32 extern const char *surf_action_state_names[6];
33
34 typedef struct surf_model_private {
35   int (*resource_used) (void *resource_id);
36   /* Share the resources to the actions and return in how much time
37      the next action may terminate */
38   double (*share_resources) (double now);
39   /* Update the actions' state */
40   void (*update_actions_state) (double now, double delta);
41   void (*update_resource_state) (void *id, tmgr_trace_event_t event_type,
42                                  double value, double time);
43   void (*finalize) (void);
44 } s_surf_model_private_t;
45
46 double generic_maxmin_share_resources(xbt_swag_t running_actions,
47                                       size_t offset,
48                                       lmm_system_t sys,
49                                       void (*solve) (lmm_system_t));
50
51 /* Generic functions common to all models */
52 e_surf_action_state_t surf_action_state_get(surf_action_t action); /* cannot declare inline since we use a pointer to it */
53 double surf_action_get_start_time(surf_action_t action); /* cannot declare inline since we use a pointer to it */
54 double surf_action_get_finish_time(surf_action_t action); /* cannot declare inline since we use a pointer to it */
55 void surf_action_free(surf_action_t * action);
56 void surf_action_state_set(surf_action_t action, e_surf_action_state_t state);
57 void surf_action_data_set(surf_action_t action, void *data); /* cannot declare inline since we use a pointer to it */
58 FILE *surf_fopen(const char *name, const char *mode);
59
60 extern tmgr_history_t history;
61 extern xbt_dynar_t surf_path;
62
63 void surf_config_init(int *argc, char **argv);
64 void surf_config_finalize(void);
65 void surf_config(const char *name, va_list pa);
66
67
68 void net_action_recycle(surf_action_t action);
69 double net_action_get_remains(surf_action_t action);
70 int net_get_link_latency(surf_action_t action);
71 void net_action_set_max_duration(surf_action_t action, double duration);
72
73 /*
74  * Returns the initial path. On Windows the initial path is
75  * the current directory for the current process in the other
76  * case the function returns "./" that represents the current
77  * directory on Unix/Linux platforms.
78  */
79 const char *__surf_get_initial_path(void);
80
81 /* The __surf_is_absolute_file_path() returns 1 if
82  * file_path is a absolute file path, in the other
83  * case the function returns 0.
84  */
85 int __surf_is_absolute_file_path(const char *file_path);
86
87 /*
88  * One link routing list
89  */
90 typedef struct {
91         int src_id;
92         int dst_id;
93         void *link_ptr;
94 }s_onelink, *s_onelink_t;
95
96
97 /*
98  * Routing logic
99  */
100
101 // FIXME: the next lines cant be comented without fix the code in network.c file.
102 // struct s_routing {
103 //   const char *name;
104 //   xbt_dict_t host_id; /* char* -> int* */
105 //   xbt_dynar_t (*get_route)(int src, int dst);
106 //   xbt_dict_t (*get_onelink_routes)(void);
107 //   int (*is_router)(int id);
108 //   void (*finalize)(void);
109 //   int host_count;
110 //   int router_count;
111 // };
112
113 ////////////////////////////////////////////////////////////////////////////////
114 // HERE START THE NEW STRUCTURES
115 ////////////////////////////////////////////////////////////////////////////////
116
117 typedef enum {
118   SURF_NETWORK_ELEMENT_NULL = 0,   /* NULL */
119   SURF_NETWORK_ELEMENT_HOST,       /* host type */
120   SURF_NETWORK_ELEMENT_ROUTER,     /* router type */
121   SURF_NETWORK_ELEMENT_GATEWAY,    /* gateway type of the AS */
122   SURF_NETWORK_ELEMENT_AS,         /* AS type */
123   SURF_NETWORK_ELEMENT_AS_GATEWAY, /* gateway type for internals AS */
124   SURF_NETWORK_ELEMENT_LINK        /* link type */
125 } e_surf_network_element_type_t;
126
127 typedef struct s_model_type s_model_type_t, *model_type_t;
128 typedef struct s_network_element s_network_element_t, *network_element_t;
129 typedef struct s_route s_route_t, *route_t;
130 typedef struct s_route_limits s_route_limits_t, *route_limits_t;
131 typedef struct s_route_extended s_route_extended_t, *route_extended_t;
132 typedef struct s_routing_component s_routing_component_t, *routing_component_t;
133 //typedef struct s_routing_global s_routing_global_t, *routing_global_t;
134
135 struct s_model_type {
136   const char *name;
137   const char *desc;
138   void* (*create)();
139   void (*load)();
140   void (*unload)();
141   void (*end)();
142 };
143
144 struct s_network_element {
145   int id;
146   e_surf_network_element_type_t type;
147 };
148
149 struct s_route {
150   xbt_dynar_t link_list;
151 };
152
153 struct s_route_limits {
154   char* src_gateway;
155   char* dst_gateway;
156 };
157
158 struct s_route_extended {
159   s_route_t generic_route;
160   char* src_gateway;
161   char* dst_gateway;
162 };
163
164 struct s_routing_component {
165   model_type_t routing;
166   char *name;
167   struct s_routing_component* routing_father;
168   xbt_dict_t routing_sons;
169   route_extended_t (*get_route)(routing_component_t rc, const char* src, const char* dst);
170   xbt_dict_t (*get_network_elements)(routing_component_t rc, e_surf_network_element_type_t type);
171   void (*finalize)(routing_component_t rc);
172 };
173
174 struct s_routing_global {
175   routing_component_t root;
176   xbt_dict_t where_network_elements; /* char* -> s_routing_component* */
177   void *loopback;
178   size_t size_of_link;
179   xbt_dynar_t (*get_route)(const char* src, const char* dst);
180   void (*finalize)(void);
181   xbt_dynar_t last_route;
182 };
183
184 XBT_PUBLIC(void) routing_model_create(size_t size_of_link,void *loopback);
185
186 ////////////////////////////////////////////////////////////////////////////////
187 // HERE END THE NEW STRUCTURES
188 ////////////////////////////////////////////////////////////////////////////////
189
190 /*
191  * Resource protected methods
192  */
193 xbt_dict_t surf_resource_properties(const void *resource);
194
195 XBT_PUBLIC(void) surfxml_bufferstack_push(int new);
196 XBT_PUBLIC(void) surfxml_bufferstack_pop(int new);
197 XBT_PUBLIC_DATA(int) surfxml_bufferstack_size;
198
199
200 #endif /* _SURF_SURF_PRIVATE_H */