1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
9 #include <rte_string_fns.h>
11 #include "hash_func.h"
12 #include "rte_eth_softnic_internals.h"
18 softnic_port_in_action_profile_init(struct pmd_internals *p)
20 TAILQ_INIT(&p->port_in_action_profile_list);
26 softnic_port_in_action_profile_free(struct pmd_internals *p)
29 struct softnic_port_in_action_profile *profile;
31 profile = TAILQ_FIRST(&p->port_in_action_profile_list);
35 TAILQ_REMOVE(&p->port_in_action_profile_list, profile, node);
40 struct softnic_port_in_action_profile *
41 softnic_port_in_action_profile_find(struct pmd_internals *p,
44 struct softnic_port_in_action_profile *profile;
49 TAILQ_FOREACH(profile, &p->port_in_action_profile_list, node)
50 if (strcmp(profile->name, name) == 0)
56 struct softnic_port_in_action_profile *
57 softnic_port_in_action_profile_create(struct pmd_internals *p,
59 struct softnic_port_in_action_profile_params *params)
61 struct softnic_port_in_action_profile *profile;
62 struct rte_port_in_action_profile *ap;
65 /* Check input params */
67 softnic_port_in_action_profile_find(p, name) ||
71 if ((params->action_mask & (1LLU << RTE_PORT_IN_ACTION_LB)) &&
72 params->lb.f_hash == NULL) {
73 switch (params->lb.key_size) {
75 params->lb.f_hash = hash_default_key8;
79 params->lb.f_hash = hash_default_key16;
83 params->lb.f_hash = hash_default_key24;
87 params->lb.f_hash = hash_default_key32;
91 params->lb.f_hash = hash_default_key40;
95 params->lb.f_hash = hash_default_key48;
99 params->lb.f_hash = hash_default_key56;
103 params->lb.f_hash = hash_default_key64;
114 ap = rte_port_in_action_profile_create(0);
118 if (params->action_mask & (1LLU << RTE_PORT_IN_ACTION_FLTR)) {
119 status = rte_port_in_action_profile_action_register(ap,
120 RTE_PORT_IN_ACTION_FLTR,
124 rte_port_in_action_profile_free(ap);
129 if (params->action_mask & (1LLU << RTE_PORT_IN_ACTION_LB)) {
130 status = rte_port_in_action_profile_action_register(ap,
131 RTE_PORT_IN_ACTION_LB,
135 rte_port_in_action_profile_free(ap);
140 status = rte_port_in_action_profile_freeze(ap);
142 rte_port_in_action_profile_free(ap);
146 /* Node allocation */
147 profile = calloc(1, sizeof(struct softnic_port_in_action_profile));
148 if (profile == NULL) {
149 rte_port_in_action_profile_free(ap);
154 strlcpy(profile->name, name, sizeof(profile->name));
155 memcpy(&profile->params, params, sizeof(*params));
158 /* Node add to list */
159 TAILQ_INSERT_TAIL(&p->port_in_action_profile_list, profile, node);