/* Parsing tokens. Defined conveniently, so that any correction is easy. */
#define MRVL_TOK_DEFAULT "default"
+#define MRVL_TOK_DSA_MODE "dsa_mode"
+#define MRVL_TOK_DSA_MODE_NONE "none"
+#define MRVL_TOK_DSA_MODE_DSA "dsa"
+#define MRVL_TOK_DSA_MODE_EXT_DSA "ext_dsa"
#define MRVL_TOK_DEFAULT_TC "default_tc"
#define MRVL_TOK_DSCP "dscp"
#define MRVL_TOK_MAPPING_PRIORITY "mapping_priority"
/** Maximum possible value of DSCP. */
#define MAX_DSCP 63
-/** Global QoS configuration. */
-struct mrvl_qos_cfg *mrvl_qos_cfg;
+/** Global configuration. */
+struct mrvl_cfg *mrvl_cfg;
/**
* Convert string to uint32_t with extra checks for result correctness.
* @param file Path to the configuration file.
* @param port Port number.
* @param outq Out queue number.
- * @param cfg Pointer to the Marvell QoS configuration structure.
+ * @param cfg Pointer to the Marvell configuration structure.
* @returns 0 in case of success, negative value otherwise.
*/
static int
get_outq_cfg(struct rte_cfgfile *file, int port, int outq,
- struct mrvl_qos_cfg *cfg)
+ struct mrvl_cfg *cfg)
{
char sec_name[32];
const char *entry;
*/
static int
parse_tc_cfg(struct rte_cfgfile *file, int port, int tc,
- struct mrvl_qos_cfg *cfg)
+ struct mrvl_cfg *cfg)
{
char sec_name[32];
const char *entry;
*/
static int
parse_policer(struct rte_cfgfile *file, int port, const char *sec_name,
- struct mrvl_qos_cfg *cfg)
+ struct mrvl_cfg *cfg)
{
const char *entry;
uint32_t val;
}
/**
- * Parse QoS configuration - rte_kvargs_process handler.
+ * Parse configuration - rte_kvargs_process handler.
*
* Opens configuration file and parses its content.
*
* @returns 0 in case of success, exits otherwise.
*/
int
-mrvl_get_qoscfg(const char *key __rte_unused, const char *path,
- void *extra_args)
+mrvl_get_cfg(const char *key __rte_unused, const char *path, void *extra_args)
{
- struct mrvl_qos_cfg **cfg = extra_args;
+ struct mrvl_cfg **cfg = extra_args;
struct rte_cfgfile *file = rte_cfgfile_load(path, 0);
uint32_t val;
int n, i, ret;
const char *entry;
char sec_name[32];
- if (file == NULL)
- rte_exit(EXIT_FAILURE, "Cannot load configuration %s\n", path);
+ if (file == NULL) {
+ MRVL_LOG(ERR, "Cannot load configuration %s\n", path);
+ return -1;
+ }
/* Create configuration. This is never accessed on the fast path,
* so we can ignore socket.
*/
- *cfg = rte_zmalloc("mrvl_qos_cfg", sizeof(struct mrvl_qos_cfg), 0);
- if (*cfg == NULL)
- rte_exit(EXIT_FAILURE, "Cannot allocate configuration %s\n",
- path);
+ *cfg = rte_zmalloc("mrvl_cfg", sizeof(struct mrvl_cfg), 0);
+ if (*cfg == NULL) {
+ MRVL_LOG(ERR, "Cannot allocate configuration %s\n", path);
+ return -1;
+ }
n = rte_cfgfile_num_sections(file, MRVL_TOK_PORT,
sizeof(MRVL_TOK_PORT) - 1);
continue;
}
+ entry = rte_cfgfile_get_entry(file, sec_name,
+ MRVL_TOK_DSA_MODE);
+ if (entry) {
+ if (!strncmp(entry, MRVL_TOK_DSA_MODE_NONE,
+ sizeof(MRVL_TOK_DSA_MODE_NONE)))
+ (*cfg)->port[n].eth_start_hdr =
+ PP2_PPIO_HDR_ETH;
+ else if (!strncmp(entry, MRVL_TOK_DSA_MODE_DSA,
+ sizeof(MRVL_TOK_DSA_MODE_DSA)))
+ (*cfg)->port[n].eth_start_hdr =
+ PP2_PPIO_HDR_ETH_DSA;
+ else if (!strncmp(entry, MRVL_TOK_DSA_MODE_EXT_DSA,
+ sizeof(MRVL_TOK_DSA_MODE_EXT_DSA))) {
+ (*cfg)->port[n].eth_start_hdr =
+ PP2_PPIO_HDR_ETH_EXT_DSA;
+ } else {
+ MRVL_LOG(ERR,
+ "Error in parsing %s value (%s)!\n",
+ MRVL_TOK_DSA_MODE, entry);
+ return -1;
+ }
+ } else {
+ (*cfg)->port[n].eth_start_hdr = PP2_PPIO_HDR_ETH;
+ }
+
/*
* Read per-port rate limiting. Setting that will
* disable per-queue rate limiting.
(*cfg)->port[n].mapping_priority =
PP2_CLS_QOS_TBL_IP_PRI;
else if (!strncmp(entry, MRVL_TOK_VLAN,
- sizeof(MRVL_TOK_VLAN)))
+ sizeof(MRVL_TOK_VLAN))) {
(*cfg)->port[n].mapping_priority =
PP2_CLS_QOS_TBL_VLAN_PRI;
- else
- rte_exit(EXIT_FAILURE,
+ } else {
+ MRVL_LOG(ERR,
"Error in parsing %s value (%s)!\n",
MRVL_TOK_MAPPING_PRIORITY, entry);
+ return -1;
+ }
} else {
(*cfg)->port[n].mapping_priority =
PP2_CLS_QOS_TBL_VLAN_IP_PRI;
for (i = 0; i < MRVL_PP2_RXQ_MAX; ++i) {
ret = get_outq_cfg(file, n, i, *cfg);
- if (ret < 0)
- rte_exit(EXIT_FAILURE,
+ if (ret < 0) {
+ MRVL_LOG(ERR,
"Error %d parsing port %d outq %d!\n",
ret, n, i);
+ return -1;
+ }
}
for (i = 0; i < MRVL_PP2_TC_MAX; ++i) {
ret = parse_tc_cfg(file, n, i, *cfg);
- if (ret < 0)
- rte_exit(EXIT_FAILURE,
+ if (ret < 0) {
+ MRVL_LOG(ERR,
"Error %d parsing port %d tc %d!\n",
ret, n, i);
+ return -1;
+ }
}
entry = rte_cfgfile_get_entry(file, sec_name,
} else {
if ((*cfg)->port[n].use_global_defaults == 0) {
MRVL_LOG(ERR,
- "Default Traffic Class required in custom configuration!");
+ "Default Traffic Class required in "
+ "custom configuration!");
return -1;
}
}
{
size_t i, tc;
- if (mrvl_qos_cfg == NULL ||
- mrvl_qos_cfg->port[portid].use_global_defaults) {
+ if (mrvl_cfg == NULL ||
+ mrvl_cfg->port[portid].use_global_defaults) {
/*
* No port configuration, use default: 1 TC, no QoS,
* TC color set to green.
}
/* We need only a subset of configuration. */
- struct port_cfg *port_cfg = &mrvl_qos_cfg->port[portid];
+ struct port_cfg *port_cfg = &mrvl_cfg->port[portid];
priv->qos_tbl_params.type = port_cfg->mapping_priority;
uint16_t max_queues)
{
/* We need only a subset of configuration. */
- struct port_cfg *port_cfg = &mrvl_qos_cfg->port[portid];
+ struct port_cfg *port_cfg = &mrvl_cfg->port[portid];
int i;
- if (mrvl_qos_cfg == NULL)
+ if (mrvl_cfg == NULL)
return 0;
priv->ppio_params.rate_limit_enable = port_cfg->rate_limit_enable;