linux/drivers/net/ethernet/ti/cpsw_ale.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Texas Instruments N-Port Ethernet Switch Address Lookup Engine
 *
 * Copyright (C) 2012 Texas Instruments
 *
 */
#include <linux/bitmap.h>
#include <linux/if_vlan.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/stat.h>
#include <linux/sysfs.h>
#include <linux/etherdevice.h>

#include "cpsw_ale.h"

#define BITMASK(bits)

#define ALE_VERSION_MAJOR(rev, mask)
#define ALE_VERSION_MINOR(rev)
#define ALE_VERSION_1R3
#define ALE_VERSION_1R4

/* ALE Registers */
#define ALE_IDVER
#define ALE_STATUS
#define ALE_CONTROL
#define ALE_PRESCALE
#define ALE_AGING_TIMER
#define ALE_UNKNOWNVLAN
#define ALE_TABLE_CONTROL
#define ALE_TABLE
#define ALE_PORTCTL

/* ALE NetCP NU switch specific Registers */
#define ALE_UNKNOWNVLAN_MEMBER
#define ALE_UNKNOWNVLAN_UNREG_MCAST_FLOOD
#define ALE_UNKNOWNVLAN_REG_MCAST_FLOOD
#define ALE_UNKNOWNVLAN_FORCE_UNTAG_EGRESS
#define ALE_VLAN_MASK_MUX(reg)

#define ALE_POLICER_PORT_OUI
#define ALE_POLICER_DA_SA
#define ALE_POLICER_VLAN
#define ALE_POLICER_ETHERTYPE_IPSA
#define ALE_POLICER_IPDA
#define ALE_POLICER_PIR
#define ALE_POLICER_CIR
#define ALE_POLICER_TBL_CTL
#define ALE_POLICER_CTL
#define ALE_POLICER_TEST_CTL
#define ALE_POLICER_HIT_STATUS
#define ALE_THREAD_DEF
#define ALE_THREAD_CTL
#define ALE_THREAD_VAL

#define ALE_POLICER_TBL_WRITE_ENABLE
#define ALE_POLICER_TBL_INDEX_MASK

#define AM65_CPSW_ALE_THREAD_DEF_REG

/* ALE_AGING_TIMER */
#define ALE_AGING_TIMER_MASK

#define ALE_RATE_LIMIT_MIN_PPS

/**
 * struct ale_entry_fld - The ALE tbl entry field description
 * @start_bit: field start bit
 * @num_bits: field bit length
 * @flags: field flags
 */
struct ale_entry_fld {};

enum {};

/**
 * struct cpsw_ale_dev_id - The ALE version/SoC specific configuration
 * @dev_id: ALE version/SoC id
 * @features: features supported by ALE
 * @tbl_entries: number of ALE entries
 * @reg_fields: pointer to array of register field configuration
 * @num_fields: number of fields in the reg_fields array
 * @nu_switch_ale: NU Switch ALE
 * @vlan_entry_tbl: ALE vlan entry fields description tbl
 */
struct cpsw_ale_dev_id {};

#define ALE_TABLE_WRITE

#define ALE_TYPE_FREE
#define ALE_TYPE_ADDR
#define ALE_TYPE_VLAN
#define ALE_TYPE_VLAN_ADDR

#define ALE_UCAST_PERSISTANT
#define ALE_UCAST_UNTOUCHED
#define ALE_UCAST_OUI
#define ALE_UCAST_TOUCHED

#define ALE_TABLE_SIZE_MULTIPLIER
#define ALE_POLICER_SIZE_MULTIPLIER

static inline int cpsw_ale_get_field(u32 *ale_entry, u32 start, u32 bits)
{}

static inline void cpsw_ale_set_field(u32 *ale_entry, u32 start, u32 bits,
				      u32 value)
{}

#define DEFINE_ALE_FIELD(name, start, bits)

#define DEFINE_ALE_FIELD1(name, start)

enum {};

#define ALE_FLD_ALLOWED
#define ALE_FLD_SIZE_PORT_MASK_BITS
#define ALE_FLD_SIZE_PORT_NUM_BITS

#define ALE_ENTRY_FLD(id, start, bits)

#define ALE_ENTRY_FLD_DYN_MSK_SIZE(id, start)

/* dm814x, am3/am4/am5, k2hk */
static const struct ale_entry_fld vlan_entry_cpsw[ALE_ENT_VID_LAST] =;

/* k2e/k2l, k3 am65/j721e cpsw2g  */
static const struct ale_entry_fld vlan_entry_nu[ALE_ENT_VID_LAST] =;

/* K3 j721e/j7200 cpsw9g/5g, am64x cpsw3g  */
static const struct ale_entry_fld vlan_entry_k3_cpswxg[] =;

DEFINE_ALE_FIELD(entry_type,		60,	2)
DEFINE_ALE_FIELD(vlan_id,		48,	12)
DEFINE_ALE_FIELD(mcast_state,		62,	2)
DEFINE_ALE_FIELD1(port_mask,		66)
DEFINE_ALE_FIELD(super,			65,	1)
DEFINE_ALE_FIELD(ucast_type,		62,     2)
DEFINE_ALE_FIELD1(port_num,		66)
DEFINE_ALE_FIELD(blocked,		65,     1)
DEFINE_ALE_FIELD(secure,		64,     1)
DEFINE_ALE_FIELD(mcast,			40,	1)

#define NU_VLAN_UNREG_MCAST_IDX

static int cpsw_ale_entry_get_fld(struct cpsw_ale *ale,
				  u32 *ale_entry,
				  const struct ale_entry_fld *entry_tbl,
				  int fld_id)
{}

