/* * <:copyright-BRCM:2013:DUAL/GPL:standard * * Copyright (c) 2013 Broadcom * All Rights Reserved * * Unless you and Broadcom execute a separate written software license * agreement governing use of this software, this software is licensed * to you under the terms of the GNU General Public License version 2 * (the "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, * with the following added to such license: * * As a special exception, the copyright holders of this software give * you permission to link this software with independent modules, and * to copy and distribute the resulting executable under terms of your * choice, provided that you also meet, for each linked independent * module, the terms and conditions of the license of that module. * An independent module is a module which is not derived from this * software. The special exception does not apply to any modifications * of the software. * * Not withstanding the above, under no circumstances may you combine * this software in any way with any other Broadcom software provided * under a license other than the GPL, without Broadcom's express prior * written consent. * * :> */ #ifndef RDPA_CPU_H_ #define RDPA_CPU_H_ #ifdef __cplusplus extern "C" { #endif #include "rdpa_types.h" #include "rdpa_cpu_basic.h" #if defined(DSL_63138) || defined(DSL_63148) #include "rdpa_ipsec.h" #endif /** \defgroup cpu CPU Interface * Functions in this module: * - Send packets from the host to any egress port or to virtual "bridge" port * - Receive packets via one of host termination (CPU_RX) or Wi-Fi acceleration (WLAN_TX) queues * - Connect per-port and/or per-receive queue interrupt handlers * - Configure CPU trap reason --> queue mapping * * Runner to host traffic management parameters can be configured similarly to any other egress queue. * Initial port level (CPU, WLAN0, WLAN1) configuration is done using the appropriate port configuration * that fixes parameters such as scheduling type, number of queues, etc.\n * @{ */ /** \defgroup isr Interrupt Control * \ingroup cpu * Functions in this group allow to * - Register / unregister per-queue interrupt handler * - Enable / disable / clear per-queue interrupt * @{ */ /** Enable CPU queue interrupt * \param[in] port port. rdpa_cpu, rdpa_wlan0, rdpa_wlan1 * \param[in] queue Queue index < num_queues in port tm configuration */ void rdpa_cpu_int_enable(rdpa_cpu_port port, int queue); /** Disable CPU queue interrupt * \param[in] port port. rdpa_cpu, rdpa_wlan0, rdpa_wlan1 * \param[in] queue Queue index < num_queues in port tm configuration */ void rdpa_cpu_int_disable(rdpa_cpu_port port, int queue); /** Clear CPU queue interrupt * \param[in] port port. rdpa_cpu, rdpa_wlan0, rdpa_wlan1 * \param[in] queue Queue index < num_queues in port tm configuration */ void rdpa_cpu_int_clear(rdpa_cpu_port port, int queue); /** @} end of isr Doxygen group */ /** \defgroup cpu_rx Receive * \ingroup cpu * Functions in this group allow to * - Register/unregister per-port and per-queue interrupt handlers * - Register/unregister packet handler * - Pull received packets from port (scheduling) or queue * @{ */ /** Max number of CPU interface meters per direction */ #ifndef XRDP #define RDPA_CPU_MAX_DS_METERS 4 /**< Number of meters for packets received from WAN port(s) */ #else #define RDPA_CPU_MAX_DS_METERS 16 /**< Number of meters for packets received from WAN port(s) */ #endif #define RDPA_CPU_MAX_US_METERS 16 /**< Number of meters for packets received from LAN port(s) */ /** CPU meter SR validation constants */ #define RDPA_CPU_METER_MIN_SR 100 /**< Min CPU meter SR value in pps */ #define RDPA_CPU_METER_MAX_SR 40000 /**< Max CPU meter SR value in pps */ #define RDPA_CPU_METER_SR_QUANTA 100 /**< CPU meter SR must be a multiple of quanta */ /** Reason index. Underlying type of cpu_reason_index aggregate */ typedef struct { rdpa_traffic_dir dir; /**< Traffic direction */ rdpa_cpu_reason reason; /**< CPU reason */ #if defined(DSL_63138) || defined(DSL_63148) || defined(WL4908) int table_index; /**< reason table index */ #endif int entry_index; /* Reserved for internal use. */ } rdpa_cpu_reason_index_t; /** Reason configuration structure. * Underlying structure for cpu_reason_cfg aggregate */ typedef struct { bdmf_index queue; /**< reason --> queue mapping */ bdmf_index meter; /**< CPU interface meter index < RDPA_CPU_MAX_METERS or BDMF_INDEX_UNDEFINED */ rdpa_ports meter_ports; /**< Mask of ports for which the policer is active */ } rdpa_cpu_reason_cfg_t; /** CPU meter configuration * Underlying structure for cpu_meter_cfg aggregate */ typedef struct { uint32_t sir; /**< SIR ( packets per sec ) */ uint32_t burst_size; /**< Burst size ( packets ) */ } rdpa_cpu_meter_cfg_t; /** L4 dst port to reason configuration * Underlying structure for l4_dst_port_to_reason aggregate */ typedef struct { bdmf_boolean is_tcp; /**< TCP or UDP */ uint16_t l4_dst_port; /**< l4 dst port */ rdpa_cpu_reason reason; /**< rdpa cpu reason */ bdmf_boolean is_static; /**< static or dynamic */ uint8_t refcnt; /**< reference count */ } rdpa_l4_dst_port_to_reason_cfg_t; /** Receive packet info */ typedef struct { rdpa_cpu_reason reason; /**< trap reason */ rdpa_if src_port; /**< source port */ uint16_t vport; uint32_t reason_data; /**< Reason-specific data. For CPU port it usually contains src_flow For Wi-Fi port it contains source SSID index in 16 MSB and destination SSID vector in 16 LSB It can contain other reason-specific info (such as OAM info, etc.). */ void *data; /** max MTU size */ uint32_t tx_rdd_error; /**< Discarded because RDD returned error */ } rdpa_cpu_tx_stat_t; /** Send system buffer * * \param[in] sysb System buffer. Released regardless on the function outcome * \param[in] info Tx info * \return 0=OK or int error code\n */ int rdpa_cpu_send_sysb(bdmf_sysb sysb, const rdpa_cpu_tx_info_t *info); int rdpa_cpu_send_wfd_to_bridge(bdmf_sysb sysb, const rdpa_cpu_tx_info_t *info, size_t offset_next); #if defined(DSL_63138) || defined(DSL_63148) || defined(WL4908) /** Send system buffer to Ethernet/DSL WAN Interface * * \param[in] sysb System buffer. Released regardless on the function outcome * \param[in] egress_queue Ethernet Egress Queue * \return 0=OK or int error code\n */ int rdpa_cpu_tx_port_enet_or_dsl_wan(bdmf_sysb sysb, uint32_t egress_queue, rdpa_flow wan_flow, rdpa_if wan_if, rdpa_cpu_tx_extra_info_t extra_info); /** Send system buffer to Ethernet LAN Interface * * \param[in] sysb System buffer. Released regardless on the function outcome * \param[in] egress_queue Ethernet Egress Queue * \param[in] phys_port Ethernet LAN physical port * \return 0=OK or int error code\n */ int rdpa_cpu_tx_port_enet_lan(bdmf_sysb sysb, uint32_t egress_queue, uint32_t phys_port, rdpa_cpu_tx_extra_info_t extra_info); /** Send system buffer to Flow Cache Offload * * \param[in] sysb: System buffer. Released regardless on the function outcome * \param[in] cpu_rx_queue: CPU Rx Queue index, in case of Runner Flow miss * \param[in] dirty: Indicates whether a packet flush from D$ is required * \return 0=OK or int error code\n */ int rdpa_cpu_tx_flow_cache_offload(bdmf_sysb sysb, uint32_t cpu_rx_queue, int dirty); /** Frees the given free index and returns a pointer to the associated * System Buffer. It is up to the caller to process the System Buffer. * * \param[in] free_index: Runner free index * \return: Pointer to the associated system buffer\n */ bdmf_sysb rdpa_cpu_return_free_index(uint16_t free_index); /** Receive a system buffer (FKB type) from an Ethernet Interface * * \param[in] queue CPU RX Queue ID * \param[in] sysb System buffer * \param[in] src_port Source RDPA Interface * \return 0=OK or int error code\n */ int rdpa_cpu_host_packet_get_enet(bdmf_index queue, bdmf_sysb *sysb, rdpa_if *src_port); /** Free all pending Tx Buffers */ void rdpa_cpu_tx_reclaim(void); /** Send system buffer to IPsec Offload * * \param[in] sysb: System buffer. * \param[in] dir: Indicates whether the packet is upstream or downstream. * \param[in] esphdr_offset: ESP header byte offset into the packet. * \param[in] sa_index: Entry index of the ddr SA descriptor table. * \param[in] sa_update: 0- sa_index entry of the ddr sa descriptor table is new. * 1- sa_index entry of the ddr sa descriptor table has been updated.. * \param[in] cpu_qid: Runner - HostCPU queue id * \return 0=OK or int error code\n */ int rdpa_cpu_tx_ipsec_offload(bdmf_sysb sysb, rdpa_traffic_dir dir, uint8_t esphdr_offset, uint8_t sa_index, uint8_t sa_update, uint8_t cpu_qid); #endif /** Send raw packet * * \param[in] data Packet data * \param[in] length Packet length * \param[in] info Info * \return 0=OK or int error code\n */ int rdpa_cpu_send_raw(void *data, uint32_t length, const rdpa_cpu_tx_info_t *info); /** Get cpu queue emptiness status * * \param[in] port CPU port (CPU, PCI1, PCI2) * \param[in] queue Queue index < num_queues in rdpa_port_tm_cfg_t or UNASSIGNED * \return 0=no packets are waiting or at least one packet in queue\n */ int rdpa_cpu_queue_not_empty(rdpa_cpu_port port, bdmf_index queue); /** Get cpu queue fullness status * * \param[in] port CPU port (CPU, PCI1, PCI2) * \param[in] queue Queue index < num_queues in rdpa_port_tm_cfg_t or UNASSIGNED * \return 1 = if queue is full or 0 if there is still place to put packets\n */ int rdpa_cpu_queue_is_full(rdpa_cpu_port port, bdmf_index queue); /** Get the Time Of Day from the FW FIFO, by the ptp index * \param[in] ptp_index ptp_index is an entry of struct rdpa_cpu_rx_info_t and is copied from struct * CPU_RX_PARAMS on each received packet. It is only relavent on ptp 1588 packets. * By this index we get the corresponding Time Of Day of the received packet. * \param[out] tod_h 4 most bytes of the TOD * \param[out] tod_l 4 least bytes of the TOD * \param[out] local_counter_delta time propogation delta between HW and NP * \return 0=OK or int error code\n */ int rdpa_cpu_ptp_1588_get_tod(uint16_t ptp_index, uint32_t *tod_h, uint32_t *tod_l, uint16_t *local_counter_delta); /** Send ptp-1588 system buffer * * \param[in] sysb System buffer. Released regardless on the function outcome * \param[in] info Tx info * \return 0=OK or int error code\n */ int rdpa_cpu_send_sysb_ptp(bdmf_sysb sysb, const rdpa_cpu_tx_info_t *info); /** Send system buffer - Special function to send EPON Dying * Gasp: * * \param[in] sysb System buffer. Released regardless on the function outcome * \param[in] info Tx info * \return 0=OK or int error code\n * * */ int rdpa_cpu_send_epon_dying_gasp(bdmf_sysb sysb, const rdpa_cpu_tx_info_t *info); /** Check if the reason is supported by port metering * \param[in] reason reason to test * \return 0=OK or int error code\n */ int rdpa_cpu_is_per_port_metering_supported(rdpa_cpu_reason reason); /** @} end of cpu_tx Doxygen group */ /** @} end of cpu Doxygen group */ rdpa_ports rdpa_ports_all_lan(void); void rdpa_cpu_rx_dump_packet(char *name, rdpa_cpu_port port, bdmf_index queue, rdpa_cpu_rx_info_t *info, uint32_t dst_ssid); #ifdef XRDP /** Platform buffer */ typedef void *bdmf_pbuf_t; static inline void bdmf_pbuf_init(uint32_t size, uint32_t offset) { } static inline void bdmf_pbuf_free(bdmf_pbuf_t *pbuf) { } static inline int bdmf_pbuf_alloc(void *data, uint32_t length, uint16_t source, bdmf_pbuf_t *pbuf) { return 0; } #endif #ifdef __cplusplus } #endif #endif /* RDPA_CPU_H_ */