diff options
Diffstat (limited to 'net/atm/mpoa_caches.c')
| -rw-r--r-- | net/atm/mpoa_caches.c | 191 |
1 files changed, 106 insertions, 85 deletions
diff --git a/net/atm/mpoa_caches.c b/net/atm/mpoa_caches.c index 4504a4b339bb..e773d8336918 100644 --- a/net/atm/mpoa_caches.c +++ b/net/atm/mpoa_caches.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #include <linux/types.h> | 1 | #include <linux/types.h> |
| 2 | #include <linux/atmmpc.h> | 2 | #include <linux/atmmpc.h> |
| 3 | #include <linux/slab.h> | ||
| 3 | #include <linux/time.h> | 4 | #include <linux/time.h> |
| 4 | 5 | ||
| 5 | #include "mpoa_caches.h" | 6 | #include "mpoa_caches.h" |
| @@ -11,15 +12,23 @@ | |||
| 11 | */ | 12 | */ |
| 12 | 13 | ||
| 13 | #if 0 | 14 | #if 0 |
| 14 | #define dprintk printk /* debug */ | 15 | #define dprintk(format, args...) \ |
| 16 | printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args) /* debug */ | ||
| 15 | #else | 17 | #else |
| 16 | #define dprintk(format,args...) | 18 | #define dprintk(format, args...) \ |
| 19 | do { if (0) \ | ||
| 20 | printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\ | ||
| 21 | } while (0) | ||
| 17 | #endif | 22 | #endif |
| 18 | 23 | ||
| 19 | #if 0 | 24 | #if 0 |
| 20 | #define ddprintk printk /* more debug */ | 25 | #define ddprintk(format, args...) \ |
| 26 | printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args) /* debug */ | ||
| 21 | #else | 27 | #else |
| 22 | #define ddprintk(format,args...) | 28 | #define ddprintk(format, args...) \ |
| 29 | do { if (0) \ | ||
| 30 | printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\ | ||
| 31 | } while (0) | ||
| 23 | #endif | 32 | #endif |
| 24 | 33 | ||
| 25 | static in_cache_entry *in_cache_get(__be32 dst_ip, | 34 | static in_cache_entry *in_cache_get(__be32 dst_ip, |
| @@ -29,8 +38,8 @@ static in_cache_entry *in_cache_get(__be32 dst_ip, | |||
| 29 | 38 | ||
| 30 | read_lock_bh(&client->ingress_lock); | 39 | read_lock_bh(&client->ingress_lock); |
| 31 | entry = client->in_cache; | 40 | entry = client->in_cache; |
| 32 | while(entry != NULL){ | 41 | while (entry != NULL) { |
| 33 | if( entry->ctrl_info.in_dst_ip == dst_ip ){ | 42 | if (entry->ctrl_info.in_dst_ip == dst_ip) { |
| 34 | atomic_inc(&entry->use); | 43 | atomic_inc(&entry->use); |
| 35 | read_unlock_bh(&client->ingress_lock); | 44 | read_unlock_bh(&client->ingress_lock); |
| 36 | return entry; | 45 | return entry; |
| @@ -50,8 +59,8 @@ static in_cache_entry *in_cache_get_with_mask(__be32 dst_ip, | |||
| 50 | 59 | ||
| 51 | read_lock_bh(&client->ingress_lock); | 60 | read_lock_bh(&client->ingress_lock); |
| 52 | entry = client->in_cache; | 61 | entry = client->in_cache; |
| 53 | while(entry != NULL){ | 62 | while (entry != NULL) { |
| 54 | if((entry->ctrl_info.in_dst_ip & mask) == (dst_ip & mask )){ | 63 | if ((entry->ctrl_info.in_dst_ip & mask) == (dst_ip & mask)) { |
| 55 | atomic_inc(&entry->use); | 64 | atomic_inc(&entry->use); |
| 56 | read_unlock_bh(&client->ingress_lock); | 65 | read_unlock_bh(&client->ingress_lock); |
| 57 | return entry; | 66 | return entry; |
| @@ -65,14 +74,14 @@ static in_cache_entry *in_cache_get_with_mask(__be32 dst_ip, | |||
| 65 | } | 74 | } |
| 66 | 75 | ||
| 67 | static in_cache_entry *in_cache_get_by_vcc(struct atm_vcc *vcc, | 76 | static in_cache_entry *in_cache_get_by_vcc(struct atm_vcc *vcc, |
| 68 | struct mpoa_client *client ) | 77 | struct mpoa_client *client) |
| 69 | { | 78 | { |
| 70 | in_cache_entry *entry; | 79 | in_cache_entry *entry; |
| 71 | 80 | ||
| 72 | read_lock_bh(&client->ingress_lock); | 81 | read_lock_bh(&client->ingress_lock); |
| 73 | entry = client->in_cache; | 82 | entry = client->in_cache; |
| 74 | while(entry != NULL){ | 83 | while (entry != NULL) { |
| 75 | if(entry->shortcut == vcc) { | 84 | if (entry->shortcut == vcc) { |
| 76 | atomic_inc(&entry->use); | 85 | atomic_inc(&entry->use); |
| 77 | read_unlock_bh(&client->ingress_lock); | 86 | read_unlock_bh(&client->ingress_lock); |
| 78 | return entry; | 87 | return entry; |
| @@ -90,14 +99,14 @@ static in_cache_entry *in_cache_add_entry(__be32 dst_ip, | |||
| 90 | in_cache_entry *entry = kzalloc(sizeof(in_cache_entry), GFP_KERNEL); | 99 | in_cache_entry *entry = kzalloc(sizeof(in_cache_entry), GFP_KERNEL); |
| 91 | 100 | ||
| 92 | if (entry == NULL) { | 101 | if (entry == NULL) { |
| 93 | printk("mpoa: mpoa_caches.c: new_in_cache_entry: out of memory\n"); | 102 | pr_info("mpoa: mpoa_caches.c: new_in_cache_entry: out of memory\n"); |
| 94 | return NULL; | 103 | return NULL; |
| 95 | } | 104 | } |
| 96 | 105 | ||
| 97 | dprintk("mpoa: mpoa_caches.c: adding an ingress entry, ip = %pI4\n", &dst_ip); | 106 | dprintk("adding an ingress entry, ip = %pI4\n", &dst_ip); |
| 98 | 107 | ||
| 99 | atomic_set(&entry->use, 1); | 108 | atomic_set(&entry->use, 1); |
| 100 | dprintk("mpoa: mpoa_caches.c: new_in_cache_entry: about to lock\n"); | 109 | dprintk("new_in_cache_entry: about to lock\n"); |
| 101 | write_lock_bh(&client->ingress_lock); | 110 | write_lock_bh(&client->ingress_lock); |
| 102 | entry->next = client->in_cache; | 111 | entry->next = client->in_cache; |
| 103 | entry->prev = NULL; | 112 | entry->prev = NULL; |
| @@ -115,7 +124,7 @@ static in_cache_entry *in_cache_add_entry(__be32 dst_ip, | |||
| 115 | atomic_inc(&entry->use); | 124 | atomic_inc(&entry->use); |
| 116 | 125 | ||
| 117 | write_unlock_bh(&client->ingress_lock); | 126 | write_unlock_bh(&client->ingress_lock); |
| 118 | dprintk("mpoa: mpoa_caches.c: new_in_cache_entry: unlocked\n"); | 127 | dprintk("new_in_cache_entry: unlocked\n"); |
| 119 | 128 | ||
| 120 | return entry; | 129 | return entry; |
| 121 | } | 130 | } |
| @@ -126,39 +135,41 @@ static int cache_hit(in_cache_entry *entry, struct mpoa_client *mpc) | |||
| 126 | struct k_message msg; | 135 | struct k_message msg; |
| 127 | 136 | ||
| 128 | entry->count++; | 137 | entry->count++; |
| 129 | if(entry->entry_state == INGRESS_RESOLVED && entry->shortcut != NULL) | 138 | if (entry->entry_state == INGRESS_RESOLVED && entry->shortcut != NULL) |
| 130 | return OPEN; | 139 | return OPEN; |
| 131 | 140 | ||
| 132 | if(entry->entry_state == INGRESS_REFRESHING){ | 141 | if (entry->entry_state == INGRESS_REFRESHING) { |
| 133 | if(entry->count > mpc->parameters.mpc_p1){ | 142 | if (entry->count > mpc->parameters.mpc_p1) { |
| 134 | msg.type = SND_MPOA_RES_RQST; | 143 | msg.type = SND_MPOA_RES_RQST; |
| 135 | msg.content.in_info = entry->ctrl_info; | 144 | msg.content.in_info = entry->ctrl_info; |
| 136 | memcpy(msg.MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN); | 145 | memcpy(msg.MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN); |
| 137 | qos = atm_mpoa_search_qos(entry->ctrl_info.in_dst_ip); | 146 | qos = atm_mpoa_search_qos(entry->ctrl_info.in_dst_ip); |
| 138 | if (qos != NULL) msg.qos = qos->qos; | 147 | if (qos != NULL) |
| 148 | msg.qos = qos->qos; | ||
| 139 | msg_to_mpoad(&msg, mpc); | 149 | msg_to_mpoad(&msg, mpc); |
| 140 | do_gettimeofday(&(entry->reply_wait)); | 150 | do_gettimeofday(&(entry->reply_wait)); |
| 141 | entry->entry_state = INGRESS_RESOLVING; | 151 | entry->entry_state = INGRESS_RESOLVING; |
| 142 | } | 152 | } |
| 143 | if(entry->shortcut != NULL) | 153 | if (entry->shortcut != NULL) |
| 144 | return OPEN; | 154 | return OPEN; |
| 145 | return CLOSED; | 155 | return CLOSED; |
| 146 | } | 156 | } |
| 147 | 157 | ||
| 148 | if(entry->entry_state == INGRESS_RESOLVING && entry->shortcut != NULL) | 158 | if (entry->entry_state == INGRESS_RESOLVING && entry->shortcut != NULL) |
| 149 | return OPEN; | 159 | return OPEN; |
| 150 | 160 | ||
| 151 | if( entry->count > mpc->parameters.mpc_p1 && | 161 | if (entry->count > mpc->parameters.mpc_p1 && |
| 152 | entry->entry_state == INGRESS_INVALID){ | 162 | entry->entry_state == INGRESS_INVALID) { |
| 153 | dprintk("mpoa: (%s) mpoa_caches.c: threshold exceeded for ip %pI4, sending MPOA res req\n", | 163 | dprintk("(%s) threshold exceeded for ip %pI4, sending MPOA res req\n", |
| 154 | mpc->dev->name, &entry->ctrl_info.in_dst_ip); | 164 | mpc->dev->name, &entry->ctrl_info.in_dst_ip); |
| 155 | entry->entry_state = INGRESS_RESOLVING; | 165 | entry->entry_state = INGRESS_RESOLVING; |
| 156 | msg.type = SND_MPOA_RES_RQST; | 166 | msg.type = SND_MPOA_RES_RQST; |
| 157 | memcpy(msg.MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN ); | 167 | memcpy(msg.MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN); |
| 158 | msg.content.in_info = entry->ctrl_info; | 168 | msg.content.in_info = entry->ctrl_info; |
| 159 | qos = atm_mpoa_search_qos(entry->ctrl_info.in_dst_ip); | 169 | qos = atm_mpoa_search_qos(entry->ctrl_info.in_dst_ip); |
| 160 | if (qos != NULL) msg.qos = qos->qos; | 170 | if (qos != NULL) |
| 161 | msg_to_mpoad( &msg, mpc); | 171 | msg.qos = qos->qos; |
| 172 | msg_to_mpoad(&msg, mpc); | ||
| 162 | do_gettimeofday(&(entry->reply_wait)); | 173 | do_gettimeofday(&(entry->reply_wait)); |
| 163 | } | 174 | } |
| 164 | 175 | ||
| @@ -185,7 +196,7 @@ static void in_cache_remove_entry(in_cache_entry *entry, | |||
| 185 | struct k_message msg; | 196 | struct k_message msg; |
| 186 | 197 | ||
| 187 | vcc = entry->shortcut; | 198 | vcc = entry->shortcut; |
| 188 | dprintk("mpoa: mpoa_caches.c: removing an ingress entry, ip = %pI4\n", | 199 | dprintk("removing an ingress entry, ip = %pI4\n", |
| 189 | &entry->ctrl_info.in_dst_ip); | 200 | &entry->ctrl_info.in_dst_ip); |
| 190 | 201 | ||
| 191 | if (entry->prev != NULL) | 202 | if (entry->prev != NULL) |
| @@ -195,14 +206,15 @@ static void in_cache_remove_entry(in_cache_entry *entry, | |||
| 195 | if (entry->next != NULL) | 206 | if (entry->next != NULL) |
| 196 | entry->next->prev = entry->prev; | 207 | entry->next->prev = entry->prev; |
| 197 | client->in_ops->put(entry); | 208 | client->in_ops->put(entry); |
| 198 | if(client->in_cache == NULL && client->eg_cache == NULL){ | 209 | if (client->in_cache == NULL && client->eg_cache == NULL) { |
| 199 | msg.type = STOP_KEEP_ALIVE_SM; | 210 | msg.type = STOP_KEEP_ALIVE_SM; |
| 200 | msg_to_mpoad(&msg,client); | 211 | msg_to_mpoad(&msg, client); |
| 201 | } | 212 | } |
| 202 | 213 | ||
| 203 | /* Check if the egress side still uses this VCC */ | 214 | /* Check if the egress side still uses this VCC */ |
| 204 | if (vcc != NULL) { | 215 | if (vcc != NULL) { |
| 205 | eg_cache_entry *eg_entry = client->eg_ops->get_by_vcc(vcc, client); | 216 | eg_cache_entry *eg_entry = client->eg_ops->get_by_vcc(vcc, |
| 217 | client); | ||
| 206 | if (eg_entry != NULL) { | 218 | if (eg_entry != NULL) { |
| 207 | client->eg_ops->put(eg_entry); | 219 | client->eg_ops->put(eg_entry); |
| 208 | return; | 220 | return; |
| @@ -213,7 +225,6 @@ static void in_cache_remove_entry(in_cache_entry *entry, | |||
| 213 | return; | 225 | return; |
| 214 | } | 226 | } |
| 215 | 227 | ||
| 216 | |||
| 217 | /* Call this every MPC-p2 seconds... Not exactly correct solution, | 228 | /* Call this every MPC-p2 seconds... Not exactly correct solution, |
| 218 | but an easy one... */ | 229 | but an easy one... */ |
| 219 | static void clear_count_and_expired(struct mpoa_client *client) | 230 | static void clear_count_and_expired(struct mpoa_client *client) |
| @@ -225,12 +236,12 @@ static void clear_count_and_expired(struct mpoa_client *client) | |||
| 225 | 236 | ||
| 226 | write_lock_bh(&client->ingress_lock); | 237 | write_lock_bh(&client->ingress_lock); |
| 227 | entry = client->in_cache; | 238 | entry = client->in_cache; |
| 228 | while(entry != NULL){ | 239 | while (entry != NULL) { |
| 229 | entry->count=0; | 240 | entry->count = 0; |
| 230 | next_entry = entry->next; | 241 | next_entry = entry->next; |
| 231 | if((now.tv_sec - entry->tv.tv_sec) | 242 | if ((now.tv_sec - entry->tv.tv_sec) |
| 232 | > entry->ctrl_info.holding_time){ | 243 | > entry->ctrl_info.holding_time) { |
| 233 | dprintk("mpoa: mpoa_caches.c: holding time expired, ip = %pI4\n", | 244 | dprintk("holding time expired, ip = %pI4\n", |
| 234 | &entry->ctrl_info.in_dst_ip); | 245 | &entry->ctrl_info.in_dst_ip); |
| 235 | client->in_ops->remove_entry(entry, client); | 246 | client->in_ops->remove_entry(entry, client); |
| 236 | } | 247 | } |
| @@ -250,33 +261,38 @@ static void check_resolving_entries(struct mpoa_client *client) | |||
| 250 | struct timeval now; | 261 | struct timeval now; |
| 251 | struct k_message msg; | 262 | struct k_message msg; |
| 252 | 263 | ||
| 253 | do_gettimeofday( &now ); | 264 | do_gettimeofday(&now); |
| 254 | 265 | ||
| 255 | read_lock_bh(&client->ingress_lock); | 266 | read_lock_bh(&client->ingress_lock); |
| 256 | entry = client->in_cache; | 267 | entry = client->in_cache; |
| 257 | while( entry != NULL ){ | 268 | while (entry != NULL) { |
| 258 | if(entry->entry_state == INGRESS_RESOLVING){ | 269 | if (entry->entry_state == INGRESS_RESOLVING) { |
| 259 | if(now.tv_sec - entry->hold_down.tv_sec < client->parameters.mpc_p6){ | 270 | if ((now.tv_sec - entry->hold_down.tv_sec) < |
| 260 | entry = entry->next; /* Entry in hold down */ | 271 | client->parameters.mpc_p6) { |
| 272 | entry = entry->next; /* Entry in hold down */ | ||
| 261 | continue; | 273 | continue; |
| 262 | } | 274 | } |
| 263 | if( (now.tv_sec - entry->reply_wait.tv_sec) > | 275 | if ((now.tv_sec - entry->reply_wait.tv_sec) > |
| 264 | entry->retry_time ){ | 276 | entry->retry_time) { |
| 265 | entry->retry_time = MPC_C1*( entry->retry_time ); | 277 | entry->retry_time = MPC_C1 * (entry->retry_time); |
| 266 | if(entry->retry_time > client->parameters.mpc_p5){ | 278 | /* |
| 267 | /* Retry time maximum exceeded, put entry in hold down. */ | 279 | * Retry time maximum exceeded, |
| 280 | * put entry in hold down. | ||
| 281 | */ | ||
| 282 | if (entry->retry_time > client->parameters.mpc_p5) { | ||
| 268 | do_gettimeofday(&(entry->hold_down)); | 283 | do_gettimeofday(&(entry->hold_down)); |
| 269 | entry->retry_time = client->parameters.mpc_p4; | 284 | entry->retry_time = client->parameters.mpc_p4; |
| 270 | entry = entry->next; | 285 | entry = entry->next; |
| 271 | continue; | 286 | continue; |
| 272 | } | 287 | } |
| 273 | /* Ask daemon to send a resolution request. */ | 288 | /* Ask daemon to send a resolution request. */ |
| 274 | memset(&(entry->hold_down),0,sizeof(struct timeval)); | 289 | memset(&(entry->hold_down), 0, sizeof(struct timeval)); |
| 275 | msg.type = SND_MPOA_RES_RTRY; | 290 | msg.type = SND_MPOA_RES_RTRY; |
| 276 | memcpy(msg.MPS_ctrl, client->mps_ctrl_addr, ATM_ESA_LEN); | 291 | memcpy(msg.MPS_ctrl, client->mps_ctrl_addr, ATM_ESA_LEN); |
| 277 | msg.content.in_info = entry->ctrl_info; | 292 | msg.content.in_info = entry->ctrl_info; |
| 278 | qos = atm_mpoa_search_qos(entry->ctrl_info.in_dst_ip); | 293 | qos = atm_mpoa_search_qos(entry->ctrl_info.in_dst_ip); |
| 279 | if (qos != NULL) msg.qos = qos->qos; | 294 | if (qos != NULL) |
| 295 | msg.qos = qos->qos; | ||
| 280 | msg_to_mpoad(&msg, client); | 296 | msg_to_mpoad(&msg, client); |
| 281 | do_gettimeofday(&(entry->reply_wait)); | 297 | do_gettimeofday(&(entry->reply_wait)); |
| 282 | } | 298 | } |
| @@ -292,16 +308,17 @@ static void refresh_entries(struct mpoa_client *client) | |||
| 292 | struct timeval now; | 308 | struct timeval now; |
| 293 | struct in_cache_entry *entry = client->in_cache; | 309 | struct in_cache_entry *entry = client->in_cache; |
| 294 | 310 | ||
| 295 | ddprintk("mpoa: mpoa_caches.c: refresh_entries\n"); | 311 | ddprintk("refresh_entries\n"); |
| 296 | do_gettimeofday(&now); | 312 | do_gettimeofday(&now); |
| 297 | 313 | ||
| 298 | read_lock_bh(&client->ingress_lock); | 314 | read_lock_bh(&client->ingress_lock); |
| 299 | while( entry != NULL ){ | 315 | while (entry != NULL) { |
| 300 | if( entry->entry_state == INGRESS_RESOLVED ){ | 316 | if (entry->entry_state == INGRESS_RESOLVED) { |
| 301 | if(!(entry->refresh_time)) | 317 | if (!(entry->refresh_time)) |
| 302 | entry->refresh_time = (2*(entry->ctrl_info.holding_time))/3; | 318 | entry->refresh_time = (2 * (entry->ctrl_info.holding_time))/3; |
| 303 | if( (now.tv_sec - entry->reply_wait.tv_sec) > entry->refresh_time ){ | 319 | if ((now.tv_sec - entry->reply_wait.tv_sec) > |
| 304 | dprintk("mpoa: mpoa_caches.c: refreshing an entry.\n"); | 320 | entry->refresh_time) { |
| 321 | dprintk("refreshing an entry.\n"); | ||
| 305 | entry->entry_state = INGRESS_REFRESHING; | 322 | entry->entry_state = INGRESS_REFRESHING; |
| 306 | 323 | ||
| 307 | } | 324 | } |
| @@ -314,21 +331,22 @@ static void refresh_entries(struct mpoa_client *client) | |||
| 314 | static void in_destroy_cache(struct mpoa_client *mpc) | 331 | static void in_destroy_cache(struct mpoa_client *mpc) |
| 315 | { | 332 | { |
| 316 | write_lock_irq(&mpc->ingress_lock); | 333 | write_lock_irq(&mpc->ingress_lock); |
| 317 | while(mpc->in_cache != NULL) | 334 | while (mpc->in_cache != NULL) |
| 318 | mpc->in_ops->remove_entry(mpc->in_cache, mpc); | 335 | mpc->in_ops->remove_entry(mpc->in_cache, mpc); |
| 319 | write_unlock_irq(&mpc->ingress_lock); | 336 | write_unlock_irq(&mpc->ingress_lock); |
| 320 | 337 | ||
| 321 | return; | 338 | return; |
| 322 | } | 339 | } |
| 323 | 340 | ||
| 324 | static eg_cache_entry *eg_cache_get_by_cache_id(__be32 cache_id, struct mpoa_client *mpc) | 341 | static eg_cache_entry *eg_cache_get_by_cache_id(__be32 cache_id, |
| 342 | struct mpoa_client *mpc) | ||
| 325 | { | 343 | { |
| 326 | eg_cache_entry *entry; | 344 | eg_cache_entry *entry; |
| 327 | 345 | ||
| 328 | read_lock_irq(&mpc->egress_lock); | 346 | read_lock_irq(&mpc->egress_lock); |
| 329 | entry = mpc->eg_cache; | 347 | entry = mpc->eg_cache; |
| 330 | while(entry != NULL){ | 348 | while (entry != NULL) { |
| 331 | if(entry->ctrl_info.cache_id == cache_id){ | 349 | if (entry->ctrl_info.cache_id == cache_id) { |
| 332 | atomic_inc(&entry->use); | 350 | atomic_inc(&entry->use); |
| 333 | read_unlock_irq(&mpc->egress_lock); | 351 | read_unlock_irq(&mpc->egress_lock); |
| 334 | return entry; | 352 | return entry; |
| @@ -348,7 +366,7 @@ static eg_cache_entry *eg_cache_get_by_tag(__be32 tag, struct mpoa_client *mpc) | |||
| 348 | 366 | ||
| 349 | read_lock_irqsave(&mpc->egress_lock, flags); | 367 | read_lock_irqsave(&mpc->egress_lock, flags); |
| 350 | entry = mpc->eg_cache; | 368 | entry = mpc->eg_cache; |
| 351 | while (entry != NULL){ | 369 | while (entry != NULL) { |
| 352 | if (entry->ctrl_info.tag == tag) { | 370 | if (entry->ctrl_info.tag == tag) { |
| 353 | atomic_inc(&entry->use); | 371 | atomic_inc(&entry->use); |
| 354 | read_unlock_irqrestore(&mpc->egress_lock, flags); | 372 | read_unlock_irqrestore(&mpc->egress_lock, flags); |
| @@ -362,14 +380,15 @@ static eg_cache_entry *eg_cache_get_by_tag(__be32 tag, struct mpoa_client *mpc) | |||
| 362 | } | 380 | } |
| 363 | 381 | ||
| 364 | /* This can be called from any context since it saves CPU flags */ | 382 | /* This can be called from any context since it saves CPU flags */ |
| 365 | static eg_cache_entry *eg_cache_get_by_vcc(struct atm_vcc *vcc, struct mpoa_client *mpc) | 383 | static eg_cache_entry *eg_cache_get_by_vcc(struct atm_vcc *vcc, |
| 384 | struct mpoa_client *mpc) | ||
| 366 | { | 385 | { |
| 367 | unsigned long flags; | 386 | unsigned long flags; |
| 368 | eg_cache_entry *entry; | 387 | eg_cache_entry *entry; |
| 369 | 388 | ||
| 370 | read_lock_irqsave(&mpc->egress_lock, flags); | 389 | read_lock_irqsave(&mpc->egress_lock, flags); |
| 371 | entry = mpc->eg_cache; | 390 | entry = mpc->eg_cache; |
| 372 | while (entry != NULL){ | 391 | while (entry != NULL) { |
| 373 | if (entry->shortcut == vcc) { | 392 | if (entry->shortcut == vcc) { |
| 374 | atomic_inc(&entry->use); | 393 | atomic_inc(&entry->use); |
| 375 | read_unlock_irqrestore(&mpc->egress_lock, flags); | 394 | read_unlock_irqrestore(&mpc->egress_lock, flags); |
| @@ -382,14 +401,15 @@ static eg_cache_entry *eg_cache_get_by_vcc(struct atm_vcc *vcc, struct mpoa_clie | |||
| 382 | return NULL; | 401 | return NULL; |
| 383 | } | 402 | } |
| 384 | 403 | ||
| 385 | static eg_cache_entry *eg_cache_get_by_src_ip(__be32 ipaddr, struct mpoa_client *mpc) | 404 | static eg_cache_entry *eg_cache_get_by_src_ip(__be32 ipaddr, |
| 405 | struct mpoa_client *mpc) | ||
| 386 | { | 406 | { |
| 387 | eg_cache_entry *entry; | 407 | eg_cache_entry *entry; |
| 388 | 408 | ||
| 389 | read_lock_irq(&mpc->egress_lock); | 409 | read_lock_irq(&mpc->egress_lock); |
| 390 | entry = mpc->eg_cache; | 410 | entry = mpc->eg_cache; |
| 391 | while(entry != NULL){ | 411 | while (entry != NULL) { |
| 392 | if(entry->latest_ip_addr == ipaddr) { | 412 | if (entry->latest_ip_addr == ipaddr) { |
| 393 | atomic_inc(&entry->use); | 413 | atomic_inc(&entry->use); |
| 394 | read_unlock_irq(&mpc->egress_lock); | 414 | read_unlock_irq(&mpc->egress_lock); |
| 395 | return entry; | 415 | return entry; |
| @@ -421,7 +441,7 @@ static void eg_cache_remove_entry(eg_cache_entry *entry, | |||
| 421 | struct k_message msg; | 441 | struct k_message msg; |
| 422 | 442 | ||
| 423 | vcc = entry->shortcut; | 443 | vcc = entry->shortcut; |
| 424 | dprintk("mpoa: mpoa_caches.c: removing an egress entry.\n"); | 444 | dprintk("removing an egress entry.\n"); |
| 425 | if (entry->prev != NULL) | 445 | if (entry->prev != NULL) |
| 426 | entry->prev->next = entry->next; | 446 | entry->prev->next = entry->next; |
| 427 | else | 447 | else |
| @@ -429,9 +449,9 @@ static void eg_cache_remove_entry(eg_cache_entry *entry, | |||
| 429 | if (entry->next != NULL) | 449 | if (entry->next != NULL) |
| 430 | entry->next->prev = entry->prev; | 450 | entry->next->prev = entry->prev; |
| 431 | client->eg_ops->put(entry); | 451 | client->eg_ops->put(entry); |
| 432 | if(client->in_cache == NULL && client->eg_cache == NULL){ | 452 | if (client->in_cache == NULL && client->eg_cache == NULL) { |
| 433 | msg.type = STOP_KEEP_ALIVE_SM; | 453 | msg.type = STOP_KEEP_ALIVE_SM; |
| 434 | msg_to_mpoad(&msg,client); | 454 | msg_to_mpoad(&msg, client); |
| 435 | } | 455 | } |
| 436 | 456 | ||
| 437 | /* Check if the ingress side still uses this VCC */ | 457 | /* Check if the ingress side still uses this VCC */ |
| @@ -447,20 +467,21 @@ static void eg_cache_remove_entry(eg_cache_entry *entry, | |||
| 447 | return; | 467 | return; |
| 448 | } | 468 | } |
| 449 | 469 | ||
| 450 | static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_client *client) | 470 | static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, |
| 471 | struct mpoa_client *client) | ||
| 451 | { | 472 | { |
| 452 | eg_cache_entry *entry = kzalloc(sizeof(eg_cache_entry), GFP_KERNEL); | 473 | eg_cache_entry *entry = kzalloc(sizeof(eg_cache_entry), GFP_KERNEL); |
| 453 | 474 | ||
| 454 | if (entry == NULL) { | 475 | if (entry == NULL) { |
| 455 | printk("mpoa: mpoa_caches.c: new_eg_cache_entry: out of memory\n"); | 476 | pr_info("out of memory\n"); |
| 456 | return NULL; | 477 | return NULL; |
| 457 | } | 478 | } |
| 458 | 479 | ||
| 459 | dprintk("mpoa: mpoa_caches.c: adding an egress entry, ip = %pI4, this should be our IP\n", | 480 | dprintk("adding an egress entry, ip = %pI4, this should be our IP\n", |
| 460 | &msg->content.eg_info.eg_dst_ip); | 481 | &msg->content.eg_info.eg_dst_ip); |
| 461 | 482 | ||
| 462 | atomic_set(&entry->use, 1); | 483 | atomic_set(&entry->use, 1); |
| 463 | dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry: about to lock\n"); | 484 | dprintk("new_eg_cache_entry: about to lock\n"); |
| 464 | write_lock_irq(&client->egress_lock); | 485 | write_lock_irq(&client->egress_lock); |
| 465 | entry->next = client->eg_cache; | 486 | entry->next = client->eg_cache; |
| 466 | entry->prev = NULL; | 487 | entry->prev = NULL; |
| @@ -472,18 +493,18 @@ static eg_cache_entry *eg_cache_add_entry(struct k_message *msg, struct mpoa_cli | |||
| 472 | entry->ctrl_info = msg->content.eg_info; | 493 | entry->ctrl_info = msg->content.eg_info; |
| 473 | do_gettimeofday(&(entry->tv)); | 494 | do_gettimeofday(&(entry->tv)); |
| 474 | entry->entry_state = EGRESS_RESOLVED; | 495 | entry->entry_state = EGRESS_RESOLVED; |
| 475 | dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry cache_id %lu\n", ntohl(entry->ctrl_info.cache_id)); | 496 | dprintk("new_eg_cache_entry cache_id %u\n", |
| 476 | dprintk("mpoa: mpoa_caches.c: mps_ip = %pI4\n", | 497 | ntohl(entry->ctrl_info.cache_id)); |
| 477 | &entry->ctrl_info.mps_ip); | 498 | dprintk("mps_ip = %pI4\n", &entry->ctrl_info.mps_ip); |
| 478 | atomic_inc(&entry->use); | 499 | atomic_inc(&entry->use); |
| 479 | 500 | ||
| 480 | write_unlock_irq(&client->egress_lock); | 501 | write_unlock_irq(&client->egress_lock); |
| 481 | dprintk("mpoa: mpoa_caches.c: new_eg_cache_entry: unlocked\n"); | 502 | dprintk("new_eg_cache_entry: unlocked\n"); |
| 482 | 503 | ||
| 483 | return entry; | 504 | return entry; |
| 484 | } | 505 | } |
| 485 | 506 | ||
| 486 | static void update_eg_cache_entry(eg_cache_entry * entry, uint16_t holding_time) | 507 | static void update_eg_cache_entry(eg_cache_entry *entry, uint16_t holding_time) |
| 487 | { | 508 | { |
| 488 | do_gettimeofday(&(entry->tv)); | 509 | do_gettimeofday(&(entry->tv)); |
| 489 | entry->entry_state = EGRESS_RESOLVED; | 510 | entry->entry_state = EGRESS_RESOLVED; |
| @@ -502,13 +523,14 @@ static void clear_expired(struct mpoa_client *client) | |||
| 502 | 523 | ||
| 503 | write_lock_irq(&client->egress_lock); | 524 | write_lock_irq(&client->egress_lock); |
| 504 | entry = client->eg_cache; | 525 | entry = client->eg_cache; |
| 505 | while(entry != NULL){ | 526 | while (entry != NULL) { |
| 506 | next_entry = entry->next; | 527 | next_entry = entry->next; |
| 507 | if((now.tv_sec - entry->tv.tv_sec) | 528 | if ((now.tv_sec - entry->tv.tv_sec) |
| 508 | > entry->ctrl_info.holding_time){ | 529 | > entry->ctrl_info.holding_time) { |
| 509 | msg.type = SND_EGRESS_PURGE; | 530 | msg.type = SND_EGRESS_PURGE; |
| 510 | msg.content.eg_info = entry->ctrl_info; | 531 | msg.content.eg_info = entry->ctrl_info; |
| 511 | dprintk("mpoa: mpoa_caches.c: egress_cache: holding time expired, cache_id = %lu.\n",ntohl(entry->ctrl_info.cache_id)); | 532 | dprintk("egress_cache: holding time expired, cache_id = %u.\n", |
| 533 | ntohl(entry->ctrl_info.cache_id)); | ||
| 512 | msg_to_mpoad(&msg, client); | 534 | msg_to_mpoad(&msg, client); |
| 513 | client->eg_ops->remove_entry(entry, client); | 535 | client->eg_ops->remove_entry(entry, client); |
| 514 | } | 536 | } |
| @@ -522,7 +544,7 @@ static void clear_expired(struct mpoa_client *client) | |||
| 522 | static void eg_destroy_cache(struct mpoa_client *mpc) | 544 | static void eg_destroy_cache(struct mpoa_client *mpc) |
| 523 | { | 545 | { |
| 524 | write_lock_irq(&mpc->egress_lock); | 546 | write_lock_irq(&mpc->egress_lock); |
| 525 | while(mpc->eg_cache != NULL) | 547 | while (mpc->eg_cache != NULL) |
| 526 | mpc->eg_ops->remove_entry(mpc->eg_cache, mpc); | 548 | mpc->eg_ops->remove_entry(mpc->eg_cache, mpc); |
| 527 | write_unlock_irq(&mpc->egress_lock); | 549 | write_unlock_irq(&mpc->egress_lock); |
| 528 | 550 | ||
| @@ -530,7 +552,6 @@ static void eg_destroy_cache(struct mpoa_client *mpc) | |||
| 530 | } | 552 | } |
| 531 | 553 | ||
| 532 | 554 | ||
| 533 | |||
| 534 | static struct in_cache_ops ingress_ops = { | 555 | static struct in_cache_ops ingress_ops = { |
| 535 | in_cache_add_entry, /* add_entry */ | 556 | in_cache_add_entry, /* add_entry */ |
| 536 | in_cache_get, /* get */ | 557 | in_cache_get, /* get */ |
