2019-06-25 11:12:58 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright(c) 2017 Intel Corporation
|
2018-05-15 09:49:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
|
|
|
|
#define __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__
|
|
|
|
|
2019-06-25 11:12:58 +00:00
|
|
|
#include <stddef.h>
|
2018-05-15 09:49:22 +00:00
|
|
|
#include <stdint.h>
|
2019-06-25 11:12:58 +00:00
|
|
|
#include <sys/queue.h>
|
2018-05-15 09:49:22 +00:00
|
|
|
|
2019-06-25 11:12:58 +00:00
|
|
|
#include <rte_mempool.h>
|
2018-05-15 09:49:22 +00:00
|
|
|
#include <rte_mbuf.h>
|
2019-06-25 11:12:58 +00:00
|
|
|
#include <rte_ring.h>
|
2019-01-18 09:27:45 +00:00
|
|
|
#include <rte_ethdev.h>
|
2023-09-13 12:21:49 +00:00
|
|
|
#include <rte_swx_pipeline.h>
|
|
|
|
#include <rte_swx_ctl.h>
|
2019-06-25 11:12:58 +00:00
|
|
|
|
|
|
|
#include <rte_ethdev_core.h>
|
2022-09-06 04:00:10 +00:00
|
|
|
#include <ethdev_driver.h>
|
2018-05-15 09:49:22 +00:00
|
|
|
|
|
|
|
#include "rte_eth_softnic.h"
|
2019-06-25 11:12:58 +00:00
|
|
|
#include "conn.h"
|
|
|
|
|
|
|
|
#define NAME_SIZE 64
|
2022-09-02 04:40:05 +00:00
|
|
|
#define SOFTNIC_PATH_MAX 4096
|
2018-05-15 09:49:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PMD Parameters
|
|
|
|
*/
|
|
|
|
|
2019-06-25 11:12:58 +00:00
|
|
|
struct pmd_params {
|
2022-09-02 04:40:05 +00:00
|
|
|
char name[NAME_SIZE];
|
|
|
|
char firmware[SOFTNIC_PATH_MAX];
|
2019-06-25 11:12:58 +00:00
|
|
|
uint16_t conn_port;
|
|
|
|
uint32_t cpu_id;
|
2020-06-18 16:55:50 +00:00
|
|
|
int sc; /**< Service cores. */
|
2018-05-15 09:49:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2019-06-25 11:12:58 +00:00
|
|
|
* MEMPOOL
|
2018-05-15 09:49:22 +00:00
|
|
|
*/
|
2019-06-25 11:12:58 +00:00
|
|
|
struct softnic_mempool_params {
|
|
|
|
uint32_t buffer_size;
|
|
|
|
uint32_t pool_size;
|
|
|
|
uint32_t cache_size;
|
|
|
|
};
|
2018-05-15 09:49:22 +00:00
|
|
|
|
2019-06-25 11:12:58 +00:00
|
|
|
struct softnic_mempool {
|
|
|
|
TAILQ_ENTRY(softnic_mempool) node;
|
|
|
|
char name[NAME_SIZE];
|
|
|
|
struct rte_mempool *m;
|
|
|
|
uint32_t buffer_size;
|
|
|
|
};
|
2018-05-15 09:49:22 +00:00
|
|
|
|
2019-06-25 11:12:58 +00:00
|
|
|
TAILQ_HEAD(softnic_mempool_list, softnic_mempool);
|
2018-12-06 14:17:51 +00:00
|
|
|
|
2019-06-25 11:12:58 +00:00
|
|
|
/**
|
|
|
|
* SWQ
|
|
|
|
*/
|
|
|
|
struct softnic_swq_params {
|
|
|
|
uint32_t size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct softnic_swq {
|
|
|
|
TAILQ_ENTRY(softnic_swq) node;
|
|
|
|
char name[NAME_SIZE];
|
|
|
|
struct rte_ring *r;
|
2018-05-15 09:49:22 +00:00
|
|
|
};
|
|
|
|
|
2019-06-25 11:12:58 +00:00
|
|
|
TAILQ_HEAD(softnic_swq_list, softnic_swq);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pipeline
|
|
|
|
*/
|
|
|
|
struct pipeline {
|
|
|
|
TAILQ_ENTRY(pipeline) node;
|
|
|
|
char name[NAME_SIZE];
|
|
|
|
|
2023-09-13 12:21:49 +00:00
|
|
|
struct rte_swx_pipeline *p;
|
|
|
|
struct rte_swx_ctl_pipeline *ctl;
|
2019-06-25 11:12:58 +00:00
|
|
|
|
|
|
|
int enabled;
|
|
|
|
uint32_t thread_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
TAILQ_HEAD(pipeline_list, pipeline);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Thread
|
|
|
|
*/
|
|
|
|
#ifndef THREAD_PIPELINES_MAX
|
|
|
|
#define THREAD_PIPELINES_MAX 256
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef THREAD_MSGQ_SIZE
|
|
|
|
#define THREAD_MSGQ_SIZE 64
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef THREAD_TIMER_PERIOD_MS
|
|
|
|
#define THREAD_TIMER_PERIOD_MS 100
|
|
|
|
#endif
|
|
|
|
|
2023-09-13 12:21:49 +00:00
|
|
|
/* Pipeline instruction quanta: Needs to be big enough to do some meaningful
|
|
|
|
* work, but not too big to avoid starving any other pipelines mapped to the
|
|
|
|
* same thread. For a pipeline that executes 10 instructions per packet, a
|
|
|
|
* quanta of 1000 instructions equates to processing 100 packets.
|
|
|
|
*/
|
|
|
|
#ifndef PIPELINE_INSTR_QUANTA
|
|
|
|
#define PIPELINE_INSTR_QUANTA 1000
|
|
|
|
#endif
|
|
|
|
|
2019-06-25 11:12:58 +00:00
|
|
|
/**
|
2021-02-05 08:48:47 +00:00
|
|
|
* Main thread: data plane thread context
|
2019-06-25 11:12:58 +00:00
|
|
|
*/
|
|
|
|
struct softnic_thread {
|
|
|
|
struct rte_ring *msgq_req;
|
|
|
|
struct rte_ring *msgq_rsp;
|
|
|
|
|
2020-06-18 16:55:50 +00:00
|
|
|
uint32_t service_id;
|
2019-06-25 11:12:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data plane threads: context
|
|
|
|
*/
|
|
|
|
struct softnic_thread_data {
|
2023-09-13 12:21:49 +00:00
|
|
|
struct rte_swx_pipeline *p[THREAD_PIPELINES_MAX];
|
2019-06-25 11:12:58 +00:00
|
|
|
uint32_t n_pipelines;
|
|
|
|
|
|
|
|
struct rte_ring *msgq_req;
|
|
|
|
struct rte_ring *msgq_rsp;
|
|
|
|
uint64_t timer_period; /* Measured in CPU cycles. */
|
|
|
|
uint64_t time_next;
|
|
|
|
uint64_t iter;
|
|
|
|
} __rte_cache_aligned;
|
|
|
|
|
2018-05-15 09:49:22 +00:00
|
|
|
/**
|
|
|
|
* PMD Internals
|
|
|
|
*/
|
|
|
|
struct pmd_internals {
|
|
|
|
/** Params */
|
|
|
|
struct pmd_params params;
|
|
|
|
|
2019-06-25 11:12:58 +00:00
|
|
|
struct softnic_conn *conn;
|
|
|
|
struct softnic_mempool_list mempool_list;
|
|
|
|
struct softnic_swq_list swq_list;
|
|
|
|
struct pipeline_list pipeline_list;
|
|
|
|
struct softnic_thread thread[RTE_MAX_LCORE];
|
|
|
|
struct softnic_thread_data thread_data[RTE_MAX_LCORE];
|
2019-01-18 09:27:45 +00:00
|
|
|
};
|
2018-12-06 14:17:51 +00:00
|
|
|
|
2019-06-25 11:12:58 +00:00
|
|
|
static inline struct rte_eth_dev *
|
|
|
|
ETHDEV(struct pmd_internals *softnic)
|
|
|
|
{
|
|
|
|
uint16_t port_id;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
if (softnic == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
status = rte_eth_dev_get_port_by_name(softnic->params.name, &port_id);
|
|
|
|
if (status)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return &rte_eth_devices[port_id];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MEMPOOL
|
|
|
|
*/
|
2018-12-06 14:17:51 +00:00
|
|
|
int
|
2019-06-25 11:12:58 +00:00
|
|
|
softnic_mempool_init(struct pmd_internals *p);
|
|
|
|
|
|
|
|
void
|
|
|
|
softnic_mempool_free(struct pmd_internals *p);
|
|
|
|
|
|
|
|
struct softnic_mempool *
|
|
|
|
softnic_mempool_find(struct pmd_internals *p,
|
|
|
|
const char *name);
|
|
|
|
|
|
|
|
struct softnic_mempool *
|
|
|
|
softnic_mempool_create(struct pmd_internals *p,
|
|
|
|
const char *name,
|
|
|
|
struct softnic_mempool_params *params);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SWQ
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
softnic_swq_init(struct pmd_internals *p);
|
|
|
|
|
|
|
|
void
|
|
|
|
softnic_swq_free(struct pmd_internals *p);
|
|
|
|
|
|
|
|
void
|
|
|
|
softnic_softnic_swq_free_keep_rxq_txq(struct pmd_internals *p);
|
|
|
|
|
|
|
|
struct softnic_swq *
|
|
|
|
softnic_swq_find(struct pmd_internals *p,
|
|
|
|
const char *name);
|
|
|
|
|
|
|
|
struct softnic_swq *
|
|
|
|
softnic_swq_create(struct pmd_internals *p,
|
|
|
|
const char *name,
|
|
|
|
struct softnic_swq_params *params);
|
2018-05-15 09:49:22 +00:00
|
|
|
|
2019-06-25 11:12:58 +00:00
|
|
|
/**
|
|
|
|
* Pipeline
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
softnic_pipeline_init(struct pmd_internals *p);
|
|
|
|
|
|
|
|
void
|
|
|
|
softnic_pipeline_free(struct pmd_internals *p);
|
|
|
|
|
|
|
|
void
|
|
|
|
softnic_pipeline_disable_all(struct pmd_internals *p);
|
|
|
|
|
2020-06-18 16:55:50 +00:00
|
|
|
uint32_t
|
|
|
|
softnic_pipeline_thread_count(struct pmd_internals *p, uint32_t thread_id);
|
|
|
|
|
2019-06-25 11:12:58 +00:00
|
|
|
struct pipeline *
|
|
|
|
softnic_pipeline_find(struct pmd_internals *p, const char *name);
|
|
|
|
|
|
|
|
struct pipeline *
|
|
|
|
softnic_pipeline_create(struct pmd_internals *p,
|
|
|
|
const char *name,
|
2023-09-13 12:21:49 +00:00
|
|
|
const char *lib_file_name,
|
|
|
|
const char *iospec_file_name,
|
|
|
|
int numa_node);
|
2019-06-25 11:12:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Thread
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
softnic_thread_init(struct pmd_internals *p);
|
|
|
|
|
|
|
|
void
|
|
|
|
softnic_thread_free(struct pmd_internals *p);
|
|
|
|
|
|
|
|
int
|
|
|
|
softnic_thread_pipeline_enable(struct pmd_internals *p,
|
|
|
|
uint32_t thread_id,
|
2023-09-13 12:21:49 +00:00
|
|
|
struct pipeline *pipeline);
|
2019-06-25 11:12:58 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
softnic_thread_pipeline_disable(struct pmd_internals *p,
|
|
|
|
uint32_t thread_id,
|
2023-09-13 12:21:49 +00:00
|
|
|
struct pipeline *pipeline);
|
|
|
|
|
|
|
|
void
|
|
|
|
softnic_thread_pipeline_disable_all(struct pmd_internals *p);
|
2019-06-25 11:12:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CLI
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
softnic_cli_process(char *in,
|
|
|
|
char *out,
|
|
|
|
size_t out_size,
|
|
|
|
void *arg);
|
|
|
|
|
|
|
|
int
|
|
|
|
softnic_cli_script_process(struct pmd_internals *softnic,
|
|
|
|
const char *file_name,
|
|
|
|
size_t msg_in_len_max,
|
|
|
|
size_t msg_out_len_max);
|
|
|
|
|
2018-05-15 09:49:22 +00:00
|
|
|
#endif /* __INCLUDE_RTE_ETH_SOFTNIC_INTERNALS_H__ */
|