04b9ce8e32
Manual verification on switch (TH3 device) admin@str2-xxxxx-01:~$ bcmcmd bsv bsv BRCM SAI ver: [6.0.0.10], OCP SAI ver: [1.9.1], SDK ver: [sdk-6.5.23] drivshell> admin@str2-xxxxx-01:~$ bcmcmd version version Broadcom Command Monitor: Copyright (c) 1998-2021 Broadcom Release: sdk-6.5.23 built 20211020 (Wed Oct 20 06:52:58 2021) From root@fedbbfdbee81:/__w/2/s/output/x86-xgsall-deb/hsdk Platform: X86 OS: Unix (Posix) Chips: BCM56640_A0, BCM56850_A0, BCM56340_A0, BCM56960_A0, BCM56860_A0, BCM56970_A0, BCM56870_A0, BCM56980_A0, BCM56980_B0, BCM56370_A0, BCM56275_A0, BCM56770_A0, Chips: BCM56780_A0, BCM56782_A0, BCM56784_A0, BCM56785_A0, BCM56786_A0, BCM56787_A0, BCM56788_A0, BCM56789_A0, BCM56880_A0, BCM56880_B0, BCM56881_A0, BCM56881_B0, BCM56883_A0, BCM56883_B0, BCM56990_A0, BCM56990_B0, BCM56991_B0, BCM56992_B0, BCM56996_A0, BCM56996_B0, BCM56997_A0, BCM56997_B0 Variant drivers: BCM56780_A0_CNA_1_2_10, BCM56780_A0_DNA_2_7_6_0, BCM56880_A0_CNA_1_2_9, BCM56880_A0_DNA_4_9_5_0 PHYs: BCM5400, BCM54182, BCM54185, BCM54180, BCM54140, BCM54192, BCM54195, BCM54190, BCM54194, BCM54210, BCM54220, BCM54280, BCM54282, BCM54240, BCM54285, BCM5428X, BCM54290, BCM54292, BCM54294, BCM54295, BCM54296, BCM56160-GPHY, BCM53540-GPHY, BCM56275-GPHY, BCM8750, BCM8752, BCM8754, BCM84740, BCM84164, BCM84758, BCM84780, BCM84784, BCM84318, BCM84328, Sesto, BCM82780, copper sfp drivshell>
358 lines
8.2 KiB
C
358 lines
8.2 KiB
C
/*! \file ngknet_callback.c
|
|
*
|
|
* Utility routines for NGKNET callbacks.
|
|
*
|
|
*/
|
|
/*
|
|
* $Copyright: Copyright 2018-2021 Broadcom. All rights reserved.
|
|
* The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* version 2 as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* A copy of the GNU General Public License version 2 (GPLv2) can
|
|
* be found in the LICENSES folder.$
|
|
*/
|
|
|
|
#include "ngknet_callback.h"
|
|
|
|
static struct ngknet_callback_ctrl callback_ctrl;
|
|
|
|
int
|
|
ngknet_callback_control_get(struct ngknet_callback_ctrl **cbc)
|
|
{
|
|
*cbc = &callback_ctrl;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*!
|
|
* Call-back interfaces for other Linux kernel drivers.
|
|
*/
|
|
|
|
int
|
|
ngknet_dev_init_cb_register(ngknet_dev_init_cb_f dev_init_cb)
|
|
{
|
|
if (callback_ctrl.dev_init_cb != NULL) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.dev_init_cb = dev_init_cb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_dev_init_cb_unregister(ngknet_dev_init_cb_f dev_init_cb)
|
|
{
|
|
if (dev_init_cb == NULL || callback_ctrl.dev_init_cb != dev_init_cb) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.dev_init_cb = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_rx_cb_register(ngknet_rx_cb_f rx_cb)
|
|
{
|
|
if (callback_ctrl.rx_cb != NULL) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.rx_cb = rx_cb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_rx_cb_unregister(ngknet_rx_cb_f rx_cb)
|
|
{
|
|
if (rx_cb == NULL || callback_ctrl.rx_cb != rx_cb) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.rx_cb = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_tx_cb_register(ngknet_tx_cb_f tx_cb)
|
|
{
|
|
if (callback_ctrl.tx_cb != NULL) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.tx_cb = tx_cb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_tx_cb_unregister(ngknet_tx_cb_f tx_cb)
|
|
{
|
|
if (tx_cb == NULL || callback_ctrl.tx_cb != tx_cb) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.tx_cb = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_filter_cb_register(ngknet_filter_cb_f filter_cb)
|
|
{
|
|
if (callback_ctrl.filter_cb != NULL) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.filter_cb = filter_cb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_filter_cb_unregister(ngknet_filter_cb_f filter_cb)
|
|
{
|
|
if (filter_cb == NULL || callback_ctrl.filter_cb != filter_cb) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.filter_cb = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_rx_config_set_cb_register(ngknet_ptp_config_set_cb_f ptp_rx_config_set_cb)
|
|
{
|
|
if (callback_ctrl.ptp_rx_config_set_cb != NULL) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_rx_config_set_cb = ptp_rx_config_set_cb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_rx_config_set_cb_unregister(ngknet_ptp_config_set_cb_f ptp_rx_config_set_cb)
|
|
{
|
|
if (ptp_rx_config_set_cb == NULL ||
|
|
callback_ctrl.ptp_rx_config_set_cb != ptp_rx_config_set_cb) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_rx_config_set_cb = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_tx_config_set_cb_register(ngknet_ptp_config_set_cb_f ptp_tx_config_set_cb)
|
|
{
|
|
if (callback_ctrl.ptp_tx_config_set_cb != NULL) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_tx_config_set_cb = ptp_tx_config_set_cb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_tx_config_set_cb_unregister(ngknet_ptp_config_set_cb_f ptp_tx_config_set_cb)
|
|
{
|
|
if (ptp_tx_config_set_cb == NULL ||
|
|
callback_ctrl.ptp_tx_config_set_cb != ptp_tx_config_set_cb) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_tx_config_set_cb = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_rx_hwts_get_cb_register(ngknet_ptp_hwts_get_cb_f ptp_rx_hwts_get_cb)
|
|
{
|
|
if (callback_ctrl.ptp_rx_hwts_get_cb != NULL) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_rx_hwts_get_cb = ptp_rx_hwts_get_cb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_rx_hwts_get_cb_unregister(ngknet_ptp_hwts_get_cb_f ptp_rx_hwts_get_cb)
|
|
{
|
|
if (ptp_rx_hwts_get_cb == NULL ||
|
|
callback_ctrl.ptp_rx_hwts_get_cb != ptp_rx_hwts_get_cb) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_rx_hwts_get_cb = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_tx_hwts_get_cb_register(ngknet_ptp_hwts_get_cb_f ptp_tx_hwts_get_cb)
|
|
{
|
|
if (callback_ctrl.ptp_tx_hwts_get_cb != NULL) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_tx_hwts_get_cb = ptp_tx_hwts_get_cb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_tx_hwts_get_cb_unregister(ngknet_ptp_hwts_get_cb_f ptp_tx_hwts_get_cb)
|
|
{
|
|
if (ptp_tx_hwts_get_cb == NULL ||
|
|
callback_ctrl.ptp_tx_hwts_get_cb != ptp_tx_hwts_get_cb) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_tx_hwts_get_cb = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_tx_meta_set_cb_register(ngknet_ptp_meta_set_cb_f ptp_tx_meta_set_cb)
|
|
{
|
|
if (callback_ctrl.ptp_tx_meta_set_cb != NULL) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_tx_meta_set_cb = ptp_tx_meta_set_cb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_tx_meta_set_cb_unregister(ngknet_ptp_meta_set_cb_f ptp_tx_meta_set_cb)
|
|
{
|
|
if (ptp_tx_meta_set_cb == NULL ||
|
|
callback_ctrl.ptp_tx_meta_set_cb != ptp_tx_meta_set_cb) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_tx_meta_set_cb = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_phc_index_get_cb_register(ngknet_ptp_phc_index_get_cb_f ptp_phc_index_get_cb)
|
|
{
|
|
if (callback_ctrl.ptp_phc_index_get_cb != NULL) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_phc_index_get_cb = ptp_phc_index_get_cb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_phc_index_get_cb_unregister(ngknet_ptp_phc_index_get_cb_f ptp_phc_index_get_cb)
|
|
{
|
|
if (ptp_phc_index_get_cb == NULL ||
|
|
callback_ctrl.ptp_phc_index_get_cb != ptp_phc_index_get_cb) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_phc_index_get_cb = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_dev_ctrl_cb_register(ngknet_ptp_dev_ctrl_cb_f ptp_dev_ctrl_cb)
|
|
{
|
|
if (callback_ctrl.ptp_dev_ctrl_cb != NULL) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_dev_ctrl_cb = ptp_dev_ctrl_cb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_ptp_dev_ctrl_cb_unregister(ngknet_ptp_dev_ctrl_cb_f ptp_dev_ctrl_cb)
|
|
{
|
|
if (ptp_dev_ctrl_cb == NULL ||
|
|
callback_ctrl.ptp_dev_ctrl_cb != ptp_dev_ctrl_cb) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.ptp_dev_ctrl_cb = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_netif_create_cb_register(ngknet_netif_cb_f netif_cb)
|
|
{
|
|
if (callback_ctrl.netif_create_cb != NULL) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.netif_create_cb = netif_cb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_netif_create_cb_unregister(ngknet_netif_cb_f netif_cb)
|
|
{
|
|
if (netif_cb == NULL || callback_ctrl.netif_create_cb != netif_cb) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.netif_create_cb = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_netif_destroy_cb_register(ngknet_netif_cb_f netif_cb)
|
|
{
|
|
if (callback_ctrl.netif_destroy_cb != NULL) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.netif_destroy_cb = netif_cb;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
ngknet_netif_destroy_cb_unregister(ngknet_netif_cb_f netif_cb)
|
|
{
|
|
if (netif_cb == NULL || callback_ctrl.netif_destroy_cb != netif_cb) {
|
|
return -1;
|
|
}
|
|
callback_ctrl.netif_destroy_cb = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
EXPORT_SYMBOL(ngknet_dev_init_cb_register);
|
|
EXPORT_SYMBOL(ngknet_dev_init_cb_unregister);
|
|
EXPORT_SYMBOL(ngknet_rx_cb_register);
|
|
EXPORT_SYMBOL(ngknet_rx_cb_unregister);
|
|
EXPORT_SYMBOL(ngknet_tx_cb_register);
|
|
EXPORT_SYMBOL(ngknet_tx_cb_unregister);
|
|
EXPORT_SYMBOL(ngknet_filter_cb_register);
|
|
EXPORT_SYMBOL(ngknet_filter_cb_unregister);
|
|
EXPORT_SYMBOL(ngknet_ptp_rx_config_set_cb_register);
|
|
EXPORT_SYMBOL(ngknet_ptp_rx_config_set_cb_unregister);
|
|
EXPORT_SYMBOL(ngknet_ptp_tx_config_set_cb_register);
|
|
EXPORT_SYMBOL(ngknet_ptp_tx_config_set_cb_unregister);
|
|
EXPORT_SYMBOL(ngknet_ptp_rx_hwts_get_cb_register);
|
|
EXPORT_SYMBOL(ngknet_ptp_rx_hwts_get_cb_unregister);
|
|
EXPORT_SYMBOL(ngknet_ptp_tx_hwts_get_cb_register);
|
|
EXPORT_SYMBOL(ngknet_ptp_tx_hwts_get_cb_unregister);
|
|
EXPORT_SYMBOL(ngknet_ptp_tx_meta_set_cb_register);
|
|
EXPORT_SYMBOL(ngknet_ptp_tx_meta_set_cb_unregister);
|
|
EXPORT_SYMBOL(ngknet_ptp_phc_index_get_cb_register);
|
|
EXPORT_SYMBOL(ngknet_ptp_phc_index_get_cb_unregister);
|
|
EXPORT_SYMBOL(ngknet_ptp_dev_ctrl_cb_register);
|
|
EXPORT_SYMBOL(ngknet_ptp_dev_ctrl_cb_unregister);
|
|
EXPORT_SYMBOL(ngknet_netif_create_cb_register);
|
|
EXPORT_SYMBOL(ngknet_netif_create_cb_unregister);
|
|
EXPORT_SYMBOL(ngknet_netif_destroy_cb_register);
|
|
EXPORT_SYMBOL(ngknet_netif_destroy_cb_unregister);
|