linux/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c

// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
/* Copyright (C) 2015-2017 Netronome Systems, Inc. */

/* Authors: David Brunecz <[email protected]>
 *          Jakub Kicinski <[email protected]>
 *          Jason Mcmullan <[email protected]>
 */

#include <linux/bitfield.h>
#include <linux/ethtool.h>
#include <linux/if_ether.h>
#include <linux/kernel.h>
#include <linux/module.h>

#include "nfp.h"
#include "nfp_nsp.h"
#include "nfp6000/nfp6000.h"

#define NSP_ETH_NBI_PORT_COUNT
#define NSP_ETH_MAX_COUNT
#define NSP_ETH_TABLE_SIZE

#define NSP_ETH_PORT_LANES
#define NSP_ETH_PORT_INDEX
#define NSP_ETH_PORT_LABEL
#define NSP_ETH_PORT_PHYLABEL
#define NSP_ETH_PORT_FEC_SUPP_BASER
#define NSP_ETH_PORT_FEC_SUPP_RS
#define NSP_ETH_PORT_SUPP_ANEG

#define NSP_ETH_PORT_LANES_MASK

#define NSP_ETH_STATE_CONFIGURED
#define NSP_ETH_STATE_ENABLED
#define NSP_ETH_STATE_TX_ENABLED
#define NSP_ETH_STATE_RX_ENABLED
#define NSP_ETH_STATE_RATE
#define NSP_ETH_STATE_INTERFACE
#define NSP_ETH_STATE_MEDIA
#define NSP_ETH_STATE_OVRD_CHNG
#define NSP_ETH_STATE_ANEG
#define NSP_ETH_STATE_FEC
#define NSP_ETH_STATE_ACT_FEC
#define NSP_ETH_STATE_TX_PAUSE
#define NSP_ETH_STATE_RX_PAUSE

#define NSP_ETH_CTRL_CONFIGURED
#define NSP_ETH_CTRL_ENABLED
#define NSP_ETH_CTRL_TX_ENABLED
#define NSP_ETH_CTRL_RX_ENABLED
#define NSP_ETH_CTRL_SET_RATE
#define NSP_ETH_CTRL_SET_LANES
#define NSP_ETH_CTRL_SET_ANEG
#define NSP_ETH_CTRL_SET_FEC
#define NSP_ETH_CTRL_SET_IDMODE
#define NSP_ETH_CTRL_SET_TX_PAUSE
#define NSP_ETH_CTRL_SET_RX_PAUSE

enum nfp_eth_raw {};

enum nfp_eth_rate {};

eth_table_entry;

static const struct {} nsp_eth_rate_tbl[] =;

static unsigned int nfp_eth_rate2speed(enum nfp_eth_rate rate)
{}

static unsigned int nfp_eth_speed2rate(unsigned int speed)
{}

static void nfp_eth_copy_mac_reverse(u8 *dst, const u8 *src)
{}

static void
nfp_eth_port_translate(struct nfp_nsp *nsp, const union eth_table_entry *src,
		       unsigned int index, struct nfp_eth_table_port *dst)
{}

static void
nfp_eth_calc_port_geometry(struct nfp_cpp *cpp, struct nfp_eth_table *table)
{}

static void
nfp_eth_calc_port_type(struct nfp_cpp *cpp, struct nfp_eth_table_port *entry)
{}

static void
nfp_eth_read_media(struct nfp_cpp *cpp, struct nfp_nsp *nsp, struct nfp_eth_table_port *entry)
{}

/**
 * nfp_eth_read_ports() - retrieve port information
 * @cpp:	NFP CPP handle
 *
 * Read the port information from the device.  Returned structure should
 * be freed with kfree() once no longer needed.
 *
 * Return: populated ETH table or NULL on error.
 */
struct nfp_eth_table *nfp_eth_read_ports(struct nfp_cpp *cpp)
{}

struct nfp_eth_table *
__nfp_eth_read_ports(struct nfp_cpp *cpp, struct nfp_nsp *nsp)
{}

struct nfp_nsp *nfp_eth_config_start(struct nfp_cpp *cpp, unsigned int idx)
{}

void nfp_eth_config_cleanup_end(struct nfp_nsp *nsp)
{}

/**
 * nfp_eth_config_commit_end() - perform recorded configuration changes
 * @nsp:	NFP NSP handle returned from nfp_eth_config_start()
 *
 * Perform the configuration which was requested with __nfp_eth_set_*()
 * helpers and recorded in @nsp state.  If device was already configured
 * as requested or no __nfp_eth_set_*() operations were made no NSP command
 * will be performed.
 *
 * Return:
 * 0 - configuration successful;
 * 1 - no changes were needed;
 * -ERRNO - configuration failed.
 */
int nfp_eth_config_commit_end(struct nfp_nsp *nsp)
{}

/**
 * nfp_eth_set_mod_enable() - set PHY module enable control bit
 * @cpp:	NFP CPP handle
 * @idx:	NFP chip-wide port index
 * @enable:	Desired state
 *
 * Enable or disable PHY module (this usually means setting the TX lanes
 * disable bits).
 *
 * Return:
 * 0 - configuration successful;
 * 1 - no changes were needed;
 * -ERRNO - configuration failed.
 */
