1 #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
3 #include <linux/kernel.h>
4 #include <linux/string.h>
5 #include <linux/slab.h>
6 #include <linux/timer.h>
7 #include <linux/init.h>
8 #include <linux/bitops.h>
9 #include <linux/capability.h>
10 #include <linux/seq_file.h>
12 /* We are an ethernet device */
13 #include <linux/if_ether.h>
14 #include <linux/netdevice.h>
15 #include <linux/etherdevice.h>
17 #include <linux/skbuff.h>
19 #include <linux/uaccess.h>
20 #include <asm/byteorder.h>
21 #include <net/checksum.h> /* for ip_fast_csum() */
24 #include <linux/proc_fs.h>
27 #include <linux/atmdev.h>
28 #include <linux/atmlec.h>
29 #include <linux/atmmpc.h>
31 #include <linux/module.h>
35 #include "resources.h"
38 * mpc.c: Implementation of MPOA client kernel part
41 #define dprintk(format, args...) \
43 printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args);\
45 #define dprintk_cont(format, args...) \
46 do { if (0) printk(KERN_CONT format, ##args); } while (0)
48 #define ddprintk(format, args...) \
50 printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args);\
52 #define ddprintk_cont(format, args...) \
53 do { if (0) printk(KERN_CONT format, ##args); } while (0)
55 #define MPOA_TAG_LEN 4
57 /* mpc_daemon -> kernel */
58 static void MPOA_trigger_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
);
59 static void MPOA_res_reply_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
);
60 static void ingress_purge_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
);
61 static void egress_purge_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
);
62 static void mps_death(struct k_message
*msg
, struct mpoa_client
*mpc
);
63 static void clean_up(struct k_message
*msg
, struct mpoa_client
*mpc
,
65 static void MPOA_cache_impos_rcvd(struct k_message
*msg
,
66 struct mpoa_client
*mpc
);
67 static void set_mpc_ctrl_addr_rcvd(struct k_message
*mesg
,
68 struct mpoa_client
*mpc
);
69 static void set_mps_mac_addr_rcvd(struct k_message
*mesg
,
70 struct mpoa_client
*mpc
);
72 static const uint8_t *copy_macs(struct mpoa_client
*mpc
,
73 const uint8_t *router_mac
,
74 const uint8_t *tlvs
, uint8_t mps_macs
,
76 static void purge_egress_shortcut(struct atm_vcc
*vcc
, eg_cache_entry
*entry
);
78 static void send_set_mps_ctrl_addr(const char *addr
, struct mpoa_client
*mpc
);
79 static void mpoad_close(struct atm_vcc
*vcc
);
80 static int msg_from_mpoad(struct atm_vcc
*vcc
, struct sk_buff
*skb
);
82 static void mpc_push(struct atm_vcc
*vcc
, struct sk_buff
*skb
);
83 static netdev_tx_t
mpc_send_packet(struct sk_buff
*skb
,
84 struct net_device
*dev
);
85 static int mpoa_event_listener(struct notifier_block
*mpoa_notifier
,
86 unsigned long event
, void *dev
);
87 static void mpc_timer_refresh(void);
88 static void mpc_cache_check(unsigned long checking_time
);
90 static struct llc_snap_hdr llc_snap_mpoa_ctrl
= {
93 {0x00, 0x03} /* For MPOA control PDUs */
95 static struct llc_snap_hdr llc_snap_mpoa_data
= {
98 {0x08, 0x00} /* This is for IP PDUs only */
100 static struct llc_snap_hdr llc_snap_mpoa_data_tagged
= {
103 {0x88, 0x4c} /* This is for tagged data PDUs */
106 static struct notifier_block mpoa_notifier
= {
112 struct mpoa_client
*mpcs
= NULL
;
113 static struct atm_mpoa_qos
*qos_head
= NULL
;
114 static DEFINE_TIMER(mpc_timer
, NULL
, 0, 0);
117 static struct mpoa_client
*find_mpc_by_itfnum(int itf
)
119 struct mpoa_client
*mpc
;
121 mpc
= mpcs
; /* our global linked list */
122 while (mpc
!= NULL
) {
123 if (mpc
->dev_num
== itf
)
128 return NULL
; /* not found */
131 static struct mpoa_client
*find_mpc_by_vcc(struct atm_vcc
*vcc
)
133 struct mpoa_client
*mpc
;
135 mpc
= mpcs
; /* our global linked list */
136 while (mpc
!= NULL
) {
137 if (mpc
->mpoad_vcc
== vcc
)
142 return NULL
; /* not found */
145 static struct mpoa_client
*find_mpc_by_lec(struct net_device
*dev
)
147 struct mpoa_client
*mpc
;
149 mpc
= mpcs
; /* our global linked list */
150 while (mpc
!= NULL
) {
156 return NULL
; /* not found */
160 * Functions for managing QoS list
164 * Overwrites the old entry or makes a new one.
166 struct atm_mpoa_qos
*atm_mpoa_add_qos(__be32 dst_ip
, struct atm_qos
*qos
)
168 struct atm_mpoa_qos
*entry
;
170 entry
= atm_mpoa_search_qos(dst_ip
);
176 entry
= kmalloc(sizeof(struct atm_mpoa_qos
), GFP_KERNEL
);
178 pr_info("mpoa: out of memory\n");
182 entry
->ipaddr
= dst_ip
;
185 entry
->next
= qos_head
;
191 struct atm_mpoa_qos
*atm_mpoa_search_qos(__be32 dst_ip
)
193 struct atm_mpoa_qos
*qos
;
197 if (qos
->ipaddr
== dst_ip
)
206 * Returns 0 for failure
208 int atm_mpoa_delete_qos(struct atm_mpoa_qos
*entry
)
210 struct atm_mpoa_qos
*curr
;
214 if (entry
== qos_head
) {
215 qos_head
= qos_head
->next
;
221 while (curr
!= NULL
) {
222 if (curr
->next
== entry
) {
223 curr
->next
= entry
->next
;
233 /* this is buggered - we need locking for qos_head */
234 void atm_mpoa_disp_qos(struct seq_file
*m
)
236 struct atm_mpoa_qos
*qos
;
239 seq_printf(m
, "QoS entries for shortcuts:\n");
240 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");
242 while (qos
!= NULL
) {
243 seq_printf(m
, "%pI4\n %-7d %-7d %-7d %-7d %-7d\n %-7d %-7d %-7d %-7d %-7d\n",
245 qos
->qos
.txtp
.max_pcr
,
247 qos
->qos
.txtp
.min_pcr
,
248 qos
->qos
.txtp
.max_cdv
,
249 qos
->qos
.txtp
.max_sdu
,
250 qos
->qos
.rxtp
.max_pcr
,
252 qos
->qos
.rxtp
.min_pcr
,
253 qos
->qos
.rxtp
.max_cdv
,
254 qos
->qos
.rxtp
.max_sdu
);
259 static struct net_device
*find_lec_by_itfnum(int itf
)
261 struct net_device
*dev
;
264 sprintf(name
, "lec%d", itf
);
265 dev
= dev_get_by_name(&init_net
, name
);
270 static struct mpoa_client
*alloc_mpc(void)
272 struct mpoa_client
*mpc
;
274 mpc
= kzalloc(sizeof(struct mpoa_client
), GFP_KERNEL
);
277 rwlock_init(&mpc
->ingress_lock
);
278 rwlock_init(&mpc
->egress_lock
);
280 atm_mpoa_init_cache(mpc
);
282 mpc
->parameters
.mpc_p1
= MPC_P1
;
283 mpc
->parameters
.mpc_p2
= MPC_P2
;
284 memset(mpc
->parameters
.mpc_p3
, 0, sizeof(mpc
->parameters
.mpc_p3
));
285 mpc
->parameters
.mpc_p4
= MPC_P4
;
286 mpc
->parameters
.mpc_p5
= MPC_P5
;
287 mpc
->parameters
.mpc_p6
= MPC_P6
;
296 * start_mpc() puts the MPC on line. All the packets destined
297 * to the lec underneath us are now being monitored and
298 * shortcuts will be established.
301 static void start_mpc(struct mpoa_client
*mpc
, struct net_device
*dev
)
304 dprintk("(%s)\n", mpc
->dev
->name
);
305 if (!dev
->netdev_ops
)
306 pr_info("(%s) not starting\n", dev
->name
);
308 mpc
->old_ops
= dev
->netdev_ops
;
309 mpc
->new_ops
= *mpc
->old_ops
;
310 mpc
->new_ops
.ndo_start_xmit
= mpc_send_packet
;
311 dev
->netdev_ops
= &mpc
->new_ops
;
315 static void stop_mpc(struct mpoa_client
*mpc
)
317 struct net_device
*dev
= mpc
->dev
;
318 dprintk("(%s)", mpc
->dev
->name
);
320 /* Lets not nullify lec device's dev->hard_start_xmit */
321 if (dev
->netdev_ops
!= &mpc
->new_ops
) {
322 dprintk_cont(" mpc already stopped, not fatal\n");
327 dev
->netdev_ops
= mpc
->old_ops
;
332 static const char *mpoa_device_type_string(char type
) __attribute__ ((unused
));
334 static const char *mpoa_device_type_string(char type
)
338 return "non-MPOA device";
344 return "both MPS and MPC";
347 return "unspecified (non-MPOA) device";
351 * lec device calls this via its netdev_priv(dev)->lane2_ops
352 * ->associate_indicator() when it sees a TLV in LE_ARP packet.
353 * We fill in the pointer above when we see a LANE2 lec initializing
354 * See LANE2 spec 3.1.5
356 * Quite a big and ugly function but when you look at it
357 * all it does is to try to locate and parse MPOA Device
359 * We give our lec a pointer to this function and when the
360 * lec sees a TLV it uses the pointer to call this function.
363 static void lane2_assoc_ind(struct net_device
*dev
, const u8
*mac_addr
,
364 const u8
*tlvs
, u32 sizeoftlvs
)
367 uint8_t length
, mpoa_device_type
, number_of_mps_macs
;
368 const uint8_t *end_of_tlvs
;
369 struct mpoa_client
*mpc
;
371 mpoa_device_type
= number_of_mps_macs
= 0; /* silence gcc */
372 dprintk("(%s) received TLV(s), ", dev
->name
);
373 dprintk("total length of all TLVs %d\n", sizeoftlvs
);
374 mpc
= find_mpc_by_lec(dev
); /* Sampo-Fix: moved here from below */
376 pr_info("(%s) no mpc\n", dev
->name
);
379 end_of_tlvs
= tlvs
+ sizeoftlvs
;
380 while (end_of_tlvs
- tlvs
>= 5) {
381 type
= ((tlvs
[0] << 24) | (tlvs
[1] << 16) |
382 (tlvs
[2] << 8) | tlvs
[3]);
385 dprintk(" type 0x%x length %02x\n", type
, length
);
386 if (tlvs
+ length
> end_of_tlvs
) {
387 pr_info("TLV value extends past its buffer, aborting parse\n");
392 pr_info("mpoa: (%s) TLV type was 0, returning\n",
397 if (type
!= TLV_MPOA_DEVICE_TYPE
) {
399 continue; /* skip other TLVs */
401 mpoa_device_type
= *tlvs
++;
402 number_of_mps_macs
= *tlvs
++;
403 dprintk("(%s) MPOA device type '%s', ",
404 dev
->name
, mpoa_device_type_string(mpoa_device_type
));
405 if (mpoa_device_type
== MPS_AND_MPC
&&
406 length
< (42 + number_of_mps_macs
*ETH_ALEN
)) { /* :) */
407 pr_info("(%s) short MPOA Device Type TLV\n",
411 if ((mpoa_device_type
== MPS
|| mpoa_device_type
== MPC
) &&
412 length
< 22 + number_of_mps_macs
*ETH_ALEN
) {
413 pr_info("(%s) short MPOA Device Type TLV\n", dev
->name
);
416 if (mpoa_device_type
!= MPS
&&
417 mpoa_device_type
!= MPS_AND_MPC
) {
418 dprintk("ignoring non-MPS device ");
419 if (mpoa_device_type
== MPC
)
421 continue; /* we are only interested in MPSs */
423 if (number_of_mps_macs
== 0 &&
424 mpoa_device_type
== MPS_AND_MPC
) {
425 pr_info("(%s) MPS_AND_MPC has zero MACs\n", dev
->name
);
426 continue; /* someone should read the spec */
428 dprintk_cont("this MPS has %d MAC addresses\n",
432 * ok, now we can go and tell our daemon
433 * the control address of MPS
435 send_set_mps_ctrl_addr(tlvs
, mpc
);
437 tlvs
= copy_macs(mpc
, mac_addr
, tlvs
,
438 number_of_mps_macs
, mpoa_device_type
);
442 if (end_of_tlvs
- tlvs
!= 0)
443 pr_info("(%s) ignoring %Zd bytes of trailing TLV garbage\n",
444 dev
->name
, end_of_tlvs
- tlvs
);
448 * Store at least advertizing router's MAC address
449 * plus the possible MAC address(es) to mpc->mps_macs.
450 * For a freshly allocated MPOA client mpc->mps_macs == 0.
452 static const uint8_t *copy_macs(struct mpoa_client
*mpc
,
453 const uint8_t *router_mac
,
454 const uint8_t *tlvs
, uint8_t mps_macs
,
458 num_macs
= (mps_macs
> 1) ? mps_macs
: 1;
460 if (mpc
->number_of_mps_macs
!= num_macs
) { /* need to reallocate? */
461 if (mpc
->number_of_mps_macs
!= 0)
462 kfree(mpc
->mps_macs
);
463 mpc
->number_of_mps_macs
= 0;
464 mpc
->mps_macs
= kmalloc(num_macs
* ETH_ALEN
, GFP_KERNEL
);
465 if (mpc
->mps_macs
== NULL
) {
466 pr_info("(%s) out of mem\n", mpc
->dev
->name
);
470 memcpy(mpc
->mps_macs
, router_mac
, ETH_ALEN
);
471 tlvs
+= 20; if (device_type
== MPS_AND_MPC
) tlvs
+= 20;
473 memcpy(mpc
->mps_macs
, tlvs
, mps_macs
*ETH_ALEN
);
474 tlvs
+= mps_macs
*ETH_ALEN
;
475 mpc
->number_of_mps_macs
= num_macs
;
480 static int send_via_shortcut(struct sk_buff
*skb
, struct mpoa_client
*mpc
)
482 in_cache_entry
*entry
;
488 struct llc_snap_hdr hdr
;
490 } tagged_llc_snap_hdr
= {
491 {0xaa, 0xaa, 0x03, {0x00, 0x00, 0x00}, {0x88, 0x4c}},
495 buff
= skb
->data
+ mpc
->dev
->hard_header_len
;
496 iph
= (struct iphdr
*)buff
;
499 ddprintk("(%s) ipaddr 0x%x\n",
500 mpc
->dev
->name
, ipaddr
);
502 entry
= mpc
->in_ops
->get(ipaddr
, mpc
);
504 entry
= mpc
->in_ops
->add_entry(ipaddr
, mpc
);
506 mpc
->in_ops
->put(entry
);
509 /* threshold not exceeded or VCC not ready */
510 if (mpc
->in_ops
->cache_hit(entry
, mpc
) != OPEN
) {
511 ddprintk("(%s) cache_hit: returns != OPEN\n",
513 mpc
->in_ops
->put(entry
);
517 ddprintk("(%s) using shortcut\n",
519 /* MPOA spec A.1.4, MPOA client must decrement IP ttl at least by one */
521 ddprintk("(%s) IP ttl = %u, using LANE\n",
522 mpc
->dev
->name
, iph
->ttl
);
523 mpc
->in_ops
->put(entry
);
528 iph
->check
= ip_fast_csum((unsigned char *)iph
, iph
->ihl
);
530 if (entry
->ctrl_info
.tag
!= 0) {
531 ddprintk("(%s) adding tag 0x%x\n",
532 mpc
->dev
->name
, entry
->ctrl_info
.tag
);
533 tagged_llc_snap_hdr
.tag
= entry
->ctrl_info
.tag
;
534 skb_pull(skb
, ETH_HLEN
); /* get rid of Eth header */
535 skb_push(skb
, sizeof(tagged_llc_snap_hdr
));
536 /* add LLC/SNAP header */
537 skb_copy_to_linear_data(skb
, &tagged_llc_snap_hdr
,
538 sizeof(tagged_llc_snap_hdr
));
540 skb_pull(skb
, ETH_HLEN
); /* get rid of Eth header */
541 skb_push(skb
, sizeof(struct llc_snap_hdr
));
542 /* add LLC/SNAP header + tag */
543 skb_copy_to_linear_data(skb
, &llc_snap_mpoa_data
,
544 sizeof(struct llc_snap_hdr
));
547 atomic_add(skb
->truesize
, &sk_atm(entry
->shortcut
)->sk_wmem_alloc
);
548 ATM_SKB(skb
)->atm_options
= entry
->shortcut
->atm_options
;
549 entry
->shortcut
->send(entry
->shortcut
, skb
);
550 entry
->packets_fwded
++;
551 mpc
->in_ops
->put(entry
);
557 * Probably needs some error checks and locking, not sure...
559 static netdev_tx_t
mpc_send_packet(struct sk_buff
*skb
,
560 struct net_device
*dev
)
562 struct mpoa_client
*mpc
;
566 mpc
= find_mpc_by_lec(dev
); /* this should NEVER fail */
568 pr_info("(%s) no MPC found\n", dev
->name
);
572 eth
= (struct ethhdr
*)skb
->data
;
573 if (eth
->h_proto
!= htons(ETH_P_IP
))
574 goto non_ip
; /* Multi-Protocol Over ATM :-) */
576 /* Weed out funny packets (e.g., AF_PACKET or raw). */
577 if (skb
->len
< ETH_HLEN
+ sizeof(struct iphdr
))
579 skb_set_network_header(skb
, ETH_HLEN
);
580 if (skb
->len
< ETH_HLEN
+ ip_hdr(skb
)->ihl
* 4 || ip_hdr(skb
)->ihl
< 5)
583 while (i
< mpc
->number_of_mps_macs
) {
584 if (!compare_ether_addr(eth
->h_dest
,
585 (mpc
->mps_macs
+ i
*ETH_ALEN
)))
586 if (send_via_shortcut(skb
, mpc
) == 0) /* try shortcut */
592 return mpc
->old_ops
->ndo_start_xmit(skb
, dev
);
595 static int atm_mpoa_vcc_attach(struct atm_vcc
*vcc
, void __user
*arg
)
598 struct mpoa_client
*mpc
;
599 struct atmmpc_ioc ioc_data
;
600 in_cache_entry
*in_entry
;
603 bytes_left
= copy_from_user(&ioc_data
, arg
, sizeof(struct atmmpc_ioc
));
604 if (bytes_left
!= 0) {
605 pr_info("mpoa:Short read (missed %d bytes) from userland\n",
609 ipaddr
= ioc_data
.ipaddr
;
610 if (ioc_data
.dev_num
< 0 || ioc_data
.dev_num
>= MAX_LEC_ITF
)
613 mpc
= find_mpc_by_itfnum(ioc_data
.dev_num
);
617 if (ioc_data
.type
== MPC_SOCKET_INGRESS
) {
618 in_entry
= mpc
->in_ops
->get(ipaddr
, mpc
);
619 if (in_entry
== NULL
||
620 in_entry
->entry_state
< INGRESS_RESOLVED
) {
621 pr_info("(%s) did not find RESOLVED entry from ingress cache\n",
623 if (in_entry
!= NULL
)
624 mpc
->in_ops
->put(in_entry
);
627 pr_info("(%s) attaching ingress SVC, entry = %pI4\n",
628 mpc
->dev
->name
, &in_entry
->ctrl_info
.in_dst_ip
);
629 in_entry
->shortcut
= vcc
;
630 mpc
->in_ops
->put(in_entry
);
632 pr_info("(%s) attaching egress SVC\n", mpc
->dev
->name
);
635 vcc
->proto_data
= mpc
->dev
;
636 vcc
->push
= mpc_push
;
644 static void mpc_vcc_close(struct atm_vcc
*vcc
, struct net_device
*dev
)
646 struct mpoa_client
*mpc
;
647 in_cache_entry
*in_entry
;
648 eg_cache_entry
*eg_entry
;
650 mpc
= find_mpc_by_lec(dev
);
652 pr_info("(%s) close for unknown MPC\n", dev
->name
);
656 dprintk("(%s)\n", dev
->name
);
657 in_entry
= mpc
->in_ops
->get_by_vcc(vcc
, mpc
);
659 dprintk("(%s) ingress SVC closed ip = %pI4\n",
660 mpc
->dev
->name
, &in_entry
->ctrl_info
.in_dst_ip
);
661 in_entry
->shortcut
= NULL
;
662 mpc
->in_ops
->put(in_entry
);
664 eg_entry
= mpc
->eg_ops
->get_by_vcc(vcc
, mpc
);
666 dprintk("(%s) egress SVC closed\n", mpc
->dev
->name
);
667 eg_entry
->shortcut
= NULL
;
668 mpc
->eg_ops
->put(eg_entry
);
671 if (in_entry
== NULL
&& eg_entry
== NULL
)
672 dprintk("(%s) unused vcc closed\n", dev
->name
);
675 static void mpc_push(struct atm_vcc
*vcc
, struct sk_buff
*skb
)
677 struct net_device
*dev
= (struct net_device
*)vcc
->proto_data
;
678 struct sk_buff
*new_skb
;
680 struct mpoa_client
*mpc
;
684 ddprintk("(%s)\n", dev
->name
);
686 dprintk("(%s) null skb, closing VCC\n", dev
->name
);
687 mpc_vcc_close(vcc
, dev
);
692 if (memcmp(skb
->data
, &llc_snap_mpoa_ctrl
,
693 sizeof(struct llc_snap_hdr
)) == 0) {
694 struct sock
*sk
= sk_atm(vcc
);
696 dprintk("(%s) control packet arrived\n", dev
->name
);
697 /* Pass control packets to daemon */
698 skb_queue_tail(&sk
->sk_receive_queue
, skb
);
699 sk
->sk_data_ready(sk
, skb
->len
);
703 /* data coming over the shortcut */
704 atm_return(vcc
, skb
->truesize
);
706 mpc
= find_mpc_by_lec(dev
);
708 pr_info("(%s) unknown MPC\n", dev
->name
);
712 if (memcmp(skb
->data
, &llc_snap_mpoa_data_tagged
,
713 sizeof(struct llc_snap_hdr
)) == 0) { /* MPOA tagged data */
714 ddprintk("(%s) tagged data packet arrived\n", dev
->name
);
716 } else if (memcmp(skb
->data
, &llc_snap_mpoa_data
,
717 sizeof(struct llc_snap_hdr
)) == 0) { /* MPOA data */
718 pr_info("(%s) Unsupported non-tagged data packet arrived. Purging\n",
720 dev_kfree_skb_any(skb
);
723 pr_info("(%s) garbage arrived, purging\n", dev
->name
);
724 dev_kfree_skb_any(skb
);
728 tmp
= skb
->data
+ sizeof(struct llc_snap_hdr
);
729 tag
= *(__be32
*)tmp
;
731 eg
= mpc
->eg_ops
->get_by_tag(tag
, mpc
);
733 pr_info("mpoa: (%s) Didn't find egress cache entry, tag = %u\n",
735 purge_egress_shortcut(vcc
, NULL
);
736 dev_kfree_skb_any(skb
);
741 * See if ingress MPC is using shortcut we opened as a return channel.
742 * This means we have a bi-directional vcc opened by us.
744 if (eg
->shortcut
== NULL
) {
746 pr_info("(%s) egress SVC in use\n", dev
->name
);
749 skb_pull(skb
, sizeof(struct llc_snap_hdr
) + sizeof(tag
));
750 /* get rid of LLC/SNAP header */
751 new_skb
= skb_realloc_headroom(skb
, eg
->ctrl_info
.DH_length
);
752 /* LLC/SNAP is shorter than MAC header :( */
753 dev_kfree_skb_any(skb
);
754 if (new_skb
== NULL
) {
755 mpc
->eg_ops
->put(eg
);
758 skb_push(new_skb
, eg
->ctrl_info
.DH_length
); /* add MAC header */
759 skb_copy_to_linear_data(new_skb
, eg
->ctrl_info
.DLL_header
,
760 eg
->ctrl_info
.DH_length
);
761 new_skb
->protocol
= eth_type_trans(new_skb
, dev
);
762 skb_reset_network_header(new_skb
);
764 eg
->latest_ip_addr
= ip_hdr(new_skb
)->saddr
;
766 mpc
->eg_ops
->put(eg
);
768 memset(ATM_SKB(new_skb
), 0, sizeof(struct atm_skb_data
));
772 static struct atmdev_ops mpc_ops
= { /* only send is required */
773 .close
= mpoad_close
,
774 .send
= msg_from_mpoad
777 static struct atm_dev mpc_dev
= {
781 .lock
= __SPIN_LOCK_UNLOCKED(mpc_dev
.lock
)
782 /* members not explicitly initialised will be 0 */
785 static int atm_mpoa_mpoad_attach(struct atm_vcc
*vcc
, int arg
)
787 struct mpoa_client
*mpc
;
788 struct lec_priv
*priv
;
792 init_timer(&mpc_timer
);
795 /* This lets us now how our LECs are doing */
796 err
= register_netdevice_notifier(&mpoa_notifier
);
798 del_timer(&mpc_timer
);
803 mpc
= find_mpc_by_itfnum(arg
);
805 dprintk("allocating new mpc for itf %d\n", arg
);
810 mpc
->dev
= find_lec_by_itfnum(arg
);
811 /* NULL if there was no lec */
813 if (mpc
->mpoad_vcc
) {
814 pr_info("mpoad is already present for itf %d\n", arg
);
818 if (mpc
->dev
) { /* check if the lec is LANE2 capable */
819 priv
= netdev_priv(mpc
->dev
);
820 if (priv
->lane_version
< 2) {
824 priv
->lane2_ops
->associate_indicator
= lane2_assoc_ind
;
827 mpc
->mpoad_vcc
= vcc
;
829 vcc_insert_socket(sk_atm(vcc
));
830 set_bit(ATM_VF_META
, &vcc
->flags
);
831 set_bit(ATM_VF_READY
, &vcc
->flags
);
834 char empty
[ATM_ESA_LEN
];
835 memset(empty
, 0, ATM_ESA_LEN
);
837 start_mpc(mpc
, mpc
->dev
);
838 /* set address if mpcd e.g. gets killed and restarted.
839 * If we do not do it now we have to wait for the next LE_ARP
841 if (memcmp(mpc
->mps_ctrl_addr
, empty
, ATM_ESA_LEN
) != 0)
842 send_set_mps_ctrl_addr(mpc
->mps_ctrl_addr
, mpc
);
845 __module_get(THIS_MODULE
);
849 static void send_set_mps_ctrl_addr(const char *addr
, struct mpoa_client
*mpc
)
851 struct k_message mesg
;
853 memcpy(mpc
->mps_ctrl_addr
, addr
, ATM_ESA_LEN
);
855 mesg
.type
= SET_MPS_CTRL_ADDR
;
856 memcpy(mesg
.MPS_ctrl
, addr
, ATM_ESA_LEN
);
857 msg_to_mpoad(&mesg
, mpc
);
860 static void mpoad_close(struct atm_vcc
*vcc
)
862 struct mpoa_client
*mpc
;
865 mpc
= find_mpc_by_vcc(vcc
);
867 pr_info("did not find MPC\n");
870 if (!mpc
->mpoad_vcc
) {
871 pr_info("close for non-present mpoad\n");
875 mpc
->mpoad_vcc
= NULL
;
877 struct lec_priv
*priv
= netdev_priv(mpc
->dev
);
878 priv
->lane2_ops
->associate_indicator
= NULL
;
883 mpc
->in_ops
->destroy_cache(mpc
);
884 mpc
->eg_ops
->destroy_cache(mpc
);
886 while ((skb
= skb_dequeue(&sk_atm(vcc
)->sk_receive_queue
))) {
887 atm_return(vcc
, skb
->truesize
);
891 pr_info("(%s) going down\n",
892 (mpc
->dev
) ? mpc
->dev
->name
: "<unknown>");
893 module_put(THIS_MODULE
);
899 static int msg_from_mpoad(struct atm_vcc
*vcc
, struct sk_buff
*skb
)
902 struct mpoa_client
*mpc
= find_mpc_by_vcc(vcc
);
903 struct k_message
*mesg
= (struct k_message
*)skb
->data
;
904 atomic_sub(skb
->truesize
, &sk_atm(vcc
)->sk_wmem_alloc
);
907 pr_info("no mpc found\n");
910 dprintk("(%s)", mpc
->dev
? mpc
->dev
->name
: "<unknown>");
911 switch (mesg
->type
) {
912 case MPOA_RES_REPLY_RCVD
:
913 dprintk_cont("mpoa_res_reply_rcvd\n");
914 MPOA_res_reply_rcvd(mesg
, mpc
);
916 case MPOA_TRIGGER_RCVD
:
917 dprintk_cont("mpoa_trigger_rcvd\n");
918 MPOA_trigger_rcvd(mesg
, mpc
);
920 case INGRESS_PURGE_RCVD
:
921 dprintk_cont("nhrp_purge_rcvd\n");
922 ingress_purge_rcvd(mesg
, mpc
);
924 case EGRESS_PURGE_RCVD
:
925 dprintk_cont("egress_purge_reply_rcvd\n");
926 egress_purge_rcvd(mesg
, mpc
);
929 dprintk_cont("mps_death\n");
930 mps_death(mesg
, mpc
);
932 case CACHE_IMPOS_RCVD
:
933 dprintk_cont("cache_impos_rcvd\n");
934 MPOA_cache_impos_rcvd(mesg
, mpc
);
936 case SET_MPC_CTRL_ADDR
:
937 dprintk_cont("set_mpc_ctrl_addr\n");
938 set_mpc_ctrl_addr_rcvd(mesg
, mpc
);
940 case SET_MPS_MAC_ADDR
:
941 dprintk_cont("set_mps_mac_addr\n");
942 set_mps_mac_addr_rcvd(mesg
, mpc
);
944 case CLEAN_UP_AND_EXIT
:
945 dprintk_cont("clean_up_and_exit\n");
946 clean_up(mesg
, mpc
, DIE
);
949 dprintk_cont("reload\n");
950 clean_up(mesg
, mpc
, RELOAD
);
953 dprintk_cont("set_mpc_params\n");
954 mpc
->parameters
= mesg
->content
.params
;
957 dprintk_cont("unknown message %d\n", mesg
->type
);
965 /* Remember that this function may not do things that sleep */
966 int msg_to_mpoad(struct k_message
*mesg
, struct mpoa_client
*mpc
)
971 if (mpc
== NULL
|| !mpc
->mpoad_vcc
) {
972 pr_info("mesg %d to a non-existent mpoad\n", mesg
->type
);
976 skb
= alloc_skb(sizeof(struct k_message
), GFP_ATOMIC
);
979 skb_put(skb
, sizeof(struct k_message
));
980 skb_copy_to_linear_data(skb
, mesg
, sizeof(*mesg
));
981 atm_force_charge(mpc
->mpoad_vcc
, skb
->truesize
);
983 sk
= sk_atm(mpc
->mpoad_vcc
);
984 skb_queue_tail(&sk
->sk_receive_queue
, skb
);
985 sk
->sk_data_ready(sk
, skb
->len
);
990 static int mpoa_event_listener(struct notifier_block
*mpoa_notifier
,
991 unsigned long event
, void *dev_ptr
)
993 struct net_device
*dev
;
994 struct mpoa_client
*mpc
;
995 struct lec_priv
*priv
;
997 dev
= (struct net_device
*)dev_ptr
;
999 if (!net_eq(dev_net(dev
), &init_net
))
1002 if (dev
->name
== NULL
|| strncmp(dev
->name
, "lec", 3))
1003 return NOTIFY_DONE
; /* we are only interested in lec:s */
1006 case NETDEV_REGISTER
: /* a new lec device was allocated */
1007 priv
= netdev_priv(dev
);
1008 if (priv
->lane_version
< 2)
1010 priv
->lane2_ops
->associate_indicator
= lane2_assoc_ind
;
1011 mpc
= find_mpc_by_itfnum(priv
->itfnum
);
1013 dprintk("allocating new mpc for %s\n", dev
->name
);
1016 pr_info("no new mpc");
1020 mpc
->dev_num
= priv
->itfnum
;
1023 dprintk("(%s) was initialized\n", dev
->name
);
1025 case NETDEV_UNREGISTER
:
1026 /* the lec device was deallocated */
1027 mpc
= find_mpc_by_lec(dev
);
1030 dprintk("device (%s) was deallocated\n", dev
->name
);
1036 /* the dev was ifconfig'ed up */
1037 mpc
= find_mpc_by_lec(dev
);
1040 if (mpc
->mpoad_vcc
!= NULL
)
1041 start_mpc(mpc
, dev
);
1044 /* the dev was ifconfig'ed down */
1045 /* this means that the flow of packets from the
1048 mpc
= find_mpc_by_lec(dev
);
1051 if (mpc
->mpoad_vcc
!= NULL
)
1056 case NETDEV_CHANGEMTU
:
1057 case NETDEV_CHANGEADDR
:
1058 case NETDEV_GOING_DOWN
:
1068 * Functions which are called after a message is received from mpcd.
1069 * Msg is reused on purpose.
1073 static void MPOA_trigger_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
)
1075 __be32 dst_ip
= msg
->content
.in_info
.in_dst_ip
;
1076 in_cache_entry
*entry
;
1078 entry
= mpc
->in_ops
->get(dst_ip
, mpc
);
1079 if (entry
== NULL
) {
1080 entry
= mpc
->in_ops
->add_entry(dst_ip
, mpc
);
1081 entry
->entry_state
= INGRESS_RESOLVING
;
1082 msg
->type
= SND_MPOA_RES_RQST
;
1083 msg
->content
.in_info
= entry
->ctrl_info
;
1084 msg_to_mpoad(msg
, mpc
);
1085 do_gettimeofday(&(entry
->reply_wait
));
1086 mpc
->in_ops
->put(entry
);
1090 if (entry
->entry_state
== INGRESS_INVALID
) {
1091 entry
->entry_state
= INGRESS_RESOLVING
;
1092 msg
->type
= SND_MPOA_RES_RQST
;
1093 msg
->content
.in_info
= entry
->ctrl_info
;
1094 msg_to_mpoad(msg
, mpc
);
1095 do_gettimeofday(&(entry
->reply_wait
));
1096 mpc
->in_ops
->put(entry
);
1100 pr_info("(%s) entry already in resolving state\n",
1101 (mpc
->dev
) ? mpc
->dev
->name
: "<unknown>");
1102 mpc
->in_ops
->put(entry
);
1106 * Things get complicated because we have to check if there's an egress
1107 * shortcut with suitable traffic parameters we could use.
1109 static void check_qos_and_open_shortcut(struct k_message
*msg
,
1110 struct mpoa_client
*client
,
1111 in_cache_entry
*entry
)
1113 __be32 dst_ip
= msg
->content
.in_info
.in_dst_ip
;
1114 struct atm_mpoa_qos
*qos
= atm_mpoa_search_qos(dst_ip
);
1115 eg_cache_entry
*eg_entry
= client
->eg_ops
->get_by_src_ip(dst_ip
, client
);
1117 if (eg_entry
&& eg_entry
->shortcut
) {
1118 if (eg_entry
->shortcut
->qos
.txtp
.traffic_class
&
1119 msg
->qos
.txtp
.traffic_class
&
1120 (qos
? qos
->qos
.txtp
.traffic_class
: ATM_UBR
| ATM_CBR
)) {
1121 if (eg_entry
->shortcut
->qos
.txtp
.traffic_class
== ATM_UBR
)
1122 entry
->shortcut
= eg_entry
->shortcut
;
1123 else if (eg_entry
->shortcut
->qos
.txtp
.max_pcr
> 0)
1124 entry
->shortcut
= eg_entry
->shortcut
;
1126 if (entry
->shortcut
) {
1127 dprintk("(%s) using egress SVC to reach %pI4\n",
1128 client
->dev
->name
, &dst_ip
);
1129 client
->eg_ops
->put(eg_entry
);
1133 if (eg_entry
!= NULL
)
1134 client
->eg_ops
->put(eg_entry
);
1136 /* No luck in the egress cache we must open an ingress SVC */
1137 msg
->type
= OPEN_INGRESS_SVC
;
1139 (qos
->qos
.txtp
.traffic_class
== msg
->qos
.txtp
.traffic_class
)) {
1140 msg
->qos
= qos
->qos
;
1141 pr_info("(%s) trying to get a CBR shortcut\n",
1144 memset(&msg
->qos
, 0, sizeof(struct atm_qos
));
1145 msg_to_mpoad(msg
, client
);
1148 static void MPOA_res_reply_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
)
1150 __be32 dst_ip
= msg
->content
.in_info
.in_dst_ip
;
1151 in_cache_entry
*entry
= mpc
->in_ops
->get(dst_ip
, mpc
);
1153 dprintk("(%s) ip %pI4\n",
1154 mpc
->dev
->name
, &dst_ip
);
1155 ddprintk("(%s) entry = %p",
1156 mpc
->dev
->name
, entry
);
1157 if (entry
== NULL
) {
1158 pr_info("(%s) ARGH, received res. reply for an entry that doesn't exist.\n",
1162 ddprintk_cont(" entry_state = %d ", entry
->entry_state
);
1164 if (entry
->entry_state
== INGRESS_RESOLVED
) {
1165 pr_info("(%s) RESOLVED entry!\n", mpc
->dev
->name
);
1166 mpc
->in_ops
->put(entry
);
1170 entry
->ctrl_info
= msg
->content
.in_info
;
1171 do_gettimeofday(&(entry
->tv
));
1172 do_gettimeofday(&(entry
->reply_wait
)); /* Used in refreshing func from now on */
1173 entry
->refresh_time
= 0;
1174 ddprintk_cont("entry->shortcut = %p\n", entry
->shortcut
);
1176 if (entry
->entry_state
== INGRESS_RESOLVING
&&
1177 entry
->shortcut
!= NULL
) {
1178 entry
->entry_state
= INGRESS_RESOLVED
;
1179 mpc
->in_ops
->put(entry
);
1180 return; /* Shortcut already open... */
1183 if (entry
->shortcut
!= NULL
) {
1184 pr_info("(%s) entry->shortcut != NULL, impossible!\n",
1186 mpc
->in_ops
->put(entry
);
1190 check_qos_and_open_shortcut(msg
, mpc
, entry
);
1191 entry
->entry_state
= INGRESS_RESOLVED
;
1192 mpc
->in_ops
->put(entry
);
1198 static void ingress_purge_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
)
1200 __be32 dst_ip
= msg
->content
.in_info
.in_dst_ip
;
1201 __be32 mask
= msg
->ip_mask
;
1202 in_cache_entry
*entry
= mpc
->in_ops
->get_with_mask(dst_ip
, mpc
, mask
);
1204 if (entry
== NULL
) {
1205 pr_info("(%s) purge for a non-existing entry, ip = %pI4\n",
1206 mpc
->dev
->name
, &dst_ip
);
1211 dprintk("(%s) removing an ingress entry, ip = %pI4\n",
1212 mpc
->dev
->name
, &dst_ip
);
1213 write_lock_bh(&mpc
->ingress_lock
);
1214 mpc
->in_ops
->remove_entry(entry
, mpc
);
1215 write_unlock_bh(&mpc
->ingress_lock
);
1216 mpc
->in_ops
->put(entry
);
1217 entry
= mpc
->in_ops
->get_with_mask(dst_ip
, mpc
, mask
);
1218 } while (entry
!= NULL
);
1221 static void egress_purge_rcvd(struct k_message
*msg
, struct mpoa_client
*mpc
)
1223 __be32 cache_id
= msg
->content
.eg_info
.cache_id
;
1224 eg_cache_entry
*entry
= mpc
->eg_ops
->get_by_cache_id(cache_id
, mpc
);
1226 if (entry
== NULL
) {
1227 dprintk("(%s) purge for a non-existing entry\n",
1232 write_lock_irq(&mpc
->egress_lock
);
1233 mpc
->eg_ops
->remove_entry(entry
, mpc
);
1234 write_unlock_irq(&mpc
->egress_lock
);
1236 mpc
->eg_ops
->put(entry
);
1239 static void purge_egress_shortcut(struct atm_vcc
*vcc
, eg_cache_entry
*entry
)
1242 struct k_message
*purge_msg
;
1243 struct sk_buff
*skb
;
1245 dprintk("entering\n");
1247 pr_info("vcc == NULL\n");
1251 skb
= alloc_skb(sizeof(struct k_message
), GFP_ATOMIC
);
1253 pr_info("out of memory\n");
1257 skb_put(skb
, sizeof(struct k_message
));
1258 memset(skb
->data
, 0, sizeof(struct k_message
));
1259 purge_msg
= (struct k_message
*)skb
->data
;
1260 purge_msg
->type
= DATA_PLANE_PURGE
;
1262 purge_msg
->content
.eg_info
= entry
->ctrl_info
;
1264 atm_force_charge(vcc
, skb
->truesize
);
1267 skb_queue_tail(&sk
->sk_receive_queue
, skb
);
1268 sk
->sk_data_ready(sk
, skb
->len
);
1269 dprintk("exiting\n");
1273 * Our MPS died. Tell our daemon to send NHRP data plane purge to each
1274 * of the egress shortcuts we have.
1276 static void mps_death(struct k_message
*msg
, struct mpoa_client
*mpc
)
1278 eg_cache_entry
*entry
;
1280 dprintk("(%s)\n", mpc
->dev
->name
);
1282 if (memcmp(msg
->MPS_ctrl
, mpc
->mps_ctrl_addr
, ATM_ESA_LEN
)) {
1283 pr_info("(%s) wrong MPS\n", mpc
->dev
->name
);
1287 read_lock_irq(&mpc
->egress_lock
);
1288 entry
= mpc
->eg_cache
;
1289 while (entry
!= NULL
) {
1290 purge_egress_shortcut(entry
->shortcut
, entry
);
1291 entry
= entry
->next
;
1293 read_unlock_irq(&mpc
->egress_lock
);
1295 mpc
->in_ops
->destroy_cache(mpc
);
1296 mpc
->eg_ops
->destroy_cache(mpc
);
1299 static void MPOA_cache_impos_rcvd(struct k_message
*msg
,
1300 struct mpoa_client
*mpc
)
1302 uint16_t holding_time
;
1303 eg_cache_entry
*entry
= mpc
->eg_ops
->get_by_cache_id(msg
->content
.eg_info
.cache_id
, mpc
);
1305 holding_time
= msg
->content
.eg_info
.holding_time
;
1306 dprintk("(%s) entry = %p, holding_time = %u\n",
1307 mpc
->dev
->name
, entry
, holding_time
);
1308 if (entry
== NULL
&& holding_time
) {
1309 entry
= mpc
->eg_ops
->add_entry(msg
, mpc
);
1310 mpc
->eg_ops
->put(entry
);
1314 mpc
->eg_ops
->update(entry
, holding_time
);
1318 write_lock_irq(&mpc
->egress_lock
);
1319 mpc
->eg_ops
->remove_entry(entry
, mpc
);
1320 write_unlock_irq(&mpc
->egress_lock
);
1322 mpc
->eg_ops
->put(entry
);
1325 static void set_mpc_ctrl_addr_rcvd(struct k_message
*mesg
,
1326 struct mpoa_client
*mpc
)
1328 struct lec_priv
*priv
;
1331 uint8_t tlv
[4 + 1 + 1 + 1 + ATM_ESA_LEN
];
1333 tlv
[0] = 00; tlv
[1] = 0xa0; tlv
[2] = 0x3e; tlv
[3] = 0x2a; /* type */
1334 tlv
[4] = 1 + 1 + ATM_ESA_LEN
; /* length */
1335 tlv
[5] = 0x02; /* MPOA client */
1336 tlv
[6] = 0x00; /* number of MPS MAC addresses */
1338 memcpy(&tlv
[7], mesg
->MPS_ctrl
, ATM_ESA_LEN
); /* MPC ctrl ATM addr */
1339 memcpy(mpc
->our_ctrl_addr
, mesg
->MPS_ctrl
, ATM_ESA_LEN
);
1341 dprintk("(%s) setting MPC ctrl ATM address to",
1342 mpc
->dev
? mpc
->dev
->name
: "<unknown>");
1343 for (i
= 7; i
< sizeof(tlv
); i
++)
1344 dprintk_cont(" %02x", tlv
[i
]);
1348 priv
= netdev_priv(mpc
->dev
);
1349 retval
= priv
->lane2_ops
->associate_req(mpc
->dev
,
1353 pr_info("(%s) MPOA device type TLV association failed\n",
1355 retval
= priv
->lane2_ops
->resolve(mpc
->dev
, NULL
, 1, NULL
, NULL
);
1357 pr_info("(%s) targetless LE_ARP request failed\n",
1362 static void set_mps_mac_addr_rcvd(struct k_message
*msg
,
1363 struct mpoa_client
*client
)
1366 if (client
->number_of_mps_macs
)
1367 kfree(client
->mps_macs
);
1368 client
->number_of_mps_macs
= 0;
1369 client
->mps_macs
= kmemdup(msg
->MPS_ctrl
, ETH_ALEN
, GFP_KERNEL
);
1370 if (client
->mps_macs
== NULL
) {
1371 pr_info("out of memory\n");
1374 client
->number_of_mps_macs
= 1;
1378 * purge egress cache and tell daemon to 'action' (DIE, RELOAD)
1380 static void clean_up(struct k_message
*msg
, struct mpoa_client
*mpc
, int action
)
1383 eg_cache_entry
*entry
;
1384 msg
->type
= SND_EGRESS_PURGE
;
1387 read_lock_irq(&mpc
->egress_lock
);
1388 entry
= mpc
->eg_cache
;
1389 while (entry
!= NULL
) {
1390 msg
->content
.eg_info
= entry
->ctrl_info
;
1391 dprintk("cache_id %u\n", entry
->ctrl_info
.cache_id
);
1392 msg_to_mpoad(msg
, mpc
);
1393 entry
= entry
->next
;
1395 read_unlock_irq(&mpc
->egress_lock
);
1398 msg_to_mpoad(msg
, mpc
);
1401 static void mpc_timer_refresh(void)
1403 mpc_timer
.expires
= jiffies
+ (MPC_P2
* HZ
);
1404 mpc_timer
.data
= mpc_timer
.expires
;
1405 mpc_timer
.function
= mpc_cache_check
;
1406 add_timer(&mpc_timer
);
1409 static void mpc_cache_check(unsigned long checking_time
)
1411 struct mpoa_client
*mpc
= mpcs
;
1412 static unsigned long previous_resolving_check_time
;
1413 static unsigned long previous_refresh_time
;
1415 while (mpc
!= NULL
) {
1416 mpc
->in_ops
->clear_count(mpc
);
1417 mpc
->eg_ops
->clear_expired(mpc
);
1418 if (checking_time
- previous_resolving_check_time
>
1419 mpc
->parameters
.mpc_p4
* HZ
) {
1420 mpc
->in_ops
->check_resolving(mpc
);
1421 previous_resolving_check_time
= checking_time
;
1423 if (checking_time
- previous_refresh_time
>
1424 mpc
->parameters
.mpc_p5
* HZ
) {
1425 mpc
->in_ops
->refresh(mpc
);
1426 previous_refresh_time
= checking_time
;
1430 mpc_timer_refresh();
1433 static int atm_mpoa_ioctl(struct socket
*sock
, unsigned int cmd
,
1437 struct atm_vcc
*vcc
= ATM_SD(sock
);
1439 if (cmd
!= ATMMPC_CTRL
&& cmd
!= ATMMPC_DATA
)
1440 return -ENOIOCTLCMD
;
1442 if (!capable(CAP_NET_ADMIN
))
1447 err
= atm_mpoa_mpoad_attach(vcc
, (int)arg
);
1449 sock
->state
= SS_CONNECTED
;
1452 err
= atm_mpoa_vcc_attach(vcc
, (void __user
*)arg
);
1460 static struct atm_ioctl atm_ioctl_ops
= {
1461 .owner
= THIS_MODULE
,
1462 .ioctl
= atm_mpoa_ioctl
,
1465 static __init
int atm_mpoa_init(void)
1467 register_atm_ioctl(&atm_ioctl_ops
);
1469 if (mpc_proc_init() != 0)
1470 pr_info("failed to initialize /proc/mpoa\n");
1472 pr_info("mpc.c: " __DATE__
" " __TIME__
" initialized\n");
1477 static void __exit
atm_mpoa_cleanup(void)
1479 struct mpoa_client
*mpc
, *tmp
;
1480 struct atm_mpoa_qos
*qos
, *nextqos
;
1481 struct lec_priv
*priv
;
1485 del_timer(&mpc_timer
);
1486 unregister_netdevice_notifier(&mpoa_notifier
);
1487 deregister_atm_ioctl(&atm_ioctl_ops
);
1491 while (mpc
!= NULL
) {
1493 if (mpc
->dev
!= NULL
) {
1495 priv
= netdev_priv(mpc
->dev
);
1496 if (priv
->lane2_ops
!= NULL
)
1497 priv
->lane2_ops
->associate_indicator
= NULL
;
1499 ddprintk("about to clear caches\n");
1500 mpc
->in_ops
->destroy_cache(mpc
);
1501 mpc
->eg_ops
->destroy_cache(mpc
);
1502 ddprintk("caches cleared\n");
1503 kfree(mpc
->mps_macs
);
1504 memset(mpc
, 0, sizeof(struct mpoa_client
));
1505 ddprintk("about to kfree %p\n", mpc
);
1507 ddprintk("next mpc is at %p\n", tmp
);
1513 while (qos
!= NULL
) {
1514 nextqos
= qos
->next
;
1515 dprintk("freeing qos entry %p\n", qos
);
1521 module_init(atm_mpoa_init
);
1522 module_exit(atm_mpoa_cleanup
);
1524 MODULE_LICENSE("GPL");