linux/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (c) 2014-2015 Hisilicon Limited.
 */

#ifndef _HNS_DSAF_RCB_H
#define _HNS_DSAF_RCB_H

#include <linux/netdevice.h>
#include <linux/platform_device.h>

#include "hnae.h"
#include "hns_dsaf_main.h"

struct rcb_common_cb;

#define HNS_RCB_IRQ_NUM_PER_QUEUE
#define HNS_RCB_IRQ_IDX_TX
#define HNS_RCB_IRQ_IDX_RX
#define HNS_RCB_TX_REG_OFFSET

#define HNS_RCB_SERVICE_NW_ENGINE_NUM
#define HNS_RCB_DEBUG_NW_ENGINE_NUM
#define HNS_RCB_RING_MAX_BD_PER_PKT
#define HNS_RCB_RING_MAX_TXBD_PER_PKT
#define HNS_RCBV2_RING_MAX_TXBD_PER_PKT
#define HNS_RCB_MAX_PKT_SIZE

#define HNS_RCB_RING_MAX_PENDING_BD
#define HNS_RCB_RING_MIN_PENDING_BD

#define HNS_RCB_REG_OFFSET

#define HNS_RCB_TX_FRAMES_LOW
#define HNS_RCB_RX_FRAMES_LOW
#define HNS_RCB_TX_FRAMES_HIGH
#define HNS_RCB_RX_FRAMES_HIGH
#define HNS_RCB_TX_USECS_LOW
#define HNS_RCB_RX_USECS_LOW
#define HNS_RCB_TX_USECS_HIGH
#define HNS_RCB_RX_USECS_HIGH
#define HNS_RCB_MAX_COALESCED_FRAMES
#define HNS_RCB_MIN_COALESCED_FRAMES
#define HNS_RCB_DEF_RX_COALESCED_FRAMES
#define HNS_RCB_DEF_TX_COALESCED_FRAMES
#define HNS_RCB_CLK_FREQ_MHZ
#define HNS_RCB_MAX_COALESCED_USECS
#define HNS_RCB_DEF_COALESCED_USECS
#define HNS_RCB_DEF_GAP_TIME_USECS
#define HNS_RCB_TX_PKTLINE_OFFSET

#define HNS_RCB_COMMON_ENDIAN

#define HNS_BD_SIZE_512_TYPE
#define HNS_BD_SIZE_1024_TYPE
#define HNS_BD_SIZE_2048_TYPE
#define HNS_BD_SIZE_4096_TYPE

#define HNS_RCB_COMMON_DUMP_REG_NUM
#define HNS_RCB_RING_DUMP_REG_NUM
#define HNS_RING_STATIC_REG_NUM

#define HNS_DUMP_REG_NUM
#define HNS_STATIC_REG_NUM

#define HNS_TSO_MODE_8BD_32K
#define HNS_TSO_MDOE_4BD_16K

enum rcb_int_flag {};

struct hns_ring_hw_stats {};

struct ring_pair_cb {};

struct rcb_common_cb {};

int hns_rcb_buf_size2type(u32 buf_size);

int hns_rcb_common_get_cfg(struct dsaf_device *dsaf_dev, int comm_index);
void hns_rcb_common_free_cfg(struct dsaf_device *dsaf_dev, u32 comm_index);
int hns_rcb_common_init_hw(struct rcb_common_cb *rcb_common);
void hns_rcb_start(struct hnae_queue *q, u32 val);
int hns_rcb_get_cfg(struct rcb_common_cb *rcb_common);
void hns_rcb_get_queue_mode(enum dsaf_mode dsaf_mode,
			    u16 *max_vfn, u16 *max_q_per_vf);

void hns_rcb_common_init_commit_hw(struct rcb_common_cb *rcb_common);

void hns_rcb_ring_enable_hw(struct hnae_queue *q, u32 val);
void hns_rcb_int_clr_hw(struct hnae_queue *q, u32 flag);
void hns_rcb_int_ctrl_hw(struct hnae_queue *q, u32 flag, u32 enable);
void hns_rcbv2_int_ctrl_hw(struct hnae_queue *q, u32 flag, u32 mask);
void hns_rcbv2_int_clr_hw(struct hnae_queue *q, u32 flag);

void hns_rcb_init_hw(struct ring_pair_cb *ring);
void hns_rcb_reset_ring_hw(struct hnae_queue *q);
void hns_rcb_wait_fbd_clean(struct hnae_queue **qs, int q_num, u32 flag);
int hns_rcb_wait_tx_ring_clean(struct hnae_queue *qs);
u32 hns_rcb_get_rx_coalesced_frames(
	struct rcb_common_cb *rcb_common, u32 port_idx);
u32 hns_rcb_get_tx_coalesced_frames(
	struct rcb_common_cb *rcb_common, u32 port_idx);
u32 hns_rcb_get_coalesce_usecs(
	struct rcb_common_cb *rcb_common, u32 port_idx);
int hns_rcb_set_coalesce_usecs(
	struct rcb_common_cb *rcb_common, u32 port_idx, u32 timeout);
int hns_rcb_set_rx_coalesced_frames(
	struct rcb_common_cb *rcb_common, u32 port_idx, u32 coalesced_frames);
int hns_rcb_set_tx_coalesced_frames(
	struct rcb_common_cb *rcb_common, u32 port_idx, u32 coalesced_frames);
void hns_rcb_update_stats(struct hnae_queue *queue);

void hns_rcb_get_stats(struct hnae_queue *queue, u64 *data);

void hns_rcb_get_common_regs(struct rcb_common_cb *rcb_common, void *data);

int hns_rcb_get_ring_sset_count(int stringset);
int hns_rcb_get_common_regs_count(void);
int hns_rcb_get_ring_regs_count(void);

void hns_rcb_get_ring_regs(struct hnae_queue *queue, void *data);

void hns_rcb_get_strings(int stringset, u8 *data, int index);
void hns_rcb_set_rx_ring_bs(struct hnae_queue *q, u32 buf_size);
void hns_rcb_set_tx_ring_bs(struct hnae_queue *q, u32 buf_size);

#endif /* _HNS_DSAF_RCB_H */