Lines Matching +full:sock +full:- +full:priv
1 // SPDX-License-Identifier: GPL-2.0-only
19 #include <net/sock.h>
45 /* Hardening for Spectre-v1 */
67 static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
69 static int lec_arp_remove(struct lec_priv *priv,
79 static int lec_addr_delete(struct lec_priv *priv, const unsigned char *atm_addr,
81 static void lec_arp_check_empties(struct lec_priv *priv,
83 static void lec_arp_destroy(struct lec_priv *priv);
84 static void lec_arp_init(struct lec_priv *priv);
85 static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
89 static void lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,
93 static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id);
94 static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc);
95 static void lec_set_flush_tran_id(struct lec_priv *priv,
98 static void lec_vcc_added(struct lec_priv *priv,
103 static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc);
108 refcount_inc(&entry->usage); in lec_arp_hold()
113 if (refcount_dec_and_test(&entry->usage)) in lec_arp_put()
132 struct lec_priv *priv; in lec_handle_bridge() local
139 buff = skb->data + skb->dev->hard_header_len; in lec_handle_bridge()
141 struct sock *sk; in lec_handle_bridge()
148 skb2->len = sizeof(struct atmlec_msg); in lec_handle_bridge()
149 mesg = (struct atmlec_msg *)skb2->data; in lec_handle_bridge()
150 mesg->type = l_topology_change; in lec_handle_bridge()
152 mesg->content.normal.flag = *buff & 0x01; in lec_handle_bridge()
155 priv = netdev_priv(dev); in lec_handle_bridge()
156 atm_force_charge(priv->lecd, skb2->truesize); in lec_handle_bridge()
157 sk = sk_atm(priv->lecd); in lec_handle_bridge()
158 skb_queue_tail(&sk->sk_receive_queue, skb2); in lec_handle_bridge()
159 sk->sk_data_ready(sk); in lec_handle_bridge()
170 * there is non-reboot way to recover if something goes wrong.
183 struct net_device *dev = skb->dev; in lec_send()
185 ATM_SKB(skb)->vcc = vcc; in lec_send()
188 if (vcc->send(vcc, skb) < 0) { in lec_send()
189 dev->stats.tx_dropped++; in lec_send()
193 dev->stats.tx_packets++; in lec_send()
194 dev->stats.tx_bytes += skb->len; in lec_send()
199 pr_info("%s\n", dev->name); in lec_tx_timeout()
208 struct lec_priv *priv = netdev_priv(dev); in lec_start_xmit() local
217 if (!priv->lecd) { in lec_start_xmit()
218 pr_info("%s:No lecd attached\n", dev->name); in lec_start_xmit()
219 dev->stats.tx_errors++; in lec_start_xmit()
226 (long)skb->head, (long)skb->data, (long)skb_tail_pointer(skb), in lec_start_xmit()
229 if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0) in lec_start_xmit()
247 lec_h = (struct lecdatahdr_8023 *)skb->data; in lec_start_xmit()
248 lec_h->le_header = htons(priv->lecid); in lec_start_xmit()
257 dev->name, skb->len, priv->lecid); in lec_start_xmit()
259 skb->data, min(skb->len, MAX_DUMP_SKB), true); in lec_start_xmit()
262 /* Minimum ethernet-frame size */ in lec_start_xmit()
264 if (skb->len < min_frame_size) { in lec_start_xmit()
265 if ((skb->len + skb_tailroom(skb)) < min_frame_size) { in lec_start_xmit()
267 min_frame_size - skb->truesize, in lec_start_xmit()
271 dev->stats.tx_dropped++; in lec_start_xmit()
276 skb_put(skb, min_frame_size - skb->len); in lec_start_xmit()
281 dst = lec_h->h_dest; in lec_start_xmit()
283 vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry); in lec_start_xmit()
285 dev->name, vcc, vcc ? vcc->flags : 0, entry); in lec_start_xmit()
286 if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) { in lec_start_xmit()
287 if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) { in lec_start_xmit()
289 dev->name, lec_h->h_dest); in lec_start_xmit()
290 skb_queue_tail(&entry->tx_wait, skb); in lec_start_xmit()
293 dev->name, lec_h->h_dest); in lec_start_xmit()
294 dev->stats.tx_dropped++; in lec_start_xmit()
301 dev->name, vcc->vpi, vcc->vci); in lec_start_xmit()
304 while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { in lec_start_xmit()
305 pr_debug("emptying tx queue, MAC address %pM\n", lec_h->h_dest); in lec_start_xmit()
314 vpriv->xoff = 1; in lec_start_xmit()
318 * vcc->pop() might have occurred in between, making in lec_start_xmit()
320 * this is the only situation we have to re-test. in lec_start_xmit()
345 struct net_device *dev = (struct net_device *)vcc->proto_data; in lec_atm_send()
346 struct lec_priv *priv = netdev_priv(dev); in lec_atm_send() local
351 WARN_ON(refcount_sub_and_test(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc)); in lec_atm_send()
352 mesg = (struct atmlec_msg *)skb->data; in lec_atm_send()
353 tmp = skb->data; in lec_atm_send()
355 pr_debug("%s: msg from zeppelin:%d\n", dev->name, mesg->type); in lec_atm_send()
356 switch (mesg->type) { in lec_atm_send()
358 eth_hw_addr_set(dev, mesg->content.normal.mac_addr); in lec_atm_send()
364 lec_addr_delete(priv, mesg->content.normal.atm_addr, in lec_atm_send()
365 mesg->content.normal.flag); in lec_atm_send()
368 priv->topology_change = mesg->content.normal.flag; in lec_atm_send()
371 lec_flush_complete(priv, mesg->content.normal.flag); in lec_atm_send()
374 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_atm_send()
375 entry = lec_arp_find(priv, mesg->content.normal.mac_addr); in lec_atm_send()
376 lec_arp_remove(priv, entry); in lec_atm_send()
377 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_atm_send()
379 if (mesg->content.normal.no_source_le_narp) in lec_atm_send()
383 lec_arp_update(priv, mesg->content.normal.mac_addr, in lec_atm_send()
384 mesg->content.normal.atm_addr, in lec_atm_send()
385 mesg->content.normal.flag, in lec_atm_send()
386 mesg->content.normal.targetless_le_arp); in lec_atm_send()
388 if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */ in lec_atm_send()
390 mesg->sizeoftlvs); in lec_atm_send()
391 lane2_associate_ind(dev, mesg->content.normal.mac_addr, in lec_atm_send()
392 tmp, mesg->sizeoftlvs); in lec_atm_send()
396 priv->maximum_unknown_frame_count = in lec_atm_send()
397 mesg->content.config.maximum_unknown_frame_count; in lec_atm_send()
398 priv->max_unknown_frame_time = in lec_atm_send()
399 (mesg->content.config.max_unknown_frame_time * HZ); in lec_atm_send()
400 priv->max_retry_count = mesg->content.config.max_retry_count; in lec_atm_send()
401 priv->aging_time = (mesg->content.config.aging_time * HZ); in lec_atm_send()
402 priv->forward_delay_time = in lec_atm_send()
403 (mesg->content.config.forward_delay_time * HZ); in lec_atm_send()
404 priv->arp_response_time = in lec_atm_send()
405 (mesg->content.config.arp_response_time * HZ); in lec_atm_send()
406 priv->flush_timeout = (mesg->content.config.flush_timeout * HZ); in lec_atm_send()
407 priv->path_switching_delay = in lec_atm_send()
408 (mesg->content.config.path_switching_delay * HZ); in lec_atm_send()
409 priv->lane_version = mesg->content.config.lane_version; in lec_atm_send()
411 priv->lane2_ops = NULL; in lec_atm_send()
412 if (priv->lane_version > 1) in lec_atm_send()
413 priv->lane2_ops = &lane2_ops; in lec_atm_send()
415 if (dev_set_mtu(dev, mesg->content.config.mtu)) in lec_atm_send()
417 dev->name, mesg->content.config.mtu); in lec_atm_send()
419 priv->is_proxy = mesg->content.config.is_proxy; in lec_atm_send()
422 lec_set_flush_tran_id(priv, mesg->content.normal.atm_addr, in lec_atm_send()
423 mesg->content.normal.flag); in lec_atm_send()
426 priv->lecid = in lec_atm_send()
427 (unsigned short)(0xffff & mesg->content.normal.flag); in lec_atm_send()
433 dev->name, mesg->content.proxy.mac_addr); in lec_atm_send()
438 if (br_fdb_test_addr_hook(dev, mesg->content.proxy.mac_addr)) { in lec_atm_send()
441 struct sock *sk; in lec_atm_send()
444 dev->name); in lec_atm_send()
448 skb2->len = sizeof(struct atmlec_msg); in lec_atm_send()
450 atm_force_charge(priv->lecd, skb2->truesize); in lec_atm_send()
451 sk = sk_atm(priv->lecd); in lec_atm_send()
452 skb_queue_tail(&sk->sk_receive_queue, skb2); in lec_atm_send()
453 sk->sk_data_ready(sk); in lec_atm_send()
459 pr_info("%s: Unknown message type %d\n", dev->name, mesg->type); in lec_atm_send()
461 return -EINVAL; in lec_atm_send()
470 struct net_device *dev = (struct net_device *)vcc->proto_data; in lec_atm_close()
471 struct lec_priv *priv = netdev_priv(dev); in lec_atm_close() local
473 priv->lecd = NULL; in lec_atm_close()
477 lec_arp_destroy(priv); in lec_atm_close()
479 if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) in lec_atm_close()
480 pr_info("%s closing with messages pending\n", dev->name); in lec_atm_close()
481 while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue))) { in lec_atm_close()
482 atm_return(vcc, skb->truesize); in lec_atm_close()
486 pr_info("%s: Shut down!\n", dev->name); in lec_atm_close()
507 send_to_lecd(struct lec_priv *priv, atmlec_msg_type type, in send_to_lecd() argument
511 struct sock *sk; in send_to_lecd()
515 if (!priv || !priv->lecd) in send_to_lecd()
516 return -1; in send_to_lecd()
519 return -1; in send_to_lecd()
520 skb->len = sizeof(struct atmlec_msg); in send_to_lecd()
521 mesg = (struct atmlec_msg *)skb->data; in send_to_lecd()
523 mesg->type = type; in send_to_lecd()
525 mesg->sizeoftlvs = data->len; in send_to_lecd()
527 ether_addr_copy(mesg->content.normal.mac_addr, mac_addr); in send_to_lecd()
529 mesg->content.normal.targetless_le_arp = 1; in send_to_lecd()
531 memcpy(&mesg->content.normal.atm_addr, atm_addr, ATM_ESA_LEN); in send_to_lecd()
533 atm_force_charge(priv->lecd, skb->truesize); in send_to_lecd()
534 sk = sk_atm(priv->lecd); in send_to_lecd()
535 skb_queue_tail(&sk->sk_receive_queue, skb); in send_to_lecd()
536 sk->sk_data_ready(sk); in send_to_lecd()
539 pr_debug("about to send %d bytes of data\n", data->len); in send_to_lecd()
540 atm_force_charge(priv->lecd, data->truesize); in send_to_lecd()
541 skb_queue_tail(&sk->sk_receive_queue, data); in send_to_lecd()
542 sk->sk_data_ready(sk); in send_to_lecd()
576 return ((vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8023) || in lec_is_data_direct()
577 (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025)); in lec_is_data_direct()
583 struct net_device *dev = (struct net_device *)vcc->proto_data; in lec_push()
584 struct lec_priv *priv = netdev_priv(dev); in lec_push() local
588 dev->name, vcc->vpi, vcc->vci); in lec_push()
591 pr_debug("%s: null skb\n", dev->name); in lec_push()
592 lec_vcc_close(priv, vcc); in lec_push()
602 dev->name, skb->len, priv->lecid); in lec_push()
604 skb->data, min(MAX_SKB_DUMP, skb->len), true); in lec_push()
606 if (memcmp(skb->data, lec_ctrl_magic, 4) == 0) { in lec_push()
608 struct sock *sk = sk_atm(vcc); in lec_push()
610 pr_debug("%s: To daemon\n", dev->name); in lec_push()
611 skb_queue_tail(&sk->sk_receive_queue, skb); in lec_push()
612 sk->sk_data_ready(sk); in lec_push()
617 atm_return(vcc, skb->truesize); in lec_push()
618 if (*(__be16 *) skb->data == htons(priv->lecid) || in lec_push()
619 !priv->lecd || !(dev->flags & IFF_UP)) { in lec_push()
628 dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest; in lec_push()
634 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_push()
636 src = ((struct lecdatahdr_8023 *)skb->data)->h_source; in lec_push()
637 entry = lec_arp_find(priv, src); in lec_push()
638 if (entry && entry->vcc != vcc) { in lec_push()
639 lec_arp_remove(priv, entry); in lec_push()
643 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_push()
646 !priv->is_proxy && /* Proxy wants all the packets */ in lec_push()
647 memcmp(dst, dev->dev_addr, dev->addr_len)) { in lec_push()
651 if (!hlist_empty(&priv->lec_arp_empty_ones)) in lec_push()
652 lec_arp_check_empties(priv, vcc, skb); in lec_push()
654 skb->protocol = eth_type_trans(skb, dev); in lec_push()
655 dev->stats.rx_packets++; in lec_push()
656 dev->stats.rx_bytes += skb->len; in lec_push()
665 struct net_device *dev = skb->dev; in lec_pop()
672 vpriv->old_pop(vcc, skb); in lec_pop()
674 if (vpriv->xoff && atm_may_send(vcc, 0)) { in lec_pop()
675 vpriv->xoff = 0; in lec_pop()
692 return -EINVAL; in lec_vcc_attach()
695 return -EINVAL; in lec_vcc_attach()
698 return -ENOMEM; in lec_vcc_attach()
699 vpriv->xoff = 0; in lec_vcc_attach()
700 vpriv->old_pop = vcc->pop; in lec_vcc_attach()
701 vcc->user_back = vpriv; in lec_vcc_attach()
702 vcc->pop = lec_pop; in lec_vcc_attach()
704 &ioc_data, vcc, vcc->push); in lec_vcc_attach()
705 vcc->proto_data = dev_lec[ioc_data.dev_num]; in lec_vcc_attach()
706 vcc->push = lec_push; in lec_vcc_attach()
713 return -EINVAL; in lec_mcast_attach()
716 return -EINVAL; in lec_mcast_attach()
717 vcc->proto_data = dev_lec[arg]; in lec_mcast_attach()
725 struct lec_priv *priv; in lecd_attach() local
730 return -EINVAL; in lecd_attach()
738 return -ENOMEM; in lecd_attach()
739 dev_lec[i]->netdev_ops = &lec_netdev_ops; in lecd_attach()
740 dev_lec[i]->max_mtu = 18190; in lecd_attach()
741 snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i); in lecd_attach()
744 return -EINVAL; in lecd_attach()
747 priv = netdev_priv(dev_lec[i]); in lecd_attach()
749 priv = netdev_priv(dev_lec[i]); in lecd_attach()
750 if (priv->lecd) in lecd_attach()
751 return -EADDRINUSE; in lecd_attach()
753 lec_arp_init(priv); in lecd_attach()
754 priv->itfnum = i; /* LANE2 addition */ in lecd_attach()
755 priv->lecd = vcc; in lecd_attach()
756 vcc->dev = &lecatm_dev; in lecd_attach()
759 vcc->proto_data = dev_lec[i]; in lecd_attach()
760 set_bit(ATM_VF_META, &vcc->flags); in lecd_attach()
761 set_bit(ATM_VF_READY, &vcc->flags); in lecd_attach()
764 priv->maximum_unknown_frame_count = 1; in lecd_attach()
765 priv->max_unknown_frame_time = (1 * HZ); in lecd_attach()
766 priv->vcc_timeout_period = (1200 * HZ); in lecd_attach()
767 priv->max_retry_count = 1; in lecd_attach()
768 priv->aging_time = (300 * HZ); in lecd_attach()
769 priv->forward_delay_time = (15 * HZ); in lecd_attach()
770 priv->topology_change = 0; in lecd_attach()
771 priv->arp_response_time = (1 * HZ); in lecd_attach()
772 priv->flush_timeout = (4 * HZ); in lecd_attach()
773 priv->path_switching_delay = (6 * HZ); in lecd_attach()
775 if (dev_lec[i]->flags & IFF_UP) in lecd_attach()
800 seq_printf(seq, "%pM ", entry->mac_addr); in lec_info()
801 seq_printf(seq, "%*phN ", ATM_ESA_LEN, entry->atm_addr); in lec_info()
802 seq_printf(seq, "%s %4.4x", lec_arp_get_status_string(entry->status), in lec_info()
803 entry->flags & 0xffff); in lec_info()
804 if (entry->vcc) in lec_info()
805 seq_printf(seq, "%3d %3d ", entry->vcc->vpi, entry->vcc->vci); in lec_info()
808 if (entry->recv_vcc) { in lec_info()
809 seq_printf(seq, " %3d %3d", entry->recv_vcc->vpi, in lec_info()
810 entry->recv_vcc->vci); in lec_info()
828 struct hlist_node *e = state->node; in lec_tbl_walk()
831 e = tbl->first; in lec_tbl_walk()
833 e = tbl->first; in lec_tbl_walk()
834 --*l; in lec_tbl_walk()
837 for (; e; e = e->next) { in lec_tbl_walk()
838 if (--*l < 0) in lec_tbl_walk()
841 state->node = e; in lec_tbl_walk()
847 struct lec_priv *priv) in lec_arp_walk() argument
852 for (p = state->arp_table; p < LEC_ARP_TABLE_SIZE; p++) { in lec_arp_walk()
853 v = lec_tbl_walk(state, &priv->lec_arp_tables[p], l); in lec_arp_walk()
857 state->arp_table = p; in lec_arp_walk()
862 struct lec_priv *priv) in lec_misc_walk() argument
865 &priv->lec_arp_empty_ones, in lec_misc_walk()
866 &priv->lec_no_forward, in lec_misc_walk()
867 &priv->mcast_fwds in lec_misc_walk()
872 for (q = state->misc_table; q < ARRAY_SIZE(lec_misc_tables); q++) { in lec_misc_walk()
877 state->misc_table = q; in lec_misc_walk()
882 struct lec_priv *priv) in lec_priv_walk() argument
884 if (!state->locked) { in lec_priv_walk()
885 state->locked = priv; in lec_priv_walk()
886 spin_lock_irqsave(&priv->lec_arp_lock, state->flags); in lec_priv_walk()
888 if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) { in lec_priv_walk()
889 spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags); in lec_priv_walk()
890 state->locked = NULL; in lec_priv_walk()
892 state->arp_table = state->misc_table = 0; in lec_priv_walk()
894 return state->locked; in lec_priv_walk()
902 dev = state->dev ? state->dev : dev_lec[state->itf]; in lec_itf_walk()
910 state->dev = dev; in lec_itf_walk()
918 for (; state->itf < MAX_LEC_ITF; state->itf++) { in lec_get_idx()
928 struct lec_state *state = seq->private; in lec_seq_start()
930 state->itf = 0; in lec_seq_start()
931 state->dev = NULL; in lec_seq_start()
932 state->locked = NULL; in lec_seq_start()
933 state->arp_table = 0; in lec_seq_start()
934 state->misc_table = 0; in lec_seq_start()
935 state->node = SEQ_START_TOKEN; in lec_seq_start()
942 struct lec_state *state = seq->private; in lec_seq_stop()
944 if (state->dev) { in lec_seq_stop()
945 spin_unlock_irqrestore(&state->locked->lec_arp_lock, in lec_seq_stop()
946 state->flags); in lec_seq_stop()
947 dev_put(state->dev); in lec_seq_stop()
953 struct lec_state *state = seq->private; in lec_seq_next()
969 struct lec_state *state = seq->private; in lec_seq_show()
970 struct net_device *dev = state->dev; in lec_seq_show()
971 struct lec_arp_table *entry = hlist_entry(state->node, in lec_seq_show()
975 seq_printf(seq, "%s ", dev->name); in lec_seq_show()
989 static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) in lane_ioctl() argument
991 struct atm_vcc *vcc = ATM_SD(sock); in lane_ioctl()
999 return -EPERM; in lane_ioctl()
1002 return -ENOIOCTLCMD; in lane_ioctl()
1009 sock->state = SS_CONNECTED; in lane_ioctl()
1036 return -ENOMEM; in lane_module_init()
1078 struct lec_priv *priv = netdev_priv(dev); in lane2_resolve() local
1084 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lane2_resolve()
1085 table = lec_arp_find(priv, dst_mac); in lane2_resolve()
1086 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lane2_resolve()
1088 return -1; in lane2_resolve()
1090 *tlvs = kmemdup(table->tlvs, table->sizeoftlvs, GFP_ATOMIC); in lane2_resolve()
1092 return -1; in lane2_resolve()
1094 *sizeoftlvs = table->sizeoftlvs; in lane2_resolve()
1100 retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, NULL); in lane2_resolve()
1105 return -1; in lane2_resolve()
1106 skb->len = *sizeoftlvs; in lane2_resolve()
1108 retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, skb); in lane2_resolve()
1125 struct lec_priv *priv = netdev_priv(dev); in lane2_associate_req() local
1127 if (!ether_addr_equal(lan_dst, dev->dev_addr)) in lane2_associate_req()
1130 kfree(priv->tlvs); /* NULL if there was no previous association */ in lane2_associate_req()
1132 priv->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL); in lane2_associate_req()
1133 if (priv->tlvs == NULL) in lane2_associate_req()
1135 priv->sizeoftlvs = sizeoftlvs; in lane2_associate_req()
1140 skb->len = sizeoftlvs; in lane2_associate_req()
1142 retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb); in lane2_associate_req()
1162 struct lec_priv *priv = netdev_priv(dev); in lane2_associate_ind() local
1169 struct lec_arp_table *entry = lec_arp_find(priv, mac_addr); in lane2_associate_ind()
1174 kfree(entry->tlvs); in lane2_associate_ind()
1176 entry->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL); in lane2_associate_ind()
1177 if (entry->tlvs == NULL) in lane2_associate_ind()
1179 entry->sizeoftlvs = sizeoftlvs; in lane2_associate_ind()
1191 if (priv->lane2_ops && priv->lane2_ops->associate_indicator) { in lane2_associate_ind()
1192 priv->lane2_ops->associate_indicator(dev, mac_addr, in lane2_associate_ind()
1228 #define HASH(ch) (ch & (LEC_ARP_TABLE_SIZE - 1))
1231 * Initialization of arp-cache
1233 static void lec_arp_init(struct lec_priv *priv) in lec_arp_init() argument
1238 INIT_HLIST_HEAD(&priv->lec_arp_tables[i]); in lec_arp_init()
1239 INIT_HLIST_HEAD(&priv->lec_arp_empty_ones); in lec_arp_init()
1240 INIT_HLIST_HEAD(&priv->lec_no_forward); in lec_arp_init()
1241 INIT_HLIST_HEAD(&priv->mcast_fwds); in lec_arp_init()
1242 spin_lock_init(&priv->lec_arp_lock); in lec_arp_init()
1243 INIT_DELAYED_WORK(&priv->lec_arp_work, lec_arp_check_expire); in lec_arp_init()
1244 schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL); in lec_arp_init()
1249 if (entry->vcc) { in lec_arp_clear_vccs()
1250 struct atm_vcc *vcc = entry->vcc; in lec_arp_clear_vccs()
1252 struct net_device *dev = (struct net_device *)vcc->proto_data; in lec_arp_clear_vccs()
1254 vcc->pop = vpriv->old_pop; in lec_arp_clear_vccs()
1255 if (vpriv->xoff) in lec_arp_clear_vccs()
1258 vcc->user_back = NULL; in lec_arp_clear_vccs()
1259 vcc->push = entry->old_push; in lec_arp_clear_vccs()
1260 vcc_release_async(vcc, -EPIPE); in lec_arp_clear_vccs()
1261 entry->vcc = NULL; in lec_arp_clear_vccs()
1263 if (entry->recv_vcc) { in lec_arp_clear_vccs()
1264 struct atm_vcc *vcc = entry->recv_vcc; in lec_arp_clear_vccs()
1268 vcc->user_back = NULL; in lec_arp_clear_vccs()
1270 entry->recv_vcc->push = entry->old_recv_push; in lec_arp_clear_vccs()
1271 vcc_release_async(entry->recv_vcc, -EPIPE); in lec_arp_clear_vccs()
1272 entry->recv_vcc = NULL; in lec_arp_clear_vccs()
1281 lec_arp_add(struct lec_priv *priv, struct lec_arp_table *entry) in lec_arp_add() argument
1285 tmp = &priv->lec_arp_tables[HASH(entry->mac_addr[ETH_ALEN - 1])]; in lec_arp_add()
1286 hlist_add_head(&entry->next, tmp); in lec_arp_add()
1288 pr_debug("Added entry:%pM\n", entry->mac_addr); in lec_arp_add()
1295 lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove) in lec_arp_remove() argument
1301 return -1; in lec_arp_remove()
1303 hlist_del(&to_remove->next); in lec_arp_remove()
1304 del_timer(&to_remove->timer); in lec_arp_remove()
1310 if (to_remove->status >= ESI_FLUSH_PENDING) { in lec_arp_remove()
1316 &priv->lec_arp_tables[i], next) { in lec_arp_remove()
1317 if (memcmp(to_remove->atm_addr, in lec_arp_remove()
1318 entry->atm_addr, ATM_ESA_LEN) == 0) { in lec_arp_remove()
1327 skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */ in lec_arp_remove()
1329 pr_debug("Removed entry:%pM\n", to_remove->mac_addr); in lec_arp_remove()
1351 static void dump_arp_table(struct lec_priv *priv) in dump_arp_table() argument
1357 pr_info("Dump %p:\n", priv); in dump_arp_table()
1360 &priv->lec_arp_tables[i], next) { in dump_arp_table()
1364 rulla->mac_addr); in dump_arp_table()
1366 rulla->atm_addr); in dump_arp_table()
1369 rulla->vcc ? rulla->vcc->vpi : 0, in dump_arp_table()
1370 rulla->vcc ? rulla->vcc->vci : 0, in dump_arp_table()
1371 rulla->recv_vcc ? rulla->recv_vcc-> in dump_arp_table()
1373 rulla->recv_vcc ? rulla->recv_vcc-> in dump_arp_table()
1374 vci : 0, rulla->last_used, in dump_arp_table()
1375 rulla->timestamp, rulla->no_tries); in dump_arp_table()
1379 rulla->flags, rulla->packets_flooded, in dump_arp_table()
1380 get_status_string(rulla->status)); in dump_arp_table()
1385 if (!hlist_empty(&priv->lec_no_forward)) in dump_arp_table()
1387 hlist_for_each_entry(rulla, &priv->lec_no_forward, next) { in dump_arp_table()
1389 offset += sprintf(buf + offset, "Mac: %pM ", rulla->mac_addr); in dump_arp_table()
1391 rulla->atm_addr); in dump_arp_table()
1394 rulla->vcc ? rulla->vcc->vpi : 0, in dump_arp_table()
1395 rulla->vcc ? rulla->vcc->vci : 0, in dump_arp_table()
1396 rulla->recv_vcc ? rulla->recv_vcc->vpi : 0, in dump_arp_table()
1397 rulla->recv_vcc ? rulla->recv_vcc->vci : 0, in dump_arp_table()
1398 rulla->last_used, in dump_arp_table()
1399 rulla->timestamp, rulla->no_tries); in dump_arp_table()
1402 rulla->flags, rulla->packets_flooded, in dump_arp_table()
1403 get_status_string(rulla->status)); in dump_arp_table()
1407 if (!hlist_empty(&priv->lec_arp_empty_ones)) in dump_arp_table()
1409 hlist_for_each_entry(rulla, &priv->lec_arp_empty_ones, next) { in dump_arp_table()
1411 offset += sprintf(buf + offset, "Mac: %pM ", rulla->mac_addr); in dump_arp_table()
1413 rulla->atm_addr); in dump_arp_table()
1416 rulla->vcc ? rulla->vcc->vpi : 0, in dump_arp_table()
1417 rulla->vcc ? rulla->vcc->vci : 0, in dump_arp_table()
1418 rulla->recv_vcc ? rulla->recv_vcc->vpi : 0, in dump_arp_table()
1419 rulla->recv_vcc ? rulla->recv_vcc->vci : 0, in dump_arp_table()
1420 rulla->last_used, in dump_arp_table()
1421 rulla->timestamp, rulla->no_tries); in dump_arp_table()
1424 rulla->flags, rulla->packets_flooded, in dump_arp_table()
1425 get_status_string(rulla->status)); in dump_arp_table()
1429 if (!hlist_empty(&priv->mcast_fwds)) in dump_arp_table()
1431 hlist_for_each_entry(rulla, &priv->mcast_fwds, next) { in dump_arp_table()
1433 offset += sprintf(buf + offset, "Mac: %pM ", rulla->mac_addr); in dump_arp_table()
1435 rulla->atm_addr); in dump_arp_table()
1438 rulla->vcc ? rulla->vcc->vpi : 0, in dump_arp_table()
1439 rulla->vcc ? rulla->vcc->vci : 0, in dump_arp_table()
1440 rulla->recv_vcc ? rulla->recv_vcc->vpi : 0, in dump_arp_table()
1441 rulla->recv_vcc ? rulla->recv_vcc->vci : 0, in dump_arp_table()
1442 rulla->last_used, in dump_arp_table()
1443 rulla->timestamp, rulla->no_tries); in dump_arp_table()
1446 rulla->flags, rulla->packets_flooded, in dump_arp_table()
1447 get_status_string(rulla->status)); in dump_arp_table()
1453 #define dump_arp_table(priv) do { } while (0) argument
1457 * Destruction of arp-cache
1459 static void lec_arp_destroy(struct lec_priv *priv) in lec_arp_destroy() argument
1466 cancel_delayed_work_sync(&priv->lec_arp_work); in lec_arp_destroy()
1472 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_arp_destroy()
1475 &priv->lec_arp_tables[i], next) { in lec_arp_destroy()
1476 lec_arp_remove(priv, entry); in lec_arp_destroy()
1479 INIT_HLIST_HEAD(&priv->lec_arp_tables[i]); in lec_arp_destroy()
1483 &priv->lec_arp_empty_ones, next) { in lec_arp_destroy()
1484 del_timer_sync(&entry->timer); in lec_arp_destroy()
1486 hlist_del(&entry->next); in lec_arp_destroy()
1489 INIT_HLIST_HEAD(&priv->lec_arp_empty_ones); in lec_arp_destroy()
1492 &priv->lec_no_forward, next) { in lec_arp_destroy()
1493 del_timer_sync(&entry->timer); in lec_arp_destroy()
1495 hlist_del(&entry->next); in lec_arp_destroy()
1498 INIT_HLIST_HEAD(&priv->lec_no_forward); in lec_arp_destroy()
1500 hlist_for_each_entry_safe(entry, next, &priv->mcast_fwds, next) { in lec_arp_destroy()
1503 hlist_del(&entry->next); in lec_arp_destroy()
1506 INIT_HLIST_HEAD(&priv->mcast_fwds); in lec_arp_destroy()
1507 priv->mcast_vcc = NULL; in lec_arp_destroy()
1508 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_arp_destroy()
1514 static struct lec_arp_table *lec_arp_find(struct lec_priv *priv, in lec_arp_find() argument
1522 head = &priv->lec_arp_tables[HASH(mac_addr[ETH_ALEN - 1])]; in lec_arp_find()
1524 if (ether_addr_equal(mac_addr, entry->mac_addr)) in lec_arp_find()
1530 static struct lec_arp_table *make_entry(struct lec_priv *priv, in make_entry() argument
1538 ether_addr_copy(to_return->mac_addr, mac_addr); in make_entry()
1539 INIT_HLIST_NODE(&to_return->next); in make_entry()
1540 timer_setup(&to_return->timer, lec_arp_expire_arp, 0); in make_entry()
1541 to_return->last_used = jiffies; in make_entry()
1542 to_return->priv = priv; in make_entry()
1543 skb_queue_head_init(&to_return->tx_wait); in make_entry()
1544 refcount_set(&to_return->usage, 1); in make_entry()
1556 if (entry->status == ESI_ARP_PENDING) { in lec_arp_expire_arp()
1557 if (entry->no_tries <= entry->priv->max_retry_count) { in lec_arp_expire_arp()
1558 if (entry->is_rdesc) in lec_arp_expire_arp()
1559 send_to_lecd(entry->priv, l_rdesc_arp_xmt, in lec_arp_expire_arp()
1560 entry->mac_addr, NULL, NULL); in lec_arp_expire_arp()
1562 send_to_lecd(entry->priv, l_arp_xmt, in lec_arp_expire_arp()
1563 entry->mac_addr, NULL, NULL); in lec_arp_expire_arp()
1564 entry->no_tries++; in lec_arp_expire_arp()
1566 mod_timer(&entry->timer, jiffies + (1 * HZ)); in lec_arp_expire_arp()
1575 struct lec_priv *priv = to_remove->priv; in lec_arp_expire_vcc() local
1577 del_timer(&to_remove->timer); in lec_arp_expire_vcc()
1580 to_remove, priv, in lec_arp_expire_vcc()
1581 to_remove->vcc ? to_remove->recv_vcc->vpi : 0, in lec_arp_expire_vcc()
1582 to_remove->vcc ? to_remove->recv_vcc->vci : 0); in lec_arp_expire_vcc()
1584 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_arp_expire_vcc()
1585 hlist_del(&to_remove->next); in lec_arp_expire_vcc()
1586 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_arp_expire_vcc()
1594 struct lec_priv *priv) in __lec_arp_check_expire() argument
1598 if ((entry->flags) & LEC_REMOTE_FLAG && priv->topology_change) in __lec_arp_check_expire()
1599 time_to_check = priv->forward_delay_time; in __lec_arp_check_expire()
1601 time_to_check = priv->aging_time; in __lec_arp_check_expire()
1603 pr_debug("About to expire: %lx - %lx > %lx\n", in __lec_arp_check_expire()
1604 now, entry->last_used, time_to_check); in __lec_arp_check_expire()
1605 if (time_after(now, entry->last_used + time_to_check) && in __lec_arp_check_expire()
1606 !(entry->flags & LEC_PERMANENT_FLAG) && in __lec_arp_check_expire()
1607 !(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */ in __lec_arp_check_expire()
1610 lec_arp_remove(priv, entry); in __lec_arp_check_expire()
1614 if ((entry->status == ESI_VC_PENDING || in __lec_arp_check_expire()
1615 entry->status == ESI_ARP_PENDING) && in __lec_arp_check_expire()
1616 time_after_eq(now, entry->timestamp + in __lec_arp_check_expire()
1617 priv->max_unknown_frame_time)) { in __lec_arp_check_expire()
1618 entry->timestamp = jiffies; in __lec_arp_check_expire()
1619 entry->packets_flooded = 0; in __lec_arp_check_expire()
1620 if (entry->status == ESI_VC_PENDING) in __lec_arp_check_expire()
1621 send_to_lecd(priv, l_svc_setup, in __lec_arp_check_expire()
1622 entry->mac_addr, in __lec_arp_check_expire()
1623 entry->atm_addr, in __lec_arp_check_expire()
1626 if (entry->status == ESI_FLUSH_PENDING && in __lec_arp_check_expire()
1627 time_after_eq(now, entry->timestamp + in __lec_arp_check_expire()
1628 priv->path_switching_delay)) { in __lec_arp_check_expire()
1638 * 1. Re-set timer
1655 struct lec_priv *priv = in lec_arp_check_expire() local
1662 pr_debug("%p\n", priv); in lec_arp_check_expire()
1665 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_arp_check_expire()
1668 &priv->lec_arp_tables[i], next) { in lec_arp_check_expire()
1669 if (__lec_arp_check_expire(entry, now, priv)) { in lec_arp_check_expire()
1671 struct atm_vcc *vcc = entry->vcc; in lec_arp_check_expire()
1673 spin_unlock_irqrestore(&priv->lec_arp_lock, in lec_arp_check_expire()
1675 while ((skb = skb_dequeue(&entry->tx_wait))) in lec_arp_check_expire()
1677 entry->last_used = jiffies; in lec_arp_check_expire()
1678 entry->status = ESI_FORWARD_DIRECT; in lec_arp_check_expire()
1685 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_arp_check_expire()
1687 schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL); in lec_arp_check_expire()
1694 static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv, in lec_arp_resolve() argument
1704 switch (priv->lane_version) { in lec_arp_resolve()
1706 return priv->mcast_vcc; in lec_arp_resolve()
1709 return priv->mcast_vcc; in lec_arp_resolve()
1716 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_arp_resolve()
1717 entry = lec_arp_find(priv, mac_to_find); in lec_arp_resolve()
1720 if (entry->status == ESI_FORWARD_DIRECT) { in lec_arp_resolve()
1722 entry->last_used = jiffies; in lec_arp_resolve()
1725 found = entry->vcc; in lec_arp_resolve()
1732 if (entry->status == ESI_ARP_PENDING) in lec_arp_resolve()
1733 entry->no_tries = 0; in lec_arp_resolve()
1740 if (entry->status != ESI_FLUSH_PENDING && in lec_arp_resolve()
1741 entry->packets_flooded < in lec_arp_resolve()
1742 priv->maximum_unknown_frame_count) { in lec_arp_resolve()
1743 entry->packets_flooded++; in lec_arp_resolve()
1745 found = priv->mcast_vcc; in lec_arp_resolve()
1749 * We got here because entry->status == ESI_FLUSH_PENDING in lec_arp_resolve()
1755 pr_debug("entry->status %d entry->vcc %p\n", entry->status, in lec_arp_resolve()
1756 entry->vcc); in lec_arp_resolve()
1760 entry = make_entry(priv, mac_to_find); in lec_arp_resolve()
1763 found = priv->mcast_vcc; in lec_arp_resolve()
1766 lec_arp_add(priv, entry); in lec_arp_resolve()
1767 /* We want arp-request(s) to be sent */ in lec_arp_resolve()
1768 entry->packets_flooded = 1; in lec_arp_resolve()
1769 entry->status = ESI_ARP_PENDING; in lec_arp_resolve()
1770 entry->no_tries = 1; in lec_arp_resolve()
1771 entry->last_used = entry->timestamp = jiffies; in lec_arp_resolve()
1772 entry->is_rdesc = is_rdesc; in lec_arp_resolve()
1773 if (entry->is_rdesc) in lec_arp_resolve()
1774 send_to_lecd(priv, l_rdesc_arp_xmt, mac_to_find, NULL, in lec_arp_resolve()
1777 send_to_lecd(priv, l_arp_xmt, mac_to_find, NULL, NULL); in lec_arp_resolve()
1778 entry->timer.expires = jiffies + (1 * HZ); in lec_arp_resolve()
1779 entry->timer.function = lec_arp_expire_arp; in lec_arp_resolve()
1780 add_timer(&entry->timer); in lec_arp_resolve()
1781 found = priv->mcast_vcc; in lec_arp_resolve()
1785 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_arp_resolve()
1790 lec_addr_delete(struct lec_priv *priv, const unsigned char *atm_addr, in lec_addr_delete() argument
1799 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_addr_delete()
1802 &priv->lec_arp_tables[i], next) { in lec_addr_delete()
1803 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN) && in lec_addr_delete()
1805 !(entry->flags & LEC_PERMANENT_FLAG))) { in lec_addr_delete()
1806 lec_arp_remove(priv, entry); in lec_addr_delete()
1809 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_addr_delete()
1813 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_addr_delete()
1814 return -1; in lec_addr_delete()
1821 lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr, in lec_arp_update() argument
1833 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_arp_update()
1834 entry = lec_arp_find(priv, mac_addr); in lec_arp_update()
1840 if (!hlist_empty(&priv->lec_arp_empty_ones)) { in lec_arp_update()
1842 &priv->lec_arp_empty_ones, next) { in lec_arp_update()
1843 if (memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN) == 0) { in lec_arp_update()
1844 hlist_del(&entry->next); in lec_arp_update()
1845 del_timer(&entry->timer); in lec_arp_update()
1846 tmp = lec_arp_find(priv, mac_addr); in lec_arp_update()
1848 del_timer(&tmp->timer); in lec_arp_update()
1849 tmp->status = ESI_FORWARD_DIRECT; in lec_arp_update()
1850 memcpy(tmp->atm_addr, atm_addr, ATM_ESA_LEN); in lec_arp_update()
1851 tmp->vcc = entry->vcc; in lec_arp_update()
1852 tmp->old_push = entry->old_push; in lec_arp_update()
1853 tmp->last_used = jiffies; in lec_arp_update()
1854 del_timer(&entry->timer); in lec_arp_update()
1858 entry->status = ESI_FORWARD_DIRECT; in lec_arp_update()
1859 ether_addr_copy(entry->mac_addr, in lec_arp_update()
1861 entry->last_used = jiffies; in lec_arp_update()
1862 lec_arp_add(priv, entry); in lec_arp_update()
1865 entry->flags |= LEC_REMOTE_FLAG; in lec_arp_update()
1867 entry->flags &= ~LEC_REMOTE_FLAG; in lec_arp_update()
1869 dump_arp_table(priv); in lec_arp_update()
1875 entry = lec_arp_find(priv, mac_addr); in lec_arp_update()
1877 entry = make_entry(priv, mac_addr); in lec_arp_update()
1880 entry->status = ESI_UNKNOWN; in lec_arp_update()
1881 lec_arp_add(priv, entry); in lec_arp_update()
1884 memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN); in lec_arp_update()
1885 del_timer(&entry->timer); in lec_arp_update()
1888 &priv->lec_arp_tables[i], next) { in lec_arp_update()
1890 !memcmp(tmp->atm_addr, atm_addr, ATM_ESA_LEN)) { in lec_arp_update()
1892 if (tmp->status > ESI_VC_PENDING) { in lec_arp_update()
1897 entry->vcc = tmp->vcc; in lec_arp_update()
1898 entry->old_push = tmp->old_push; in lec_arp_update()
1900 entry->status = tmp->status; in lec_arp_update()
1906 entry->flags |= LEC_REMOTE_FLAG; in lec_arp_update()
1908 entry->flags &= ~LEC_REMOTE_FLAG; in lec_arp_update()
1909 if (entry->status == ESI_ARP_PENDING || entry->status == ESI_UNKNOWN) { in lec_arp_update()
1910 entry->status = ESI_VC_PENDING; in lec_arp_update()
1911 send_to_lecd(priv, l_svc_setup, entry->mac_addr, atm_addr, NULL); in lec_arp_update()
1914 dump_arp_table(priv); in lec_arp_update()
1916 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_arp_update()
1923 lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data, in lec_vcc_added() argument
1931 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_vcc_added()
1933 if (ioc_data->receive == 2) { in lec_vcc_added()
1936 entry = lec_arp_find(priv, bus_mac); in lec_vcc_added()
1941 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); in lec_vcc_added()
1942 entry->recv_vcc = vcc; in lec_vcc_added()
1943 entry->old_recv_push = old_push; in lec_vcc_added()
1945 entry = make_entry(priv, bus_mac); in lec_vcc_added()
1948 del_timer(&entry->timer); in lec_vcc_added()
1949 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); in lec_vcc_added()
1950 entry->recv_vcc = vcc; in lec_vcc_added()
1951 entry->old_recv_push = old_push; in lec_vcc_added()
1952 hlist_add_head(&entry->next, &priv->mcast_fwds); in lec_vcc_added()
1954 } else if (ioc_data->receive == 1) { in lec_vcc_added()
1960 ATM_ESA_LEN, ioc_data->atm_addr); in lec_vcc_added()
1961 entry = make_entry(priv, bus_mac); in lec_vcc_added()
1964 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); in lec_vcc_added()
1965 eth_zero_addr(entry->mac_addr); in lec_vcc_added()
1966 entry->recv_vcc = vcc; in lec_vcc_added()
1967 entry->old_recv_push = old_push; in lec_vcc_added()
1968 entry->status = ESI_UNKNOWN; in lec_vcc_added()
1969 entry->timer.expires = jiffies + priv->vcc_timeout_period; in lec_vcc_added()
1970 entry->timer.function = lec_arp_expire_vcc; in lec_vcc_added()
1971 hlist_add_head(&entry->next, &priv->lec_no_forward); in lec_vcc_added()
1972 add_timer(&entry->timer); in lec_vcc_added()
1973 dump_arp_table(priv); in lec_vcc_added()
1977 ATM_ESA_LEN, ioc_data->atm_addr); in lec_vcc_added()
1980 &priv->lec_arp_tables[i], next) { in lec_vcc_added()
1982 (ioc_data->atm_addr, entry->atm_addr, in lec_vcc_added()
1985 pr_debug("Currently -> Vcc: %d, Rvcc:%d\n", in lec_vcc_added()
1986 entry->vcc ? entry->vcc->vci : 0, in lec_vcc_added()
1987 entry->recv_vcc ? entry->recv_vcc-> in lec_vcc_added()
1990 del_timer(&entry->timer); in lec_vcc_added()
1991 entry->vcc = vcc; in lec_vcc_added()
1992 entry->old_push = old_push; in lec_vcc_added()
1993 if (entry->status == ESI_VC_PENDING) { in lec_vcc_added()
1994 if (priv->maximum_unknown_frame_count in lec_vcc_added()
1996 entry->status = in lec_vcc_added()
1999 entry->timestamp = jiffies; in lec_vcc_added()
2000 entry->status = in lec_vcc_added()
2003 send_to_lecd(priv, l_flush_xmt, in lec_vcc_added()
2005 entry->atm_addr, in lec_vcc_added()
2028 dump_arp_table(priv); in lec_vcc_added()
2035 entry = make_entry(priv, bus_mac); in lec_vcc_added()
2038 entry->vcc = vcc; in lec_vcc_added()
2039 entry->old_push = old_push; in lec_vcc_added()
2040 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); in lec_vcc_added()
2041 eth_zero_addr(entry->mac_addr); in lec_vcc_added()
2042 entry->status = ESI_UNKNOWN; in lec_vcc_added()
2043 hlist_add_head(&entry->next, &priv->lec_arp_empty_ones); in lec_vcc_added()
2044 entry->timer.expires = jiffies + priv->vcc_timeout_period; in lec_vcc_added()
2045 entry->timer.function = lec_arp_expire_vcc; in lec_vcc_added()
2046 add_timer(&entry->timer); in lec_vcc_added()
2048 dump_arp_table(priv); in lec_vcc_added()
2050 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_vcc_added()
2053 static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id) in lec_flush_complete() argument
2061 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_flush_complete()
2064 &priv->lec_arp_tables[i], next) { in lec_flush_complete()
2065 if (entry->flush_tran_id == tran_id && in lec_flush_complete()
2066 entry->status == ESI_FLUSH_PENDING) { in lec_flush_complete()
2068 struct atm_vcc *vcc = entry->vcc; in lec_flush_complete()
2071 spin_unlock_irqrestore(&priv->lec_arp_lock, in lec_flush_complete()
2073 while ((skb = skb_dequeue(&entry->tx_wait))) in lec_flush_complete()
2075 entry->last_used = jiffies; in lec_flush_complete()
2076 entry->status = ESI_FORWARD_DIRECT; in lec_flush_complete()
2083 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_flush_complete()
2084 dump_arp_table(priv); in lec_flush_complete()
2088 lec_set_flush_tran_id(struct lec_priv *priv, in lec_set_flush_tran_id() argument
2095 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_set_flush_tran_id()
2098 &priv->lec_arp_tables[i], next) { in lec_set_flush_tran_id()
2099 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) { in lec_set_flush_tran_id()
2100 entry->flush_tran_id = tran_id; in lec_set_flush_tran_id()
2105 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_set_flush_tran_id()
2108 static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc) in lec_mcast_make() argument
2120 return -ENOMEM; in lec_mcast_make()
2121 vpriv->xoff = 0; in lec_mcast_make()
2122 vpriv->old_pop = vcc->pop; in lec_mcast_make()
2123 vcc->user_back = vpriv; in lec_mcast_make()
2124 vcc->pop = lec_pop; in lec_mcast_make()
2125 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_mcast_make()
2126 to_add = make_entry(priv, mac_addr); in lec_mcast_make()
2128 vcc->pop = vpriv->old_pop; in lec_mcast_make()
2130 err = -ENOMEM; in lec_mcast_make()
2133 memcpy(to_add->atm_addr, vcc->remote.sas_addr.prv, ATM_ESA_LEN); in lec_mcast_make()
2134 to_add->status = ESI_FORWARD_DIRECT; in lec_mcast_make()
2135 to_add->flags |= LEC_PERMANENT_FLAG; in lec_mcast_make()
2136 to_add->vcc = vcc; in lec_mcast_make()
2137 to_add->old_push = vcc->push; in lec_mcast_make()
2138 vcc->push = lec_push; in lec_mcast_make()
2139 priv->mcast_vcc = vcc; in lec_mcast_make()
2140 lec_arp_add(priv, to_add); in lec_mcast_make()
2142 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_mcast_make()
2146 static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc) in lec_vcc_close() argument
2153 pr_debug("LEC_ARP: lec_vcc_close vpi:%d vci:%d\n", vcc->vpi, vcc->vci); in lec_vcc_close()
2154 dump_arp_table(priv); in lec_vcc_close()
2156 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_vcc_close()
2160 &priv->lec_arp_tables[i], next) { in lec_vcc_close()
2161 if (vcc == entry->vcc) { in lec_vcc_close()
2162 lec_arp_remove(priv, entry); in lec_vcc_close()
2164 if (priv->mcast_vcc == vcc) in lec_vcc_close()
2165 priv->mcast_vcc = NULL; in lec_vcc_close()
2171 &priv->lec_arp_empty_ones, next) { in lec_vcc_close()
2172 if (entry->vcc == vcc) { in lec_vcc_close()
2174 del_timer(&entry->timer); in lec_vcc_close()
2175 hlist_del(&entry->next); in lec_vcc_close()
2181 &priv->lec_no_forward, next) { in lec_vcc_close()
2182 if (entry->recv_vcc == vcc) { in lec_vcc_close()
2184 del_timer(&entry->timer); in lec_vcc_close()
2185 hlist_del(&entry->next); in lec_vcc_close()
2190 hlist_for_each_entry_safe(entry, next, &priv->mcast_fwds, next) { in lec_vcc_close()
2191 if (entry->recv_vcc == vcc) { in lec_vcc_close()
2194 hlist_del(&entry->next); in lec_vcc_close()
2199 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_vcc_close()
2200 dump_arp_table(priv); in lec_vcc_close()
2204 lec_arp_check_empties(struct lec_priv *priv, in lec_arp_check_empties() argument
2210 struct lecdatahdr_8023 *hdr = (struct lecdatahdr_8023 *)skb->data; in lec_arp_check_empties()
2211 unsigned char *src = hdr->h_source; in lec_arp_check_empties()
2213 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_arp_check_empties()
2215 &priv->lec_arp_empty_ones, next) { in lec_arp_check_empties()
2216 if (vcc == entry->vcc) { in lec_arp_check_empties()
2217 del_timer(&entry->timer); in lec_arp_check_empties()
2218 ether_addr_copy(entry->mac_addr, src); in lec_arp_check_empties()
2219 entry->status = ESI_FORWARD_DIRECT; in lec_arp_check_empties()
2220 entry->last_used = jiffies; in lec_arp_check_empties()
2222 tmp = lec_arp_find(priv, src); in lec_arp_check_empties()
2224 lec_arp_remove(priv, tmp); in lec_arp_check_empties()
2227 hlist_del(&entry->next); in lec_arp_check_empties()
2228 lec_arp_add(priv, entry); in lec_arp_check_empties()
2234 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_arp_check_empties()