static void cpsw_ale_entry_set_fld(struct cpsw_ale *ale,
				   u32 *ale_entry,
				   const struct ale_entry_fld *entry_tbl,
				   int fld_id,
				   u32 value)
{}

static int cpsw_ale_vlan_get_fld(struct cpsw_ale *ale,
				 u32 *ale_entry,
				 int fld_id)
{}

static void cpsw_ale_vlan_set_fld(struct cpsw_ale *ale,
				  u32 *ale_entry,
				  int fld_id,
				  u32 value)
{}

/* The MAC address field in the ALE entry cannot be macroized as above */
static inline void cpsw_ale_get_addr(u32 *ale_entry, u8 *addr)
{}

static inline void cpsw_ale_set_addr(u32 *ale_entry, const u8 *addr)
{}

static int cpsw_ale_read(struct cpsw_ale *ale, int idx, u32 *ale_entry)
{}

static int cpsw_ale_write(struct cpsw_ale *ale, int idx, u32 *ale_entry)
{}

static int cpsw_ale_match_addr(struct cpsw_ale *ale, const u8 *addr, u16 vid)
{}

static int cpsw_ale_match_vlan(struct cpsw_ale *ale, u16 vid)
{}

static int cpsw_ale_match_free(struct cpsw_ale *ale)
{}

static int cpsw_ale_find_ageable(struct cpsw_ale *ale)
{}

static void cpsw_ale_flush_mcast(struct cpsw_ale *ale, u32 *ale_entry,
				 int port_mask)
{}

int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid)
{}

static inline void cpsw_ale_set_vlan_entry_type(u32 *ale_entry,
						int flags, u16 vid)
{}

int cpsw_ale_add_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
		       int flags, u16 vid)
{}

int cpsw_ale_del_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
		       int flags, u16 vid)
{}

int cpsw_ale_add_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
		       int flags, u16 vid, int mcast_state)
{}

int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
		       int flags, u16 vid)
{}

/* ALE NetCP NU switch specific vlan functions */
static void cpsw_ale_set_vlan_mcast(struct cpsw_ale *ale, u32 *ale_entry,
				    int reg_mcast, int unreg_mcast)
{}

static void cpsw_ale_set_vlan_untag(struct cpsw_ale *ale, u32 *ale_entry,
				    u16 vid, int untag_mask)
{}

int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port_mask, int untag,
		      int reg_mcast, int unreg_mcast)
{}

static void cpsw_ale_vlan_del_modify_int(struct cpsw_ale *ale,  u32 *ale_entry,
					 u16 vid, int port_mask)
{}

int cpsw_ale_vlan_del_modify(struct cpsw_ale *ale, u16 vid, int port_mask)
{}

int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask)
{}

int cpsw_ale_vlan_add_modify(struct cpsw_ale *ale, u16 vid, int port_mask,
			     int untag_mask, int reg_mask, int unreg_mask)
{}

void cpsw_ale_set_unreg_mcast(struct cpsw_ale *ale, int unreg_mcast_mask,
			      bool add)
{}

static void cpsw_ale_vlan_set_unreg_mcast(struct cpsw_ale *ale, u32 *ale_entry,
					  int allmulti)
{}

static void
cpsw_ale_vlan_set_unreg_mcast_idx(struct cpsw_ale *ale, u32 *ale_entry,
				  int allmulti)
{}

void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti, int port)
{}

struct ale_control_info {};

static struct ale_control_info ale_controls[ALE_NUM_CONTROLS] =;

int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int control,
			 int value)
{}

int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control)
{}

int cpsw_ale_rx_ratelimit_mc(struct cpsw_ale *ale, int port, unsigned int ratelimit_pps)

{}

int cpsw_ale_rx_ratelimit_bc(struct cpsw_ale *ale, int port, unsigned int ratelimit_pps)

{}

static void cpsw_ale_timer(struct timer_list *t)
{}

static void cpsw_ale_hw_aging_timer_start(struct cpsw_ale *ale)
{}

static void cpsw_ale_hw_aging_timer_stop(struct cpsw_ale *ale)
{}

static void cpsw_ale_aging_start(struct cpsw_ale *ale)
{}

static void cpsw_ale_aging_stop(struct cpsw_ale *ale)
{}

void cpsw_ale_start(struct cpsw_ale *ale)
{}

void cpsw_ale_stop(struct cpsw_ale *ale)
{}

static const struct reg_field ale_fields_cpsw[] =;

static const struct reg_field ale_fields_cpsw_nu[] =;

static const struct cpsw_ale_dev_id cpsw_ale_id_match[] =;

static const struct
cpsw_ale_dev_id *cpsw_ale_match_id(const struct cpsw_ale_dev_id *id,
				   const char *dev_id)
{}

static const struct regmap_config ale_regmap_cfg =;

static int cpsw_ale_regfield_init(struct cpsw_ale *ale)
{}

struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
{}

void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data)
{}

void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data)
{}

u32 cpsw_ale_get_num_entries(struct cpsw_ale *ale)
{}

/* Reads the specified policer index into ALE POLICER registers */
static void cpsw_ale_policer_read_idx(struct cpsw_ale *ale, u32 idx)
{}

/* Writes the ALE POLICER registers into the specified policer index */
static void cpsw_ale_policer_write_idx(struct cpsw_ale *ale, u32 idx)
{}

/* enables/disables the custom thread value for the specified policer index */
static void cpsw_ale_policer_thread_idx_enable(struct cpsw_ale *ale, u32 idx,
					       u32 thread_id, bool enable)
{}

/* Disable all policer entries and thread mappings */
static void cpsw_ale_policer_reset(struct cpsw_ale *ale)
{}

/* Default classifier is to map 8 user priorities to N receive channels */
void cpsw_ale_classifier_setup_default(struct cpsw_ale *ale, int num_rx_ch)
{}