linux/drivers/net/ethernet/freescale/fman/fman_dtsec.c

// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-or-later
/*
 * Copyright 2008 - 2015 Freescale Semiconductor Inc.
 */

#define pr_fmt(fmt)

#include "fman_dtsec.h"
#include "fman.h"
#include "mac.h"

#include <linux/slab.h>
#include <linux/bitrev.h>
#include <linux/io.h>
#include <linux/delay.h>
#include <linux/phy.h>
#include <linux/crc32.h>
#include <linux/of_mdio.h>
#include <linux/mii.h>
#include <linux/netdevice.h>

/* TBI register addresses */
#define MII_TBICON

/* TBICON register bit fields */
#define TBICON_SOFT_RESET
#define TBICON_DISABLE_RX_DIS
#define TBICON_DISABLE_TX_DIS
#define TBICON_AN_SENSE
#define TBICON_CLK_SELECT
#define TBICON_MI_MODE

/* Interrupt Mask Register (IMASK) */
#define DTSEC_IMASK_BREN
#define DTSEC_IMASK_RXCEN
#define DTSEC_IMASK_MSROEN
#define DTSEC_IMASK_GTSCEN
#define DTSEC_IMASK_BTEN
#define DTSEC_IMASK_TXCEN
#define DTSEC_IMASK_TXEEN
#define DTSEC_IMASK_LCEN
#define DTSEC_IMASK_CRLEN
#define DTSEC_IMASK_XFUNEN
#define DTSEC_IMASK_ABRTEN
#define DTSEC_IMASK_IFERREN
#define DTSEC_IMASK_MAGEN
#define DTSEC_IMASK_MMRDEN
#define DTSEC_IMASK_MMWREN
#define DTSEC_IMASK_GRSCEN
#define DTSEC_IMASK_TDPEEN
#define DTSEC_IMASK_RDPEEN

#define DTSEC_EVENTS_MASK

/* dtsec timestamp event bits */
#define TMR_PEMASK_TSREEN
#define TMR_PEVENT_TSRE

/* Group address bit indication */
#define MAC_GROUP_ADDRESS

/* Defaults */
#define DEFAULT_HALFDUP_RETRANSMIT
#define DEFAULT_HALFDUP_COLL_WINDOW
#define DEFAULT_TX_PAUSE_TIME
#define DEFAULT_RX_PREPEND
#define DEFAULT_PREAMBLE_LEN
#define DEFAULT_TX_PAUSE_TIME_EXTD
#define DEFAULT_NON_BACK_TO_BACK_IPG1
#define DEFAULT_NON_BACK_TO_BACK_IPG2
#define DEFAULT_MIN_IFG_ENFORCEMENT
#define DEFAULT_BACK_TO_BACK_IPG
#define DEFAULT_MAXIMUM_FRAME

/* register related defines (bits, field offsets..) */
#define DTSEC_ID2_INT_REDUCED_OFF

#define DTSEC_ECNTRL_GMIIM
#define DTSEC_ECNTRL_TBIM
#define DTSEC_ECNTRL_RPM
#define DTSEC_ECNTRL_R100M
#define DTSEC_ECNTRL_RMM
#define DTSEC_ECNTRL_SGMIIM
#define DTSEC_ECNTRL_QSGMIIM

#define TCTRL_TTSE
#define TCTRL_GTS

#define RCTRL_PAL_MASK
#define RCTRL_PAL_SHIFT
#define RCTRL_GHTX
#define RCTRL_RTSE
#define RCTRL_GRS
#define RCTRL_MPROM
#define RCTRL_RSF
#define RCTRL_UPROM

#define MACCFG1_SOFT_RESET
#define MACCFG1_RX_FLOW
#define MACCFG1_TX_FLOW
#define MACCFG1_TX_EN
#define MACCFG1_RX_EN

#define MACCFG2_NIBBLE_MODE
#define MACCFG2_BYTE_MODE
#define MACCFG2_PAD_CRC_EN
#define MACCFG2_FULL_DUPLEX
#define MACCFG2_PREAMBLE_LENGTH_MASK
#define MACCFG2_PREAMBLE_LENGTH_SHIFT

#define IPGIFG_NON_BACK_TO_BACK_IPG_1_SHIFT
#define IPGIFG_NON_BACK_TO_BACK_IPG_2_SHIFT
#define IPGIFG_MIN_IFG_ENFORCEMENT_SHIFT

#define IPGIFG_NON_BACK_TO_BACK_IPG_1
#define IPGIFG_NON_BACK_TO_BACK_IPG_2
#define IPGIFG_MIN_IFG_ENFORCEMENT
#define IPGIFG_BACK_TO_BACK_IPG

#define HAFDUP_EXCESS_DEFER
#define HAFDUP_COLLISION_WINDOW
#define HAFDUP_RETRANSMISSION_MAX_SHIFT
#define HAFDUP_RETRANSMISSION_MAX

#define NUM_OF_HASH_REGS

#define PTV_PTE_MASK
#define PTV_PT_MASK
#define PTV_PTE_SHIFT

#define MAX_PACKET_ALIGNMENT
#define MAX_INTER_PACKET_GAP
#define MAX_RETRANSMISSION
#define MAX_COLLISION_WINDOW

/* Hash table size (32 bits*8 regs) */
#define DTSEC_HASH_TABLE_SIZE
/* Extended Hash table size (32 bits*16 regs) */
#define EXTENDED_HASH_TABLE_SIZE

/* dTSEC Memory Map registers */
struct dtsec_regs {};

