linux/drivers/net/ethernet/sfc/mae.c

// SPDX-License-Identifier: GPL-2.0-only
/****************************************************************************
 * Driver for Solarflare network controllers and boards
 * Copyright 2019 Solarflare Communications Inc.
 * Copyright 2020-2022 Xilinx Inc.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation, incorporated herein by reference.
 */

#include <linux/rhashtable.h>
#include "ef100_nic.h"
#include "mae.h"
#include "mcdi.h"
#include "mcdi_pcol.h"
#include "mcdi_pcol_mae.h"
#include "tc_encap_actions.h"
#include "tc_conntrack.h"

int efx_mae_allocate_mport(struct efx_nic *efx, u32 *id, u32 *label)
{}

int efx_mae_free_mport(struct efx_nic *efx, u32 id)
{}

void efx_mae_mport_wire(struct efx_nic *efx, u32 *out)
{}

void efx_mae_mport_uplink(struct efx_nic *efx __always_unused, u32 *out)
{}

void efx_mae_mport_vf(struct efx_nic *efx __always_unused, u32 vf_id, u32 *out)
{}

/* Constructs an mport selector from an mport ID, because they're not the same */
void efx_mae_mport_mport(struct efx_nic *efx __always_unused, u32 mport_id, u32 *out)
{}

/* id is really only 24 bits wide */
int efx_mae_fw_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id)
{}

int efx_mae_start_counters(struct efx_nic *efx, struct efx_rx_queue *rx_queue)
{}

static bool efx_mae_counters_flushed(u32 *flush_gen, u32 *seen_gen)
{}

int efx_mae_stop_counters(struct efx_nic *efx, struct efx_rx_queue *rx_queue)
{}

void efx_mae_counters_grant_credits(struct work_struct *work)
{}

static int efx_mae_table_get_desc(struct efx_nic *efx,
				  struct efx_tc_table_desc *desc,
				  u32 table_id)
{}

static int efx_mae_table_hook_find(u16 n_fields,
				   struct efx_tc_table_field_fmt *fields,
				   u16 field_id)
{}

#define TABLE_FIND_KEY(_desc, _id)
#define TABLE_FIND_RESP(_desc, _id)

#define TABLE_HOOK_KEY(_meta, _name, _mcdi_name)
#define TABLE_HOOK_RESP(_meta, _name, _mcdi_name)

static int efx_mae_table_hook_ct(struct efx_nic *efx,
				 struct efx_tc_table_ct *meta_ct)
{}

static void efx_mae_table_free_desc(struct efx_tc_table_desc *desc)
{}

static bool efx_mae_check_table_exists(struct efx_nic *efx, u32 tbl_req)
{}

int efx_mae_get_tables(struct efx_nic *efx)
{}

void efx_mae_free_tables(struct efx_nic *efx)
{}

static int efx_mae_get_basic_caps(struct efx_nic *efx, struct mae_caps *caps)
{}

static int efx_mae_get_rule_fields(struct efx_nic *efx, u32 cmd,
				   u8 *field_support)
{}

int efx_mae_get_caps(struct efx_nic *efx, struct mae_caps *caps)
{}

/* Bit twiddling:
 * Prefix: 1...110...0
 *      ~: 0...001...1
 *    + 1: 0...010...0 is power of two
 * so (~x) & ((~x) + 1) == 0.  Converse holds also.
 */
#define is_prefix_byte(_x)

enum mask_type {};

static const char *mask_type_name(enum mask_type typ)
{}

/* Checks a (big-endian) bytestring is a bit prefix */
static enum mask_type classify_mask(const u8 *mask, size_t len)
{}

static int efx_mae_match_check_cap_typ(u8 support, enum mask_type typ)
{}

/* Validate field mask against hardware capabilities.  Captures caller's 'rc' */
#define CHECK
/* Booleans need special handling */
#define CHECK_BIT

