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

// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2016-2018 NXP
 * Copyright (c) 2018-2019, Vladimir Oltean <[email protected]>
 */
#include "sja1105_static_config.h"
#include <linux/crc32.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/errno.h>

/* Convenience wrappers over the generic packing functions. These take into
 * account the SJA1105 memory layout quirks and provide some level of
 * programmer protection against incorrect API use. The errors are not expected
 * to occur durring runtime, therefore printing and swallowing them here is
 * appropriate instead of clutterring up higher-level code.
 */
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)
{}

/* Little-endian Ethernet CRC32 of data packed as big-endian u32 words */
u32 sja1105_crc32(const void *buf, size_t len)
{}

static size_t sja1105et_avb_params_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)
{}

static size_t sja1105et_general_params_entry_packing(void *buf, void *entry_ptr,
						     enum packing_op op)
{}

/* TPID and TPID2 are intentionally reversed so that semantic
 * compatibility with E/T is kept.
 */
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)
{}

static size_t
sja1105_l2_forwarding_params_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)
{}

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)
{}

static size_t
sja1105et_l2_lookup_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 sja1105et_l2_lookup_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 sja1110_l2_lookup_entry_packing(void *buf, void *entry_ptr,
				       enum packing_op op)
{}

static size_t sja1105_l2_policing_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)
{}

static size_t sja1105et_mac_config_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)
{}

static size_t
sja1105_schedule_entry_points_params_entry_packing(void *buf, void *entry_ptr,
						   enum packing_op op)
{}

static size_t
sja1105_schedule_entry_points_entry_packing(void *buf, void *entry_ptr,
					    enum packing_op op)
{}

static size_t
sja1110_schedule_entry_points_entry_packing(void *buf, void *entry_ptr,
					    enum packing_op op)
{}

static size_t sja1105_schedule_params_entry_packing(void *buf, void *entry_ptr,
						    enum packing_op op)
{}

static size_t sja1110_schedule_params_entry_packing(void *buf, void *entry_ptr,
						    enum packing_op op)
{}

static size_t sja1105_schedule_entry_packing(void *buf, void *entry_ptr,
					     enum packing_op op)
{}

static size_t sja1110_schedule_entry_packing(void *buf, void *entry_ptr,
					     enum packing_op op)
{}

static size_t
sja1105_vl_forwarding_params_entry_packing(void *buf, void *entry_ptr,
					   enum packing_op op)
{}

static size_t
sja1110_vl_forwarding_params_entry_packing(void *buf, void *entry_ptr,
					   enum packing_op op)
{}

static size_t sja1105_vl_forwarding_entry_packing(void *buf, void *entry_ptr,
						  enum packing_op op)
{}

static size_t sja1110_vl_forwarding_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)
{}

static size_t sja1105_vl_policing_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 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)
{}

static size_t sja1105_xmii_params_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 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)
{}

static size_t sja1110_pcp_remapping_entry_packing(void *buf, void *entry_ptr,
						  enum packing_op op)
{}

size_t sja1105_table_header_packing(void *buf, void *entry_ptr,
				    enum packing_op op)
{}

/* WARNING: the *hdr pointer is really non-const, because it is
 * modifying the CRC of the header for a 2-stage packing operation
 */
void
sja1105_table_header_pack_with_crc(void *buf, struct sja1105_table_header *hdr)
{}

static void sja1105_table_write_crc(u8 *table_start, u8 *crc_ptr)
{}

/* The block IDs that the switches support are unfortunately sparse, so keep a
 * mapping table to "block indices" and translate back and forth so that we
 * don't waste useless memory in struct sja1105_static_config.
 * Also, since the block id comes from essentially untrusted input (unpacking
 * the static config from userspace) it has to be sanitized (range-checked)
 * before blindly indexing kernel memory with the blk_idx.
 */
static u64 blk_id_map[BLK_IDX_MAX] =;

const char *sja1105_static_config_error_msg[] =;

static sja1105_config_valid_t
static_config_check_memory_size(const struct sja1105_table *tables, int max_mem)
{}

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)
{}

size_t
sja1105_static_config_get_length(const struct sja1105_static_config *config)
{}

/* Compatibility matrices */

/* SJA1105E: First generation, no TTEthernet */
const struct sja1105_table_ops sja1105e_table_ops[BLK_IDX_MAX] =;

/* SJA1105T: First generation, TTEthernet */
const struct sja1105_table_ops sja1105t_table_ops[BLK_IDX_MAX] =;

/* SJA1105P: Second generation, no TTEthernet, no SGMII */
const struct sja1105_table_ops sja1105p_table_ops[BLK_IDX_MAX] =;

/* SJA1105Q: Second generation, TTEthernet, no SGMII */
const struct sja1105_table_ops sja1105q_table_ops[BLK_IDX_MAX] =;

/* SJA1105R: Second generation, no TTEthernet, SGMII */
const struct sja1105_table_ops sja1105r_table_ops[BLK_IDX_MAX] =;

/* SJA1105S: Second generation, TTEthernet, SGMII */
const struct sja1105_table_ops sja1105s_table_ops[BLK_IDX_MAX] =;

/* SJA1110A: Third generation */
const struct sja1105_table_ops sja1110_table_ops[BLK_IDX_MAX] =;

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)
{}

/* No pointers to table->entries should be kept when this is called. */
int sja1105_table_resize(struct sja1105_table *table, size_t new_count)
{}