Lines Matching refs:mrp

55 	struct br_mrp *mrp;  in br_mrp_find_id()  local
57 hlist_for_each_entry_rcu(mrp, &br->mrp_list, list, in br_mrp_find_id()
59 if (mrp->ring_id == ring_id) { in br_mrp_find_id()
60 res = mrp; in br_mrp_find_id()
71 struct br_mrp *mrp; in br_mrp_find_in_id() local
73 hlist_for_each_entry_rcu(mrp, &br->mrp_list, list, in br_mrp_find_in_id()
75 if (mrp->in_id == in_id) { in br_mrp_find_in_id()
76 res = mrp; in br_mrp_find_in_id()
86 struct br_mrp *mrp; in br_mrp_unique_ifindex() local
88 hlist_for_each_entry_rcu(mrp, &br->mrp_list, list, in br_mrp_unique_ifindex()
92 p = rtnl_dereference(mrp->p_port); in br_mrp_unique_ifindex()
96 p = rtnl_dereference(mrp->s_port); in br_mrp_unique_ifindex()
100 p = rtnl_dereference(mrp->i_port); in br_mrp_unique_ifindex()
112 struct br_mrp *mrp; in br_mrp_find_port() local
114 hlist_for_each_entry_rcu(mrp, &br->mrp_list, list, in br_mrp_find_port()
116 if (rcu_access_pointer(mrp->p_port) == p || in br_mrp_find_port()
117 rcu_access_pointer(mrp->s_port) == p || in br_mrp_find_port()
118 rcu_access_pointer(mrp->i_port) == p) { in br_mrp_find_port()
119 res = mrp; in br_mrp_find_port()
127 static int br_mrp_next_seq(struct br_mrp *mrp) in br_mrp_next_seq() argument
129 mrp->seq_id++; in br_mrp_next_seq()
130 return mrp->seq_id; in br_mrp_next_seq()
171 static void br_mrp_skb_common(struct sk_buff *skb, struct br_mrp *mrp) in br_mrp_skb_common() argument
178 hdr->seq_id = cpu_to_be16(br_mrp_next_seq(mrp)); in br_mrp_skb_common()
182 static struct sk_buff *br_mrp_alloc_test_skb(struct br_mrp *mrp, in br_mrp_alloc_test_skb() argument
199 hdr->prio = cpu_to_be16(mrp->prio); in br_mrp_alloc_test_skb()
202 hdr->state = cpu_to_be16(mrp->ring_state); in br_mrp_alloc_test_skb()
203 hdr->transitions = cpu_to_be16(mrp->ring_transitions); in br_mrp_alloc_test_skb()
206 br_mrp_skb_common(skb, mrp); in br_mrp_alloc_test_skb()
212 if (mrp->ring_role == BR_MRP_RING_ROLE_MRA) { in br_mrp_alloc_test_skb()
239 static struct sk_buff *br_mrp_alloc_in_test_skb(struct br_mrp *mrp, in br_mrp_alloc_in_test_skb() argument
256 hdr->id = cpu_to_be16(mrp->in_id); in br_mrp_alloc_in_test_skb()
259 hdr->state = cpu_to_be16(mrp->in_state); in br_mrp_alloc_in_test_skb()
260 hdr->transitions = cpu_to_be16(mrp->in_transitions); in br_mrp_alloc_in_test_skb()
263 br_mrp_skb_common(skb, mrp); in br_mrp_alloc_in_test_skb()
282 struct br_mrp *mrp = container_of(del_work, struct br_mrp, test_work); in br_mrp_test_work_expired() local
287 if (time_before_eq(mrp->test_end, jiffies)) in br_mrp_test_work_expired()
290 if (mrp->test_count_miss < mrp->test_max_miss) { in br_mrp_test_work_expired()
291 mrp->test_count_miss++; in br_mrp_test_work_expired()
302 if (mrp->ring_state == BR_MRP_RING_STATE_CLOSED || in br_mrp_test_work_expired()
303 mrp->test_monitor) in br_mrp_test_work_expired()
309 p = rcu_dereference(mrp->p_port); in br_mrp_test_work_expired()
311 if (!mrp->test_monitor) { in br_mrp_test_work_expired()
312 skb = br_mrp_alloc_test_skb(mrp, p, in br_mrp_test_work_expired()
321 if (notify_open && !mrp->ring_role_offloaded) in br_mrp_test_work_expired()
325 p = rcu_dereference(mrp->s_port); in br_mrp_test_work_expired()
327 if (!mrp->test_monitor) { in br_mrp_test_work_expired()
328 skb = br_mrp_alloc_test_skb(mrp, p, in br_mrp_test_work_expired()
337 if (notify_open && !mrp->ring_role_offloaded) in br_mrp_test_work_expired()
344 queue_delayed_work(system_wq, &mrp->test_work, in br_mrp_test_work_expired()
345 usecs_to_jiffies(mrp->test_interval)); in br_mrp_test_work_expired()
355 struct br_mrp *mrp = container_of(del_work, struct br_mrp, in_test_work); in br_mrp_in_test_work_expired() local
360 if (time_before_eq(mrp->in_test_end, jiffies)) in br_mrp_in_test_work_expired()
363 if (mrp->in_test_count_miss < mrp->in_test_max_miss) { in br_mrp_in_test_work_expired()
364 mrp->in_test_count_miss++; in br_mrp_in_test_work_expired()
370 if (mrp->in_state == BR_MRP_IN_STATE_CLOSED) in br_mrp_in_test_work_expired()
376 p = rcu_dereference(mrp->p_port); in br_mrp_in_test_work_expired()
378 skb = br_mrp_alloc_in_test_skb(mrp, p, in br_mrp_in_test_work_expired()
386 if (notify_open && !mrp->in_role_offloaded) in br_mrp_in_test_work_expired()
390 p = rcu_dereference(mrp->s_port); in br_mrp_in_test_work_expired()
392 skb = br_mrp_alloc_in_test_skb(mrp, p, in br_mrp_in_test_work_expired()
400 if (notify_open && !mrp->in_role_offloaded) in br_mrp_in_test_work_expired()
404 p = rcu_dereference(mrp->i_port); in br_mrp_in_test_work_expired()
406 skb = br_mrp_alloc_in_test_skb(mrp, p, in br_mrp_in_test_work_expired()
414 if (notify_open && !mrp->in_role_offloaded) in br_mrp_in_test_work_expired()
421 queue_delayed_work(system_wq, &mrp->in_test_work, in br_mrp_in_test_work_expired()
422 usecs_to_jiffies(mrp->in_test_interval)); in br_mrp_in_test_work_expired()
428 static void br_mrp_del_impl(struct net_bridge *br, struct br_mrp *mrp) in br_mrp_del_impl() argument
434 cancel_delayed_work_sync(&mrp->test_work); in br_mrp_del_impl()
435 br_mrp_switchdev_send_ring_test(br, mrp, 0, 0, 0, 0); in br_mrp_del_impl()
438 cancel_delayed_work_sync(&mrp->in_test_work); in br_mrp_del_impl()
439 br_mrp_switchdev_send_in_test(br, mrp, 0, 0, 0); in br_mrp_del_impl()
442 br_mrp_switchdev_set_ring_role(br, mrp, BR_MRP_RING_ROLE_DISABLED); in br_mrp_del_impl()
443 p = rtnl_dereference(mrp->i_port); in br_mrp_del_impl()
445 br_mrp_switchdev_set_in_role(br, mrp, mrp->in_id, mrp->ring_id, in br_mrp_del_impl()
448 br_mrp_switchdev_del(br, mrp); in br_mrp_del_impl()
451 p = rtnl_dereference(mrp->p_port); in br_mrp_del_impl()
460 rcu_assign_pointer(mrp->p_port, NULL); in br_mrp_del_impl()
463 p = rtnl_dereference(mrp->s_port); in br_mrp_del_impl()
472 rcu_assign_pointer(mrp->s_port, NULL); in br_mrp_del_impl()
475 p = rtnl_dereference(mrp->i_port); in br_mrp_del_impl()
484 rcu_assign_pointer(mrp->i_port, NULL); in br_mrp_del_impl()
487 hlist_del_rcu(&mrp->list); in br_mrp_del_impl()
488 kfree_rcu(mrp, rcu); in br_mrp_del_impl()
500 struct br_mrp *mrp; in br_mrp_add() local
506 mrp = br_mrp_find_id(br, instance->ring_id); in br_mrp_add()
507 if (mrp) in br_mrp_add()
519 mrp = kzalloc(sizeof(*mrp), GFP_KERNEL); in br_mrp_add()
520 if (!mrp) in br_mrp_add()
523 mrp->ring_id = instance->ring_id; in br_mrp_add()
524 mrp->prio = instance->prio; in br_mrp_add()
531 rcu_assign_pointer(mrp->p_port, p); in br_mrp_add()
538 rcu_assign_pointer(mrp->s_port, p); in br_mrp_add()
543 INIT_DELAYED_WORK(&mrp->test_work, br_mrp_test_work_expired); in br_mrp_add()
544 INIT_DELAYED_WORK(&mrp->in_test_work, br_mrp_in_test_work_expired); in br_mrp_add()
545 hlist_add_tail_rcu(&mrp->list, &br->mrp_list); in br_mrp_add()
547 err = br_mrp_switchdev_add(br, mrp); in br_mrp_add()
554 br_mrp_del_impl(br, mrp); in br_mrp_add()
564 struct br_mrp *mrp = br_mrp_find_port(br, p); in br_mrp_port_del() local
567 if (!mrp) in br_mrp_port_del()
570 br_mrp_del_impl(br, mrp); in br_mrp_port_del()
578 struct br_mrp *mrp = br_mrp_find_id(br, instance->ring_id); in br_mrp_del() local
580 if (!mrp) in br_mrp_del()
583 br_mrp_del_impl(br, mrp); in br_mrp_del()
620 struct br_mrp *mrp; in br_mrp_set_port_role() local
625 mrp = br_mrp_find_port(p->br, p); in br_mrp_set_port_role()
627 if (!mrp) in br_mrp_set_port_role()
632 rcu_assign_pointer(mrp->p_port, p); in br_mrp_set_port_role()
635 rcu_assign_pointer(mrp->s_port, p); in br_mrp_set_port_role()
652 struct br_mrp *mrp = br_mrp_find_id(br, state->ring_id); in br_mrp_set_ring_state() local
654 if (!mrp) in br_mrp_set_ring_state()
657 if (mrp->ring_state != state->ring_state) in br_mrp_set_ring_state()
658 mrp->ring_transitions++; in br_mrp_set_ring_state()
660 mrp->ring_state = state->ring_state; in br_mrp_set_ring_state()
662 br_mrp_switchdev_set_ring_state(br, mrp, state->ring_state); in br_mrp_set_ring_state()
674 struct br_mrp *mrp = br_mrp_find_id(br, role->ring_id); in br_mrp_set_ring_role() local
677 if (!mrp) in br_mrp_set_ring_role()
680 mrp->ring_role = role->ring_role; in br_mrp_set_ring_role()
683 support = br_mrp_switchdev_set_ring_role(br, mrp, role->ring_role); in br_mrp_set_ring_role()
693 mrp->ring_role_offloaded = support == BR_MRP_SW ? 0 : 1; in br_mrp_set_ring_role()
705 struct br_mrp *mrp = br_mrp_find_id(br, test->ring_id); in br_mrp_start_test() local
708 if (!mrp) in br_mrp_start_test()
714 support = br_mrp_switchdev_send_ring_test(br, mrp, test->interval, in br_mrp_start_test()
723 mrp->test_interval = test->interval; in br_mrp_start_test()
724 mrp->test_end = jiffies + usecs_to_jiffies(test->period); in br_mrp_start_test()
725 mrp->test_max_miss = test->max_miss; in br_mrp_start_test()
726 mrp->test_monitor = test->monitor; in br_mrp_start_test()
727 mrp->test_count_miss = 0; in br_mrp_start_test()
728 queue_delayed_work(system_wq, &mrp->test_work, in br_mrp_start_test()
739 struct br_mrp *mrp = br_mrp_find_in_id(br, state->in_id); in br_mrp_set_in_state() local
741 if (!mrp) in br_mrp_set_in_state()
744 if (mrp->in_state != state->in_state) in br_mrp_set_in_state()
745 mrp->in_transitions++; in br_mrp_set_in_state()
747 mrp->in_state = state->in_state; in br_mrp_set_in_state()
749 br_mrp_switchdev_set_in_state(br, mrp, state->in_state); in br_mrp_set_in_state()
760 struct br_mrp *mrp = br_mrp_find_id(br, role->ring_id); in br_mrp_set_in_role() local
764 if (!mrp) in br_mrp_set_in_role()
774 p = rtnl_dereference(mrp->i_port); in br_mrp_set_in_role()
779 cancel_delayed_work_sync(&mrp->in_test_work); in br_mrp_set_in_role()
780 br_mrp_switchdev_send_in_test(br, mrp, 0, 0, 0); in br_mrp_set_in_role()
790 rcu_assign_pointer(mrp->i_port, NULL); in br_mrp_set_in_role()
792 mrp->in_role = role->in_role; in br_mrp_set_in_role()
793 mrp->in_id = 0; in br_mrp_set_in_role()
806 if (rcu_access_pointer(mrp->i_port)) in br_mrp_set_in_role()
814 rcu_assign_pointer(mrp->i_port, p); in br_mrp_set_in_role()
816 mrp->in_role = role->in_role; in br_mrp_set_in_role()
817 mrp->in_id = role->in_id; in br_mrp_set_in_role()
820 support = br_mrp_switchdev_set_in_role(br, mrp, role->in_id, in br_mrp_set_in_role()
831 mrp->in_role_offloaded = support == BR_MRP_SW ? 0 : 1; in br_mrp_set_in_role()
843 struct br_mrp *mrp = br_mrp_find_in_id(br, in_test->in_id); in br_mrp_start_in_test() local
846 if (!mrp) in br_mrp_start_in_test()
849 if (mrp->in_role != BR_MRP_IN_ROLE_MIM) in br_mrp_start_in_test()
855 support = br_mrp_switchdev_send_in_test(br, mrp, in_test->interval, in br_mrp_start_in_test()
864 mrp->in_test_interval = in_test->interval; in br_mrp_start_in_test()
865 mrp->in_test_end = jiffies + usecs_to_jiffies(in_test->period); in br_mrp_start_in_test()
866 mrp->in_test_max_miss = in_test->max_miss; in br_mrp_start_in_test()
867 mrp->in_test_count_miss = 0; in br_mrp_start_in_test()
868 queue_delayed_work(system_wq, &mrp->in_test_work, in br_mrp_start_in_test()
918 static void br_mrp_mrm_process(struct br_mrp *mrp, struct net_bridge_port *port, in br_mrp_mrm_process() argument
934 mrp->test_count_miss = 0; in br_mrp_mrm_process()
939 if (mrp->ring_state != BR_MRP_RING_STATE_CLOSED) in br_mrp_mrm_process()
944 static bool br_mrp_test_better_than_own(struct br_mrp *mrp, in br_mrp_test_better_than_own() argument
950 if (prio < mrp->prio || in br_mrp_test_better_than_own()
951 (prio == mrp->prio && in br_mrp_test_better_than_own()
962 static void br_mrp_mra_process(struct br_mrp *mrp, struct net_bridge *br, in br_mrp_mra_process() argument
990 if (br_mrp_test_better_than_own(mrp, br, test_hdr)) in br_mrp_mra_process()
991 mrp->test_count_miss = 0; in br_mrp_mra_process()
998 static bool br_mrp_mim_process(struct br_mrp *mrp, struct net_bridge_port *port, in br_mrp_mim_process() argument
1020 if (mrp->in_id != ntohs(in_hdr->id)) in br_mrp_mim_process()
1023 mrp->in_test_count_miss = 0; in br_mrp_mim_process()
1028 if (mrp->in_state != BR_MRP_IN_STATE_CLOSED) in br_mrp_mim_process()
1052 static bool br_mrp_mrm_behaviour(struct br_mrp *mrp) in br_mrp_mrm_behaviour() argument
1054 if (mrp->ring_role == BR_MRP_RING_ROLE_MRM || in br_mrp_mrm_behaviour()
1055 (mrp->ring_role == BR_MRP_RING_ROLE_MRA && !mrp->test_monitor)) in br_mrp_mrm_behaviour()
1061 static bool br_mrp_mrc_behaviour(struct br_mrp *mrp) in br_mrp_mrc_behaviour() argument
1063 if (mrp->ring_role == BR_MRP_RING_ROLE_MRC || in br_mrp_mrc_behaviour()
1064 (mrp->ring_role == BR_MRP_RING_ROLE_MRA && mrp->test_monitor)) in br_mrp_mrc_behaviour()
1080 struct br_mrp *mrp; in br_mrp_rcv() local
1087 mrp = br_mrp_find_port(br, p); in br_mrp_rcv()
1088 if (unlikely(!mrp)) in br_mrp_rcv()
1091 p_port = rcu_dereference(mrp->p_port); in br_mrp_rcv()
1096 s_port = rcu_dereference(mrp->s_port); in br_mrp_rcv()
1106 if (mrp->ring_role == BR_MRP_RING_ROLE_MRM) { in br_mrp_rcv()
1107 br_mrp_mrm_process(mrp, p, skb); in br_mrp_rcv()
1114 if (mrp->ring_role == BR_MRP_RING_ROLE_MRA) { in br_mrp_rcv()
1115 if (!mrp->test_monitor) { in br_mrp_rcv()
1116 br_mrp_mrm_process(mrp, p, skb); in br_mrp_rcv()
1120 br_mrp_mra_process(mrp, br, p, skb); in br_mrp_rcv()
1129 i_port = rcu_dereference(mrp->i_port); in br_mrp_rcv()
1144 if (br_mrp_mrm_behaviour(mrp) && in br_mrp_rcv()
1156 if (br_mrp_mrc_behaviour(mrp) && in br_mrp_rcv()
1157 mrp->in_role == BR_MRP_IN_ROLE_DISABLED) in br_mrp_rcv()
1160 if (mrp->in_role == BR_MRP_IN_ROLE_MIM) { in br_mrp_rcv()
1165 if (br_mrp_mim_process(mrp, p, skb)) { in br_mrp_rcv()
1190 if (mrp->in_role == BR_MRP_IN_ROLE_MIC) { in br_mrp_rcv()