Lines Matching refs:p
29 void br_set_state(struct net_bridge_port *p, unsigned int state) in br_set_state() argument
32 .orig_dev = p->dev, in br_set_state()
42 if (p->flags & BR_MRP_AWARE) in br_set_state()
45 p->state = state; in br_set_state()
46 if (br_opt_get(p->br, BROPT_MST_ENABLED)) { in br_set_state()
47 err = br_mst_set_state(p, 0, state, NULL); in br_set_state()
49 br_warn(p->br, "error setting MST state on port %u(%s)\n", in br_set_state()
50 p->port_no, netdev_name(p->dev)); in br_set_state()
52 err = switchdev_port_attr_set(p->dev, &attr, NULL); in br_set_state()
54 br_warn(p->br, "error setting offload STP state on port %u(%s)\n", in br_set_state()
55 (unsigned int) p->port_no, p->dev->name); in br_set_state()
57 br_info(p->br, "port %u(%s) entered %s state\n", in br_set_state()
58 (unsigned int) p->port_no, p->dev->name, in br_set_state()
59 br_port_state_names[p->state]); in br_set_state()
61 if (p->br->stp_enabled == BR_KERNEL_STP) { in br_set_state()
62 switch (p->state) { in br_set_state()
64 p->stp_xstats.transition_blk++; in br_set_state()
67 p->stp_xstats.transition_fwd++; in br_set_state()
75 struct net_bridge_port *p; in br_port_get_stp_state() local
79 p = br_port_get_rtnl(dev); in br_port_get_stp_state()
80 if (!p) in br_port_get_stp_state()
83 return p->state; in br_port_get_stp_state()
90 struct net_bridge_port *p; in br_get_port() local
92 list_for_each_entry_rcu(p, &br->port_list, list, in br_get_port()
94 if (p->port_no == port_no) in br_get_port()
95 return p; in br_get_port()
102 static int br_should_become_root_port(const struct net_bridge_port *p, in br_should_become_root_port() argument
109 br = p->br; in br_should_become_root_port()
110 if (p->state == BR_STATE_DISABLED || in br_should_become_root_port()
111 br_is_designated_port(p)) in br_should_become_root_port()
114 if (memcmp(&br->bridge_id, &p->designated_root, 8) <= 0) in br_should_become_root_port()
122 t = memcmp(&p->designated_root, &rp->designated_root, 8); in br_should_become_root_port()
128 if (p->designated_cost + p->path_cost < in br_should_become_root_port()
131 else if (p->designated_cost + p->path_cost > in br_should_become_root_port()
135 t = memcmp(&p->designated_bridge, &rp->designated_bridge, 8); in br_should_become_root_port()
141 if (p->designated_port < rp->designated_port) in br_should_become_root_port()
143 else if (p->designated_port > rp->designated_port) in br_should_become_root_port()
146 if (p->port_id < rp->port_id) in br_should_become_root_port()
153 struct net_bridge_port *p) in br_root_port_block() argument
157 (unsigned int) p->port_no, p->dev->name); in br_root_port_block()
159 br_set_state(p, BR_STATE_LISTENING); in br_root_port_block()
160 br_ifinfo_notify(RTM_NEWLINK, NULL, p); in br_root_port_block()
163 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_root_port_block()
169 struct net_bridge_port *p; in br_root_selection() local
172 list_for_each_entry(p, &br->port_list, list) { in br_root_selection()
173 if (!br_should_become_root_port(p, root_port)) in br_root_selection()
176 if (p->flags & BR_ROOT_BLOCK) in br_root_selection()
177 br_root_port_block(br, p); in br_root_selection()
179 root_port = p->port_no; in br_root_selection()
188 p = br_get_port(br, root_port); in br_root_selection()
189 br->designated_root = p->designated_root; in br_root_selection()
190 br->root_path_cost = p->designated_cost + p->path_cost; in br_root_selection()
210 void br_transmit_config(struct net_bridge_port *p) in br_transmit_config() argument
215 if (timer_pending(&p->hold_timer)) { in br_transmit_config()
216 p->config_pending = 1; in br_transmit_config()
220 br = p->br; in br_transmit_config()
223 bpdu.topology_change_ack = p->topology_change_ack; in br_transmit_config()
227 bpdu.port_id = p->port_id; in br_transmit_config()
241 br_send_config_bpdu(p, &bpdu); in br_transmit_config()
242 p->topology_change_ack = 0; in br_transmit_config()
243 p->config_pending = 0; in br_transmit_config()
244 if (p->br->stp_enabled == BR_KERNEL_STP) in br_transmit_config()
245 mod_timer(&p->hold_timer, in br_transmit_config()
251 static void br_record_config_information(struct net_bridge_port *p, in br_record_config_information() argument
254 p->designated_root = bpdu->root; in br_record_config_information()
255 p->designated_cost = bpdu->root_path_cost; in br_record_config_information()
256 p->designated_bridge = bpdu->bridge_id; in br_record_config_information()
257 p->designated_port = bpdu->port_id; in br_record_config_information()
258 p->designated_age = jiffies - bpdu->message_age; in br_record_config_information()
260 mod_timer(&p->message_age_timer, jiffies in br_record_config_information()
277 struct net_bridge_port *p; in br_transmit_tcn() local
279 p = br_get_port(br, br->root_port); in br_transmit_tcn()
280 if (p) in br_transmit_tcn()
281 br_send_tcn_bpdu(p); in br_transmit_tcn()
288 static int br_should_become_designated_port(const struct net_bridge_port *p) in br_should_become_designated_port() argument
293 br = p->br; in br_should_become_designated_port()
294 if (br_is_designated_port(p)) in br_should_become_designated_port()
297 if (memcmp(&p->designated_root, &br->designated_root, 8)) in br_should_become_designated_port()
300 if (br->root_path_cost < p->designated_cost) in br_should_become_designated_port()
302 else if (br->root_path_cost > p->designated_cost) in br_should_become_designated_port()
305 t = memcmp(&br->bridge_id, &p->designated_bridge, 8); in br_should_become_designated_port()
311 if (p->port_id < p->designated_port) in br_should_become_designated_port()
320 struct net_bridge_port *p; in br_designated_port_selection() local
322 list_for_each_entry(p, &br->port_list, list) { in br_designated_port_selection()
323 if (p->state != BR_STATE_DISABLED && in br_designated_port_selection()
324 br_should_become_designated_port(p)) in br_designated_port_selection()
325 br_become_designated_port(p); in br_designated_port_selection()
331 static int br_supersedes_port_info(const struct net_bridge_port *p, in br_supersedes_port_info() argument
336 t = memcmp(&bpdu->root, &p->designated_root, 8); in br_supersedes_port_info()
342 if (bpdu->root_path_cost < p->designated_cost) in br_supersedes_port_info()
344 else if (bpdu->root_path_cost > p->designated_cost) in br_supersedes_port_info()
347 t = memcmp(&bpdu->bridge_id, &p->designated_bridge, 8); in br_supersedes_port_info()
353 if (memcmp(&bpdu->bridge_id, &p->br->bridge_id, 8)) in br_supersedes_port_info()
356 if (bpdu->port_id <= p->designated_port) in br_supersedes_port_info()
395 struct net_bridge_port *p; in br_config_bpdu_generation() local
397 list_for_each_entry(p, &br->port_list, list) { in br_config_bpdu_generation()
398 if (p->state != BR_STATE_DISABLED && in br_config_bpdu_generation()
399 br_is_designated_port(p)) in br_config_bpdu_generation()
400 br_transmit_config(p); in br_config_bpdu_generation()
405 static void br_reply(struct net_bridge_port *p) in br_reply() argument
407 br_transmit_config(p); in br_reply()
418 void br_become_designated_port(struct net_bridge_port *p) in br_become_designated_port() argument
422 br = p->br; in br_become_designated_port()
423 p->designated_root = br->designated_root; in br_become_designated_port()
424 p->designated_cost = br->root_path_cost; in br_become_designated_port()
425 p->designated_bridge = br->bridge_id; in br_become_designated_port()
426 p->designated_port = p->port_id; in br_become_designated_port()
431 static void br_make_blocking(struct net_bridge_port *p) in br_make_blocking() argument
433 if (p->state != BR_STATE_DISABLED && in br_make_blocking()
434 p->state != BR_STATE_BLOCKING) { in br_make_blocking()
435 if (p->state == BR_STATE_FORWARDING || in br_make_blocking()
436 p->state == BR_STATE_LEARNING) in br_make_blocking()
437 br_topology_change_detection(p->br); in br_make_blocking()
439 br_set_state(p, BR_STATE_BLOCKING); in br_make_blocking()
440 br_ifinfo_notify(RTM_NEWLINK, NULL, p); in br_make_blocking()
442 del_timer(&p->forward_delay_timer); in br_make_blocking()
447 static void br_make_forwarding(struct net_bridge_port *p) in br_make_forwarding() argument
449 struct net_bridge *br = p->br; in br_make_forwarding()
451 if (p->state != BR_STATE_BLOCKING) in br_make_forwarding()
455 br_set_state(p, BR_STATE_FORWARDING); in br_make_forwarding()
457 del_timer(&p->forward_delay_timer); in br_make_forwarding()
459 br_set_state(p, BR_STATE_LISTENING); in br_make_forwarding()
461 br_set_state(p, BR_STATE_LEARNING); in br_make_forwarding()
463 br_ifinfo_notify(RTM_NEWLINK, NULL, p); in br_make_forwarding()
466 mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); in br_make_forwarding()
472 struct net_bridge_port *p; in br_port_state_selection() local
475 list_for_each_entry(p, &br->port_list, list) { in br_port_state_selection()
476 if (p->state == BR_STATE_DISABLED) in br_port_state_selection()
481 if (p->port_no == br->root_port) { in br_port_state_selection()
482 p->config_pending = 0; in br_port_state_selection()
483 p->topology_change_ack = 0; in br_port_state_selection()
484 br_make_forwarding(p); in br_port_state_selection()
485 } else if (br_is_designated_port(p)) { in br_port_state_selection()
486 del_timer(&p->message_age_timer); in br_port_state_selection()
487 br_make_forwarding(p); in br_port_state_selection()
489 p->config_pending = 0; in br_port_state_selection()
490 p->topology_change_ack = 0; in br_port_state_selection()
491 br_make_blocking(p); in br_port_state_selection()
495 if (p->state != BR_STATE_BLOCKING) in br_port_state_selection()
496 br_multicast_enable_port(p); in br_port_state_selection()
501 if (p->state == BR_STATE_FORWARDING) in br_port_state_selection()
512 static void br_topology_change_acknowledge(struct net_bridge_port *p) in br_topology_change_acknowledge() argument
514 p->topology_change_ack = 1; in br_topology_change_acknowledge()
515 br_transmit_config(p); in br_topology_change_acknowledge()
519 void br_received_config_bpdu(struct net_bridge_port *p, in br_received_config_bpdu() argument
525 p->stp_xstats.rx_bpdu++; in br_received_config_bpdu()
527 br = p->br; in br_received_config_bpdu()
530 if (br_supersedes_port_info(p, bpdu)) { in br_received_config_bpdu()
531 br_record_config_information(p, bpdu); in br_received_config_bpdu()
546 if (p->port_no == br->root_port) { in br_received_config_bpdu()
552 } else if (br_is_designated_port(p)) { in br_received_config_bpdu()
553 br_reply(p); in br_received_config_bpdu()
558 void br_received_tcn_bpdu(struct net_bridge_port *p) in br_received_tcn_bpdu() argument
560 p->stp_xstats.rx_tcn++; in br_received_tcn_bpdu()
562 if (br_is_designated_port(p)) { in br_received_tcn_bpdu()
563 br_info(p->br, "port %u(%s) received tcn bpdu\n", in br_received_tcn_bpdu()
564 (unsigned int) p->port_no, p->dev->name); in br_received_tcn_bpdu()
566 br_topology_change_detection(p->br); in br_received_tcn_bpdu()
567 br_topology_change_acknowledge(p); in br_received_tcn_bpdu()