// SPDX-License-Identifier: GPL-2.0+
/* Microchip VCAP API
*
* Copyright (c) 2022 Microchip Technology Inc. and its subsidiaries.
*/
#include <net/tc_act/tc_gate.h>
#include <net/tcp.h>
#include "sparx5_tc.h"
#include "vcap_api.h"
#include "vcap_api_client.h"
#include "vcap_tc.h"
#include "sparx5_main.h"
#include "sparx5_vcap_impl.h"
#define SPX5_MAX_RULE_SIZE 13 /* allows X1, X2, X4, X6 and X12 rules */
/* Collect keysets and type ids for multiple rules per size */
struct sparx5_wildcard_rule {
bool selected;
u8 value;
u8 mask;
enum vcap_keyfield_set keyset;
};
struct sparx5_multiple_rules {
struct sparx5_wildcard_rule rule[SPX5_MAX_RULE_SIZE];
};
struct sparx5_tc_flower_template {
struct list_head list; /* for insertion in the list of templates */
int cid; /* chain id */
enum vcap_keyfield_set orig; /* keyset used before the template */
enum vcap_keyfield_set keyset; /* new keyset used by template */
u16 l3_proto; /* protocol specified in the template */
};
static int
sparx5_tc_flower_es0_tpid(struct vcap_tc_flower_parse_usage *st)
{
int err = 0;
switch (st->tpid) {
case ETH_P_8021Q:
err = vcap_rule_add_key_u32(st->vrule,
VCAP_KF_8021Q_TPID,
SPX5_TPID_SEL_8100, ~0);
break;