int efx_mae_match_check_caps(struct efx_nic *efx,
			     const struct efx_tc_match_fields *mask,
			     struct netlink_ext_ack *extack)
{}

/* Checks for match fields not supported in LHS Outer Rules */
#define UNSUPPORTED
#define UNSUPPORTED_BIT(_field)

/* LHS rules are (normally) inserted in the Outer Rule table, which means
 * they use ENC_ fields in hardware to match regular (not enc_) fields from
 * &struct efx_tc_match_fields.
 */
int efx_mae_match_check_caps_lhs(struct efx_nic *efx,
				 const struct efx_tc_match_fields *mask,
				 struct netlink_ext_ack *extack)
{}
#undef UNSUPPORTED
#undef CHECK_BIT
#undef CHECK

#define CHECK
/* Checks that the fields needed for encap-rule matches are supported by the
 * MAE.  All the fields are exact-match, except possibly ENC_IP_TOS.
 */
int efx_mae_check_encap_match_caps(struct efx_nic *efx, bool ipv6,
				   u8 ip_tos_mask, __be16 udp_sport_mask,
				   struct netlink_ext_ack *extack)
{}
#undef CHECK

int efx_mae_check_encap_type_supported(struct efx_nic *efx, enum efx_encap_type typ)
{}

int efx_mae_allocate_counter(struct efx_nic *efx, struct efx_tc_counter *cnt)
{}

int efx_mae_free_counter(struct efx_nic *efx, struct efx_tc_counter *cnt)
{}

static int efx_mae_encap_type_to_mae_type(enum efx_encap_type type)
{}

int efx_mae_allocate_encap_md(struct efx_nic *efx,
			      struct efx_tc_encap_action *encap)
{}

int efx_mae_update_encap_md(struct efx_nic *efx,
			    struct efx_tc_encap_action *encap)
{}

int efx_mae_free_encap_md(struct efx_nic *efx,
			  struct efx_tc_encap_action *encap)
{}

int efx_mae_lookup_mport(struct efx_nic *efx, u32 vf_idx, u32 *id)
{}

static bool efx_mae_asl_id(u32 id)
{}

/* mport handling */
static const struct rhashtable_params efx_mae_mports_ht_params =;

struct mae_mport_desc *efx_mae_get_mport(struct efx_nic *efx, u32 mport_id)
{}

static int efx_mae_add_mport(struct efx_nic *efx, struct mae_mport_desc *desc)
{}

void efx_mae_remove_mport(void *desc, void *arg)
{}

static int efx_mae_process_mport(struct efx_nic *efx,
				 struct mae_mport_desc *desc)
{}

#define MCDI_MPORT_JOURNAL_LEN

int efx_mae_enumerate_mports(struct efx_nic *efx)
{}

/**
 * efx_mae_allocate_pedit_mac() - allocate pedit MAC address in HW.
 * @efx:	NIC we're installing a pedit MAC address on
 * @ped:	pedit MAC action to be installed
 *
 * Attempts to install @ped in HW and populates its id with an index of this
 * entry in the firmware MAC address table on success.
 *
 * Return: negative value on error, 0 in success.
 */
int efx_mae_allocate_pedit_mac(struct efx_nic *efx,
			       struct efx_tc_mac_pedit_action *ped)
{}

/**
 * efx_mae_free_pedit_mac() - free pedit MAC address in HW.
 * @efx:	NIC we're installing a pedit MAC address on
 * @ped:	pedit MAC action that needs to be freed
 *
 * Frees @ped in HW, check that firmware did not free a different one and clears
 * the id (which denotes the index of the entry in the MAC address table).
 */
void efx_mae_free_pedit_mac(struct efx_nic *efx,
			    struct efx_tc_mac_pedit_action *ped)
{}

int efx_mae_alloc_action_set(struct efx_nic *efx, struct efx_tc_action_set *act)
{}

int efx_mae_free_action_set(struct efx_nic *efx, u32 fw_id)
{}

