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()
184 unsigned int len = skb->len; in lec_send()
186 ATM_SKB(skb)->vcc = vcc; in lec_send()
189 if (vcc->send(vcc, skb) < 0) { in lec_send()
190 dev->stats.tx_dropped++; in lec_send()
194 dev->stats.tx_packets++; in lec_send()
195 dev->stats.tx_bytes += len; in lec_send()
200 pr_info("%s\n", dev->name); in lec_tx_timeout()
209 struct lec_priv *priv = netdev_priv(dev); in lec_start_xmit() local
218 if (!priv->lecd) { in lec_start_xmit()
219 pr_info("%s:No lecd attached\n", dev->name); in lec_start_xmit()
220 dev->stats.tx_errors++; in lec_start_xmit()
227 (long)skb->head, (long)skb->data, (long)skb_tail_pointer(skb), in lec_start_xmit()
230 if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0) in lec_start_xmit()
248 lec_h = (struct lecdatahdr_8023 *)skb->data; in lec_start_xmit()
249 lec_h->le_header = htons(priv->lecid); in lec_start_xmit()
258 dev->name, skb->len, priv->lecid); in lec_start_xmit()
260 skb->data, min(skb->len, MAX_DUMP_SKB), true); in lec_start_xmit()
263 /* Minimum ethernet-frame size */ in lec_start_xmit()
265 if (skb->len < min_frame_size) { in lec_start_xmit()
266 if ((skb->len + skb_tailroom(skb)) < min_frame_size) { in lec_start_xmit()
268 min_frame_size - skb->truesize, in lec_start_xmit()
272 dev->stats.tx_dropped++; in lec_start_xmit()
277 skb_put(skb, min_frame_size - skb->len); in lec_start_xmit()
282 dst = lec_h->h_dest; in lec_start_xmit()
284 vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry); in lec_start_xmit()
286 dev->name, vcc, vcc ? vcc->flags : 0, entry); in lec_start_xmit()
287 if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) { in lec_start_xmit()
288 if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) { in lec_start_xmit()
290 dev->name, lec_h->h_dest); in lec_start_xmit()
291 skb_queue_tail(&entry->tx_wait, skb); in lec_start_xmit()
294 dev->name, lec_h->h_dest); in lec_start_xmit()
295 dev->stats.tx_dropped++; in lec_start_xmit()
302 dev->name, vcc->vpi, vcc->vci); in lec_start_xmit()
305 while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { in lec_start_xmit()
306 pr_debug("emptying tx queue, MAC address %pM\n", lec_h->h_dest); in lec_start_xmit()
315 vpriv->xoff = 1; in lec_start_xmit()
319 * vcc->pop() might have occurred in between, making in lec_start_xmit()
321 * this is the only situation we have to re-test. in lec_start_xmit()
346 struct net_device *dev = (struct net_device *)vcc->proto_data; in lec_atm_send()
347 struct lec_priv *priv = netdev_priv(dev); in lec_atm_send() local
352 WARN_ON(refcount_sub_and_test(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc)); in lec_atm_send()
353 mesg = (struct atmlec_msg *)skb->data; in lec_atm_send()
354 tmp = skb->data; in lec_atm_send()
356 pr_debug("%s: msg from zeppelin:%d\n", dev->name, mesg->type); in lec_atm_send()
357 switch (mesg->type) { in lec_atm_send()
359 eth_hw_addr_set(dev, mesg->content.normal.mac_addr); in lec_atm_send()
365 lec_addr_delete(priv, mesg->content.normal.atm_addr, in lec_atm_send()
366 mesg->content.normal.flag); in lec_atm_send()
369 priv->topology_change = mesg->content.normal.flag; in lec_atm_send()
372 lec_flush_complete(priv, mesg->content.normal.flag); in lec_atm_send()
375 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_atm_send()
376 entry = lec_arp_find(priv, mesg->content.normal.mac_addr); in lec_atm_send()
377 lec_arp_remove(priv, entry); in lec_atm_send()
378 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_atm_send()
380 if (mesg->content.normal.no_source_le_narp) in lec_atm_send()
384 lec_arp_update(priv, mesg->content.normal.mac_addr, in lec_atm_send()
385 mesg->content.normal.atm_addr, in lec_atm_send()
386 mesg->content.normal.flag, in lec_atm_send()
387 mesg->content.normal.targetless_le_arp); in lec_atm_send()
389 if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */ in lec_atm_send()
391 mesg->sizeoftlvs); in lec_atm_send()
392 lane2_associate_ind(dev, mesg->content.normal.mac_addr, in lec_atm_send()
393 tmp, mesg->sizeoftlvs); in lec_atm_send()
397 priv->maximum_unknown_frame_count = in lec_atm_send()
398 mesg->content.config.maximum_unknown_frame_count; in lec_atm_send()
399 priv->max_unknown_frame_time = in lec_atm_send()
400 (mesg->content.config.max_unknown_frame_time * HZ); in lec_atm_send()
401 priv->max_retry_count = mesg->content.config.max_retry_count; in lec_atm_send()
402 priv->aging_time = (mesg->content.config.aging_time * HZ); in lec_atm_send()
403 priv->forward_delay_time = in lec_atm_send()
404 (mesg->content.config.forward_delay_time * HZ); in lec_atm_send()
405 priv->arp_response_time = in lec_atm_send()
406 (mesg->content.config.arp_response_time * HZ); in lec_atm_send()
407 priv->flush_timeout = (mesg->content.config.flush_timeout * HZ); in lec_atm_send()
408 priv->path_switching_delay = in lec_atm_send()
409 (mesg->content.config.path_switching_delay * HZ); in lec_atm_send()
410 priv->lane_version = mesg->content.config.lane_version; in lec_atm_send()
412 priv->lane2_ops = NULL; in lec_atm_send()
413 if (priv->lane_version > 1) in lec_atm_send()
414 priv->lane2_ops = &lane2_ops; in lec_atm_send()
416 if (dev_set_mtu(dev, mesg->content.config.mtu)) in lec_atm_send()
418 dev->name, mesg->content.config.mtu); in lec_atm_send()
420 priv->is_proxy = mesg->content.config.is_proxy; in lec_atm_send()
423 lec_set_flush_tran_id(priv, mesg->content.normal.atm_addr, in lec_atm_send()
424 mesg->content.normal.flag); in lec_atm_send()
427 priv->lecid = in lec_atm_send()
428 (unsigned short)(0xffff & mesg->content.normal.flag); in lec_atm_send()
434 dev->name, mesg->content.proxy.mac_addr); in lec_atm_send()
439 if (br_fdb_test_addr_hook(dev, mesg->content.proxy.mac_addr)) { in lec_atm_send()
442 struct sock *sk; in lec_atm_send()
445 dev->name); in lec_atm_send()
449 skb2->len = sizeof(struct atmlec_msg); in lec_atm_send()
451 atm_force_charge(priv->lecd, skb2->truesize); in lec_atm_send()
452 sk = sk_atm(priv->lecd); in lec_atm_send()
453 skb_queue_tail(&sk->sk_receive_queue, skb2); in lec_atm_send()
454 sk->sk_data_ready(sk); in lec_atm_send()
460 pr_info("%s: Unknown message type %d\n", dev->name, mesg->type); in lec_atm_send()
462 return -EINVAL; in lec_atm_send()
471 struct net_device *dev = (struct net_device *)vcc->proto_data; in lec_atm_close()
472 struct lec_priv *priv = netdev_priv(dev); in lec_atm_close() local
474 priv->lecd = NULL; in lec_atm_close()
478 lec_arp_destroy(priv); in lec_atm_close()
480 if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) in lec_atm_close()
481 pr_info("%s closing with messages pending\n", dev->name); in lec_atm_close()
482 while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue))) { in lec_atm_close()
483 atm_return(vcc, skb->truesize); in lec_atm_close()
487 pr_info("%s: Shut down!\n", dev->name); in lec_atm_close()
508 send_to_lecd(struct lec_priv *priv, atmlec_msg_type type, in send_to_lecd() argument
512 struct sock *sk; in send_to_lecd()
516 if (!priv || !priv->lecd) in send_to_lecd()
517 return -1; in send_to_lecd()
520 return -1; in send_to_lecd()
521 skb->len = sizeof(struct atmlec_msg); in send_to_lecd()
522 mesg = (struct atmlec_msg *)skb->data; in send_to_lecd()
524 mesg->type = type; in send_to_lecd()
526 mesg->sizeoftlvs = data->len; in send_to_lecd()
528 ether_addr_copy(mesg->content.normal.mac_addr, mac_addr); in send_to_lecd()
530 mesg->content.normal.targetless_le_arp = 1; in send_to_lecd()
532 memcpy(&mesg->content.normal.atm_addr, atm_addr, ATM_ESA_LEN); in send_to_lecd()
534 atm_force_charge(priv->lecd, skb->truesize); in send_to_lecd()
535 sk = sk_atm(priv->lecd); in send_to_lecd()
536 skb_queue_tail(&sk->sk_receive_queue, skb); in send_to_lecd()
537 sk->sk_data_ready(sk); in send_to_lecd()
540 pr_debug("about to send %d bytes of data\n", data->len); in send_to_lecd()
541 atm_force_charge(priv->lecd, data->truesize); in send_to_lecd()
542 skb_queue_tail(&sk->sk_receive_queue, data); in send_to_lecd()
543 sk->sk_data_ready(sk); in send_to_lecd()
577 return ((vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8023) || in lec_is_data_direct()
578 (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025)); in lec_is_data_direct()
584 struct net_device *dev = (struct net_device *)vcc->proto_data; in lec_push()
585 struct lec_priv *priv = netdev_priv(dev); in lec_push() local
589 dev->name, vcc->vpi, vcc->vci); in lec_push()
592 pr_debug("%s: null skb\n", dev->name); in lec_push()
593 lec_vcc_close(priv, vcc); in lec_push()
603 dev->name, skb->len, priv->lecid); in lec_push()
605 skb->data, min(MAX_SKB_DUMP, skb->len), true); in lec_push()
607 if (memcmp(skb->data, lec_ctrl_magic, 4) == 0) { in lec_push()
609 struct sock *sk = sk_atm(vcc); in lec_push()
611 pr_debug("%s: To daemon\n", dev->name); in lec_push()
612 skb_queue_tail(&sk->sk_receive_queue, skb); in lec_push()
613 sk->sk_data_ready(sk); in lec_push()
618 atm_return(vcc, skb->truesize); in lec_push()
619 if (*(__be16 *) skb->data == htons(priv->lecid) || in lec_push()
620 !priv->lecd || !(dev->flags & IFF_UP)) { in lec_push()
629 dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest; in lec_push()
635 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_push()
637 src = ((struct lecdatahdr_8023 *)skb->data)->h_source; in lec_push()
638 entry = lec_arp_find(priv, src); in lec_push()
639 if (entry && entry->vcc != vcc) { in lec_push()
640 lec_arp_remove(priv, entry); in lec_push()
644 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_push()
647 !priv->is_proxy && /* Proxy wants all the packets */ in lec_push()
648 memcmp(dst, dev->dev_addr, dev->addr_len)) { in lec_push()
652 if (!hlist_empty(&priv->lec_arp_empty_ones)) in lec_push()
653 lec_arp_check_empties(priv, vcc, skb); in lec_push()
655 skb->protocol = eth_type_trans(skb, dev); in lec_push()
656 dev->stats.rx_packets++; in lec_push()
657 dev->stats.rx_bytes += skb->len; in lec_push()
666 struct net_device *dev = skb->dev; in lec_pop()
673 vpriv->old_pop(vcc, skb); in lec_pop()
675 if (vpriv->xoff && atm_may_send(vcc, 0)) { in lec_pop()
676 vpriv->xoff = 0; in lec_pop()
693 return -EINVAL; in lec_vcc_attach()
696 return -EINVAL; in lec_vcc_attach()
699 return -ENOMEM; in lec_vcc_attach()
700 vpriv->xoff = 0; in lec_vcc_attach()
701 vpriv->old_pop = vcc->pop; in lec_vcc_attach()
702 vcc->user_back = vpriv; in lec_vcc_attach()
703 vcc->pop = lec_pop; in lec_vcc_attach()
705 &ioc_data, vcc, vcc->push); in lec_vcc_attach()
706 vcc->proto_data = dev_lec[ioc_data.dev_num]; in lec_vcc_attach()
707 vcc->push = lec_push; in lec_vcc_attach()
714 return -EINVAL; in lec_mcast_attach()
717 return -EINVAL; in lec_mcast_attach()
718 vcc->proto_data = dev_lec[arg]; in lec_mcast_attach()
726 struct lec_priv *priv; in lecd_attach() local
731 return -EINVAL; in lecd_attach()
739 return -ENOMEM; in lecd_attach()
740 dev_lec[i]->netdev_ops = &lec_netdev_ops; in lecd_attach()
741 dev_lec[i]->max_mtu = 18190; in lecd_attach()
742 snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i); in lecd_attach()
745 return -EINVAL; in lecd_attach()
748 priv = netdev_priv(dev_lec[i]); in lecd_attach()
750 priv = netdev_priv(dev_lec[i]); in lecd_attach()
751 if (priv->lecd) in lecd_attach()
752 return -EADDRINUSE; in lecd_attach()
754 lec_arp_init(priv); in lecd_attach()
755 priv->itfnum = i; /* LANE2 addition */ in lecd_attach()
756 priv->lecd = vcc; in lecd_attach()
757 vcc->dev = &lecatm_dev; in lecd_attach()
760 vcc->proto_data = dev_lec[i]; in lecd_attach()
761 set_bit(ATM_VF_META, &vcc->flags); in lecd_attach()
762 set_bit(ATM_VF_READY, &vcc->flags); in lecd_attach()
765 priv->maximum_unknown_frame_count = 1; in lecd_attach()
766 priv->max_unknown_frame_time = (1 * HZ); in lecd_attach()
767 priv->vcc_timeout_period = (1200 * HZ); in lecd_attach()
768 priv->max_retry_count = 1; in lecd_attach()
769 priv->aging_time = (300 * HZ); in lecd_attach()
770 priv->forward_delay_time = (15 * HZ); in lecd_attach()
771 priv->topology_change = 0; in lecd_attach()
772 priv->arp_response_time = (1 * HZ); in lecd_attach()
773 priv->flush_timeout = (4 * HZ); in lecd_attach()
774 priv->path_switching_delay = (6 * HZ); in lecd_attach()
776 if (dev_lec[i]->flags & IFF_UP) in lecd_attach()
801 seq_printf(seq, "%pM ", entry->mac_addr); in lec_info()
802 seq_printf(seq, "%*phN ", ATM_ESA_LEN, entry->atm_addr); in lec_info()
803 seq_printf(seq, "%s %4.4x", lec_arp_get_status_string(entry->status), in lec_info()
804 entry->flags & 0xffff); in lec_info()
805 if (entry->vcc) in lec_info()
806 seq_printf(seq, "%3d %3d ", entry->vcc->vpi, entry->vcc->vci); in lec_info()
809 if (entry->recv_vcc) { in lec_info()
810 seq_printf(seq, " %3d %3d", entry->recv_vcc->vpi, in lec_info()
811 entry->recv_vcc->vci); in lec_info()
829 struct hlist_node *e = state->node; in lec_tbl_walk()
832 e = tbl->first; in lec_tbl_walk()
834 e = tbl->first; in lec_tbl_walk()
835 --*l; in lec_tbl_walk()
838 for (; e; e = e->next) { in lec_tbl_walk()
839 if (--*l < 0) in lec_tbl_walk()
842 state->node = e; in lec_tbl_walk()
848 struct lec_priv *priv) in lec_arp_walk() argument
853 for (p = state->arp_table; p < LEC_ARP_TABLE_SIZE; p++) { in lec_arp_walk()
854 v = lec_tbl_walk(state, &priv->lec_arp_tables[p], l); in lec_arp_walk()
858 state->arp_table = p; in lec_arp_walk()
863 struct lec_priv *priv) in lec_misc_walk() argument
866 &priv->lec_arp_empty_ones, in lec_misc_walk()
867 &priv->lec_no_forward, in lec_misc_walk()
868 &priv->mcast_fwds in lec_misc_walk()
873 for (q = state->misc_table; q < ARRAY_SIZE(lec_misc_tables); q++) { in lec_misc_walk()
878 state->misc_table = q; in lec_misc_walk()
883 struct lec_priv *priv) in lec_priv_walk() argument
885 if (!state->locked) { in lec_priv_walk()
886 state->locked = priv; in lec_priv_walk()
887 spin_lock_irqsave(&priv->lec_arp_lock, state->flags); in lec_priv_walk()
889 if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) { in lec_priv_walk()
890 spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags); in lec_priv_walk()
891 state->locked = NULL; in lec_priv_walk()
893 state->arp_table = state->misc_table = 0; in lec_priv_walk()
895 return state->locked; in lec_priv_walk()
903 dev = state->dev ? state->dev : dev_lec[state->itf]; in lec_itf_walk()
911 state->dev = dev; in lec_itf_walk()
919 for (; state->itf < MAX_LEC_ITF; state->itf++) { in lec_get_idx()
929 struct lec_state *state = seq->private; in lec_seq_start()
931 state->itf = 0; in lec_seq_start()
932 state->dev = NULL; in lec_seq_start()
933 state->locked = NULL; in lec_seq_start()
934 state->arp_table = 0; in lec_seq_start()
935 state->misc_table = 0; in lec_seq_start()
936 state->node = SEQ_START_TOKEN; in lec_seq_start()
943 struct lec_state *state = seq->private; in lec_seq_stop()
945 if (state->dev) { in lec_seq_stop()
946 spin_unlock_irqrestore(&state->locked->lec_arp_lock, in lec_seq_stop()
947 state->flags); in lec_seq_stop()
948 dev_put(state->dev); in lec_seq_stop()
954 struct lec_state *state = seq->private; in lec_seq_next()
970 struct lec_state *state = seq->private; in lec_seq_show()
971 struct net_device *dev = state->dev; in lec_seq_show()
972 struct lec_arp_table *entry = hlist_entry(state->node, in lec_seq_show()
976 seq_printf(seq, "%s ", dev->name); in lec_seq_show()
990 static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) in lane_ioctl() argument
992 struct atm_vcc *vcc = ATM_SD(sock); in lane_ioctl()
1000 return -EPERM; in lane_ioctl()
1003 return -ENOIOCTLCMD; in lane_ioctl()
1010 sock->state = SS_CONNECTED; in lane_ioctl()
1037 return -ENOMEM; in lane_module_init()
1079 struct lec_priv *priv = netdev_priv(dev); in lane2_resolve() local
1085 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lane2_resolve()
1086 table = lec_arp_find(priv, dst_mac); in lane2_resolve()
1087 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lane2_resolve()
1089 return -1; in lane2_resolve()
1091 *tlvs = kmemdup(table->tlvs, table->sizeoftlvs, GFP_ATOMIC); in lane2_resolve()
1093 return -1; in lane2_resolve()
1095 *sizeoftlvs = table->sizeoftlvs; in lane2_resolve()
1101 retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, NULL); in lane2_resolve()
1106 return -1; in lane2_resolve()
1107 skb->len = *sizeoftlvs; in lane2_resolve()
1109 retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, skb); in lane2_resolve()
1126 struct lec_priv *priv = netdev_priv(dev); in lane2_associate_req() local
1128 if (!ether_addr_equal(lan_dst, dev->dev_addr)) in lane2_associate_req()
1131 kfree(priv->tlvs); /* NULL if there was no previous association */ in lane2_associate_req()
1133 priv->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL); in lane2_associate_req()
1134 if (priv->tlvs == NULL) in lane2_associate_req()
1136 priv->sizeoftlvs = sizeoftlvs; in lane2_associate_req()
1141 skb->len = sizeoftlvs; in lane2_associate_req()
1143 retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb); in lane2_associate_req()
1163 struct lec_priv *priv = netdev_priv(dev); in lane2_associate_ind() local
1170 struct lec_arp_table *entry = lec_arp_find(priv, mac_addr); in lane2_associate_ind()
1175 kfree(entry->tlvs); in lane2_associate_ind()
1177 entry->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL); in lane2_associate_ind()
1178 if (entry->tlvs == NULL) in lane2_associate_ind()
1180 entry->sizeoftlvs = sizeoftlvs; in lane2_associate_ind()
1192 if (priv->lane2_ops && priv->lane2_ops->associate_indicator) { in lane2_associate_ind()
1193 priv->lane2_ops->associate_indicator(dev, mac_addr, in lane2_associate_ind()
1229 #define HASH(ch) (ch & (LEC_ARP_TABLE_SIZE - 1))
1232 * Initialization of arp-cache
1234 static void lec_arp_init(struct lec_priv *priv) in lec_arp_init() argument
1239 INIT_HLIST_HEAD(&priv->lec_arp_tables[i]); in lec_arp_init()
1240 INIT_HLIST_HEAD(&priv->lec_arp_empty_ones); in lec_arp_init()
1241 INIT_HLIST_HEAD(&priv->lec_no_forward); in lec_arp_init()
1242 INIT_HLIST_HEAD(&priv->mcast_fwds); in lec_arp_init()
1243 spin_lock_init(&priv->lec_arp_lock); in lec_arp_init()
1244 INIT_DELAYED_WORK(&priv->lec_arp_work, lec_arp_check_expire); in lec_arp_init()
1245 schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL); in lec_arp_init()
1250 if (entry->vcc) { in lec_arp_clear_vccs()
1251 struct atm_vcc *vcc = entry->vcc; in lec_arp_clear_vccs()
1253 struct net_device *dev = (struct net_device *)vcc->proto_data; in lec_arp_clear_vccs()
1255 vcc->pop = vpriv->old_pop; in lec_arp_clear_vccs()
1256 if (vpriv->xoff) in lec_arp_clear_vccs()
1259 vcc->user_back = NULL; in lec_arp_clear_vccs()
1260 vcc->push = entry->old_push; in lec_arp_clear_vccs()
1261 vcc_release_async(vcc, -EPIPE); in lec_arp_clear_vccs()
1262 entry->vcc = NULL; in lec_arp_clear_vccs()
1264 if (entry->recv_vcc) { in lec_arp_clear_vccs()
1265 struct atm_vcc *vcc = entry->recv_vcc; in lec_arp_clear_vccs()
1269 vcc->user_back = NULL; in lec_arp_clear_vccs()
1271 entry->recv_vcc->push = entry->old_recv_push; in lec_arp_clear_vccs()
1272 vcc_release_async(entry->recv_vcc, -EPIPE); in lec_arp_clear_vccs()
1273 entry->recv_vcc = NULL; in lec_arp_clear_vccs()
1282 lec_arp_add(struct lec_priv *priv, struct lec_arp_table *entry) in lec_arp_add() argument
1286 tmp = &priv->lec_arp_tables[HASH(entry->mac_addr[ETH_ALEN - 1])]; in lec_arp_add()
1287 hlist_add_head(&entry->next, tmp); in lec_arp_add()
1289 pr_debug("Added entry:%pM\n", entry->mac_addr); in lec_arp_add()
1296 lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove) in lec_arp_remove() argument
1302 return -1; in lec_arp_remove()
1304 hlist_del(&to_remove->next); in lec_arp_remove()
1305 del_timer(&to_remove->timer); in lec_arp_remove()
1311 if (to_remove->status >= ESI_FLUSH_PENDING) { in lec_arp_remove()
1317 &priv->lec_arp_tables[i], next) { in lec_arp_remove()
1318 if (memcmp(to_remove->atm_addr, in lec_arp_remove()
1319 entry->atm_addr, ATM_ESA_LEN) == 0) { in lec_arp_remove()
1328 skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */ in lec_arp_remove()
1330 pr_debug("Removed entry:%pM\n", to_remove->mac_addr); in lec_arp_remove()
1352 static void dump_arp_table(struct lec_priv *priv) in dump_arp_table() argument
1358 pr_info("Dump %p:\n", priv); in dump_arp_table()
1361 &priv->lec_arp_tables[i], next) { in dump_arp_table()
1365 rulla->mac_addr); in dump_arp_table()
1367 rulla->atm_addr); in dump_arp_table()
1370 rulla->vcc ? rulla->vcc->vpi : 0, in dump_arp_table()
1371 rulla->vcc ? rulla->vcc->vci : 0, in dump_arp_table()
1372 rulla->recv_vcc ? rulla->recv_vcc-> in dump_arp_table()
1374 rulla->recv_vcc ? rulla->recv_vcc-> in dump_arp_table()
1375 vci : 0, rulla->last_used, in dump_arp_table()
1376 rulla->timestamp, rulla->no_tries); in dump_arp_table()
1380 rulla->flags, rulla->packets_flooded, in dump_arp_table()
1381 get_status_string(rulla->status)); in dump_arp_table()
1386 if (!hlist_empty(&priv->lec_no_forward)) in dump_arp_table()
1388 hlist_for_each_entry(rulla, &priv->lec_no_forward, next) { in dump_arp_table()
1390 offset += sprintf(buf + offset, "Mac: %pM ", rulla->mac_addr); in dump_arp_table()
1392 rulla->atm_addr); in dump_arp_table()
1395 rulla->vcc ? rulla->vcc->vpi : 0, in dump_arp_table()
1396 rulla->vcc ? rulla->vcc->vci : 0, in dump_arp_table()
1397 rulla->recv_vcc ? rulla->recv_vcc->vpi : 0, in dump_arp_table()
1398 rulla->recv_vcc ? rulla->recv_vcc->vci : 0, in dump_arp_table()
1399 rulla->last_used, in dump_arp_table()
1400 rulla->timestamp, rulla->no_tries); in dump_arp_table()
1403 rulla->flags, rulla->packets_flooded, in dump_arp_table()
1404 get_status_string(rulla->status)); in dump_arp_table()
1408 if (!hlist_empty(&priv->lec_arp_empty_ones)) in dump_arp_table()
1410 hlist_for_each_entry(rulla, &priv->lec_arp_empty_ones, next) { in dump_arp_table()
1412 offset += sprintf(buf + offset, "Mac: %pM ", rulla->mac_addr); in dump_arp_table()
1414 rulla->atm_addr); in dump_arp_table()
1417 rulla->vcc ? rulla->vcc->vpi : 0, in dump_arp_table()
1418 rulla->vcc ? rulla->vcc->vci : 0, in dump_arp_table()
1419 rulla->recv_vcc ? rulla->recv_vcc->vpi : 0, in dump_arp_table()
1420 rulla->recv_vcc ? rulla->recv_vcc->vci : 0, in dump_arp_table()
1421 rulla->last_used, in dump_arp_table()
1422 rulla->timestamp, rulla->no_tries); in dump_arp_table()
1425 rulla->flags, rulla->packets_flooded, in dump_arp_table()
1426 get_status_string(rulla->status)); in dump_arp_table()
1430 if (!hlist_empty(&priv->mcast_fwds)) in dump_arp_table()
1432 hlist_for_each_entry(rulla, &priv->mcast_fwds, next) { in dump_arp_table()
1434 offset += sprintf(buf + offset, "Mac: %pM ", rulla->mac_addr); in dump_arp_table()
1436 rulla->atm_addr); in dump_arp_table()
1439 rulla->vcc ? rulla->vcc->vpi : 0, in dump_arp_table()
1440 rulla->vcc ? rulla->vcc->vci : 0, in dump_arp_table()
1441 rulla->recv_vcc ? rulla->recv_vcc->vpi : 0, in dump_arp_table()
1442 rulla->recv_vcc ? rulla->recv_vcc->vci : 0, in dump_arp_table()
1443 rulla->last_used, in dump_arp_table()
1444 rulla->timestamp, rulla->no_tries); in dump_arp_table()
1447 rulla->flags, rulla->packets_flooded, in dump_arp_table()
1448 get_status_string(rulla->status)); in dump_arp_table()
1454 #define dump_arp_table(priv) do { } while (0) argument
1458 * Destruction of arp-cache
1460 static void lec_arp_destroy(struct lec_priv *priv) in lec_arp_destroy() argument
1467 cancel_delayed_work_sync(&priv->lec_arp_work); in lec_arp_destroy()
1473 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_arp_destroy()
1476 &priv->lec_arp_tables[i], next) { in lec_arp_destroy()
1477 lec_arp_remove(priv, entry); in lec_arp_destroy()
1480 INIT_HLIST_HEAD(&priv->lec_arp_tables[i]); in lec_arp_destroy()
1484 &priv->lec_arp_empty_ones, next) { in lec_arp_destroy()
1485 del_timer_sync(&entry->timer); in lec_arp_destroy()
1487 hlist_del(&entry->next); in lec_arp_destroy()
1490 INIT_HLIST_HEAD(&priv->lec_arp_empty_ones); in lec_arp_destroy()
1493 &priv->lec_no_forward, next) { in lec_arp_destroy()
1494 del_timer_sync(&entry->timer); in lec_arp_destroy()
1496 hlist_del(&entry->next); in lec_arp_destroy()
1499 INIT_HLIST_HEAD(&priv->lec_no_forward); in lec_arp_destroy()
1501 hlist_for_each_entry_safe(entry, next, &priv->mcast_fwds, next) { in lec_arp_destroy()
1504 hlist_del(&entry->next); in lec_arp_destroy()
1507 INIT_HLIST_HEAD(&priv->mcast_fwds); in lec_arp_destroy()
1508 priv->mcast_vcc = NULL; in lec_arp_destroy()
1509 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_arp_destroy()
1515 static struct lec_arp_table *lec_arp_find(struct lec_priv *priv, in lec_arp_find() argument
1523 head = &priv->lec_arp_tables[HASH(mac_addr[ETH_ALEN - 1])]; in lec_arp_find()
1525 if (ether_addr_equal(mac_addr, entry->mac_addr)) in lec_arp_find()
1531 static struct lec_arp_table *make_entry(struct lec_priv *priv, in make_entry() argument
1539 ether_addr_copy(to_return->mac_addr, mac_addr); in make_entry()
1540 INIT_HLIST_NODE(&to_return->next); in make_entry()
1541 timer_setup(&to_return->timer, lec_arp_expire_arp, 0); in make_entry()
1542 to_return->last_used = jiffies; in make_entry()
1543 to_return->priv = priv; in make_entry()
1544 skb_queue_head_init(&to_return->tx_wait); in make_entry()
1545 refcount_set(&to_return->usage, 1); in make_entry()
1557 if (entry->status == ESI_ARP_PENDING) { in lec_arp_expire_arp()
1558 if (entry->no_tries <= entry->priv->max_retry_count) { in lec_arp_expire_arp()
1559 if (entry->is_rdesc) in lec_arp_expire_arp()
1560 send_to_lecd(entry->priv, l_rdesc_arp_xmt, in lec_arp_expire_arp()
1561 entry->mac_addr, NULL, NULL); in lec_arp_expire_arp()
1563 send_to_lecd(entry->priv, l_arp_xmt, in lec_arp_expire_arp()
1564 entry->mac_addr, NULL, NULL); in lec_arp_expire_arp()
1565 entry->no_tries++; in lec_arp_expire_arp()
1567 mod_timer(&entry->timer, jiffies + (1 * HZ)); in lec_arp_expire_arp()
1576 struct lec_priv *priv = to_remove->priv; in lec_arp_expire_vcc() local
1578 del_timer(&to_remove->timer); in lec_arp_expire_vcc()
1581 to_remove, priv, in lec_arp_expire_vcc()
1582 to_remove->vcc ? to_remove->recv_vcc->vpi : 0, in lec_arp_expire_vcc()
1583 to_remove->vcc ? to_remove->recv_vcc->vci : 0); in lec_arp_expire_vcc()
1585 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_arp_expire_vcc()
1586 hlist_del(&to_remove->next); in lec_arp_expire_vcc()
1587 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_arp_expire_vcc()
1595 struct lec_priv *priv) in __lec_arp_check_expire() argument
1599 if ((entry->flags) & LEC_REMOTE_FLAG && priv->topology_change) in __lec_arp_check_expire()
1600 time_to_check = priv->forward_delay_time; in __lec_arp_check_expire()
1602 time_to_check = priv->aging_time; in __lec_arp_check_expire()
1604 pr_debug("About to expire: %lx - %lx > %lx\n", in __lec_arp_check_expire()
1605 now, entry->last_used, time_to_check); in __lec_arp_check_expire()
1606 if (time_after(now, entry->last_used + time_to_check) && in __lec_arp_check_expire()
1607 !(entry->flags & LEC_PERMANENT_FLAG) && in __lec_arp_check_expire()
1608 !(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */ in __lec_arp_check_expire()
1611 lec_arp_remove(priv, entry); in __lec_arp_check_expire()
1615 if ((entry->status == ESI_VC_PENDING || in __lec_arp_check_expire()
1616 entry->status == ESI_ARP_PENDING) && in __lec_arp_check_expire()
1617 time_after_eq(now, entry->timestamp + in __lec_arp_check_expire()
1618 priv->max_unknown_frame_time)) { in __lec_arp_check_expire()
1619 entry->timestamp = jiffies; in __lec_arp_check_expire()
1620 entry->packets_flooded = 0; in __lec_arp_check_expire()
1621 if (entry->status == ESI_VC_PENDING) in __lec_arp_check_expire()
1622 send_to_lecd(priv, l_svc_setup, in __lec_arp_check_expire()
1623 entry->mac_addr, in __lec_arp_check_expire()
1624 entry->atm_addr, in __lec_arp_check_expire()
1627 if (entry->status == ESI_FLUSH_PENDING && in __lec_arp_check_expire()
1628 time_after_eq(now, entry->timestamp + in __lec_arp_check_expire()
1629 priv->path_switching_delay)) { in __lec_arp_check_expire()
1639 * 1. Re-set timer
1656 struct lec_priv *priv = in lec_arp_check_expire() local
1663 pr_debug("%p\n", priv); in lec_arp_check_expire()
1666 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_arp_check_expire()
1669 &priv->lec_arp_tables[i], next) { in lec_arp_check_expire()
1670 if (__lec_arp_check_expire(entry, now, priv)) { in lec_arp_check_expire()
1672 struct atm_vcc *vcc = entry->vcc; in lec_arp_check_expire()
1674 spin_unlock_irqrestore(&priv->lec_arp_lock, in lec_arp_check_expire()
1676 while ((skb = skb_dequeue(&entry->tx_wait))) in lec_arp_check_expire()
1678 entry->last_used = jiffies; in lec_arp_check_expire()
1679 entry->status = ESI_FORWARD_DIRECT; in lec_arp_check_expire()
1686 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_arp_check_expire()
1688 schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL); in lec_arp_check_expire()
1695 static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv, in lec_arp_resolve() argument
1705 switch (priv->lane_version) { in lec_arp_resolve()
1707 return priv->mcast_vcc; in lec_arp_resolve()
1710 return priv->mcast_vcc; in lec_arp_resolve()
1717 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_arp_resolve()
1718 entry = lec_arp_find(priv, mac_to_find); in lec_arp_resolve()
1721 if (entry->status == ESI_FORWARD_DIRECT) { in lec_arp_resolve()
1723 entry->last_used = jiffies; in lec_arp_resolve()
1726 found = entry->vcc; in lec_arp_resolve()
1733 if (entry->status == ESI_ARP_PENDING) in lec_arp_resolve()
1734 entry->no_tries = 0; in lec_arp_resolve()
1741 if (entry->status != ESI_FLUSH_PENDING && in lec_arp_resolve()
1742 entry->packets_flooded < in lec_arp_resolve()
1743 priv->maximum_unknown_frame_count) { in lec_arp_resolve()
1744 entry->packets_flooded++; in lec_arp_resolve()
1746 found = priv->mcast_vcc; in lec_arp_resolve()
1750 * We got here because entry->status == ESI_FLUSH_PENDING in lec_arp_resolve()
1756 pr_debug("entry->status %d entry->vcc %p\n", entry->status, in lec_arp_resolve()
1757 entry->vcc); in lec_arp_resolve()
1761 entry = make_entry(priv, mac_to_find); in lec_arp_resolve()
1764 found = priv->mcast_vcc; in lec_arp_resolve()
1767 lec_arp_add(priv, entry); in lec_arp_resolve()
1768 /* We want arp-request(s) to be sent */ in lec_arp_resolve()
1769 entry->packets_flooded = 1; in lec_arp_resolve()
1770 entry->status = ESI_ARP_PENDING; in lec_arp_resolve()
1771 entry->no_tries = 1; in lec_arp_resolve()
1772 entry->last_used = entry->timestamp = jiffies; in lec_arp_resolve()
1773 entry->is_rdesc = is_rdesc; in lec_arp_resolve()
1774 if (entry->is_rdesc) in lec_arp_resolve()
1775 send_to_lecd(priv, l_rdesc_arp_xmt, mac_to_find, NULL, in lec_arp_resolve()
1778 send_to_lecd(priv, l_arp_xmt, mac_to_find, NULL, NULL); in lec_arp_resolve()
1779 entry->timer.expires = jiffies + (1 * HZ); in lec_arp_resolve()
1780 entry->timer.function = lec_arp_expire_arp; in lec_arp_resolve()
1781 add_timer(&entry->timer); in lec_arp_resolve()
1782 found = priv->mcast_vcc; in lec_arp_resolve()
1786 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_arp_resolve()
1791 lec_addr_delete(struct lec_priv *priv, const unsigned char *atm_addr, in lec_addr_delete() argument
1800 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_addr_delete()
1803 &priv->lec_arp_tables[i], next) { in lec_addr_delete()
1804 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN) && in lec_addr_delete()
1806 !(entry->flags & LEC_PERMANENT_FLAG))) { in lec_addr_delete()
1807 lec_arp_remove(priv, entry); in lec_addr_delete()
1810 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_addr_delete()
1814 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_addr_delete()
1815 return -1; in lec_addr_delete()
1822 lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr, in lec_arp_update() argument
1834 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_arp_update()
1835 entry = lec_arp_find(priv, mac_addr); in lec_arp_update()
1841 if (!hlist_empty(&priv->lec_arp_empty_ones)) { in lec_arp_update()
1843 &priv->lec_arp_empty_ones, next) { in lec_arp_update()
1844 if (memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN) == 0) { in lec_arp_update()
1845 hlist_del(&entry->next); in lec_arp_update()
1846 del_timer(&entry->timer); in lec_arp_update()
1847 tmp = lec_arp_find(priv, mac_addr); in lec_arp_update()
1849 del_timer(&tmp->timer); in lec_arp_update()
1850 tmp->status = ESI_FORWARD_DIRECT; in lec_arp_update()
1851 memcpy(tmp->atm_addr, atm_addr, ATM_ESA_LEN); in lec_arp_update()
1852 tmp->vcc = entry->vcc; in lec_arp_update()
1853 tmp->old_push = entry->old_push; in lec_arp_update()
1854 tmp->last_used = jiffies; in lec_arp_update()
1855 del_timer(&entry->timer); in lec_arp_update()
1859 entry->status = ESI_FORWARD_DIRECT; in lec_arp_update()
1860 ether_addr_copy(entry->mac_addr, in lec_arp_update()
1862 entry->last_used = jiffies; in lec_arp_update()
1863 lec_arp_add(priv, entry); in lec_arp_update()
1866 entry->flags |= LEC_REMOTE_FLAG; in lec_arp_update()
1868 entry->flags &= ~LEC_REMOTE_FLAG; in lec_arp_update()
1870 dump_arp_table(priv); in lec_arp_update()
1876 entry = lec_arp_find(priv, mac_addr); in lec_arp_update()
1878 entry = make_entry(priv, mac_addr); in lec_arp_update()
1881 entry->status = ESI_UNKNOWN; in lec_arp_update()
1882 lec_arp_add(priv, entry); in lec_arp_update()
1885 memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN); in lec_arp_update()
1886 del_timer(&entry->timer); in lec_arp_update()
1889 &priv->lec_arp_tables[i], next) { in lec_arp_update()
1891 !memcmp(tmp->atm_addr, atm_addr, ATM_ESA_LEN)) { in lec_arp_update()
1893 if (tmp->status > ESI_VC_PENDING) { in lec_arp_update()
1898 entry->vcc = tmp->vcc; in lec_arp_update()
1899 entry->old_push = tmp->old_push; in lec_arp_update()
1901 entry->status = tmp->status; in lec_arp_update()
1907 entry->flags |= LEC_REMOTE_FLAG; in lec_arp_update()
1909 entry->flags &= ~LEC_REMOTE_FLAG; in lec_arp_update()
1910 if (entry->status == ESI_ARP_PENDING || entry->status == ESI_UNKNOWN) { in lec_arp_update()
1911 entry->status = ESI_VC_PENDING; in lec_arp_update()
1912 send_to_lecd(priv, l_svc_setup, entry->mac_addr, atm_addr, NULL); in lec_arp_update()
1915 dump_arp_table(priv); in lec_arp_update()
1917 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_arp_update()
1924 lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data, in lec_vcc_added() argument
1932 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_vcc_added()
1934 if (ioc_data->receive == 2) { in lec_vcc_added()
1937 entry = lec_arp_find(priv, bus_mac); in lec_vcc_added()
1942 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); in lec_vcc_added()
1943 entry->recv_vcc = vcc; in lec_vcc_added()
1944 entry->old_recv_push = old_push; in lec_vcc_added()
1946 entry = make_entry(priv, bus_mac); in lec_vcc_added()
1949 del_timer(&entry->timer); in lec_vcc_added()
1950 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); in lec_vcc_added()
1951 entry->recv_vcc = vcc; in lec_vcc_added()
1952 entry->old_recv_push = old_push; in lec_vcc_added()
1953 hlist_add_head(&entry->next, &priv->mcast_fwds); in lec_vcc_added()
1955 } else if (ioc_data->receive == 1) { in lec_vcc_added()
1961 ATM_ESA_LEN, ioc_data->atm_addr); in lec_vcc_added()
1962 entry = make_entry(priv, bus_mac); in lec_vcc_added()
1965 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); in lec_vcc_added()
1966 eth_zero_addr(entry->mac_addr); in lec_vcc_added()
1967 entry->recv_vcc = vcc; in lec_vcc_added()
1968 entry->old_recv_push = old_push; in lec_vcc_added()
1969 entry->status = ESI_UNKNOWN; in lec_vcc_added()
1970 entry->timer.expires = jiffies + priv->vcc_timeout_period; in lec_vcc_added()
1971 entry->timer.function = lec_arp_expire_vcc; in lec_vcc_added()
1972 hlist_add_head(&entry->next, &priv->lec_no_forward); in lec_vcc_added()
1973 add_timer(&entry->timer); in lec_vcc_added()
1974 dump_arp_table(priv); in lec_vcc_added()
1978 ATM_ESA_LEN, ioc_data->atm_addr); in lec_vcc_added()
1981 &priv->lec_arp_tables[i], next) { in lec_vcc_added()
1983 (ioc_data->atm_addr, entry->atm_addr, in lec_vcc_added()
1986 pr_debug("Currently -> Vcc: %d, Rvcc:%d\n", in lec_vcc_added()
1987 entry->vcc ? entry->vcc->vci : 0, in lec_vcc_added()
1988 entry->recv_vcc ? entry->recv_vcc-> in lec_vcc_added()
1991 del_timer(&entry->timer); in lec_vcc_added()
1992 entry->vcc = vcc; in lec_vcc_added()
1993 entry->old_push = old_push; in lec_vcc_added()
1994 if (entry->status == ESI_VC_PENDING) { in lec_vcc_added()
1995 if (priv->maximum_unknown_frame_count in lec_vcc_added()
1997 entry->status = in lec_vcc_added()
2000 entry->timestamp = jiffies; in lec_vcc_added()
2001 entry->status = in lec_vcc_added()
2004 send_to_lecd(priv, l_flush_xmt, in lec_vcc_added()
2006 entry->atm_addr, in lec_vcc_added()
2029 dump_arp_table(priv); in lec_vcc_added()
2036 entry = make_entry(priv, bus_mac); in lec_vcc_added()
2039 entry->vcc = vcc; in lec_vcc_added()
2040 entry->old_push = old_push; in lec_vcc_added()
2041 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); in lec_vcc_added()
2042 eth_zero_addr(entry->mac_addr); in lec_vcc_added()
2043 entry->status = ESI_UNKNOWN; in lec_vcc_added()
2044 hlist_add_head(&entry->next, &priv->lec_arp_empty_ones); in lec_vcc_added()
2045 entry->timer.expires = jiffies + priv->vcc_timeout_period; in lec_vcc_added()
2046 entry->timer.function = lec_arp_expire_vcc; in lec_vcc_added()
2047 add_timer(&entry->timer); in lec_vcc_added()
2049 dump_arp_table(priv); in lec_vcc_added()
2051 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_vcc_added()
2054 static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id) in lec_flush_complete() argument
2062 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_flush_complete()
2065 &priv->lec_arp_tables[i], next) { in lec_flush_complete()
2066 if (entry->flush_tran_id == tran_id && in lec_flush_complete()
2067 entry->status == ESI_FLUSH_PENDING) { in lec_flush_complete()
2069 struct atm_vcc *vcc = entry->vcc; in lec_flush_complete()
2072 spin_unlock_irqrestore(&priv->lec_arp_lock, in lec_flush_complete()
2074 while ((skb = skb_dequeue(&entry->tx_wait))) in lec_flush_complete()
2076 entry->last_used = jiffies; in lec_flush_complete()
2077 entry->status = ESI_FORWARD_DIRECT; in lec_flush_complete()
2084 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_flush_complete()
2085 dump_arp_table(priv); in lec_flush_complete()
2089 lec_set_flush_tran_id(struct lec_priv *priv, in lec_set_flush_tran_id() argument
2096 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_set_flush_tran_id()
2099 &priv->lec_arp_tables[i], next) { in lec_set_flush_tran_id()
2100 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) { in lec_set_flush_tran_id()
2101 entry->flush_tran_id = tran_id; in lec_set_flush_tran_id()
2106 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_set_flush_tran_id()
2109 static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc) in lec_mcast_make() argument
2121 return -ENOMEM; in lec_mcast_make()
2122 vpriv->xoff = 0; in lec_mcast_make()
2123 vpriv->old_pop = vcc->pop; in lec_mcast_make()
2124 vcc->user_back = vpriv; in lec_mcast_make()
2125 vcc->pop = lec_pop; in lec_mcast_make()
2126 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_mcast_make()
2127 to_add = make_entry(priv, mac_addr); in lec_mcast_make()
2129 vcc->pop = vpriv->old_pop; in lec_mcast_make()
2131 err = -ENOMEM; in lec_mcast_make()
2134 memcpy(to_add->atm_addr, vcc->remote.sas_addr.prv, ATM_ESA_LEN); in lec_mcast_make()
2135 to_add->status = ESI_FORWARD_DIRECT; in lec_mcast_make()
2136 to_add->flags |= LEC_PERMANENT_FLAG; in lec_mcast_make()
2137 to_add->vcc = vcc; in lec_mcast_make()
2138 to_add->old_push = vcc->push; in lec_mcast_make()
2139 vcc->push = lec_push; in lec_mcast_make()
2140 priv->mcast_vcc = vcc; in lec_mcast_make()
2141 lec_arp_add(priv, to_add); in lec_mcast_make()
2143 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_mcast_make()
2147 static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc) in lec_vcc_close() argument
2154 pr_debug("LEC_ARP: lec_vcc_close vpi:%d vci:%d\n", vcc->vpi, vcc->vci); in lec_vcc_close()
2155 dump_arp_table(priv); in lec_vcc_close()
2157 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_vcc_close()
2161 &priv->lec_arp_tables[i], next) { in lec_vcc_close()
2162 if (vcc == entry->vcc) { in lec_vcc_close()
2163 lec_arp_remove(priv, entry); in lec_vcc_close()
2165 if (priv->mcast_vcc == vcc) in lec_vcc_close()
2166 priv->mcast_vcc = NULL; in lec_vcc_close()
2172 &priv->lec_arp_empty_ones, next) { in lec_vcc_close()
2173 if (entry->vcc == vcc) { in lec_vcc_close()
2175 del_timer(&entry->timer); in lec_vcc_close()
2176 hlist_del(&entry->next); in lec_vcc_close()
2182 &priv->lec_no_forward, next) { in lec_vcc_close()
2183 if (entry->recv_vcc == vcc) { in lec_vcc_close()
2185 del_timer(&entry->timer); in lec_vcc_close()
2186 hlist_del(&entry->next); in lec_vcc_close()
2191 hlist_for_each_entry_safe(entry, next, &priv->mcast_fwds, next) { in lec_vcc_close()
2192 if (entry->recv_vcc == vcc) { in lec_vcc_close()
2195 hlist_del(&entry->next); in lec_vcc_close()
2200 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_vcc_close()
2201 dump_arp_table(priv); in lec_vcc_close()
2205 lec_arp_check_empties(struct lec_priv *priv, in lec_arp_check_empties() argument
2211 struct lecdatahdr_8023 *hdr = (struct lecdatahdr_8023 *)skb->data; in lec_arp_check_empties()
2212 unsigned char *src = hdr->h_source; in lec_arp_check_empties()
2214 spin_lock_irqsave(&priv->lec_arp_lock, flags); in lec_arp_check_empties()
2216 &priv->lec_arp_empty_ones, next) { in lec_arp_check_empties()
2217 if (vcc == entry->vcc) { in lec_arp_check_empties()
2218 del_timer(&entry->timer); in lec_arp_check_empties()
2219 ether_addr_copy(entry->mac_addr, src); in lec_arp_check_empties()
2220 entry->status = ESI_FORWARD_DIRECT; in lec_arp_check_empties()
2221 entry->last_used = jiffies; in lec_arp_check_empties()
2223 tmp = lec_arp_find(priv, src); in lec_arp_check_empties()
2225 lec_arp_remove(priv, tmp); in lec_arp_check_empties()
2228 hlist_del(&entry->next); in lec_arp_check_empties()
2229 lec_arp_add(priv, entry); in lec_arp_check_empties()
2235 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); in lec_arp_check_empties()