#ifndef __ECORE_LL2_H__
#define __ECORE_LL2_H__
#include "ecore.h"
#include "ecore_hsi_eth.h"
#include "ecore_chain.h"
#include "ecore_hsi_common.h"
#include "ecore_ll2_api.h"
#include "ecore_sp_api.h"
#define ECORE_MAX_NUM_OF_LL2_CONNECTIONS (4)
static OSAL_INLINE u8 ecore_ll2_handle_to_queue_id(struct ecore_hwfn *p_hwfn,
u8 handle)
{
return p_hwfn->hw_info.resc_start[ECORE_LL2_QUEUE] + handle;
}
struct ecore_ll2_rx_packet
{
osal_list_entry_t list_entry;
struct core_rx_bd_with_buff_len *rxq_bd;
dma_addr_t rx_buf_addr;
u16 buf_length;
void *cookie;
u8 placement_offset;
u16 parse_flags;
u16 packet_length;
u16 vlan;
u32 opaque_data[2];
};
struct ecore_ll2_tx_packet
{
osal_list_entry_t list_entry;
u16 bd_used;
bool notify_fw;
void *cookie;
struct {
struct core_tx_bd *txq_bd;
dma_addr_t tx_frag;
u16 frag_len;
} bds_set[1];
};
struct ecore_ll2_rx_queue {
osal_spinlock_t lock;
struct ecore_chain rxq_chain;
struct ecore_chain rcq_chain;
u8 rx_sb_index;
bool b_cb_registred;
__le16 *p_fw_cons;
osal_list_t active_descq;
osal_list_t free_descq;
osal_list_t posting_descq;
struct ecore_ll2_rx_packet *descq_array;
void OSAL_IOMEM *set_prod_addr;
};
struct ecore_ll2_tx_queue {
osal_spinlock_t lock;
struct ecore_chain txq_chain;
u8 tx_sb_index;
bool b_cb_registred;
__le16 *p_fw_cons;
osal_list_t active_descq;
osal_list_t free_descq;
osal_list_t sending_descq;
struct ecore_ll2_tx_packet *descq_array;
struct ecore_ll2_tx_packet *cur_send_packet;
struct ecore_ll2_tx_packet cur_completing_packet;
u16 cur_completing_bd_idx;
void OSAL_IOMEM *doorbell_addr;
struct core_db_data db_msg;
u16 bds_idx;
u16 cur_send_frag_num;
u16 cur_completing_frag_num;
bool b_completing_packet;
};
struct ecore_ll2_info {
osal_mutex_t mutex;
struct ecore_ll2_acquire_data_inputs input;
u32 cid;
u8 my_id;
u8 queue_id;
u8 tx_stats_id;
bool b_active;
enum core_tx_dest tx_dest;
u8 tx_stats_en;
u8 main_func_queue;
struct ecore_ll2_rx_queue rx_queue;
struct ecore_ll2_tx_queue tx_queue;
struct ecore_ll2_cbs cbs;
};
enum _ecore_status_t ecore_ll2_alloc(struct ecore_hwfn *p_hwfn);
void ecore_ll2_setup(struct ecore_hwfn *p_hwfn);
void ecore_ll2_free(struct ecore_hwfn *p_hwfn);
#ifndef LINUX_REMOVE
enum _ecore_status_t
ecore_ll2_get_fragment_of_tx_packet(struct ecore_hwfn *p_hwfn,
u8 connection_handle,
dma_addr_t *addr,
bool *last_fragment);
#endif
#endif