/*
 * Copyright (c) 2012, 2015-2019, 2021, The Linux Foundation. All rights reserved.
 * Copyright (c) 2021-2024, Qualcomm Innovation Center, Inc. All rights reserved.
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */



#ifndef _SW_API_H
#define _SW_API_H

#ifdef __cplusplus
extern "C" {
#endif                          /* __cplusplus */

#include "sw.h"
#include "sw_ioctl.h"

#define SW_MAX_API_BUF         2048
#define SW_MAX_API_PARAM       12 /* cmd type + return value + ten parameters */
#define SW_MAX_PAYLOAD         (SW_MAX_API_PARAM << 2)  /* maximum payload size for netlink msg*/
#define SW_PARAM_IN            0x1
#define SW_PARAM_OUT           0x2
#define SW_PARAM_PTR           0x4

#define SW_API_DEF(ioctl, name) {ioctl, name}

#define SW_PARAM_DEF(ioctl, data, size, type, name) {ioctl, size, data, type}

typedef enum
{
	SW_UINT8 = 1,
	SW_INT8,
	SW_UINT16,
	SW_INT16,
	SW_UINT32,
	SW_INT32,
	SW_UINT64,
	SW_INT64,
	SW_ENABLE,
	SW_SPEED,
	SW_DUPLEX,
	SW_1QMODE,
	SW_EGMODE,
	SW_CAP,
	SW_VLAN,
	SW_LAN_WAN_CFG,
	SW_PBMP,
	SW_MIB,
	SW_MIB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ACL_UDF_PKT_TYPE,
	SW_PORTGROUP,
	SW_PORTPRI,
	SW_PORTREMARK,
	SW_COSMAP,
	SW_SCHEDULER,
	SW_QUEUEBMP,
	SW_BMSTHRESH,
	SW_BMDTHRESH,
	SW_BMPORTCNT,
	SW_PORT_SHAPER_TOKEN_CONFIG,
	SW_SHAPER_TOKEN_CONFIG,
	SW_PORT_SHAPER_CONFIG,
	SW_SHAPER_CONFIG,
	SW_QM_CNT,
	SW_POLICER_COUNTER,
	SW_POLICER_PORT_CONFIG,
	SW_POLICER_ACL_CONFIG,
	SW_POLICER_CMD_CONFIG,
	SW_POLICER_GLOBAL_COUNTER,
	SW_PHY_DUMP,
	SW_RESOURCE_SCHE,
	SW_PTP_CONFIG,
	SW_PTP_REFERENCE_CLOCK,
	SW_PTP_RX_TIMESTAMP_MODE,
	SW_PTP_DIRECTION,
	SW_PTP_PKT_INFO,
	SW_PTP_TIME,
	SW_PTP_GRANDMASTER_MODE,
	SW_PTP_SECURITY,
	SW_PTP_PPS_SIGNAL_CONTROL,
	SW_PTP_ASYM_CORRECTION,
	SW_PTP_OUTPUT_WAVEFORM,
	SW_PTP_TOD_UART,
	SW_PTP_ENHANCED_TS_ENGINE,
	SW_PTP_TRIGGER,
	SW_PTP_CAPTURE,
	SW_PTP_INTERRUPT,
	SW_PORT_EEE_CONFIG,
	SW_SRC_FILTER_CONFIG,
	SW_PORT_LOOPBACK_CONFIG,
	SW_PORT_8023AH_CTRL,
	SW_SFP_DATA,
	SW_SFP_DEV_TYPE,
	SW_SFP_TRANSC_CODE,
	SW_SFP_RATE_ENCODE,
	SW_SFP_LINK_LENGTH,
	SW_SFP_VENDOR_INFO,
	SW_SFP_LASER_WAVELENGTH,
	SW_SFP_OPTION,
	SW_SFP_CTRL_RATE,
	SW_SFP_ENHANCED_CFG,
	SW_SFP_DIAG_THRESHOLD,
	SW_SFP_DIAG_CAL_CONST,
	SW_SFP_DIAG_REALTIME,
	SW_SFP_CTRL_STATUS,
	SW_SFP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
	SW_PPE_CAPACITY,
	SW_RTC_SRC_TYPE,
	SW_QM_PROFILE,
	SW_QM_PRI,
	SW_QM_CLASS,
	SW_QM_QBASE,
	SW_QM_HASH,
	SW_DIRECTION,
	SW_ATHTAG_PRI_MAPPING,
	SW_ATHTAG_PORT_MAPPING,
	SW_ATHTAG_RX_CFG,
	SW_ATHTAG_TX_CFG,
	SW_SERVCODE_ATHTAG,
	SW_COMBO_LINK,
	SW_ERP_POWER_MODE,
	SW_TOEPLITZ_SECRET_KEY,
	SW_RSS_HASH_ALGM,
	SW_TOEPLITZ_CONFIG,
/* auto_insert_flag */
} sw_data_type_e;

    typedef struct
    {
        a_uint32_t api_id;
        void *func;
    } sw_api_func_t;

    typedef struct
    {
        a_uint32_t api_id;
        a_uint16_t data_size;
	a_uint16_t  data_type;
        a_uint8_t  param_type;
    } sw_api_param_t;

    typedef struct
    {
        a_uint32_t api_id;
        sw_api_func_t *api_fp;
        sw_api_param_t *api_pp;
        a_uint32_t api_nr;
    } sw_api_t;

#ifdef __cplusplus
}
#endif                          /* __cplusplus */

#endif                          /* _SW_API_H */