int nfp_eth_set_mod_enable(struct nfp_cpp *cpp, unsigned int idx, bool enable)
{}

/**
 * nfp_eth_set_configured() - set PHY module configured control bit
 * @cpp:	NFP CPP handle
 * @idx:	NFP chip-wide port index
 * @configed:	Desired state
 *
 * Set the ifup/ifdown state on the PHY.
 *
 * Return:
 * 0 - configuration successful;
 * 1 - no changes were needed;
 * -ERRNO - configuration failed.
 */
int nfp_eth_set_configured(struct nfp_cpp *cpp, unsigned int idx, bool configed)
{}

static int
nfp_eth_set_bit_config(struct nfp_nsp *nsp, unsigned int raw_idx,
		       const u64 mask, const unsigned int shift,
		       u64 val, const u64 ctrl_bit)
{}

int nfp_eth_set_idmode(struct nfp_cpp *cpp, unsigned int idx, bool state)
{}

#define NFP_ETH_SET_BIT_CONFIG(nsp, raw_idx, mask, val, ctrl_bit)

/**
 * __nfp_eth_set_aneg() - set PHY autonegotiation control bit
 * @nsp:	NFP NSP handle returned from nfp_eth_config_start()
 * @mode:	Desired autonegotiation mode
 *
 * Allow/disallow PHY module to advertise/perform autonegotiation.
 * Will write to hwinfo overrides in the flash (persistent config).
 *
 * Return: 0 or -ERRNO.
 */
int __nfp_eth_set_aneg(struct nfp_nsp *nsp, enum nfp_eth_aneg mode)
{}

/**
 * __nfp_eth_set_fec() - set PHY forward error correction control bit
 * @nsp:	NFP NSP handle returned from nfp_eth_config_start()
 * @mode:	Desired fec mode
 *
 * Set the PHY module forward error correction mode.
 * Will write to hwinfo overrides in the flash (persistent config).
 *
 * Return: 0 or -ERRNO.
 */
static int __nfp_eth_set_fec(struct nfp_nsp *nsp, enum nfp_eth_fec mode)
{}

/**
 * nfp_eth_set_fec() - set PHY forward error correction control mode
 * @cpp:	NFP CPP handle
 * @idx:	NFP chip-wide port index
 * @mode:	Desired fec mode
 *
 * Return:
 * 0 - configuration successful;
 * 1 - no changes were needed;
 * -ERRNO - configuration failed.
 */
int
nfp_eth_set_fec(struct nfp_cpp *cpp, unsigned int idx, enum nfp_eth_fec mode)
{}

/**
 * __nfp_eth_set_txpause() - set tx pause control bit
 * @nsp:	NFP NSP handle returned from nfp_eth_config_start()
 * @tx_pause:	TX pause switch
 *
 * Set TX pause switch.
 *
 * Return: 0 or -ERRNO.
 */
static int __nfp_eth_set_txpause(struct nfp_nsp *nsp, unsigned int tx_pause)
{}

/**
 * __nfp_eth_set_rxpause() - set rx pause control bit
 * @nsp:	NFP NSP handle returned from nfp_eth_config_start()
 * @rx_pause:	RX pause switch
 *
 * Set RX pause switch.
 *
 * Return: 0 or -ERRNO.
 */
static int __nfp_eth_set_rxpause(struct nfp_nsp *nsp, unsigned int rx_pause)
{}

/**
 * nfp_eth_set_pauseparam() - Set TX/RX pause switch.
 * @cpp:	NFP CPP handle
 * @idx:	NFP chip-wide port index
 * @tx_pause:	TX pause switch
 * @rx_pause:	RX pause switch
 *
 * Return:
 * 0 - configuration successful;
 * 1 - no changes were needed;
 * -ERRNO - configuration failed.
 */
int
nfp_eth_set_pauseparam(struct nfp_cpp *cpp, unsigned int idx,
		       unsigned int tx_pause, unsigned int rx_pause)
{}

/**
 * __nfp_eth_set_speed() - set interface speed/rate
 * @nsp:	NFP NSP handle returned from nfp_eth_config_start()
 * @speed:	Desired speed (per lane)
 *
 * Set lane speed.  Provided @speed value should be subport speed divided
 * by number of lanes this subport is spanning (i.e. 10000 for 40G, 25000 for
 * 50G, etc.)
 * Will write to hwinfo overrides in the flash (persistent config).
 *
 * Return: 0 or -ERRNO.
 */
int __nfp_eth_set_speed(struct nfp_nsp *nsp, unsigned int speed)
{}

/**
 * __nfp_eth_set_split() - set interface lane split
 * @nsp:	NFP NSP handle returned from nfp_eth_config_start()
 * @lanes:	Desired lanes per port
 *
 * Set number of lanes in the port.
 * Will write to hwinfo overrides in the flash (persistent config).
 *
 * Return: 0 or -ERRNO.
 */
int __nfp_eth_set_split(struct nfp_nsp *nsp, unsigned int lanes)
{}