linux/drivers/net/dsa/sja1105/sja1105_static_config.h

/* SPDX-License-Identifier: BSD-3-Clause */
/* Copyright 2016-2018 NXP
 * Copyright (c) 2018-2019, Vladimir Oltean <[email protected]>
 */
#ifndef _SJA1105_STATIC_CONFIG_H
#define _SJA1105_STATIC_CONFIG_H

#include <linux/packing.h>
#include <linux/types.h>
#include <asm/types.h>

#define SJA1105_NUM_PORTS
#define SJA1110_NUM_PORTS
#define SJA1105_MAX_NUM_PORTS
#define SJA1105_NUM_TC

#define SJA1105_SIZE_SPI_MSG_HEADER
#define SJA1105_SIZE_SPI_MSG_MAXLEN
#define SJA1105_SIZE_DEVICE_ID
#define SJA1105_SIZE_TABLE_HEADER
#define SJA1105_SIZE_SCHEDULE_ENTRY
#define SJA1110_SIZE_SCHEDULE_ENTRY
#define SJA1105_SIZE_SCHEDULE_ENTRY_POINTS_ENTRY
#define SJA1110_SIZE_SCHEDULE_ENTRY_POINTS_ENTRY
#define SJA1105_SIZE_VL_LOOKUP_ENTRY
#define SJA1105_SIZE_VL_POLICING_ENTRY
#define SJA1105_SIZE_VL_FORWARDING_ENTRY
#define SJA1105_SIZE_L2_POLICING_ENTRY
#define SJA1105_SIZE_VLAN_LOOKUP_ENTRY
#define SJA1110_SIZE_VLAN_LOOKUP_ENTRY
#define SJA1105_SIZE_L2_FORWARDING_ENTRY
#define SJA1105_SIZE_L2_FORWARDING_PARAMS_ENTRY
#define SJA1105_SIZE_RETAGGING_ENTRY
#define SJA1105_SIZE_XMII_PARAMS_ENTRY
#define SJA1110_SIZE_XMII_PARAMS_ENTRY
#define SJA1105_SIZE_SCHEDULE_PARAMS_ENTRY
#define SJA1105_SIZE_SCHEDULE_ENTRY_POINTS_PARAMS_ENTRY
#define SJA1105_SIZE_VL_FORWARDING_PARAMS_ENTRY
#define SJA1105ET_SIZE_L2_LOOKUP_ENTRY
#define SJA1105ET_SIZE_MAC_CONFIG_ENTRY
#define SJA1105ET_SIZE_L2_LOOKUP_PARAMS_ENTRY
#define SJA1105ET_SIZE_GENERAL_PARAMS_ENTRY
#define SJA1105ET_SIZE_AVB_PARAMS_ENTRY
#define SJA1105ET_SIZE_CBS_ENTRY
#define SJA1105PQRS_SIZE_L2_LOOKUP_ENTRY
#define SJA1110_SIZE_L2_LOOKUP_ENTRY
#define SJA1105PQRS_SIZE_MAC_CONFIG_ENTRY
#define SJA1105PQRS_SIZE_L2_LOOKUP_PARAMS_ENTRY
#define SJA1110_SIZE_L2_LOOKUP_PARAMS_ENTRY
#define SJA1105PQRS_SIZE_GENERAL_PARAMS_ENTRY
#define SJA1110_SIZE_GENERAL_PARAMS_ENTRY
#define SJA1105PQRS_SIZE_AVB_PARAMS_ENTRY
#define SJA1105PQRS_SIZE_CBS_ENTRY
#define SJA1110_SIZE_PCP_REMAPPING_ENTRY

/* UM10944.pdf Page 11, Table 2. Configuration Blocks */
enum {};

enum sja1105_blk_idx {};