int efx_mae_alloc_action_set_list(struct efx_nic *efx,
				  struct efx_tc_action_set_list *acts)
{}

int efx_mae_free_action_set_list(struct efx_nic *efx,
				 struct efx_tc_action_set_list *acts)
{}

int efx_mae_register_encap_match(struct efx_nic *efx,
				 struct efx_tc_encap_match *encap)
{}

int efx_mae_unregister_encap_match(struct efx_nic *efx,
				   struct efx_tc_encap_match *encap)
{}

static int efx_mae_populate_lhs_match_criteria(MCDI_DECLARE_STRUCT_PTR(match_crit),
					       const struct efx_tc_match *match)
{}

static int efx_mae_insert_lhs_outer_rule(struct efx_nic *efx,
					 struct efx_tc_lhs_rule *rule, u32 prio)
{}

static int efx_mae_populate_match_criteria(MCDI_DECLARE_STRUCT_PTR(match_crit),
					   const struct efx_tc_match *match);

static int efx_mae_insert_lhs_action_rule(struct efx_nic *efx,
					  struct efx_tc_lhs_rule *rule,
					  u32 prio)
{}

int efx_mae_insert_lhs_rule(struct efx_nic *efx, struct efx_tc_lhs_rule *rule,
			    u32 prio)
{}

static int efx_mae_remove_lhs_outer_rule(struct efx_nic *efx,
					 struct efx_tc_lhs_rule *rule)
{}

int efx_mae_remove_lhs_rule(struct efx_nic *efx, struct efx_tc_lhs_rule *rule)
{}

/* Populating is done by taking each byte of @value in turn and storing
 * it in the appropriate bits of @row.  @value must be big-endian; we
 * convert it to little-endianness as we go.
 */
static int efx_mae_table_populate(struct efx_tc_table_field_fmt field,
				  __le32 *row, size_t row_bits,
				  void *value, size_t value_size)
{}

static int efx_mae_table_populate_bool(struct efx_tc_table_field_fmt field,
				       __le32 *row, size_t row_bits, bool value)
{}

static int efx_mae_table_populate_ipv4(struct efx_tc_table_field_fmt field,
				       __le32 *row, size_t row_bits, __be32 value)
{}

static int efx_mae_table_populate_u24(struct efx_tc_table_field_fmt field,
				      __le32 *row, size_t row_bits, u32 value)
{}

#define _TABLE_POPULATE(dst, dw, _field, _value)
#define TABLE_POPULATE_KEY_IPV4(dst, _table, _field, _value)
#define TABLE_POPULATE_KEY(dst, _table, _field, _value)

#define TABLE_POPULATE_RESP_BOOL(dst, _table, _field, _value)
#define TABLE_POPULATE_RESP(dst, _table, _field, _value)

#define TABLE_POPULATE_RESP_U24(dst, _table, _field, _value)

static int efx_mae_populate_ct_key(struct efx_nic *efx, __le32 *key, size_t kw,
				   struct efx_tc_ct_entry *conn)
{}

int efx_mae_insert_ct(struct efx_nic *efx, struct efx_tc_ct_entry *conn)
{}

int efx_mae_remove_ct(struct efx_nic *efx, struct efx_tc_ct_entry *conn)
{}

static int efx_mae_populate_match_criteria(MCDI_DECLARE_STRUCT_PTR(match_crit),
					   const struct efx_tc_match *match)
{}

int efx_mae_insert_rule(struct efx_nic *efx, const struct efx_tc_match *match,
			u32 prio, u32 acts_id, u32 *id)
{}

int efx_mae_update_rule(struct efx_nic *efx, u32 acts_id, u32 id)
{}

int efx_mae_delete_rule(struct efx_nic *efx, u32 id)
{}

int efx_init_mae(struct efx_nic *efx)
{}

void efx_fini_mae(struct efx_nic *efx)
{}