/* struct dtsec_cfg - dTSEC configuration
 * Transmit half-duplex flow control, under software control for 10/100-Mbps
 * half-duplex media. If set, back pressure is applied to media by raising
 * carrier.
 * halfdup_retransmit:
 * Number of retransmission attempts following a collision.
 * If this is exceeded dTSEC aborts transmission due to excessive collisions.
 * The standard specifies the attempt limit to be 15.
 * halfdup_coll_window:
 * The number of bytes of the frame during which collisions may occur.
 * The default value of 55 corresponds to the frame byte at the end of the
 * standard 512-bit slot time window. If collisions are detected after this
 * byte, the late collision event is asserted and transmission of current
 * frame is aborted.
 * tx_pad_crc:
 * Pad and append CRC. If set, the MAC pads all ransmitted short frames and
 * appends a CRC to every frame regardless of padding requirement.
 * tx_pause_time:
 * Transmit pause time value. This pause value is used as part of the pause
 * frame to be sent when a transmit pause frame is initiated.
 * If set to 0 this disables transmission of pause frames.
 * preamble_len:
 * Length, in bytes, of the preamble field preceding each Ethernet
 * start-of-frame delimiter byte. The default value of 0x7 should be used in
 * order to guarantee reliable operation with IEEE 802.3 compliant hardware.
 * rx_prepend:
 * Packet alignment padding length. The specified number of bytes (1-31)
 * of zero padding are inserted before the start of each received frame.
 * For Ethernet, where optional preamble extraction is enabled, the padding
 * appears before the preamble, otherwise the padding precedes the
 * layer 2 header.
 *
 * This structure contains basic dTSEC configuration and must be passed to
 * init() function. A default set of configuration values can be
 * obtained by calling set_dflts().
 */
struct dtsec_cfg {};

struct fman_mac {};

static void set_dflts(struct dtsec_cfg *cfg)
{}

static void set_mac_address(struct dtsec_regs __iomem *regs, const u8 *adr)
{}

static int init(struct dtsec_regs __iomem *regs, struct dtsec_cfg *cfg,
		phy_interface_t iface, u16 iface_speed, u64 addr,
		u32 exception_mask, u8 tbi_addr)
{}

static void set_bucket(struct dtsec_regs __iomem *regs, int bucket,
		       bool enable)
{}

static int check_init_parameters(struct fman_mac *dtsec)
{}

static int get_exception_flag(enum fman_mac_exceptions exception)
{}

static u16 dtsec_get_max_frame_length(struct fman_mac *dtsec)
{}

static void dtsec_isr(void *handle)
{}

static void dtsec_1588_isr(void *handle)
{}

static void free_init_resources(struct fman_mac *dtsec)
{}

static struct fman_mac *pcs_to_dtsec(struct phylink_pcs *pcs)
{}

static void dtsec_pcs_get_state(struct phylink_pcs *pcs,
				struct phylink_link_state *state)
{}

static int dtsec_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
			    phy_interface_t interface,
			    const unsigned long *advertising,
			    bool permit_pause_to_mac)
{}

static void dtsec_pcs_an_restart(struct phylink_pcs *pcs)
{}

static const struct phylink_pcs_ops dtsec_pcs_ops =;

static void graceful_start(struct fman_mac *dtsec)
{}

static void graceful_stop(struct fman_mac *dtsec)
{}

static int dtsec_enable(struct fman_mac *dtsec)
{}

static void dtsec_disable(struct fman_mac *dtsec)
{}

static int dtsec_set_tx_pause_frames(struct fman_mac *dtsec,
				     u8 __maybe_unused priority,
				     u16 pause_time,
				     u16 __maybe_unused thresh_time)
{}

static int dtsec_accept_rx_pause_frames(struct fman_mac *dtsec, bool en)
{}

static struct phylink_pcs *dtsec_select_pcs(struct phylink_config *config,
					    phy_interface_t iface)
{}

static void dtsec_mac_config(struct phylink_config *config, unsigned int mode,
			     const struct phylink_link_state *state)
{}

static void dtsec_link_up(struct phylink_config *config, struct phy_device *phy,
			  unsigned int mode, phy_interface_t interface,
			  int speed, int duplex, bool tx_pause, bool rx_pause)
{}

static void dtsec_link_down(struct phylink_config *config, unsigned int mode,
			    phy_interface_t interface)
{}

static const struct phylink_mac_ops dtsec_mac_ops =;

static int dtsec_modify_mac_address(struct fman_mac *dtsec,
				    const enet_addr_t *enet_addr)
{}

static int dtsec_add_hash_mac_address(struct fman_mac *dtsec,
				      enet_addr_t *eth_addr)
{}

static int dtsec_set_allmulti(struct fman_mac *dtsec, bool enable)
{}

static int dtsec_set_tstamp(struct fman_mac *dtsec, bool enable)
{}

static int dtsec_del_hash_mac_address(struct fman_mac *dtsec,
				      enet_addr_t *eth_addr)
{}

static int dtsec_set_promiscuous(struct fman_mac *dtsec, bool new_val)
{}

static int dtsec_set_exception(struct fman_mac *dtsec,
			       enum fman_mac_exceptions exception, bool enable)
{}

static int dtsec_init(struct fman_mac *dtsec)
{}

static int dtsec_free(struct fman_mac *dtsec)
{}

static struct fman_mac *dtsec_config(struct mac_device *mac_dev,
				     struct fman_mac_params *params)
{}

int dtsec_initialization(struct mac_device *mac_dev,
			 struct device_node *mac_node,
			 struct fman_mac_params *params)
{}