linux/drivers/net/ethernet/marvell/octeontx2/af/cgx.c

// SPDX-License-Identifier: GPL-2.0
/* Marvell OcteonTx2 CGX driver
 *
 * Copyright (C) 2018 Marvell.
 *
 */

#include <linux/acpi.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/phy.h>
#include <linux/of.h>
#include <linux/of_mdio.h>
#include <linux/of_net.h>

#include "cgx.h"
#include "rvu.h"
#include "lmac_common.h"

#define DRV_NAME
#define DRV_STRING

#define CGX_RX_STAT_GLOBAL_INDEX

static LIST_HEAD(cgx_list);

/* Convert firmware speed encoding to user format(Mbps) */
static const u32 cgx_speed_mbps[CGX_LINK_SPEED_MAX] =;

/* Convert firmware lmac type encoding to string */
static const char *cgx_lmactype_string[LMAC_MODE_MAX] =;

/* CGX PHY management internal APIs */
static int cgx_fwi_link_change(struct cgx *cgx, int lmac_id, bool en);

/* Supported devices */
static const struct pci_device_id cgx_id_table[] =;

MODULE_DEVICE_TABLE(pci, cgx_id_table);

static bool is_dev_rpm(void *cgxd)
{}

bool is_lmac_valid(struct cgx *cgx, int lmac_id)
{}

/* Helper function to get sequential index
 * given the enabled LMAC of a CGX
 */
static int get_sequence_id_of_lmac(struct cgx *cgx, int lmac_id)
{}

struct mac_ops *get_mac_ops(void *cgxd)
{}

void cgx_write(struct cgx *cgx, u64 lmac, u64 offset, u64 val)
{}

u64 cgx_read(struct cgx *cgx, u64 lmac, u64 offset)
{}

struct lmac *lmac_pdata(u8 lmac_id, struct cgx *cgx)
{}

int cgx_get_cgxcnt_max(void)
{}

int cgx_get_lmac_cnt(void *cgxd)
{}

void *cgx_get_pdata(int cgx_id)
{}

void cgx_lmac_write(int cgx_id, int lmac_id, u64 offset, u64 val)
{}

u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset)
{}

int cgx_get_cgxid(void *cgxd)
{}

u8 cgx_lmac_get_p2x(int cgx_id, int lmac_id)
{}

/* Ensure the required lock for event queue(where asynchronous events are
 * posted) is acquired before calling this API. Else an asynchronous event(with
 * latest link status) can reach the destination before this function returns
 * and could make the link status appear wrong.
 */
int cgx_get_link_info(void *cgxd, int lmac_id,
		      struct cgx_link_user_info *linfo)
{}

int cgx_lmac_addr_set(u8 cgx_id, u8 lmac_id, u8 *mac_addr)
{}

u64 cgx_read_dmac_ctrl(void *cgxd, int lmac_id)
{}

u64 cgx_read_dmac_entry(void *cgxd, int index)
{}

int cgx_lmac_addr_add(u8 cgx_id, u8 lmac_id, u8 *mac_addr)
{}

int cgx_lmac_addr_reset(u8 cgx_id, u8 lmac_id)
{}

/* Allows caller to change macaddress associated with index
 * in dmac filter table including index 0 reserved for
 * interface mac address
 */
int cgx_lmac_addr_update(u8 cgx_id, u8 lmac_id, u8 *mac_addr, u8 index)
{}

int cgx_lmac_addr_del(u8 cgx_id, u8 lmac_id, u8 index)
{}

int cgx_lmac_addr_max_entries_get(u8 cgx_id, u8 lmac_id)
{}

u64 cgx_lmac_addr_get(u8 cgx_id, u8 lmac_id)
{}

int cgx_set_pkind(void *cgxd, u8 lmac_id, int pkind)
{}

static u8 cgx_get_lmac_type(void *cgxd, int lmac_id)
{}

static u32 cgx_get_lmac_fifo_len(void *cgxd, int lmac_id)
{}

/* Configure CGX LMAC in internal loopback mode */
int cgx_lmac_internal_loopback(void *cgxd, int lmac_id, bool enable)
{}

void cgx_lmac_promisc_config(int cgx_id, int lmac_id, bool enable)
{}

static int cgx_lmac_get_pause_frm_status(void *cgxd, int lmac_id,
					 u8 *tx_pause, u8 *rx_pause)
{}

/* Enable or disable forwarding received pause frames to Tx block */
void cgx_lmac_enadis_rx_pause_fwding(void *cgxd, int lmac_id, bool enable)
{}

int cgx_get_rx_stats(void *cgxd, int lmac_id, int idx, u64 *rx_stat)
{}

