linux/drivers/net/ethernet/engleder/tsnep.h

/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (C) 2021 Gerhard Engleder <[email protected]> */

#ifndef _TSNEP_H
#define _TSNEP_H

#include "tsnep_hw.h"

#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
#include <linux/etherdevice.h>
#include <linux/phy.h>
#include <linux/ethtool.h>
#include <linux/net_tstamp.h>
#include <linux/ptp_clock_kernel.h>
#include <linux/miscdevice.h>
#include <net/xdp.h>

#define TSNEP

#define TSNEP_RING_SIZE
#define TSNEP_RING_MASK
#define TSNEP_RING_RX_REFILL
#define TSNEP_RING_RX_REUSE
#define TSNEP_RING_ENTRIES_PER_PAGE
#define TSNEP_RING_PAGE_COUNT

struct tsnep_gcl {};

enum tsnep_rxnfc_filter_type {};

struct tsnep_rxnfc_filter {};

struct tsnep_rxnfc_rule {};

struct tsnep_tx_entry {};

struct tsnep_tx {};

struct tsnep_rx_entry {};

struct tsnep_rx {};

struct tsnep_queue {};

struct tsnep_adapter {};

extern const struct ethtool_ops tsnep_ethtool_ops;

int tsnep_ptp_init(struct tsnep_adapter *adapter);
void tsnep_ptp_cleanup(struct tsnep_adapter *adapter);
int tsnep_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);

int tsnep_tc_init(struct tsnep_adapter *adapter);
void tsnep_tc_cleanup(struct tsnep_adapter *adapter);
int tsnep_tc_setup(struct net_device *netdev, enum tc_setup_type type,
		   void *type_data);

int tsnep_rxnfc_init(struct tsnep_adapter *adapter);
void tsnep_rxnfc_cleanup(struct tsnep_adapter *adapter);
int tsnep_rxnfc_get_rule(struct tsnep_adapter *adapter,
			 struct ethtool_rxnfc *cmd);
int tsnep_rxnfc_get_all(struct tsnep_adapter *adapter,
			struct ethtool_rxnfc *cmd,
			u32 *rule_locs);
int tsnep_rxnfc_add_rule(struct tsnep_adapter *adapter,
			 struct ethtool_rxnfc *cmd);
int tsnep_rxnfc_del_rule(struct tsnep_adapter *adapter,
			 struct ethtool_rxnfc *cmd);

int tsnep_xdp_setup_prog(struct tsnep_adapter *adapter, struct bpf_prog *prog,
			 struct netlink_ext_ack *extack);
int tsnep_xdp_setup_pool(struct tsnep_adapter *adapter,
			 struct xsk_buff_pool *pool, u16 queue_id);

#if IS_ENABLED(CONFIG_TSNEP_SELFTESTS)
int tsnep_ethtool_get_test_count(void);
void tsnep_ethtool_get_test_strings(u8 *data);
void tsnep_ethtool_self_test(struct net_device *netdev,
			     struct ethtool_test *eth_test, u64 *data);
#else
static inline int tsnep_ethtool_get_test_count(void)
{
	return -EOPNOTSUPP;
}

static inline void tsnep_ethtool_get_test_strings(u8 *data)
{
	/* not enabled */
}

static inline void tsnep_ethtool_self_test(struct net_device *dev,
					   struct ethtool_test *eth_test,
					   u64 *data)
{
	/* not enabled */
}
#endif /* CONFIG_TSNEP_SELFTESTS */

void tsnep_get_system_time(struct tsnep_adapter *adapter, u64 *time);
int tsnep_set_irq_coalesce(struct tsnep_queue *queue, u32 usecs);
u32 tsnep_get_irq_coalesce(struct tsnep_queue *queue);
int tsnep_enable_xsk(struct tsnep_queue *queue, struct xsk_buff_pool *pool);
void tsnep_disable_xsk(struct tsnep_queue *queue);

#endif /* _TSNEP_H */