#define SJA1105_MAX_SCHEDULE_COUNT
#define SJA1110_MAX_SCHEDULE_COUNT
#define SJA1105_MAX_SCHEDULE_ENTRY_POINTS_COUNT
#define SJA1105_MAX_VL_LOOKUP_COUNT
#define SJA1110_MAX_VL_LOOKUP_COUNT
#define SJA1105_MAX_VL_POLICING_COUNT
#define SJA1110_MAX_VL_POLICING_COUNT
#define SJA1105_MAX_VL_FORWARDING_COUNT
#define SJA1110_MAX_VL_FORWARDING_COUNT
#define SJA1105_MAX_L2_LOOKUP_COUNT
#define SJA1105_MAX_L2_POLICING_COUNT
#define SJA1110_MAX_L2_POLICING_COUNT
#define SJA1105_MAX_VLAN_LOOKUP_COUNT
#define SJA1105_MAX_L2_FORWARDING_COUNT
#define SJA1110_MAX_L2_FORWARDING_COUNT
#define SJA1105_MAX_MAC_CONFIG_COUNT
#define SJA1110_MAX_MAC_CONFIG_COUNT
#define SJA1105_MAX_SCHEDULE_PARAMS_COUNT
#define SJA1105_MAX_SCHEDULE_ENTRY_POINTS_PARAMS_COUNT
#define SJA1105_MAX_VL_FORWARDING_PARAMS_COUNT
#define SJA1105_MAX_L2_LOOKUP_PARAMS_COUNT
#define SJA1105_MAX_L2_FORWARDING_PARAMS_COUNT
#define SJA1105_MAX_GENERAL_PARAMS_COUNT
#define SJA1105_MAX_RETAGGING_COUNT
#define SJA1105_MAX_XMII_PARAMS_COUNT
#define SJA1105_MAX_AVB_PARAMS_COUNT
#define SJA1105ET_MAX_CBS_COUNT
#define SJA1105PQRS_MAX_CBS_COUNT
#define SJA1110_MAX_CBS_COUNT
#define SJA1110_MAX_PCP_REMAPPING_COUNT

#define SJA1105_MAX_FRAME_MEMORY
#define SJA1110_MAX_FRAME_MEMORY
#define SJA1105_FRAME_MEMORY_RETAGGING_OVERHEAD
#define SJA1105_VL_FRAME_MEMORY

#define SJA1105E_DEVICE_ID
#define SJA1105T_DEVICE_ID
#define SJA1105PR_DEVICE_ID
#define SJA1105QS_DEVICE_ID
#define SJA1110_DEVICE_ID

#define SJA1105ET_PART_NO
#define SJA1105P_PART_NO
#define SJA1105Q_PART_NO
#define SJA1105R_PART_NO
#define SJA1105S_PART_NO
#define SJA1110A_PART_NO
#define SJA1110B_PART_NO
#define SJA1110C_PART_NO
#define SJA1110D_PART_NO

#define SJA1110_ACU
#define SJA1110_RGU
#define SJA1110_CGU

#define SJA1110_SPI_ADDR(x)
#define SJA1110_ACU_ADDR(x)
#define SJA1110_CGU_ADDR(x)
#define SJA1110_RGU_ADDR(x)

#define SJA1105_RSV_ADDR

struct sja1105_schedule_entry {};

struct sja1105_schedule_params_entry {};

struct sja1105_general_params_entry {};

struct sja1105_schedule_entry_points_entry {};

struct sja1105_schedule_entry_points_params_entry {};

struct sja1105_vlan_lookup_entry {};

struct sja1105_l2_lookup_entry {};

struct sja1105_l2_lookup_params_entry {};

struct sja1105_l2_forwarding_entry {};

struct sja1105_l2_forwarding_params_entry {};

struct sja1105_l2_policing_entry {};

struct sja1105_avb_params_entry {};

struct sja1105_mac_config_entry {};

struct sja1105_retagging_entry {};

struct sja1105_cbs_entry {};

struct sja1105_xmii_params_entry {};

struct sja1110_pcp_remapping_entry {};

enum {};

struct sja1105_vl_lookup_entry {};

struct sja1105_vl_policing_entry {};

struct sja1105_vl_forwarding_entry {};

struct sja1105_vl_forwarding_params_entry {};

struct sja1105_table_header {};

struct sja1105_table_ops {};

struct sja1105_table {};

struct sja1105_static_config {};

extern const struct sja1105_table_ops sja1105e_table_ops[BLK_IDX_MAX];
extern const struct sja1105_table_ops sja1105t_table_ops[BLK_IDX_MAX];
extern const struct sja1105_table_ops sja1105p_table_ops[BLK_IDX_MAX];
extern const struct sja1105_table_ops sja1105q_table_ops[BLK_IDX_MAX];
extern const struct sja1105_table_ops sja1105r_table_ops[BLK_IDX_MAX];
extern const struct sja1105_table_ops sja1105s_table_ops[BLK_IDX_MAX];
extern const struct sja1105_table_ops sja1110_table_ops[BLK_IDX_MAX];