int cgx_get_tx_stats(void *cgxd, int lmac_id, int idx, u64 *tx_stat)
{}

u64 cgx_features_get(void *cgxd)
{}

int cgx_stats_reset(void *cgxd, int lmac_id)
{}

static int cgx_set_fec_stats_count(struct cgx_link_user_info *linfo)
{}

int cgx_get_fec_stats(void *cgxd, int lmac_id, struct cgx_fec_stats_rsp *rsp)
{}

int cgx_lmac_rx_tx_enable(void *cgxd, int lmac_id, bool enable)
{}

int cgx_lmac_tx_enable(void *cgxd, int lmac_id, bool enable)
{}

static int cgx_lmac_enadis_pause_frm(void *cgxd, int lmac_id,
				     u8 tx_pause, u8 rx_pause)
{}

static void cgx_lmac_pause_frm_config(void *cgxd, int lmac_id, bool enable)
{}

int verify_lmac_fc_cfg(void *cgxd, int lmac_id, u8 tx_pause, u8 rx_pause,
		       int pfvf_idx)
{}

int cgx_lmac_pfc_config(void *cgxd, int lmac_id, u8 tx_pause,
			u8 rx_pause, u16 pfc_en)
{}

int cgx_lmac_get_pfc_frm_cfg(void *cgxd, int lmac_id, u8 *tx_pause,
			     u8 *rx_pause)
{}

void cgx_lmac_ptp_config(void *cgxd, int lmac_id, bool enable)
{}

/* CGX Firmware interface low level support */
int cgx_fwi_cmd_send(u64 req, u64 *resp, struct lmac *lmac)
{}

int cgx_fwi_cmd_generic(u64 req, u64 *resp, struct cgx *cgx, int lmac_id)
{}

static int cgx_link_usertable_index_map(int speed)
{}

static void set_mod_args(struct cgx_set_link_mode_args *args,
			 u32 speed, u8 duplex, u8 autoneg, u64 mode)
{}

static void otx2_map_ethtool_link_modes(u64 bitmask,
					struct cgx_set_link_mode_args *args)
{}

static inline void link_status_user_format(u64 lstat,
					   struct cgx_link_user_info *linfo,
					   struct cgx *cgx, u8 lmac_id)
{}

/* Hardware event handlers */
static inline void cgx_link_change_handler(u64 lstat,
					   struct lmac *lmac)
{}

static inline bool cgx_cmdresp_is_linkevent(u64 event)
{}

static inline bool cgx_event_is_linkevent(u64 event)
{}

static irqreturn_t cgx_fwi_event_handler(int irq, void *data)
{}

/* APIs for PHY management using CGX firmware interface */

/* callback registration for hardware events like link change */
int cgx_lmac_evh_register(struct cgx_event_cb *cb, void *cgxd, int lmac_id)
{}

int cgx_lmac_evh_unregister(void *cgxd, int lmac_id)
{}

int cgx_get_fwdata_base(u64 *base)
{}

int cgx_set_link_mode(void *cgxd, struct cgx_set_link_mode_args args,
		      int cgx_id, int lmac_id)
{}
int cgx_set_fec(u64 fec, int cgx_id, int lmac_id)
{}

int cgx_get_phy_fec_stats(void *cgxd, int lmac_id)
{}

static int cgx_fwi_link_change(struct cgx *cgx, int lmac_id, bool enable)
{}

static inline int cgx_fwi_read_version(u64 *resp, struct cgx *cgx)
{}

static int cgx_lmac_verify_fwi_version(struct cgx *cgx)
{}

static void cgx_lmac_linkup_work(struct work_struct *work)
{}

int cgx_lmac_linkup_start(void *cgxd)
{}

int cgx_lmac_reset(void *cgxd, int lmac_id, u8 pf_req_flr)
{}

static int cgx_configure_interrupt(struct cgx *cgx, struct lmac *lmac,
				   int cnt, bool req_free)
{}

int cgx_get_nr_lmacs(void *cgxd)
{}

u8 cgx_get_lmacid(void *cgxd, u8 lmac_index)
{}

unsigned long cgx_get_lmac_bmap(void *cgxd)
{}

static int cgx_lmac_init(struct cgx *cgx)
{}

static int cgx_lmac_exit(struct cgx *cgx)
{}

static void cgx_populate_features(struct cgx *cgx)
{}

static u8 cgx_get_rxid_mapoffset(struct cgx *cgx)
{}

static struct mac_ops	cgx_mac_ops    =;

static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{}

static void cgx_remove(struct pci_dev *pdev)
{}

struct pci_driver cgx_driver =;