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

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

#ifndef __HNAE_H
#define __HNAE_H

/* Names used in this framework:
 *      ae handle (handle):
 *        a set of queues provided by AE
 *      ring buffer queue (rbq):
 *        the channel between upper layer and the AE, can do tx and rx
 *      ring:
 *        a tx or rx channel within a rbq
 *      ring description (desc):
 *        an element in the ring with packet information
 *      buffer:
 *        a memory region referred by desc with the full packet payload
 *
 * "num" means a static number set as a parameter, "count" mean a dynamic
 *   number set while running
 * "cb" means control block
 */

#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/notifier.h>
#include <linux/phy.h>
#include <linux/types.h>

#define HNAE_DRIVER_VERSION
#define HNAE_DRIVER_NAME
#define HNAE_COPYRIGHT
#define HNAE_DRIVER_STRING
#define HNAE_DEFAULT_DEVICE_DESCR

#ifdef DEBUG

#ifndef assert
#define assert
#endif

#else

#ifndef assert
#define assert(expr)
#endif

#endif

#define AE_VERSION_1
#define AE_VERSION_2
#define AE_IS_VER1(ver)
#define AE_NAME_SIZE

#define BD_SIZE_2048_MAX_MTU

/* some said the RX and TX RCB format should not be the same in the future. But
 * it is the same now...
 */
#define RCB_REG_BASEADDR_L
#define RCB_REG_BASEADDR_H
#define RCB_REG_BD_NUM
#define RCB_REG_BD_LEN
#define RCB_REG_PKTLINE
#define RCB_REG_TAIL
#define RCB_REG_HEAD
#define RCB_REG_FBDNUM
#define RCB_REG_OFFSET
#define RCB_REG_PKTNUM_RECORD

#define HNS_RX_HEAD_SIZE

#define HNAE_AE_REGISTER

#define RCB_RING_NAME_LEN

#define HNAE_LOWEST_LATENCY_COAL_PARAM
#define HNAE_LOW_LATENCY_COAL_PARAM
#define HNAE_BULK_LATENCY_COAL_PARAM

enum hnae_led_state {};

#define HNS_RX_FLAG_VLAN_PRESENT
#define HNS_RX_FLAG_L3ID_IPV4
#define HNS_RX_FLAG_L3ID_IPV6
#define HNS_RX_FLAG_L4ID_UDP
#define HNS_RX_FLAG_L4ID_TCP
#define HNS_RX_FLAG_L4ID_SCTP

#define HNS_TXD_ASID_S
#define HNS_TXD_ASID_M
#define HNS_TXD_BUFNUM_S
#define HNS_TXD_BUFNUM_M
#define HNS_TXD_PORTID_S
#define HNS_TXD_PORTID_M

#define HNS_TXD_RA_B
#define HNS_TXD_RI_B
#define HNS_TXD_L4CS_B
#define HNS_TXD_L3CS_B
#define HNS_TXD_FE_B
#define HNS_TXD_VLD_B
#define HNS_TXD_IPOFFSET_S
#define HNS_TXD_IPOFFSET_M

#define HNS_RXD_IPOFFSET_S
#define HNS_RXD_IPOFFSET_M
#define HNS_RXD_BUFNUM_S
#define HNS_RXD_BUFNUM_M
#define HNS_RXD_PORTID_S
#define HNS_RXD_PORTID_M
#define HNS_RXD_DMAC_S
#define HNS_RXD_DMAC_M
#define HNS_RXD_VLAN_S
#define HNS_RXD_VLAN_M
#define HNS_RXD_L3ID_S
#define HNS_RXD_L3ID_M
#define HNS_RXD_L4ID_S
#define HNS_RXD_L4ID_M
#define HNS_RXD_FE_B
#define HNS_RXD_FRAG_B
#define HNS_RXD_VLD_B
#define HNS_RXD_L2E_B
#define HNS_RXD_L3E_B
#define HNS_RXD_L4E_B
#define HNS_RXD_DROP_B

#define HNS_RXD_VLANID_S
#define HNS_RXD_VLANID_M
#define HNS_RXD_CFI_B
#define HNS_RXD_PRI_S
#define HNS_RXD_PRI_M
#define HNS_RXD_ASID_S
#define HNS_RXD_ASID_M

#define HNSV2_TXD_BUFNUM_S
#define HNSV2_TXD_BUFNUM_M
#define HNSV2_TXD_PORTID_S
#define HNSV2_TXD_PORTID_M
#define HNSV2_TXD_RI_B
#define HNSV2_TXD_L4CS_B
#define HNSV2_TXD_L3CS_B
#define HNSV2_TXD_FE_B
#define HNSV2_TXD_VLD_B

#define HNSV2_TXD_TSE_B
#define HNSV2_TXD_VLAN_EN_B
#define HNSV2_TXD_SNAP_B
#define HNSV2_TXD_IPV6_B
#define HNSV2_TXD_SCTP_B

/* hardware spec ring buffer format */
struct __packed hnae_desc {};

struct hnae_desc_cb {};

#define setflags(flags, bits)
#define unsetflags(flags, bits)

/* hnae_ring->flags fields */
#define RINGF_DIR
#define is_tx_ring(ring)
#define is_rx_ring(ring)
#define ring_to_dma_dir(ring)

struct ring_stats {};

struct hnae_queue;

struct hnae_ring {};

#define ring_ptr_move_fw(ring, p)
#define ring_ptr_move_bw(ring, p)