size_t sja1105_table_header_packing(void *buf, void *hdr, enum packing_op op);
void
sja1105_table_header_pack_with_crc(void *buf, struct sja1105_table_header *hdr);
size_t
sja1105_static_config_get_length(const struct sja1105_static_config *config);

sja1105_config_valid_t;

extern const char *sja1105_static_config_error_msg[];

sja1105_config_valid_t
sja1105_static_config_check_valid(const struct sja1105_static_config *config,
				  int max_mem);
void
sja1105_static_config_pack(void *buf, struct sja1105_static_config *config);
int sja1105_static_config_init(struct sja1105_static_config *config,
			       const struct sja1105_table_ops *static_ops,
			       u64 device_id);
void sja1105_static_config_free(struct sja1105_static_config *config);

int sja1105_table_delete_entry(struct sja1105_table *table, int i);
int sja1105_table_resize(struct sja1105_table *table, size_t new_count);

u32 sja1105_crc32(const void *buf, size_t len);

void sja1105_pack(void *buf, const u64 *val, int start, int end, size_t len);
void sja1105_unpack(const void *buf, u64 *val, int start, int end, size_t len);
void sja1105_packing(void *buf, u64 *val, int start, int end,
		     size_t len, enum packing_op op);

/* Common implementations for the static and dynamic configs */
size_t sja1105pqrs_general_params_entry_packing(void *buf, void *entry_ptr,
						enum packing_op op);
size_t sja1110_general_params_entry_packing(void *buf, void *entry_ptr,
					    enum packing_op op);
size_t sja1105pqrs_l2_lookup_params_entry_packing(void *buf, void *entry_ptr,
						  enum packing_op op);
size_t sja1110_l2_lookup_params_entry_packing(void *buf, void *entry_ptr,
					      enum packing_op op);
size_t sja1105_l2_forwarding_entry_packing(void *buf, void *entry_ptr,
					   enum packing_op op);
size_t sja1110_l2_forwarding_entry_packing(void *buf, void *entry_ptr,
					   enum packing_op op);
size_t sja1105pqrs_l2_lookup_entry_packing(void *buf, void *entry_ptr,
					   enum packing_op op);
size_t sja1105et_l2_lookup_entry_packing(void *buf, void *entry_ptr,
					 enum packing_op op);
size_t sja1110_l2_lookup_entry_packing(void *buf, void *entry_ptr,
				       enum packing_op op);
size_t sja1105_vlan_lookup_entry_packing(void *buf, void *entry_ptr,
					 enum packing_op op);
size_t sja1110_vlan_lookup_entry_packing(void *buf, void *entry_ptr,
					 enum packing_op op);
size_t sja1105_retagging_entry_packing(void *buf, void *entry_ptr,
				       enum packing_op op);
size_t sja1110_retagging_entry_packing(void *buf, void *entry_ptr,
				       enum packing_op op);
size_t sja1105pqrs_mac_config_entry_packing(void *buf, void *entry_ptr,
					    enum packing_op op);
size_t sja1110_mac_config_entry_packing(void *buf, void *entry_ptr,
					enum packing_op op);
size_t sja1105pqrs_avb_params_entry_packing(void *buf, void *entry_ptr,
					    enum packing_op op);
size_t sja1105_vl_lookup_entry_packing(void *buf, void *entry_ptr,
				       enum packing_op op);
size_t sja1110_vl_lookup_entry_packing(void *buf, void *entry_ptr,
				       enum packing_op op);
size_t sja1110_vl_policing_entry_packing(void *buf, void *entry_ptr,
					 enum packing_op op);
size_t sja1110_xmii_params_entry_packing(void *buf, void *entry_ptr,
					 enum packing_op op);
size_t sja1110_l2_policing_entry_packing(void *buf, void *entry_ptr,
					 enum packing_op op);
size_t sja1110_l2_forwarding_params_entry_packing(void *buf, void *entry_ptr,
						  enum packing_op op);

#endif