Lines Matching refs:linecard

518 		struct devlink_linecard *linecard;  in devlink_linecard_get_from_attrs()  local
521 linecard = devlink_linecard_get_by_index(devlink, linecard_index); in devlink_linecard_get_from_attrs()
522 if (linecard) in devlink_linecard_get_from_attrs()
523 refcount_inc(&linecard->refcount); in devlink_linecard_get_from_attrs()
525 if (!linecard) in devlink_linecard_get_from_attrs()
527 return linecard; in devlink_linecard_get_from_attrs()
538 static void devlink_linecard_put(struct devlink_linecard *linecard) in devlink_linecard_put() argument
540 if (refcount_dec_and_test(&linecard->refcount)) { in devlink_linecard_put()
541 mutex_destroy(&linecard->state_lock); in devlink_linecard_put()
542 kfree(linecard); in devlink_linecard_put()
775 struct devlink_linecard *linecard; in devlink_nl_pre_doit() local
815 linecard = devlink_linecard_get_from_info(devlink, info); in devlink_nl_pre_doit()
816 if (IS_ERR(linecard)) { in devlink_nl_pre_doit()
817 err = PTR_ERR(linecard); in devlink_nl_pre_doit()
820 info->user_ptr[1] = linecard; in devlink_nl_pre_doit()
833 struct devlink_linecard *linecard; in devlink_nl_post_doit() local
838 linecard = info->user_ptr[1]; in devlink_nl_post_doit()
839 devlink_linecard_put(linecard); in devlink_nl_post_doit()
1329 if (devlink_port->linecard && in devlink_nl_port_fill()
1331 devlink_port->linecard->index)) in devlink_nl_port_fill()
2116 struct devlink_linecard *linecard, in devlink_nl_linecard_fill() argument
2132 if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_INDEX, linecard->index)) in devlink_nl_linecard_fill()
2134 if (nla_put_u8(msg, DEVLINK_ATTR_LINECARD_STATE, linecard->state)) in devlink_nl_linecard_fill()
2136 if (linecard->type && in devlink_nl_linecard_fill()
2137 nla_put_string(msg, DEVLINK_ATTR_LINECARD_TYPE, linecard->type)) in devlink_nl_linecard_fill()
2140 if (linecard->types_count) { in devlink_nl_linecard_fill()
2145 for (i = 0; i < linecard->types_count; i++) { in devlink_nl_linecard_fill()
2146 linecard_type = &linecard->types[i]; in devlink_nl_linecard_fill()
2156 if (linecard->nested_devlink && in devlink_nl_linecard_fill()
2157 devlink_nl_put_nested_handle(msg, linecard->nested_devlink)) in devlink_nl_linecard_fill()
2168 static void devlink_linecard_notify(struct devlink_linecard *linecard, in devlink_linecard_notify() argument
2171 struct devlink *devlink = linecard->devlink; in devlink_linecard_notify()
2185 err = devlink_nl_linecard_fill(msg, devlink, linecard, cmd, 0, 0, 0, in devlink_linecard_notify()
2199 struct devlink_linecard *linecard = info->user_ptr[1]; in devlink_nl_cmd_linecard_get_doit() local
2200 struct devlink *devlink = linecard->devlink; in devlink_nl_cmd_linecard_get_doit()
2208 mutex_lock(&linecard->state_lock); in devlink_nl_cmd_linecard_get_doit()
2209 err = devlink_nl_linecard_fill(msg, devlink, linecard, in devlink_nl_cmd_linecard_get_doit()
2213 mutex_unlock(&linecard->state_lock); in devlink_nl_cmd_linecard_get_doit()
2225 struct devlink_linecard *linecard; in devlink_nl_cmd_linecard_get_dumpit() local
2234 list_for_each_entry(linecard, &devlink->linecard_list, list) { in devlink_nl_cmd_linecard_get_dumpit()
2239 mutex_lock(&linecard->state_lock); in devlink_nl_cmd_linecard_get_dumpit()
2240 err = devlink_nl_linecard_fill(msg, devlink, linecard, in devlink_nl_cmd_linecard_get_dumpit()
2246 mutex_unlock(&linecard->state_lock); in devlink_nl_cmd_linecard_get_dumpit()
2263 devlink_linecard_type_lookup(struct devlink_linecard *linecard, in devlink_linecard_type_lookup() argument
2269 for (i = 0; i < linecard->types_count; i++) { in devlink_linecard_type_lookup()
2270 linecard_type = &linecard->types[i]; in devlink_linecard_type_lookup()
2277 static int devlink_linecard_type_set(struct devlink_linecard *linecard, in devlink_linecard_type_set() argument
2281 const struct devlink_linecard_ops *ops = linecard->ops; in devlink_linecard_type_set()
2285 mutex_lock(&linecard->state_lock); in devlink_linecard_type_set()
2286 if (linecard->state == DEVLINK_LINECARD_STATE_PROVISIONING) { in devlink_linecard_type_set()
2291 if (linecard->state == DEVLINK_LINECARD_STATE_UNPROVISIONING) { in devlink_linecard_type_set()
2297 linecard_type = devlink_linecard_type_lookup(linecard, type); in devlink_linecard_type_set()
2304 if (linecard->state != DEVLINK_LINECARD_STATE_UNPROVISIONED && in devlink_linecard_type_set()
2305 linecard->state != DEVLINK_LINECARD_STATE_PROVISIONING_FAILED) { in devlink_linecard_type_set()
2313 ops->same_provision(linecard, linecard->priv, in devlink_linecard_type_set()
2320 linecard->state = DEVLINK_LINECARD_STATE_PROVISIONING; in devlink_linecard_type_set()
2321 linecard->type = linecard_type->type; in devlink_linecard_type_set()
2322 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); in devlink_linecard_type_set()
2323 mutex_unlock(&linecard->state_lock); in devlink_linecard_type_set()
2324 err = ops->provision(linecard, linecard->priv, linecard_type->type, in devlink_linecard_type_set()
2330 mutex_lock(&linecard->state_lock); in devlink_linecard_type_set()
2331 linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; in devlink_linecard_type_set()
2332 linecard->type = NULL; in devlink_linecard_type_set()
2333 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); in devlink_linecard_type_set()
2334 mutex_unlock(&linecard->state_lock); in devlink_linecard_type_set()
2339 mutex_unlock(&linecard->state_lock); in devlink_linecard_type_set()
2343 static int devlink_linecard_type_unset(struct devlink_linecard *linecard, in devlink_linecard_type_unset() argument
2348 mutex_lock(&linecard->state_lock); in devlink_linecard_type_unset()
2349 if (linecard->state == DEVLINK_LINECARD_STATE_PROVISIONING) { in devlink_linecard_type_unset()
2354 if (linecard->state == DEVLINK_LINECARD_STATE_UNPROVISIONING) { in devlink_linecard_type_unset()
2359 if (linecard->state == DEVLINK_LINECARD_STATE_PROVISIONING_FAILED) { in devlink_linecard_type_unset()
2360 linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; in devlink_linecard_type_unset()
2361 linecard->type = NULL; in devlink_linecard_type_unset()
2362 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); in devlink_linecard_type_unset()
2367 if (linecard->state == DEVLINK_LINECARD_STATE_UNPROVISIONED) { in devlink_linecard_type_unset()
2372 linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONING; in devlink_linecard_type_unset()
2373 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); in devlink_linecard_type_unset()
2374 mutex_unlock(&linecard->state_lock); in devlink_linecard_type_unset()
2375 err = linecard->ops->unprovision(linecard, linecard->priv, in devlink_linecard_type_unset()
2381 mutex_lock(&linecard->state_lock); in devlink_linecard_type_unset()
2382 linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; in devlink_linecard_type_unset()
2383 linecard->type = NULL; in devlink_linecard_type_unset()
2384 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); in devlink_linecard_type_unset()
2385 mutex_unlock(&linecard->state_lock); in devlink_linecard_type_unset()
2390 mutex_unlock(&linecard->state_lock); in devlink_linecard_type_unset()
2397 struct devlink_linecard *linecard = info->user_ptr[1]; in devlink_nl_cmd_linecard_set_doit() local
2406 err = devlink_linecard_type_set(linecard, type, extack); in devlink_nl_cmd_linecard_set_doit()
2410 err = devlink_linecard_type_unset(linecard, extack); in devlink_nl_cmd_linecard_set_doit()
9690 struct devlink_linecard *linecard; in devlink_notify_register() local
9695 list_for_each_entry(linecard, &devlink->linecard_list, list) in devlink_notify_register()
9696 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); in devlink_notify_register()
10317 struct devlink_linecard *linecard) in devlink_port_linecard_set() argument
10321 devlink_port->linecard = linecard; in devlink_port_linecard_set()
10336 if (devlink_port->linecard) in __devlink_port_phys_port_name_get()
10338 devlink_port->linecard->index); in __devlink_port_phys_port_name_get()
10396 static int devlink_linecard_types_init(struct devlink_linecard *linecard) in devlink_linecard_types_init() argument
10402 count = linecard->ops->types_count(linecard, linecard->priv); in devlink_linecard_types_init()
10403 linecard->types = kmalloc_array(count, sizeof(*linecard_type), in devlink_linecard_types_init()
10405 if (!linecard->types) in devlink_linecard_types_init()
10407 linecard->types_count = count; in devlink_linecard_types_init()
10410 linecard_type = &linecard->types[i]; in devlink_linecard_types_init()
10411 linecard->ops->types_get(linecard, linecard->priv, i, in devlink_linecard_types_init()
10418 static void devlink_linecard_types_fini(struct devlink_linecard *linecard) in devlink_linecard_types_fini() argument
10420 kfree(linecard->types); in devlink_linecard_types_fini()
10440 struct devlink_linecard *linecard; in devlink_linecard_create() local
10453 linecard = kzalloc(sizeof(*linecard), GFP_KERNEL); in devlink_linecard_create()
10454 if (!linecard) { in devlink_linecard_create()
10459 linecard->devlink = devlink; in devlink_linecard_create()
10460 linecard->index = linecard_index; in devlink_linecard_create()
10461 linecard->ops = ops; in devlink_linecard_create()
10462 linecard->priv = priv; in devlink_linecard_create()
10463 linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; in devlink_linecard_create()
10464 mutex_init(&linecard->state_lock); in devlink_linecard_create()
10466 err = devlink_linecard_types_init(linecard); in devlink_linecard_create()
10468 mutex_destroy(&linecard->state_lock); in devlink_linecard_create()
10469 kfree(linecard); in devlink_linecard_create()
10474 list_add_tail(&linecard->list, &devlink->linecard_list); in devlink_linecard_create()
10475 refcount_set(&linecard->refcount, 1); in devlink_linecard_create()
10477 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); in devlink_linecard_create()
10478 return linecard; in devlink_linecard_create()
10487 void devlink_linecard_destroy(struct devlink_linecard *linecard) in devlink_linecard_destroy() argument
10489 struct devlink *devlink = linecard->devlink; in devlink_linecard_destroy()
10491 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_DEL); in devlink_linecard_destroy()
10493 list_del(&linecard->list); in devlink_linecard_destroy()
10494 devlink_linecard_types_fini(linecard); in devlink_linecard_destroy()
10496 devlink_linecard_put(linecard); in devlink_linecard_destroy()
10509 void devlink_linecard_provision_set(struct devlink_linecard *linecard, in devlink_linecard_provision_set() argument
10512 mutex_lock(&linecard->state_lock); in devlink_linecard_provision_set()
10513 WARN_ON(linecard->type && strcmp(linecard->type, type)); in devlink_linecard_provision_set()
10514 linecard->state = DEVLINK_LINECARD_STATE_PROVISIONED; in devlink_linecard_provision_set()
10515 linecard->type = type; in devlink_linecard_provision_set()
10516 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); in devlink_linecard_provision_set()
10517 mutex_unlock(&linecard->state_lock); in devlink_linecard_provision_set()
10529 void devlink_linecard_provision_clear(struct devlink_linecard *linecard) in devlink_linecard_provision_clear() argument
10531 mutex_lock(&linecard->state_lock); in devlink_linecard_provision_clear()
10532 WARN_ON(linecard->nested_devlink); in devlink_linecard_provision_clear()
10533 linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; in devlink_linecard_provision_clear()
10534 linecard->type = NULL; in devlink_linecard_provision_clear()
10535 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); in devlink_linecard_provision_clear()
10536 mutex_unlock(&linecard->state_lock); in devlink_linecard_provision_clear()
10548 void devlink_linecard_provision_fail(struct devlink_linecard *linecard) in devlink_linecard_provision_fail() argument
10550 mutex_lock(&linecard->state_lock); in devlink_linecard_provision_fail()
10551 WARN_ON(linecard->nested_devlink); in devlink_linecard_provision_fail()
10552 linecard->state = DEVLINK_LINECARD_STATE_PROVISIONING_FAILED; in devlink_linecard_provision_fail()
10553 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); in devlink_linecard_provision_fail()
10554 mutex_unlock(&linecard->state_lock); in devlink_linecard_provision_fail()
10563 void devlink_linecard_activate(struct devlink_linecard *linecard) in devlink_linecard_activate() argument
10565 mutex_lock(&linecard->state_lock); in devlink_linecard_activate()
10566 WARN_ON(linecard->state != DEVLINK_LINECARD_STATE_PROVISIONED); in devlink_linecard_activate()
10567 linecard->state = DEVLINK_LINECARD_STATE_ACTIVE; in devlink_linecard_activate()
10568 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); in devlink_linecard_activate()
10569 mutex_unlock(&linecard->state_lock); in devlink_linecard_activate()
10578 void devlink_linecard_deactivate(struct devlink_linecard *linecard) in devlink_linecard_deactivate() argument
10580 mutex_lock(&linecard->state_lock); in devlink_linecard_deactivate()
10581 switch (linecard->state) { in devlink_linecard_deactivate()
10583 linecard->state = DEVLINK_LINECARD_STATE_PROVISIONED; in devlink_linecard_deactivate()
10584 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); in devlink_linecard_deactivate()
10595 mutex_unlock(&linecard->state_lock); in devlink_linecard_deactivate()
10606 void devlink_linecard_nested_dl_set(struct devlink_linecard *linecard, in devlink_linecard_nested_dl_set() argument
10609 mutex_lock(&linecard->state_lock); in devlink_linecard_nested_dl_set()
10610 linecard->nested_devlink = nested_devlink; in devlink_linecard_nested_dl_set()
10611 devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); in devlink_linecard_nested_dl_set()
10612 mutex_unlock(&linecard->state_lock); in devlink_linecard_nested_dl_set()