enum hns_desc_type {};

#define assert_is_ring_idx(ring, idx)

/* the distance between [begin, end) in a ring buffer
 * note: there is a unuse slot between the begin and the end
 */
static inline int ring_dist(struct hnae_ring *ring, int begin, int end)
{}

static inline int ring_space(struct hnae_ring *ring)
{}

static inline int is_ring_empty(struct hnae_ring *ring)
{}

#define hnae_buf_size(_ring)
#define hnae_page_order(_ring)
#define hnae_page_size(_ring)

struct hnae_handle;

/* allocate and dma map space for hnae desc */
struct hnae_buf_ops {};

struct hnae_queue {};

/*hnae loop mode*/
enum hnae_loop {};

/*hnae port type*/
enum hnae_port_type {};

/* mac media type */
enum hnae_media_type {};

/* This struct defines the operation on the handle.
 *
 * get_handle(): (mandatory)
 *   Get a handle from AE according to its name and options.
 *   the AE driver should manage the space used by handle and its queues while
 *   the HNAE framework will allocate desc and desc_cb for all rings in the
 *   queues.
 * put_handle():
 *   Release the handle.
 * start():
 *   Enable the hardware, include all queues
 * stop():
 *   Disable the hardware
 * set_opts(): (mandatory)
 *   Set options to the AE
 * get_opts(): (mandatory)
 *   Get options from the AE
 * get_status():
 *   Get the carrier state of the back channel of the handle, 1 for ok, 0 for
 *   non-ok
 * toggle_ring_irq(): (mandatory)
 *   Set the ring irq to be enabled(0) or disable(1)
 * toggle_queue_status(): (mandatory)
 *   Set the queue to be enabled(1) or disable(0), this will not change the
 *   ring irq state
 * adjust_link()
 *   adjust link status
 * set_loopback()
 *   set loopback
 * get_ring_bdnum_limit()
 *   get ring bd number limit
 * get_pauseparam()
 *   get tx and rx of pause frame use
 * set_pauseparam()
 *   set tx and rx of pause frame use
 * get_coalesce_usecs()
 *   get usecs to delay a TX interrupt after a packet is sent
 * get_rx_max_coalesced_frames()
 *   get Maximum number of packets to be sent before a TX interrupt.
 * set_coalesce_usecs()
 *   set usecs to delay a TX interrupt after a packet is sent
 * set_coalesce_frames()
 *   set Maximum number of packets to be sent before a TX interrupt.
 * get_ringnum()
 *   get RX/TX ring number
 * get_max_ringnum()
 *   get RX/TX ring maximum number
 * get_mac_addr()
 *   get mac address
 * set_mac_addr()
 *   set mac address
 * clr_mc_addr()
 *   clear mcast tcam table
 * set_mc_addr()
 *   set multicast mode
 * add_uc_addr()
 *   add ucast address
 * rm_uc_addr()
 *   remove ucast address
 * set_mtu()
 *   set mtu
 * update_stats()
 *   update Old network device statistics
 * get_ethtool_stats()
 *   get ethtool network device statistics
 * get_strings()
 *   get a set of strings that describe the requested objects
 * get_sset_count()
 *   get number of strings that @get_strings will write
 * update_led_status()
 *   update the led status
 * set_led_id()
 *   set led id
 * get_regs()
 *   get regs dump
 * get_regs_len()
 *   get the len of the regs dump
 */
struct hnae_ae_ops {};

struct hnae_ae_dev {};

struct hnae_handle {};

#define ring_to_dev(ring)

struct hnae_handle *hnae_get_handle(struct device *owner_dev,
				    const struct fwnode_handle	*fwnode,
				    u32 port_id,
				    struct hnae_buf_ops *bops);

void hnae_put_handle(struct hnae_handle *handle);
int hnae_ae_register(struct hnae_ae_dev *dev, struct module *owner);
void hnae_ae_unregister(struct hnae_ae_dev *dev);

int hnae_register_notifier(struct notifier_block *nb);
void hnae_unregister_notifier(struct notifier_block *nb);
int hnae_reinit_handle(struct hnae_handle *handle);

#define hnae_queue_xmit(q, buf_num)

#ifndef assert
#define assert
#endif

static inline int hnae_reserve_buffer_map(struct hnae_ring *ring,
					  struct hnae_desc_cb *cb)
{}

static inline int hnae_alloc_buffer_attach(struct hnae_ring *ring, int i)
{}

static inline void hnae_buffer_detach(struct hnae_ring *ring, int i)
{}

static inline void hnae_free_buffer_detach(struct hnae_ring *ring, int i)
{}

/* detach a in-used buffer and replace with a reserved one  */
static inline void hnae_replace_buffer(struct hnae_ring *ring, int i,
				       struct hnae_desc_cb *res_cb)
{}

static inline void hnae_reuse_buffer(struct hnae_ring *ring, int i)
{}

/* when reinit buffer size, we should reinit buffer description */
static inline void hnae_reinit_all_ring_desc(struct hnae_handle *h)
{}

/* when reinit buffer size, we should reinit page offset */
static inline void hnae_reinit_all_ring_page_off(struct hnae_handle *h)
{}

#define hnae_set_field(origin, mask, shift, val)

#define hnae_set_bit(origin, shift, val)

#define hnae_get_field(origin, mask, shift)

#define hnae_get_bit(origin, shift)

#endif