Changeset View
Changeset View
Standalone View
Standalone View
sys/net/bridgestp.c
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | |||||
static void bstp_set_port_proto(struct bstp_port *, int); | static void bstp_set_port_proto(struct bstp_port *, int); | ||||
static void bstp_set_port_tc(struct bstp_port *, int); | static void bstp_set_port_tc(struct bstp_port *, int); | ||||
static void bstp_set_timer_tc(struct bstp_port *); | static void bstp_set_timer_tc(struct bstp_port *); | ||||
static void bstp_set_timer_msgage(struct bstp_port *); | static void bstp_set_timer_msgage(struct bstp_port *); | ||||
static int bstp_rerooted(struct bstp_state *, struct bstp_port *); | static int bstp_rerooted(struct bstp_state *, struct bstp_port *); | ||||
static uint32_t bstp_calc_path_cost(struct bstp_port *); | static uint32_t bstp_calc_path_cost(struct bstp_port *); | ||||
static void bstp_notify_state(void *, int); | static void bstp_notify_state(void *, int); | ||||
static void bstp_notify_rtage(void *, int); | static void bstp_notify_rtage(void *, int); | ||||
static void bstp_notify_media(void *, int); | |||||
static void bstp_ifupdstatus(void *, int); | static void bstp_ifupdstatus(void *, int); | ||||
static void bstp_enable_port(struct bstp_state *, struct bstp_port *); | static void bstp_enable_port(struct bstp_state *, struct bstp_port *); | ||||
static void bstp_disable_port(struct bstp_state *, struct bstp_port *); | static void bstp_disable_port(struct bstp_state *, struct bstp_port *); | ||||
static void bstp_tick(void *); | static void bstp_tick(void *); | ||||
static void bstp_timer_start(struct bstp_timer *, uint16_t); | static void bstp_timer_start(struct bstp_timer *, uint16_t); | ||||
static void bstp_timer_stop(struct bstp_timer *); | static void bstp_timer_stop(struct bstp_timer *); | ||||
static void bstp_timer_latch(struct bstp_timer *); | static void bstp_timer_latch(struct bstp_timer *); | ||||
static int bstp_timer_dectest(struct bstp_timer *); | static int bstp_timer_dectest(struct bstp_timer *); | ||||
▲ Show 20 Lines • Show All 1,638 Lines • ▼ Show 20 Lines | bstp_linkstate(struct bstp_port *bp) | ||||
bstp_ifupdstatus(bp, 0); | bstp_ifupdstatus(bp, 0); | ||||
BSTP_LOCK(bs); | BSTP_LOCK(bs); | ||||
bstp_update_state(bs, bp); | bstp_update_state(bs, bp); | ||||
BSTP_UNLOCK(bs); | BSTP_UNLOCK(bs); | ||||
} | } | ||||
static void | static void | ||||
bstp_ifupdstatus(void *arg, int pending) | bstp_notify_media(void *arg, int pending) | ||||
{ | { | ||||
bstp_ifupdstatus(arg, 1); | |||||
} | |||||
static void | |||||
bstp_ifupdstatus(void *arg, int polled) | |||||
{ | |||||
struct bstp_port *bp = (struct bstp_port *)arg; | struct bstp_port *bp = (struct bstp_port *)arg; | ||||
struct bstp_state *bs = bp->bp_bs; | struct bstp_state *bs = bp->bp_bs; | ||||
struct ifnet *ifp = bp->bp_ifp; | struct ifnet *ifp = bp->bp_ifp; | ||||
struct ifmediareq ifmr; | struct ifmediareq ifmr; | ||||
int error, changed; | int error, changed; | ||||
if (!bp->bp_active) | if (!bp->bp_active) | ||||
return; | return; | ||||
Show All 11 Lines | if (ifmr.ifm_status & IFM_ACTIVE) { | ||||
fdx = ifmr.ifm_active & IFM_FDX ? 1 : 0; | fdx = ifmr.ifm_active & IFM_FDX ? 1 : 0; | ||||
if (bp->bp_ptp_link ^ fdx) { | if (bp->bp_ptp_link ^ fdx) { | ||||
bp->bp_ptp_link = fdx; | bp->bp_ptp_link = fdx; | ||||
changed = 1; | changed = 1; | ||||
} | } | ||||
} | } | ||||
/* Calc the cost if the link was down previously */ | /* | ||||
if (bp->bp_flags & BSTP_PORT_PNDCOST) { | * Recalculate the cost if the link was down previously. | ||||
* Always recalculate on real media change notifications | |||||
* (i.e. not polled). | |||||
*/ | |||||
if (!polled || (bp->bp_flags & BSTP_PORT_PNDCOST)) { | |||||
uint32_t cost; | uint32_t cost; | ||||
cost = bstp_calc_path_cost(bp); | cost = bstp_calc_path_cost(bp); | ||||
if (bp->bp_path_cost != cost) { | if (bp->bp_path_cost != cost) { | ||||
bp->bp_path_cost = cost; | bp->bp_path_cost = cost; | ||||
changed = 1; | changed = 1; | ||||
} | } | ||||
bp->bp_flags &= ~BSTP_PORT_PNDCOST; | bp->bp_flags &= ~BSTP_PORT_PNDCOST; | ||||
▲ Show 20 Lines • Show All 376 Lines • ▼ Show 20 Lines | bstp_create(struct bstp_state *bs, struct bstp_port *bp, struct ifnet *ifp) | ||||
bzero(bp, sizeof(struct bstp_port)); | bzero(bp, sizeof(struct bstp_port)); | ||||
BSTP_LOCK(bs); | BSTP_LOCK(bs); | ||||
bp->bp_ifp = ifp; | bp->bp_ifp = ifp; | ||||
bp->bp_bs = bs; | bp->bp_bs = bs; | ||||
bp->bp_priority = BSTP_DEFAULT_PORT_PRIORITY; | bp->bp_priority = BSTP_DEFAULT_PORT_PRIORITY; | ||||
TASK_INIT(&bp->bp_statetask, 0, bstp_notify_state, bp); | TASK_INIT(&bp->bp_statetask, 0, bstp_notify_state, bp); | ||||
TASK_INIT(&bp->bp_rtagetask, 0, bstp_notify_rtage, bp); | TASK_INIT(&bp->bp_rtagetask, 0, bstp_notify_rtage, bp); | ||||
TASK_INIT(&bp->bp_mediatask, 0, bstp_ifupdstatus, bp); | TASK_INIT(&bp->bp_mediatask, 0, bstp_notify_media, bp); | ||||
/* Init state */ | /* Init state */ | ||||
bp->bp_infois = BSTP_INFO_DISABLED; | bp->bp_infois = BSTP_INFO_DISABLED; | ||||
bp->bp_flags = BSTP_PORT_AUTOEDGE|BSTP_PORT_AUTOPTP; | bp->bp_flags = BSTP_PORT_AUTOEDGE|BSTP_PORT_AUTOPTP; | ||||
bstp_set_port_state(bp, BSTP_IFSTATE_DISCARDING); | bstp_set_port_state(bp, BSTP_IFSTATE_DISCARDING); | ||||
bstp_set_port_proto(bp, bs->bs_protover); | bstp_set_port_proto(bp, bs->bs_protover); | ||||
bstp_set_port_role(bp, BSTP_ROLE_DISABLED); | bstp_set_port_role(bp, BSTP_ROLE_DISABLED); | ||||
bstp_set_port_tc(bp, BSTP_TCSTATE_INACTIVE); | bstp_set_port_tc(bp, BSTP_TCSTATE_INACTIVE); | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |