1 #include <linux/kernel.h>
2 #include <linux/string.h>
3 #include <linux/timer.h>
4 #include <linux/init.h>
5 #include <linux/bitops.h>
6 #include <linux/capability.h>
7 #include <linux/seq_file.h>
9 /* We are an ethernet device */
10 #include <linux/if_ether.h>
11 #include <linux/netdevice.h>
12 #include <linux/etherdevice.h>
14 #include <linux/skbuff.h>
16 #include <asm/byteorder.h>
17 #include <asm/uaccess.h>
18 #include <net/checksum.h> /* for ip_fast_csum() */
21 #include <linux/proc_fs.h>
24 #include <linux/atmdev.h>
25 #include <linux/atmlec.h>
26 #include <linux/atmmpc.h>
28 #include <linux/module.h>
32 #include "resources.h"
35 * mpc.c: Implementation of MPOA client kernel part
39 #define dprintk printk /* debug */
41 #define dprintk(format,args...)
45 #define ddprintk printk /* more debug */
47 #define ddprintk(format,args...)
52 #define MPOA_TAG_LEN 4
54 /* mpc_daemon -> kernel */
55 static void MPOA_trigger_rcvd (struct k_message
*msg
, struct mpoa_client
*mpc
);
56 static void MPOA_res_reply_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
);
57 static void ingress_purge_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
);
58 static void egress_purge_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
);
59 static void mps_death(struct k_message
*msg
, struct mpoa_client
*mpc
);
60 static void clean_up(struct k_message
*msg
, struct mpoa_client
*mpc
, int action
);
61 static void MPOA_cache_impos_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
);
62 static void set_mpc_ctrl_addr_rcvd(struct k_message
*mesg
, struct mpoa_client
*mpc
);
63 static void set_mps_mac_addr_rcvd(struct k_message
*mesg
, struct mpoa_client
*mpc
);
65 static uint8_t *copy_macs(struct mpoa_client
*mpc
, uint8_t *router_mac
,
66 uint8_t *tlvs
, uint8_t mps_macs
, uint8_t device_type
);
67 static void purge_egress_shortcut(struct atm_vcc
*vcc
, eg_cache_entry
*entry
);
69 static void send_set_mps_ctrl_addr(char *addr
, struct mpoa_client
*mpc
);
70 static void mpoad_close(struct atm_vcc
*vcc
);
71 static int msg_from_mpoad(struct atm_vcc
*vcc
, struct sk_buff
*skb
);
73 static void mpc_push(struct atm_vcc
*vcc
, struct sk_buff
*skb
);
74 static int mpc_send_packet(struct sk_buff
*skb
, struct net_device
*dev
);
75 static int mpoa_event_listener(struct notifier_block
*mpoa_notifier
, unsigned long event
, void *dev
);
76 static void mpc_timer_refresh(void);
77 static void mpc_cache_check( unsigned long checking_time
);
79 static struct llc_snap_hdr llc_snap_mpoa_ctrl
= {
82 {0x00, 0x03} /* For MPOA control PDUs */
84 static struct llc_snap_hdr llc_snap_mpoa_data
= {
87 {0x08, 0x00} /* This is for IP PDUs only */
89 static struct llc_snap_hdr llc_snap_mpoa_data_tagged
= {
92 {0x88, 0x4c} /* This is for tagged data PDUs */
95 static struct notifier_block mpoa_notifier
= {
101 struct mpoa_client
*mpcs
= NULL
; /* FIXME */
102 static struct atm_mpoa_qos
*qos_head
= NULL
;
103 static DEFINE_TIMER(mpc_timer
, NULL
, 0, 0);
106 static struct mpoa_client
*find_mpc_by_itfnum(int itf
)
108 struct mpoa_client
*mpc
;
110 mpc
= mpcs
; /* our global linked list */
111 while (mpc
!= NULL
) {
112 if (mpc
->dev_num
== itf
)
117 return NULL
; /* not found */
120 static struct mpoa_client
*find_mpc_by_vcc(struct atm_vcc
*vcc
)
122 struct mpoa_client
*mpc
;
124 mpc
= mpcs
; /* our global linked list */
125 while (mpc
!= NULL
) {
126 if (mpc
->mpoad_vcc
== vcc
)
131 return NULL
; /* not found */
134 static struct mpoa_client
*find_mpc_by_lec(struct net_device
*dev
)
136 struct mpoa_client
*mpc
;
138 mpc
= mpcs
; /* our global linked list */
139 while (mpc
!= NULL
) {
145 return NULL
; /* not found */
149 * Functions for managing QoS list
153 * Overwrites the old entry or makes a new one.
155 struct atm_mpoa_qos
*atm_mpoa_add_qos(__be32 dst_ip
, struct atm_qos
*qos
)
157 struct atm_mpoa_qos
*entry
;
159 entry
= atm_mpoa_search_qos(dst_ip
);
165 entry
= kmalloc(sizeof(struct atm_mpoa_qos
), GFP_KERNEL
);
167 printk("mpoa: atm_mpoa_add_qos: out of memory\n");
171 entry
->ipaddr
= dst_ip
;
174 entry
->next
= qos_head
;
180 struct atm_mpoa_qos
*atm_mpoa_search_qos(__be32 dst_ip
)
182 struct atm_mpoa_qos
*qos
;
185 while( qos
!= NULL
){
186 if(qos
->ipaddr
== dst_ip
) {
196 * Returns 0 for failure
198 int atm_mpoa_delete_qos(struct atm_mpoa_qos
*entry
)
201 struct atm_mpoa_qos
*curr
;
203 if (entry
== NULL
) return 0;
204 if (entry
== qos_head
) {
205 qos_head
= qos_head
->next
;
211 while (curr
!= NULL
) {
212 if (curr
->next
== entry
) {
213 curr
->next
= entry
->next
;
223 /* this is buggered - we need locking for qos_head */
224 void atm_mpoa_disp_qos(struct seq_file
*m
)
226 struct atm_mpoa_qos
*qos
;
229 seq_printf(m
, "QoS entries for shortcuts:\n");
230 seq_printf(m
, "IP address\n TX:max_pcr pcr min_pcr max_cdv max_sdu\n RX:max_pcr pcr min_pcr max_cdv max_sdu\n");
232 while (qos
!= NULL
) {
233 seq_printf(m
, "%u.%u.%u.%u\n %-7d %-7d %-7d %-7d %-7d\n %-7d %-7d %-7d %-7d %-7d\n",
234 NIPQUAD(qos
->ipaddr
),
235 qos
->qos
.txtp
.max_pcr
, qos
->qos
.txtp
.pcr
, qos
->qos
.txtp
.min_pcr
, qos
->qos
.txtp
.max_cdv
, qos
->qos
.txtp
.max_sdu
,
236 qos
->qos
.rxtp
.max_pcr
, qos
->qos
.rxtp
.pcr
, qos
->qos
.rxtp
.min_pcr
, qos
->qos
.rxtp
.max_cdv
, qos
->qos
.rxtp
.max_sdu
);
241 static struct net_device
*find_lec_by_itfnum(int itf
)
243 struct net_device
*dev
;
246 sprintf(name
, "lec%d", itf
);
247 dev
= dev_get_by_name(name
);
252 static struct mpoa_client
*alloc_mpc(void)
254 struct mpoa_client
*mpc
;
256 mpc
= kzalloc(sizeof (struct mpoa_client
), GFP_KERNEL
);
259 rwlock_init(&mpc
->ingress_lock
);
260 rwlock_init(&mpc
->egress_lock
);
262 atm_mpoa_init_cache(mpc
);
264 mpc
->parameters
.mpc_p1
= MPC_P1
;
265 mpc
->parameters
.mpc_p2
= MPC_P2
;
266 memset(mpc
->parameters
.mpc_p3
,0,sizeof(mpc
->parameters
.mpc_p3
));
267 mpc
->parameters
.mpc_p4
= MPC_P4
;
268 mpc
->parameters
.mpc_p5
= MPC_P5
;
269 mpc
->parameters
.mpc_p6
= MPC_P6
;
278 * start_mpc() puts the MPC on line. All the packets destined
279 * to the lec underneath us are now being monitored and
280 * shortcuts will be established.
283 static void start_mpc(struct mpoa_client
*mpc
, struct net_device
*dev
)
286 dprintk("mpoa: (%s) start_mpc:\n", mpc
->dev
->name
);
287 if (dev
->hard_start_xmit
== NULL
) {
288 printk("mpoa: (%s) start_mpc: dev->hard_start_xmit == NULL, not starting\n",
292 mpc
->old_hard_start_xmit
= dev
->hard_start_xmit
;
293 dev
->hard_start_xmit
= mpc_send_packet
;
298 static void stop_mpc(struct mpoa_client
*mpc
)
301 dprintk("mpoa: (%s) stop_mpc:", mpc
->dev
->name
);
303 /* Lets not nullify lec device's dev->hard_start_xmit */
304 if (mpc
->dev
->hard_start_xmit
!= mpc_send_packet
) {
305 dprintk(" mpc already stopped, not fatal\n");
309 mpc
->dev
->hard_start_xmit
= mpc
->old_hard_start_xmit
;
310 mpc
->old_hard_start_xmit
= NULL
;
311 /* close_shortcuts(mpc); ??? FIXME */
316 static const char *mpoa_device_type_string(char type
) __attribute__ ((unused
));
318 static const char *mpoa_device_type_string(char type
)
322 return "non-MPOA device";
331 return "both MPS and MPC";
334 return "unspecified (non-MPOA) device";
338 return ""; /* not reached */
342 * lec device calls this via its dev->priv->lane2_ops->associate_indicator()
343 * when it sees a TLV in LE_ARP packet.
344 * We fill in the pointer above when we see a LANE2 lec initializing
345 * See LANE2 spec 3.1.5
347 * Quite a big and ugly function but when you look at it
348 * all it does is to try to locate and parse MPOA Device
350 * We give our lec a pointer to this function and when the
351 * lec sees a TLV it uses the pointer to call this function.
354 static void lane2_assoc_ind(struct net_device
*dev
, uint8_t *mac_addr
,
355 uint8_t *tlvs
, uint32_t sizeoftlvs
)
358 uint8_t length
, mpoa_device_type
, number_of_mps_macs
;
359 uint8_t *end_of_tlvs
;
360 struct mpoa_client
*mpc
;
362 mpoa_device_type
= number_of_mps_macs
= 0; /* silence gcc */
363 dprintk("mpoa: (%s) lane2_assoc_ind: received TLV(s), ", dev
->name
);
364 dprintk("total length of all TLVs %d\n", sizeoftlvs
);
365 mpc
= find_mpc_by_lec(dev
); /* Sampo-Fix: moved here from below */
367 printk("mpoa: (%s) lane2_assoc_ind: no mpc\n", dev
->name
);
370 end_of_tlvs
= tlvs
+ sizeoftlvs
;
371 while (end_of_tlvs
- tlvs
>= 5) {
372 type
= (tlvs
[0] << 24) | (tlvs
[1] << 16) | (tlvs
[2] << 8) | tlvs
[3];
375 dprintk(" type 0x%x length %02x\n", type
, length
);
376 if (tlvs
+ length
> end_of_tlvs
) {
377 printk("TLV value extends past its buffer, aborting parse\n");
382 printk("mpoa: (%s) lane2_assoc_ind: TLV type was 0, returning\n", dev
->name
);
386 if (type
!= TLV_MPOA_DEVICE_TYPE
) {
388 continue; /* skip other TLVs */
390 mpoa_device_type
= *tlvs
++;
391 number_of_mps_macs
= *tlvs
++;
392 dprintk("mpoa: (%s) MPOA device type '%s', ", dev
->name
, mpoa_device_type_string(mpoa_device_type
));
393 if (mpoa_device_type
== MPS_AND_MPC
&&
394 length
< (42 + number_of_mps_macs
*ETH_ALEN
)) { /* :) */
395 printk("\nmpoa: (%s) lane2_assoc_ind: short MPOA Device Type TLV\n",
399 if ((mpoa_device_type
== MPS
|| mpoa_device_type
== MPC
)
400 && length
< 22 + number_of_mps_macs
*ETH_ALEN
) {
401 printk("\nmpoa: (%s) lane2_assoc_ind: short MPOA Device Type TLV\n",
405 if (mpoa_device_type
!= MPS
&& mpoa_device_type
!= MPS_AND_MPC
) {
406 dprintk("ignoring non-MPS device\n");
407 if (mpoa_device_type
== MPC
) tlvs
+= 20;
408 continue; /* we are only interested in MPSs */
410 if (number_of_mps_macs
== 0 && mpoa_device_type
== MPS_AND_MPC
) {
411 printk("\nmpoa: (%s) lane2_assoc_ind: MPS_AND_MPC has zero MACs\n", dev
->name
);
412 continue; /* someone should read the spec */
414 dprintk("this MPS has %d MAC addresses\n", number_of_mps_macs
);
416 /* ok, now we can go and tell our daemon the control address of MPS */
417 send_set_mps_ctrl_addr(tlvs
, mpc
);
419 tlvs
= copy_macs(mpc
, mac_addr
, tlvs
, number_of_mps_macs
, mpoa_device_type
);
420 if (tlvs
== NULL
) return;
422 if (end_of_tlvs
- tlvs
!= 0)
423 printk("mpoa: (%s) lane2_assoc_ind: ignoring %Zd bytes of trailing TLV carbage\n",
424 dev
->name
, end_of_tlvs
- tlvs
);
429 * Store at least advertizing router's MAC address
430 * plus the possible MAC address(es) to mpc->mps_macs.
431 * For a freshly allocated MPOA client mpc->mps_macs == 0.
433 static uint8_t *copy_macs(struct mpoa_client
*mpc
, uint8_t *router_mac
,
434 uint8_t *tlvs
, uint8_t mps_macs
, uint8_t device_type
)
437 num_macs
= (mps_macs
> 1) ? mps_macs
: 1;
439 if (mpc
->number_of_mps_macs
!= num_macs
) { /* need to reallocate? */
440 if (mpc
->number_of_mps_macs
!= 0) kfree(mpc
->mps_macs
);
441 mpc
->number_of_mps_macs
= 0;
442 mpc
->mps_macs
= kmalloc(num_macs
*ETH_ALEN
, GFP_KERNEL
);
443 if (mpc
->mps_macs
== NULL
) {
444 printk("mpoa: (%s) copy_macs: out of mem\n", mpc
->dev
->name
);
448 memcpy(mpc
->mps_macs
, router_mac
, ETH_ALEN
);
449 tlvs
+= 20; if (device_type
== MPS_AND_MPC
) tlvs
+= 20;
451 memcpy(mpc
->mps_macs
, tlvs
, mps_macs
*ETH_ALEN
);
452 tlvs
+= mps_macs
*ETH_ALEN
;
453 mpc
->number_of_mps_macs
= num_macs
;
458 static int send_via_shortcut(struct sk_buff
*skb
, struct mpoa_client
*mpc
)
460 in_cache_entry
*entry
;
466 struct llc_snap_hdr hdr
;
468 } tagged_llc_snap_hdr
= {
469 {0xaa, 0xaa, 0x03, {0x00, 0x00, 0x00}, {0x88, 0x4c}},
473 buff
= skb
->data
+ mpc
->dev
->hard_header_len
;
474 iph
= (struct iphdr
*)buff
;
477 ddprintk("mpoa: (%s) send_via_shortcut: ipaddr 0x%x\n", mpc
->dev
->name
, ipaddr
);
479 entry
= mpc
->in_ops
->get(ipaddr
, mpc
);
481 entry
= mpc
->in_ops
->add_entry(ipaddr
, mpc
);
482 if (entry
!= NULL
) mpc
->in_ops
->put(entry
);
485 if (mpc
->in_ops
->cache_hit(entry
, mpc
) != OPEN
){ /* threshold not exceeded or VCC not ready */
486 ddprintk("mpoa: (%s) send_via_shortcut: cache_hit: returns != OPEN\n", mpc
->dev
->name
);
487 mpc
->in_ops
->put(entry
);
491 ddprintk("mpoa: (%s) send_via_shortcut: using shortcut\n", mpc
->dev
->name
);
492 /* MPOA spec A.1.4, MPOA client must decrement IP ttl at least by one */
494 ddprintk("mpoa: (%s) send_via_shortcut: IP ttl = %u, using LANE\n", mpc
->dev
->name
, iph
->ttl
);
495 mpc
->in_ops
->put(entry
);
500 iph
->check
= ip_fast_csum((unsigned char *)iph
, iph
->ihl
);
502 if (entry
->ctrl_info
.tag
!= 0) {
503 ddprintk("mpoa: (%s) send_via_shortcut: adding tag 0x%x\n", mpc
->dev
->name
, entry
->ctrl_info
.tag
);
504 tagged_llc_snap_hdr
.tag
= entry
->ctrl_info
.tag
;
505 skb_pull(skb
, ETH_HLEN
); /* get rid of Eth header */
506 skb_push(skb
, sizeof(tagged_llc_snap_hdr
)); /* add LLC/SNAP header */
507 skb_copy_to_linear_data(skb
, &tagged_llc_snap_hdr
,
508 sizeof(tagged_llc_snap_hdr
));
510 skb_pull(skb
, ETH_HLEN
); /* get rid of Eth header */
511 skb_push(skb
, sizeof(struct llc_snap_hdr
)); /* add LLC/SNAP header + tag */
512 skb_copy_to_linear_data(skb
, &llc_snap_mpoa_data
,
513 sizeof(struct llc_snap_hdr
));
516 atomic_add(skb
->truesize
, &sk_atm(entry
->shortcut
)->sk_wmem_alloc
);
517 ATM_SKB(skb
)->atm_options
= entry
->shortcut
->atm_options
;
518 entry
->shortcut
->send(entry
->shortcut
, skb
);
519 entry
->packets_fwded
++;
520 mpc
->in_ops
->put(entry
);
526 * Probably needs some error checks and locking, not sure...
528 static int mpc_send_packet(struct sk_buff
*skb
, struct net_device
*dev
)
531 struct mpoa_client
*mpc
;
535 mpc
= find_mpc_by_lec(dev
); /* this should NEVER fail */
537 printk("mpoa: (%s) mpc_send_packet: no MPC found\n", dev
->name
);
541 eth
= (struct ethhdr
*)skb
->data
;
542 if (eth
->h_proto
!= htons(ETH_P_IP
))
543 goto non_ip
; /* Multi-Protocol Over ATM :-) */
545 /* Weed out funny packets (e.g., AF_PACKET or raw). */
546 if (skb
->len
< ETH_HLEN
+ sizeof(struct iphdr
))
548 skb_set_network_header(skb
, ETH_HLEN
);
549 if (skb
->len
< ETH_HLEN
+ ip_hdr(skb
)->ihl
* 4 || ip_hdr(skb
)->ihl
< 5)
552 while (i
< mpc
->number_of_mps_macs
) {
553 if (!compare_ether_addr(eth
->h_dest
, (mpc
->mps_macs
+ i
*ETH_ALEN
)))
554 if ( send_via_shortcut(skb
, mpc
) == 0 ) /* try shortcut */
555 return 0; /* success! */
560 retval
= mpc
->old_hard_start_xmit(skb
,dev
);
565 static int atm_mpoa_vcc_attach(struct atm_vcc
*vcc
, void __user
*arg
)
568 struct mpoa_client
*mpc
;
569 struct atmmpc_ioc ioc_data
;
570 in_cache_entry
*in_entry
;
573 bytes_left
= copy_from_user(&ioc_data
, arg
, sizeof(struct atmmpc_ioc
));
574 if (bytes_left
!= 0) {
575 printk("mpoa: mpc_vcc_attach: Short read (missed %d bytes) from userland\n", bytes_left
);
578 ipaddr
= ioc_data
.ipaddr
;
579 if (ioc_data
.dev_num
< 0 || ioc_data
.dev_num
>= MAX_LEC_ITF
)
582 mpc
= find_mpc_by_itfnum(ioc_data
.dev_num
);
586 if (ioc_data
.type
== MPC_SOCKET_INGRESS
) {
587 in_entry
= mpc
->in_ops
->get(ipaddr
, mpc
);
588 if (in_entry
== NULL
|| in_entry
->entry_state
< INGRESS_RESOLVED
) {
589 printk("mpoa: (%s) mpc_vcc_attach: did not find RESOLVED entry from ingress cache\n",
591 if (in_entry
!= NULL
) mpc
->in_ops
->put(in_entry
);
594 printk("mpoa: (%s) mpc_vcc_attach: attaching ingress SVC, entry = %u.%u.%u.%u\n",
595 mpc
->dev
->name
, NIPQUAD(in_entry
->ctrl_info
.in_dst_ip
));
596 in_entry
->shortcut
= vcc
;
597 mpc
->in_ops
->put(in_entry
);
599 printk("mpoa: (%s) mpc_vcc_attach: attaching egress SVC\n", mpc
->dev
->name
);
602 vcc
->proto_data
= mpc
->dev
;
603 vcc
->push
= mpc_push
;
611 static void mpc_vcc_close(struct atm_vcc
*vcc
, struct net_device
*dev
)
613 struct mpoa_client
*mpc
;
614 in_cache_entry
*in_entry
;
615 eg_cache_entry
*eg_entry
;
617 mpc
= find_mpc_by_lec(dev
);
619 printk("mpoa: (%s) mpc_vcc_close: close for unknown MPC\n", dev
->name
);
623 dprintk("mpoa: (%s) mpc_vcc_close:\n", dev
->name
);
624 in_entry
= mpc
->in_ops
->get_by_vcc(vcc
, mpc
);
626 dprintk("mpoa: (%s) mpc_vcc_close: ingress SVC closed ip = %u.%u.%u.%u\n",
627 mpc
->dev
->name
, NIPQUAD(in_entry
->ctrl_info
.in_dst_ip
));
628 in_entry
->shortcut
= NULL
;
629 mpc
->in_ops
->put(in_entry
);
631 eg_entry
= mpc
->eg_ops
->get_by_vcc(vcc
, mpc
);
633 dprintk("mpoa: (%s) mpc_vcc_close: egress SVC closed\n", mpc
->dev
->name
);
634 eg_entry
->shortcut
= NULL
;
635 mpc
->eg_ops
->put(eg_entry
);
638 if (in_entry
== NULL
&& eg_entry
== NULL
)
639 dprintk("mpoa: (%s) mpc_vcc_close: unused vcc closed\n", dev
->name
);
644 static void mpc_push(struct atm_vcc
*vcc
, struct sk_buff
*skb
)
646 struct net_device
*dev
= (struct net_device
*)vcc
->proto_data
;
647 struct sk_buff
*new_skb
;
649 struct mpoa_client
*mpc
;
653 ddprintk("mpoa: (%s) mpc_push:\n", dev
->name
);
655 dprintk("mpoa: (%s) mpc_push: null skb, closing VCC\n", dev
->name
);
656 mpc_vcc_close(vcc
, dev
);
661 if (memcmp(skb
->data
, &llc_snap_mpoa_ctrl
, sizeof(struct llc_snap_hdr
)) == 0) {
662 struct sock
*sk
= sk_atm(vcc
);
664 dprintk("mpoa: (%s) mpc_push: control packet arrived\n", dev
->name
);
665 /* Pass control packets to daemon */
666 skb_queue_tail(&sk
->sk_receive_queue
, skb
);
667 sk
->sk_data_ready(sk
, skb
->len
);
671 /* data coming over the shortcut */
672 atm_return(vcc
, skb
->truesize
);
674 mpc
= find_mpc_by_lec(dev
);
676 printk("mpoa: (%s) mpc_push: unknown MPC\n", dev
->name
);
680 if (memcmp(skb
->data
, &llc_snap_mpoa_data_tagged
, sizeof(struct llc_snap_hdr
)) == 0) { /* MPOA tagged data */
681 ddprintk("mpoa: (%s) mpc_push: tagged data packet arrived\n", dev
->name
);
683 } else if (memcmp(skb
->data
, &llc_snap_mpoa_data
, sizeof(struct llc_snap_hdr
)) == 0) { /* MPOA data */
684 printk("mpoa: (%s) mpc_push: non-tagged data packet arrived\n", dev
->name
);
685 printk(" mpc_push: non-tagged data unsupported, purging\n");
686 dev_kfree_skb_any(skb
);
689 printk("mpoa: (%s) mpc_push: garbage arrived, purging\n", dev
->name
);
690 dev_kfree_skb_any(skb
);
694 tmp
= skb
->data
+ sizeof(struct llc_snap_hdr
);
695 tag
= *(__be32
*)tmp
;
697 eg
= mpc
->eg_ops
->get_by_tag(tag
, mpc
);
699 printk("mpoa: (%s) mpc_push: Didn't find egress cache entry, tag = %u\n",
701 purge_egress_shortcut(vcc
, NULL
);
702 dev_kfree_skb_any(skb
);
707 * See if ingress MPC is using shortcut we opened as a return channel.
708 * This means we have a bi-directional vcc opened by us.
710 if (eg
->shortcut
== NULL
) {
712 printk("mpoa: (%s) mpc_push: egress SVC in use\n", dev
->name
);
715 skb_pull(skb
, sizeof(struct llc_snap_hdr
) + sizeof(tag
)); /* get rid of LLC/SNAP header */
716 new_skb
= skb_realloc_headroom(skb
, eg
->ctrl_info
.DH_length
); /* LLC/SNAP is shorter than MAC header :( */
717 dev_kfree_skb_any(skb
);
718 if (new_skb
== NULL
){
719 mpc
->eg_ops
->put(eg
);
722 skb_push(new_skb
, eg
->ctrl_info
.DH_length
); /* add MAC header */
723 skb_copy_to_linear_data(new_skb
, eg
->ctrl_info
.DLL_header
,
724 eg
->ctrl_info
.DH_length
);
725 new_skb
->protocol
= eth_type_trans(new_skb
, dev
);
726 skb_reset_network_header(new_skb
);
728 eg
->latest_ip_addr
= ip_hdr(new_skb
)->saddr
;
730 mpc
->eg_ops
->put(eg
);
732 memset(ATM_SKB(skb
), 0, sizeof(struct atm_skb_data
));
738 static struct atmdev_ops mpc_ops
= { /* only send is required */
739 .close
= mpoad_close
,
740 .send
= msg_from_mpoad
743 static struct atm_dev mpc_dev
= {
747 .lock
= __SPIN_LOCK_UNLOCKED(mpc_dev
.lock
)
748 /* members not explicitly initialised will be 0 */
751 static int atm_mpoa_mpoad_attach (struct atm_vcc
*vcc
, int arg
)
753 struct mpoa_client
*mpc
;
754 struct lec_priv
*priv
;
758 init_timer(&mpc_timer
);
761 /* This lets us now how our LECs are doing */
762 err
= register_netdevice_notifier(&mpoa_notifier
);
764 del_timer(&mpc_timer
);
769 mpc
= find_mpc_by_itfnum(arg
);
771 dprintk("mpoa: mpoad_attach: allocating new mpc for itf %d\n", arg
);
776 mpc
->dev
= find_lec_by_itfnum(arg
); /* NULL if there was no lec */
778 if (mpc
->mpoad_vcc
) {
779 printk("mpoa: mpoad_attach: mpoad is already present for itf %d\n", arg
);
783 if (mpc
->dev
) { /* check if the lec is LANE2 capable */
784 priv
= (struct lec_priv
*)mpc
->dev
->priv
;
785 if (priv
->lane_version
< 2) {
789 priv
->lane2_ops
->associate_indicator
= lane2_assoc_ind
;
792 mpc
->mpoad_vcc
= vcc
;
794 vcc_insert_socket(sk_atm(vcc
));
795 set_bit(ATM_VF_META
,&vcc
->flags
);
796 set_bit(ATM_VF_READY
,&vcc
->flags
);
799 char empty
[ATM_ESA_LEN
];
800 memset(empty
, 0, ATM_ESA_LEN
);
802 start_mpc(mpc
, mpc
->dev
);
803 /* set address if mpcd e.g. gets killed and restarted.
804 * If we do not do it now we have to wait for the next LE_ARP
806 if ( memcmp(mpc
->mps_ctrl_addr
, empty
, ATM_ESA_LEN
) != 0 )
807 send_set_mps_ctrl_addr(mpc
->mps_ctrl_addr
, mpc
);
810 __module_get(THIS_MODULE
);
814 static void send_set_mps_ctrl_addr(char *addr
, struct mpoa_client
*mpc
)
816 struct k_message mesg
;
818 memcpy (mpc
->mps_ctrl_addr
, addr
, ATM_ESA_LEN
);
820 mesg
.type
= SET_MPS_CTRL_ADDR
;
821 memcpy(mesg
.MPS_ctrl
, addr
, ATM_ESA_LEN
);
822 msg_to_mpoad(&mesg
, mpc
);
827 static void mpoad_close(struct atm_vcc
*vcc
)
829 struct mpoa_client
*mpc
;
832 mpc
= find_mpc_by_vcc(vcc
);
834 printk("mpoa: mpoad_close: did not find MPC\n");
837 if (!mpc
->mpoad_vcc
) {
838 printk("mpoa: mpoad_close: close for non-present mpoad\n");
842 mpc
->mpoad_vcc
= NULL
;
844 struct lec_priv
*priv
= (struct lec_priv
*)mpc
->dev
->priv
;
845 priv
->lane2_ops
->associate_indicator
= NULL
;
850 mpc
->in_ops
->destroy_cache(mpc
);
851 mpc
->eg_ops
->destroy_cache(mpc
);
853 while ((skb
= skb_dequeue(&sk_atm(vcc
)->sk_receive_queue
))) {
854 atm_return(vcc
, skb
->truesize
);
858 printk("mpoa: (%s) going down\n",
859 (mpc
->dev
) ? mpc
->dev
->name
: "<unknown>");
860 module_put(THIS_MODULE
);
868 static int msg_from_mpoad(struct atm_vcc
*vcc
, struct sk_buff
*skb
)
871 struct mpoa_client
*mpc
= find_mpc_by_vcc(vcc
);
872 struct k_message
*mesg
= (struct k_message
*)skb
->data
;
873 atomic_sub(skb
->truesize
, &sk_atm(vcc
)->sk_wmem_alloc
);
876 printk("mpoa: msg_from_mpoad: no mpc found\n");
879 dprintk("mpoa: (%s) msg_from_mpoad:", (mpc
->dev
) ? mpc
->dev
->name
: "<unknown>");
881 case MPOA_RES_REPLY_RCVD
:
882 dprintk(" mpoa_res_reply_rcvd\n");
883 MPOA_res_reply_rcvd(mesg
, mpc
);
885 case MPOA_TRIGGER_RCVD
:
886 dprintk(" mpoa_trigger_rcvd\n");
887 MPOA_trigger_rcvd(mesg
, mpc
);
889 case INGRESS_PURGE_RCVD
:
890 dprintk(" nhrp_purge_rcvd\n");
891 ingress_purge_rcvd(mesg
, mpc
);
893 case EGRESS_PURGE_RCVD
:
894 dprintk(" egress_purge_reply_rcvd\n");
895 egress_purge_rcvd(mesg
, mpc
);
898 dprintk(" mps_death\n");
899 mps_death(mesg
, mpc
);
901 case CACHE_IMPOS_RCVD
:
902 dprintk(" cache_impos_rcvd\n");
903 MPOA_cache_impos_rcvd(mesg
, mpc
);
905 case SET_MPC_CTRL_ADDR
:
906 dprintk(" set_mpc_ctrl_addr\n");
907 set_mpc_ctrl_addr_rcvd(mesg
, mpc
);
909 case SET_MPS_MAC_ADDR
:
910 dprintk(" set_mps_mac_addr\n");
911 set_mps_mac_addr_rcvd(mesg
, mpc
);
913 case CLEAN_UP_AND_EXIT
:
914 dprintk(" clean_up_and_exit\n");
915 clean_up(mesg
, mpc
, DIE
);
918 dprintk(" reload\n");
919 clean_up(mesg
, mpc
, RELOAD
);
922 dprintk(" set_mpc_params\n");
923 mpc
->parameters
= mesg
->content
.params
;
926 dprintk(" unknown message %d\n", mesg
->type
);
934 /* Remember that this function may not do things that sleep */
935 int msg_to_mpoad(struct k_message
*mesg
, struct mpoa_client
*mpc
)
940 if (mpc
== NULL
|| !mpc
->mpoad_vcc
) {
941 printk("mpoa: msg_to_mpoad: mesg %d to a non-existent mpoad\n", mesg
->type
);
945 skb
= alloc_skb(sizeof(struct k_message
), GFP_ATOMIC
);
948 skb_put(skb
, sizeof(struct k_message
));
949 skb_copy_to_linear_data(skb
, mesg
, sizeof(*mesg
));
950 atm_force_charge(mpc
->mpoad_vcc
, skb
->truesize
);
952 sk
= sk_atm(mpc
->mpoad_vcc
);
953 skb_queue_tail(&sk
->sk_receive_queue
, skb
);
954 sk
->sk_data_ready(sk
, skb
->len
);
959 static int mpoa_event_listener(struct notifier_block
*mpoa_notifier
, unsigned long event
, void *dev_ptr
)
961 struct net_device
*dev
;
962 struct mpoa_client
*mpc
;
963 struct lec_priv
*priv
;
965 dev
= (struct net_device
*)dev_ptr
;
966 if (dev
->name
== NULL
|| strncmp(dev
->name
, "lec", 3))
967 return NOTIFY_DONE
; /* we are only interested in lec:s */
970 case NETDEV_REGISTER
: /* a new lec device was allocated */
971 priv
= (struct lec_priv
*)dev
->priv
;
972 if (priv
->lane_version
< 2)
974 priv
->lane2_ops
->associate_indicator
= lane2_assoc_ind
;
975 mpc
= find_mpc_by_itfnum(priv
->itfnum
);
977 dprintk("mpoa: mpoa_event_listener: allocating new mpc for %s\n",
981 printk("mpoa: mpoa_event_listener: no new mpc");
985 mpc
->dev_num
= priv
->itfnum
;
988 dprintk("mpoa: (%s) was initialized\n", dev
->name
);
990 case NETDEV_UNREGISTER
:
991 /* the lec device was deallocated */
992 mpc
= find_mpc_by_lec(dev
);
995 dprintk("mpoa: device (%s) was deallocated\n", dev
->name
);
1001 /* the dev was ifconfig'ed up */
1002 mpc
= find_mpc_by_lec(dev
);
1005 if (mpc
->mpoad_vcc
!= NULL
) {
1006 start_mpc(mpc
, dev
);
1010 /* the dev was ifconfig'ed down */
1011 /* this means that the flow of packets from the
1014 mpc
= find_mpc_by_lec(dev
);
1017 if (mpc
->mpoad_vcc
!= NULL
) {
1023 case NETDEV_CHANGEMTU
:
1024 case NETDEV_CHANGEADDR
:
1025 case NETDEV_GOING_DOWN
:
1035 * Functions which are called after a message is received from mpcd.
1036 * Msg is reused on purpose.
1040 static void MPOA_trigger_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
)
1042 __be32 dst_ip
= msg
->content
.in_info
.in_dst_ip
;
1043 in_cache_entry
*entry
;
1045 entry
= mpc
->in_ops
->get(dst_ip
, mpc
);
1047 entry
= mpc
->in_ops
->add_entry(dst_ip
, mpc
);
1048 entry
->entry_state
= INGRESS_RESOLVING
;
1049 msg
->type
= SND_MPOA_RES_RQST
;
1050 msg
->content
.in_info
= entry
->ctrl_info
;
1051 msg_to_mpoad(msg
, mpc
);
1052 do_gettimeofday(&(entry
->reply_wait
));
1053 mpc
->in_ops
->put(entry
);
1057 if(entry
->entry_state
== INGRESS_INVALID
){
1058 entry
->entry_state
= INGRESS_RESOLVING
;
1059 msg
->type
= SND_MPOA_RES_RQST
;
1060 msg
->content
.in_info
= entry
->ctrl_info
;
1061 msg_to_mpoad(msg
, mpc
);
1062 do_gettimeofday(&(entry
->reply_wait
));
1063 mpc
->in_ops
->put(entry
);
1067 printk("mpoa: (%s) MPOA_trigger_rcvd: entry already in resolving state\n",
1068 (mpc
->dev
) ? mpc
->dev
->name
: "<unknown>");
1069 mpc
->in_ops
->put(entry
);
1074 * Things get complicated because we have to check if there's an egress
1075 * shortcut with suitable traffic parameters we could use.
1077 static void check_qos_and_open_shortcut(struct k_message
*msg
, struct mpoa_client
*client
, in_cache_entry
*entry
)
1079 __be32 dst_ip
= msg
->content
.in_info
.in_dst_ip
;
1080 struct atm_mpoa_qos
*qos
= atm_mpoa_search_qos(dst_ip
);
1081 eg_cache_entry
*eg_entry
= client
->eg_ops
->get_by_src_ip(dst_ip
, client
);
1083 if(eg_entry
&& eg_entry
->shortcut
){
1084 if(eg_entry
->shortcut
->qos
.txtp
.traffic_class
&
1085 msg
->qos
.txtp
.traffic_class
&
1086 (qos
? qos
->qos
.txtp
.traffic_class
: ATM_UBR
| ATM_CBR
)){
1087 if(eg_entry
->shortcut
->qos
.txtp
.traffic_class
== ATM_UBR
)
1088 entry
->shortcut
= eg_entry
->shortcut
;
1089 else if(eg_entry
->shortcut
->qos
.txtp
.max_pcr
> 0)
1090 entry
->shortcut
= eg_entry
->shortcut
;
1092 if(entry
->shortcut
){
1093 dprintk("mpoa: (%s) using egress SVC to reach %u.%u.%u.%u\n",client
->dev
->name
, NIPQUAD(dst_ip
));
1094 client
->eg_ops
->put(eg_entry
);
1098 if (eg_entry
!= NULL
)
1099 client
->eg_ops
->put(eg_entry
);
1101 /* No luck in the egress cache we must open an ingress SVC */
1102 msg
->type
= OPEN_INGRESS_SVC
;
1103 if (qos
&& (qos
->qos
.txtp
.traffic_class
== msg
->qos
.txtp
.traffic_class
))
1105 msg
->qos
= qos
->qos
;
1106 printk("mpoa: (%s) trying to get a CBR shortcut\n",client
->dev
->name
);
1108 else memset(&msg
->qos
,0,sizeof(struct atm_qos
));
1109 msg_to_mpoad(msg
, client
);
1113 static void MPOA_res_reply_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
)
1115 __be32 dst_ip
= msg
->content
.in_info
.in_dst_ip
;
1116 in_cache_entry
*entry
= mpc
->in_ops
->get(dst_ip
, mpc
);
1118 dprintk("mpoa: (%s) MPOA_res_reply_rcvd: ip %u.%u.%u.%u\n", mpc
->dev
->name
, NIPQUAD(dst_ip
));
1119 ddprintk("mpoa: (%s) MPOA_res_reply_rcvd() entry = %p", mpc
->dev
->name
, entry
);
1121 printk("\nmpoa: (%s) ARGH, received res. reply for an entry that doesn't exist.\n", mpc
->dev
->name
);
1124 ddprintk(" entry_state = %d ", entry
->entry_state
);
1126 if (entry
->entry_state
== INGRESS_RESOLVED
) {
1127 printk("\nmpoa: (%s) MPOA_res_reply_rcvd for RESOLVED entry!\n", mpc
->dev
->name
);
1128 mpc
->in_ops
->put(entry
);
1132 entry
->ctrl_info
= msg
->content
.in_info
;
1133 do_gettimeofday(&(entry
->tv
));
1134 do_gettimeofday(&(entry
->reply_wait
)); /* Used in refreshing func from now on */
1135 entry
->refresh_time
= 0;
1136 ddprintk("entry->shortcut = %p\n", entry
->shortcut
);
1138 if(entry
->entry_state
== INGRESS_RESOLVING
&& entry
->shortcut
!= NULL
){
1139 entry
->entry_state
= INGRESS_RESOLVED
;
1140 mpc
->in_ops
->put(entry
);
1141 return; /* Shortcut already open... */
1144 if (entry
->shortcut
!= NULL
) {
1145 printk("mpoa: (%s) MPOA_res_reply_rcvd: entry->shortcut != NULL, impossible!\n",
1147 mpc
->in_ops
->put(entry
);
1151 check_qos_and_open_shortcut(msg
, mpc
, entry
);
1152 entry
->entry_state
= INGRESS_RESOLVED
;
1153 mpc
->in_ops
->put(entry
);
1159 static void ingress_purge_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
)
1161 __be32 dst_ip
= msg
->content
.in_info
.in_dst_ip
;
1162 __be32 mask
= msg
->ip_mask
;
1163 in_cache_entry
*entry
= mpc
->in_ops
->get_with_mask(dst_ip
, mpc
, mask
);
1166 printk("mpoa: (%s) ingress_purge_rcvd: purge for a non-existing entry, ", mpc
->dev
->name
);
1167 printk("ip = %u.%u.%u.%u\n", NIPQUAD(dst_ip
));
1172 dprintk("mpoa: (%s) ingress_purge_rcvd: removing an ingress entry, ip = %u.%u.%u.%u\n" ,
1173 mpc
->dev
->name
, NIPQUAD(dst_ip
));
1174 write_lock_bh(&mpc
->ingress_lock
);
1175 mpc
->in_ops
->remove_entry(entry
, mpc
);
1176 write_unlock_bh(&mpc
->ingress_lock
);
1177 mpc
->in_ops
->put(entry
);
1178 entry
= mpc
->in_ops
->get_with_mask(dst_ip
, mpc
, mask
);
1179 } while (entry
!= NULL
);
1184 static void egress_purge_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
)
1186 __be32 cache_id
= msg
->content
.eg_info
.cache_id
;
1187 eg_cache_entry
*entry
= mpc
->eg_ops
->get_by_cache_id(cache_id
, mpc
);
1189 if (entry
== NULL
) {
1190 dprintk("mpoa: (%s) egress_purge_rcvd: purge for a non-existing entry\n", mpc
->dev
->name
);
1194 write_lock_irq(&mpc
->egress_lock
);
1195 mpc
->eg_ops
->remove_entry(entry
, mpc
);
1196 write_unlock_irq(&mpc
->egress_lock
);
1198 mpc
->eg_ops
->put(entry
);
1203 static void purge_egress_shortcut(struct atm_vcc
*vcc
, eg_cache_entry
*entry
)
1206 struct k_message
*purge_msg
;
1207 struct sk_buff
*skb
;
1209 dprintk("mpoa: purge_egress_shortcut: entering\n");
1211 printk("mpoa: purge_egress_shortcut: vcc == NULL\n");
1215 skb
= alloc_skb(sizeof(struct k_message
), GFP_ATOMIC
);
1217 printk("mpoa: purge_egress_shortcut: out of memory\n");
1221 skb_put(skb
, sizeof(struct k_message
));
1222 memset(skb
->data
, 0, sizeof(struct k_message
));
1223 purge_msg
= (struct k_message
*)skb
->data
;
1224 purge_msg
->type
= DATA_PLANE_PURGE
;
1226 purge_msg
->content
.eg_info
= entry
->ctrl_info
;
1228 atm_force_charge(vcc
, skb
->truesize
);
1231 skb_queue_tail(&sk
->sk_receive_queue
, skb
);
1232 sk
->sk_data_ready(sk
, skb
->len
);
1233 dprintk("mpoa: purge_egress_shortcut: exiting:\n");
1239 * Our MPS died. Tell our daemon to send NHRP data plane purge to each
1240 * of the egress shortcuts we have.
1242 static void mps_death( struct k_message
* msg
, struct mpoa_client
* mpc
)
1244 eg_cache_entry
*entry
;
1246 dprintk("mpoa: (%s) mps_death:\n", mpc
->dev
->name
);
1248 if(memcmp(msg
->MPS_ctrl
, mpc
->mps_ctrl_addr
, ATM_ESA_LEN
)){
1249 printk("mpoa: (%s) mps_death: wrong MPS\n", mpc
->dev
->name
);
1253 /* FIXME: This knows too much of the cache structure */
1254 read_lock_irq(&mpc
->egress_lock
);
1255 entry
= mpc
->eg_cache
;
1256 while (entry
!= NULL
) {
1257 purge_egress_shortcut(entry
->shortcut
, entry
);
1258 entry
= entry
->next
;
1260 read_unlock_irq(&mpc
->egress_lock
);
1262 mpc
->in_ops
->destroy_cache(mpc
);
1263 mpc
->eg_ops
->destroy_cache(mpc
);
1268 static void MPOA_cache_impos_rcvd( struct k_message
* msg
, struct mpoa_client
* mpc
)
1270 uint16_t holding_time
;
1271 eg_cache_entry
*entry
= mpc
->eg_ops
->get_by_cache_id(msg
->content
.eg_info
.cache_id
, mpc
);
1273 holding_time
= msg
->content
.eg_info
.holding_time
;
1274 dprintk("mpoa: (%s) MPOA_cache_impos_rcvd: entry = %p, holding_time = %u\n",
1275 mpc
->dev
->name
, entry
, holding_time
);
1276 if(entry
== NULL
&& holding_time
) {
1277 entry
= mpc
->eg_ops
->add_entry(msg
, mpc
);
1278 mpc
->eg_ops
->put(entry
);
1282 mpc
->eg_ops
->update(entry
, holding_time
);
1286 write_lock_irq(&mpc
->egress_lock
);
1287 mpc
->eg_ops
->remove_entry(entry
, mpc
);
1288 write_unlock_irq(&mpc
->egress_lock
);
1290 mpc
->eg_ops
->put(entry
);
1295 static void set_mpc_ctrl_addr_rcvd(struct k_message
*mesg
, struct mpoa_client
*mpc
)
1297 struct lec_priv
*priv
;
1300 uint8_t tlv
[4 + 1 + 1 + 1 + ATM_ESA_LEN
];
1302 tlv
[0] = 00; tlv
[1] = 0xa0; tlv
[2] = 0x3e; tlv
[3] = 0x2a; /* type */
1303 tlv
[4] = 1 + 1 + ATM_ESA_LEN
; /* length */
1304 tlv
[5] = 0x02; /* MPOA client */
1305 tlv
[6] = 0x00; /* number of MPS MAC addresses */
1307 memcpy(&tlv
[7], mesg
->MPS_ctrl
, ATM_ESA_LEN
); /* MPC ctrl ATM addr */
1308 memcpy(mpc
->our_ctrl_addr
, mesg
->MPS_ctrl
, ATM_ESA_LEN
);
1310 dprintk("mpoa: (%s) setting MPC ctrl ATM address to ",
1311 (mpc
->dev
) ? mpc
->dev
->name
: "<unknown>");
1312 for (i
= 7; i
< sizeof(tlv
); i
++)
1313 dprintk("%02x ", tlv
[i
]);
1317 priv
= (struct lec_priv
*)mpc
->dev
->priv
;
1318 retval
= priv
->lane2_ops
->associate_req(mpc
->dev
, mpc
->dev
->dev_addr
, tlv
, sizeof(tlv
));
1320 printk("mpoa: (%s) MPOA device type TLV association failed\n", mpc
->dev
->name
);
1321 retval
= priv
->lane2_ops
->resolve(mpc
->dev
, NULL
, 1, NULL
, NULL
);
1323 printk("mpoa: (%s) targetless LE_ARP request failed\n", mpc
->dev
->name
);
1329 static void set_mps_mac_addr_rcvd(struct k_message
*msg
, struct mpoa_client
*client
)
1332 if(client
->number_of_mps_macs
)
1333 kfree(client
->mps_macs
);
1334 client
->number_of_mps_macs
= 0;
1335 client
->mps_macs
= kmemdup(msg
->MPS_ctrl
, ETH_ALEN
, GFP_KERNEL
);
1336 if (client
->mps_macs
== NULL
) {
1337 printk("mpoa: set_mps_mac_addr_rcvd: out of memory\n");
1340 client
->number_of_mps_macs
= 1;
1346 * purge egress cache and tell daemon to 'action' (DIE, RELOAD)
1348 static void clean_up(struct k_message
*msg
, struct mpoa_client
*mpc
, int action
)
1351 eg_cache_entry
*entry
;
1352 msg
->type
= SND_EGRESS_PURGE
;
1355 /* FIXME: This knows too much of the cache structure */
1356 read_lock_irq(&mpc
->egress_lock
);
1357 entry
= mpc
->eg_cache
;
1358 while (entry
!= NULL
){
1359 msg
->content
.eg_info
= entry
->ctrl_info
;
1360 dprintk("mpoa: cache_id %u\n", entry
->ctrl_info
.cache_id
);
1361 msg_to_mpoad(msg
, mpc
);
1362 entry
= entry
->next
;
1364 read_unlock_irq(&mpc
->egress_lock
);
1367 msg_to_mpoad(msg
, mpc
);
1371 static void mpc_timer_refresh(void)
1373 mpc_timer
.expires
= jiffies
+ (MPC_P2
* HZ
);
1374 mpc_timer
.data
= mpc_timer
.expires
;
1375 mpc_timer
.function
= mpc_cache_check
;
1376 add_timer(&mpc_timer
);
1381 static void mpc_cache_check( unsigned long checking_time
)
1383 struct mpoa_client
*mpc
= mpcs
;
1384 static unsigned long previous_resolving_check_time
;
1385 static unsigned long previous_refresh_time
;
1387 while( mpc
!= NULL
){
1388 mpc
->in_ops
->clear_count(mpc
);
1389 mpc
->eg_ops
->clear_expired(mpc
);
1390 if(checking_time
- previous_resolving_check_time
> mpc
->parameters
.mpc_p4
* HZ
){
1391 mpc
->in_ops
->check_resolving(mpc
);
1392 previous_resolving_check_time
= checking_time
;
1394 if(checking_time
- previous_refresh_time
> mpc
->parameters
.mpc_p5
* HZ
){
1395 mpc
->in_ops
->refresh(mpc
);
1396 previous_refresh_time
= checking_time
;
1400 mpc_timer_refresh();
1405 static int atm_mpoa_ioctl(struct socket
*sock
, unsigned int cmd
, unsigned long arg
)
1408 struct atm_vcc
*vcc
= ATM_SD(sock
);
1410 if (cmd
!= ATMMPC_CTRL
&& cmd
!= ATMMPC_DATA
)
1411 return -ENOIOCTLCMD
;
1413 if (!capable(CAP_NET_ADMIN
))
1418 err
= atm_mpoa_mpoad_attach(vcc
, (int)arg
);
1420 sock
->state
= SS_CONNECTED
;
1423 err
= atm_mpoa_vcc_attach(vcc
, (void __user
*)arg
);
1432 static struct atm_ioctl atm_ioctl_ops
= {
1433 .owner
= THIS_MODULE
,
1434 .ioctl
= atm_mpoa_ioctl
,
1437 static __init
int atm_mpoa_init(void)
1439 register_atm_ioctl(&atm_ioctl_ops
);
1441 if (mpc_proc_init() != 0)
1442 printk(KERN_INFO
"mpoa: failed to initialize /proc/mpoa\n");
1444 printk("mpc.c: " __DATE__
" " __TIME__
" initialized\n");
1449 static void __exit
atm_mpoa_cleanup(void)
1451 struct mpoa_client
*mpc
, *tmp
;
1452 struct atm_mpoa_qos
*qos
, *nextqos
;
1453 struct lec_priv
*priv
;
1457 del_timer(&mpc_timer
);
1458 unregister_netdevice_notifier(&mpoa_notifier
);
1459 deregister_atm_ioctl(&atm_ioctl_ops
);
1463 while (mpc
!= NULL
) {
1465 if (mpc
->dev
!= NULL
) {
1467 priv
= (struct lec_priv
*)mpc
->dev
->priv
;
1468 if (priv
->lane2_ops
!= NULL
)
1469 priv
->lane2_ops
->associate_indicator
= NULL
;
1471 ddprintk("mpoa: cleanup_module: about to clear caches\n");
1472 mpc
->in_ops
->destroy_cache(mpc
);
1473 mpc
->eg_ops
->destroy_cache(mpc
);
1474 ddprintk("mpoa: cleanup_module: caches cleared\n");
1475 kfree(mpc
->mps_macs
);
1476 memset(mpc
, 0, sizeof(struct mpoa_client
));
1477 ddprintk("mpoa: cleanup_module: about to kfree %p\n", mpc
);
1479 ddprintk("mpoa: cleanup_module: next mpc is at %p\n", tmp
);
1485 while (qos
!= NULL
) {
1486 nextqos
= qos
->next
;
1487 dprintk("mpoa: cleanup_module: freeing qos entry %p\n", qos
);
1495 module_init(atm_mpoa_init
);
1496 module_exit(atm_mpoa_cleanup
);
1498 MODULE_LICENSE("GPL");