Lines Matching +full:sw +full:- +full:exception
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /* Copyright (c) 2019-2020 Marvell International Ltd. All rights reserved */
9 /* All driver-specific traps must be documented in
127 struct prestera_switch *sw; member
146 DEVLINK_TRAP_GENERIC(EXCEPTION, TRAP, _id, \
151 DEVLINK_TRAP_DRIVER(EXCEPTION, TRAP, DEVLINK_PRESTERA_TRAP_ID_##_id, \
356 struct prestera_switch *sw = devlink_priv(dl); in prestera_dl_info_get() local
365 sw->dev->fw_rev.maj, in prestera_dl_info_get()
366 sw->dev->fw_rev.min, in prestera_dl_info_get()
367 sw->dev->fw_rev.sub); in prestera_dl_info_get()
394 dev->dev); in prestera_devlink_alloc()
399 void prestera_devlink_free(struct prestera_switch *sw) in prestera_devlink_free() argument
401 struct devlink *dl = priv_to_devlink(sw); in prestera_devlink_free()
406 void prestera_devlink_register(struct prestera_switch *sw) in prestera_devlink_register() argument
408 struct devlink *dl = priv_to_devlink(sw); in prestera_devlink_register()
413 void prestera_devlink_unregister(struct prestera_switch *sw) in prestera_devlink_unregister() argument
415 struct devlink *dl = priv_to_devlink(sw); in prestera_devlink_unregister()
422 struct prestera_switch *sw = port->sw; in prestera_devlink_port_register() local
423 struct devlink *dl = priv_to_devlink(sw); in prestera_devlink_port_register()
428 attrs.phys.port_number = port->fp_id; in prestera_devlink_port_register()
429 attrs.switch_id.id_len = sizeof(sw->id); in prestera_devlink_port_register()
430 memcpy(attrs.switch_id.id, &sw->id, attrs.switch_id.id_len); in prestera_devlink_port_register()
432 devlink_port_attrs_set(&port->dl_port, &attrs); in prestera_devlink_port_register()
434 err = devlink_port_register(dl, &port->dl_port, port->fp_id); in prestera_devlink_port_register()
436 dev_err(prestera_dev(sw), "devlink_port_register failed: %d\n", err); in prestera_devlink_port_register()
445 devlink_port_unregister(&port->dl_port); in prestera_devlink_port_unregister()
450 devlink_port_type_eth_set(&port->dl_port, port->dev); in prestera_devlink_port_set()
455 devlink_port_type_clear(&port->dl_port); in prestera_devlink_port_clear()
462 return &port->dl_port; in prestera_devlink_get_port()
465 int prestera_devlink_traps_register(struct prestera_switch *sw) in prestera_devlink_traps_register() argument
469 struct devlink *devlink = priv_to_devlink(sw); in prestera_devlink_traps_register()
476 return -ENOMEM; in prestera_devlink_traps_register()
478 trap_data->trap_items_arr = kcalloc(traps_count, in prestera_devlink_traps_register()
481 if (!trap_data->trap_items_arr) { in prestera_devlink_traps_register()
482 err = -ENOMEM; in prestera_devlink_traps_register()
486 trap_data->sw = sw; in prestera_devlink_traps_register()
487 trap_data->traps_count = traps_count; in prestera_devlink_traps_register()
488 sw->trap_data = trap_data; in prestera_devlink_traps_register()
497 err = devlink_traps_register(devlink, &prestera_trap->trap, 1, in prestera_devlink_traps_register()
498 sw); in prestera_devlink_traps_register()
506 for (i--; i >= 0; i--) { in prestera_devlink_traps_register()
508 devlink_traps_unregister(devlink, &prestera_trap->trap, 1); in prestera_devlink_traps_register()
513 kfree(trap_data->trap_items_arr); in prestera_devlink_traps_register()
520 prestera_get_trap_item_by_cpu_code(struct prestera_switch *sw, u8 cpu_code) in prestera_get_trap_item_by_cpu_code() argument
522 struct prestera_trap_data *trap_data = sw->trap_data; in prestera_get_trap_item_by_cpu_code()
526 for (i = 0; i < trap_data->traps_count; i++) { in prestera_get_trap_item_by_cpu_code()
528 if (cpu_code == prestera_trap->cpu_code) in prestera_get_trap_item_by_cpu_code()
529 return &trap_data->trap_items_arr[i]; in prestera_get_trap_item_by_cpu_code()
541 devlink = port->dl_port.devlink; in prestera_devlink_trap_report()
543 trap_item = prestera_get_trap_item_by_cpu_code(port->sw, cpu_code); in prestera_devlink_trap_report()
547 devlink_trap_report(devlink, skb, trap_item->trap_ctx, in prestera_devlink_trap_report()
548 &port->dl_port, NULL); in prestera_devlink_trap_report()
552 prestera_devlink_trap_item_lookup(struct prestera_switch *sw, u16 trap_id) in prestera_devlink_trap_item_lookup() argument
554 struct prestera_trap_data *trap_data = sw->trap_data; in prestera_devlink_trap_item_lookup()
559 return &trap_data->trap_items_arr[i]; in prestera_devlink_trap_item_lookup()
568 struct prestera_switch *sw = devlink_priv(devlink); in prestera_trap_init() local
571 trap_item = prestera_devlink_trap_item_lookup(sw, trap->id); in prestera_trap_init()
573 return -EINVAL; in prestera_trap_init()
575 trap_item->trap_ctx = trap_ctx; in prestera_trap_init()
576 trap_item->action = trap->init_action; in prestera_trap_init()
587 return -EOPNOTSUPP; in prestera_trap_action_set()
594 struct prestera_switch *sw = devlink_priv(devlink); in prestera_drop_counter_get() local
600 return prestera_hw_cpu_code_counters_get(sw, prestera_trap->cpu_code, in prestera_drop_counter_get()
604 void prestera_devlink_traps_unregister(struct prestera_switch *sw) in prestera_devlink_traps_unregister() argument
606 struct prestera_trap_data *trap_data = sw->trap_data; in prestera_devlink_traps_unregister()
607 struct devlink *dl = priv_to_devlink(sw); in prestera_devlink_traps_unregister()
618 kfree(trap_data->trap_items_arr); in prestera_devlink_traps_unregister()