linux/drivers/net/ethernet/amazon/ena/ena_netdev.h

/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
/*
 * Copyright 2015-2020 Amazon.com, Inc. or its affiliates. All rights reserved.
 */

#ifndef ENA_H
#define ENA_H

#include <linux/bitops.h>
#include <linux/dim.h>
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
#include <linux/inetdevice.h>
#include <linux/interrupt.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <net/xdp.h>
#include <uapi/linux/bpf.h>

#include "ena_com.h"
#include "ena_eth_com.h"

#define DRV_MODULE_GEN_MAJOR
#define DRV_MODULE_GEN_MINOR
#define DRV_MODULE_GEN_SUBMINOR

#define DRV_MODULE_NAME

#define DEVICE_NAME

/* 1 for AENQ + ADMIN */
#define ENA_ADMIN_MSIX_VEC
#define ENA_MAX_MSIX_VEC(io_queues)

/* The ENA buffer length fields is 16 bit long. So when PAGE_SIZE == 64kB the
 * driver passes 0.
 * Since the max packet size the ENA handles is ~9kB limit the buffer length to
 * 16kB.
 */
#if PAGE_SIZE > SZ_16K
#define ENA_PAGE_SIZE
#else
#define ENA_PAGE_SIZE
#endif

#define ENA_MIN_MSIX_VEC

#define ENA_REG_BAR
#define ENA_MEM_BAR
#define ENA_BAR_MASK

#define ENA_DEFAULT_RING_SIZE
#define ENA_MIN_RING_SIZE

#define ENA_MIN_RX_BUF_SIZE

#define ENA_MIN_NUM_IO_QUEUES

#define ENA_TX_WAKEUP_THRESH
#define ENA_DEFAULT_RX_COPYBREAK

#define ENA_MIN_MTU

#define ENA_NAME_MAX_LEN
#define ENA_IRQNAME_SIZE

#define ENA_PKT_MAX_BUFS

#define ENA_RX_RSS_TABLE_LOG_SIZE
#define ENA_RX_RSS_TABLE_SIZE

/* The number of tx packet completions that will be handled each NAPI poll
 * cycle is ring_size / ENA_TX_POLL_BUDGET_DIVIDER.
 */
#define ENA_TX_POLL_BUDGET_DIVIDER

/* Refill Rx queue when number of required descriptors is above
 * QUEUE_SIZE / ENA_RX_REFILL_THRESH_DIVIDER or ENA_RX_REFILL_THRESH_PACKET
 */
#define ENA_RX_REFILL_THRESH_DIVIDER
#define ENA_RX_REFILL_THRESH_PACKET

/* Number of queues to check for missing queues per timer service */
#define ENA_MONITORED_TX_QUEUES
/* Max timeout packets before device reset */
#define MAX_NUM_OF_TIMEOUTED_PACKETS

#define ENA_TX_RING_IDX_NEXT(idx, ring_size)

#define ENA_RX_RING_IDX_NEXT(idx, ring_size)
#define ENA_RX_RING_IDX_ADD(idx, n, ring_size)

#define ENA_IO_TXQ_IDX(q)
#define ENA_IO_RXQ_IDX(q)
#define ENA_IO_TXQ_IDX_TO_COMBINED_IDX(q)
#define ENA_IO_RXQ_IDX_TO_COMBINED_IDX(q)

#define ENA_MGMNT_IRQ_IDX
#define ENA_IO_IRQ_FIRST_IDX
#define ENA_IO_IRQ_IDX(q)

#define ENA_ADMIN_POLL_DELAY_US

/* ENA device should send keep alive msg every 1 sec.
 * We wait for 6 sec just to be on the safe side.
 */
#define ENA_DEVICE_KALIVE_TIMEOUT
#define ENA_MAX_NO_INTERRUPT_ITERATIONS

#define ENA_MMIO_DISABLE_REG_READ

struct ena_irq {};

struct ena_napi {};

struct ena_tx_buffer {} ____cacheline_aligned;

struct ena_rx_buffer {} ____cacheline_aligned;

struct ena_stats_tx {};

struct ena_stats_rx {};

struct ena_ring {} ____cacheline_aligned;

struct ena_stats_dev {};

enum ena_flags_t {};

/* adapter specific private data structure */
struct ena_adapter {};

void ena_set_ethtool_ops(struct net_device *netdev);

void ena_dump_stats_to_dmesg(struct ena_adapter *adapter);

void ena_dump_stats_to_buf(struct ena_adapter *adapter, u8 *buf);

int ena_update_hw_stats(struct ena_adapter *adapter);

int ena_update_queue_params(struct ena_adapter *adapter,
			    u32 new_tx_size,
			    u32 new_rx_size,
			    u32 new_llq_header_len);

int ena_update_queue_count(struct ena_adapter *adapter, u32 new_channel_count);

int ena_set_rx_copybreak(struct ena_adapter *adapter, u32 rx_copybreak);

int ena_get_sset_count(struct net_device *netdev, int sset);

static inline void ena_reset_device(struct ena_adapter *adapter,
				    enum ena_regs_reset_reason_types reset_reason)
{}

int handle_invalid_req_id(struct ena_ring *ring, u16 req_id,
			  struct ena_tx_buffer *tx_info, bool is_xdp);

/* Increase a stat by cnt while holding syncp seqlock on 32bit machines */
static inline void ena_increase_stat(u64 *statp, u64 cnt,
				     struct u64_stats_sync *syncp)
{}

static inline void ena_ring_tx_doorbell(struct ena_ring *tx_ring)
{}

int ena_xmit_common(struct ena_adapter *adapter,
		    struct ena_ring *ring,
		    struct ena_tx_buffer *tx_info,
		    struct ena_com_tx_ctx *ena_tx_ctx,
		    u16 next_to_use,
		    u32 bytes);
void ena_unmap_tx_buff(struct ena_ring *tx_ring,
		       struct ena_tx_buffer *tx_info);
void ena_init_io_rings(struct ena_adapter *adapter,
		       int first_index, int count);
int ena_create_io_tx_queues_in_range(struct ena_adapter *adapter,
				     int first_index, int count);
int ena_setup_tx_resources_in_range(struct ena_adapter *adapter,
				    int first_index, int count);
void ena_free_all_io_tx_resources_in_range(struct ena_adapter *adapter,
					   int first_index, int count);
void ena_free_all_io_tx_resources(struct ena_adapter *adapter);
void ena_down(struct ena_adapter *adapter);
int ena_up(struct ena_adapter *adapter);
void ena_unmask_interrupt(struct ena_ring *tx_ring, struct ena_ring *rx_ring);
void ena_update_ring_numa_node(struct ena_ring *tx_ring,
			       struct ena_ring *rx_ring);
#endif /* !(ENA_H) */