From: Danylo Vodopianov <dvo-...@napatech.com>

add flow aging API to the ops structure

Signed-off-by: Danylo Vodopianov <dvo-...@napatech.com>
---
 drivers/net/ntnic/nthw/flow_api/flow_api.c    | 71 +++++++++++++++
 drivers/net/ntnic/ntnic_filter/ntnic_filter.c | 88 +++++++++++++++++++
 drivers/net/ntnic/ntnic_mod_reg.h             | 21 +++++
 3 files changed, 180 insertions(+)

diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c 
b/drivers/net/ntnic/nthw/flow_api/flow_api.c
index efe9a1a3b9..b101a9462e 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_api.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c
@@ -1048,6 +1048,70 @@ int flow_nic_set_hasher_fields(struct flow_nic_dev 
*ndev, int hsh_idx,
        return profile_inline_ops->flow_nic_set_hasher_fields_inline(ndev, 
hsh_idx, rss_conf);
 }
 
+static int flow_get_aged_flows(struct flow_eth_dev *dev,
+       uint16_t caller_id,
+       void **context,
+       uint32_t nb_contexts,
+       struct rte_flow_error *error)
+{
+       const struct profile_inline_ops *profile_inline_ops = 
get_profile_inline_ops();
+
+       if (profile_inline_ops == NULL) {
+               NT_LOG_DBGX(ERR, FILTER, "profile_inline_ops uninitialized");
+               return -1;
+       }
+
+       if (nb_contexts > 0 && !context) {
+               error->type = RTE_FLOW_ERROR_TYPE_UNSPECIFIED;
+               error->message = "rte_flow_get_aged_flows - empty context";
+               return -1;
+       }
+
+       return profile_inline_ops->flow_get_aged_flows_profile_inline(dev, 
caller_id, context,
+                       nb_contexts, error);
+}
+
+static int flow_info_get(struct flow_eth_dev *dev, uint8_t caller_id,
+       struct rte_flow_port_info *port_info, struct rte_flow_queue_info 
*queue_info,
+       struct rte_flow_error *error)
+{
+       (void)dev;
+       (void)caller_id;
+       (void)port_info;
+       (void)queue_info;
+       (void)error;
+
+       const struct profile_inline_ops *profile_inline_ops = 
get_profile_inline_ops();
+
+       if (profile_inline_ops == NULL) {
+               NT_LOG_DBGX(ERR, FILTER, "profile_inline module uninitialized");
+               return -1;
+       }
+
+       return 0;
+}
+
+static int flow_configure(struct flow_eth_dev *dev, uint8_t caller_id,
+       const struct rte_flow_port_attr *port_attr, uint16_t nb_queue,
+       const struct rte_flow_queue_attr *queue_attr[], struct rte_flow_error 
*error)
+{
+       (void)dev;
+       (void)caller_id;
+       (void)port_attr;
+       (void)queue_attr;
+       (void)nb_queue;
+       (void)error;
+
+       const struct profile_inline_ops *profile_inline_ops = 
get_profile_inline_ops();
+
+       if (profile_inline_ops == NULL) {
+               NT_LOG_DBGX(ERR, FILTER, "profile_inline module uninitialized");
+               return -1;
+       }
+
+       return 0;
+}
+
 int flow_get_flm_stats(struct flow_nic_dev *ndev, uint64_t *data, uint64_t 
size)
 {
        const struct profile_inline_ops *profile_inline_ops = 
get_profile_inline_ops();
@@ -1076,6 +1140,13 @@ static const struct flow_filter_ops ops = {
        .flow_flush = flow_flush,
        .flow_dev_dump = flow_dev_dump,
        .flow_get_flm_stats = flow_get_flm_stats,
+       .flow_get_aged_flows = flow_get_aged_flows,
+
+       /*
+        * NT Flow asynchronous operations API
+        */
+       .flow_info_get = flow_info_get,
+       .flow_configure = flow_configure,
 
        /*
         * Other
diff --git a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c 
b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
index e2fce02afa..9f8670b32d 100644
--- a/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
+++ b/drivers/net/ntnic/ntnic_filter/ntnic_filter.c
@@ -718,6 +718,91 @@ static int eth_flow_dev_dump(struct rte_eth_dev *eth_dev,
        return res;
 }
 
+static int eth_flow_get_aged_flows(struct rte_eth_dev *eth_dev,
+       void **context,
+       uint32_t nb_contexts,
+       struct rte_flow_error *error)
+{
+       const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops();
+
+       if (flow_filter_ops == NULL) {
+               NT_LOG_DBGX(ERR, NTNIC, "flow_filter module uninitialized");
+               return -1;
+       }
+
+       struct pmd_internals *internals = (struct pmd_internals 
*)eth_dev->data->dev_private;
+
+       static struct rte_flow_error flow_error = {
+               .type = RTE_FLOW_ERROR_TYPE_NONE,
+               .message = "none" };
+
+       uint16_t caller_id = get_caller_id(eth_dev->data->port_id);
+
+       int res = flow_filter_ops->flow_get_aged_flows(internals->flw_dev, 
caller_id, context,
+                       nb_contexts, &flow_error);
+
+       convert_error(error, &flow_error);
+       return res;
+}
+
+/*
+ * NT Flow asynchronous operations API
+ */
+
+static int eth_flow_info_get(struct rte_eth_dev *dev, struct 
rte_flow_port_info *port_info,
+       struct rte_flow_queue_info *queue_info, struct rte_flow_error *error)
+{
+       const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops();
+
+       if (flow_filter_ops == NULL) {
+               NT_LOG_DBGX(ERR, FILTER, "flow_filter module uninitialized");
+               return -1;
+       }
+
+       struct pmd_internals *internals = dev->data->dev_private;
+
+       static struct rte_flow_error flow_error = {
+               .type = RTE_FLOW_ERROR_TYPE_NONE,
+               .message = "none" };
+
+       int res = flow_filter_ops->flow_info_get(internals->flw_dev,
+                       get_caller_id(dev->data->port_id),
+                       (struct rte_flow_port_info *)port_info,
+                       (struct rte_flow_queue_info *)queue_info,
+                       &flow_error);
+
+       convert_error(error, &flow_error);
+       return res;
+}
+
+static int eth_flow_configure(struct rte_eth_dev *dev, const struct 
rte_flow_port_attr *port_attr,
+       uint16_t nb_queue, const struct rte_flow_queue_attr *queue_attr[],
+       struct rte_flow_error *error)
+{
+       const struct flow_filter_ops *flow_filter_ops = get_flow_filter_ops();
+
+       if (flow_filter_ops == NULL) {
+               NT_LOG_DBGX(ERR, FILTER, "flow_filter module uninitialized");
+               return -1;
+       }
+
+       struct pmd_internals *internals = dev->data->dev_private;
+
+       static struct rte_flow_error flow_error = {
+               .type = RTE_FLOW_ERROR_TYPE_NONE,
+               .message = "none" };
+
+       int res = flow_filter_ops->flow_configure(internals->flw_dev,
+                       get_caller_id(dev->data->port_id),
+                       (const struct rte_flow_port_attr *)port_attr,
+                       nb_queue,
+                       (const struct rte_flow_queue_attr **)queue_attr,
+                       &flow_error);
+
+       convert_error(error, &flow_error);
+       return res;
+}
+
 static int poll_statistics(struct pmd_internals *internals)
 {
        int flow;
@@ -844,6 +929,9 @@ static const struct rte_flow_ops dev_flow_ops = {
        .destroy = eth_flow_destroy,
        .flush = eth_flow_flush,
        .dev_dump = eth_flow_dev_dump,
+       .get_aged_flows = eth_flow_get_aged_flows,
+       .info_get = eth_flow_info_get,
+       .configure = eth_flow_configure,
 };
 
 void dev_flow_init(void)
diff --git a/drivers/net/ntnic/ntnic_mod_reg.h 
b/drivers/net/ntnic/ntnic_mod_reg.h
index 7325bd1ea8..52f197e873 100644
--- a/drivers/net/ntnic/ntnic_mod_reg.h
+++ b/drivers/net/ntnic/ntnic_mod_reg.h
@@ -286,6 +286,12 @@ struct profile_inline_ops {
                FILE *file,
                struct rte_flow_error *error);
 
+       int (*flow_get_aged_flows_profile_inline)(struct flow_eth_dev *dev,
+               uint16_t caller_id,
+               void **context,
+               uint32_t nb_contexts,
+               struct rte_flow_error *error);
+
        int (*flow_nic_set_hasher_fields_inline)(struct flow_nic_dev *ndev,
                int hsh_idx,
                struct nt_eth_rss_conf rss_conf);
@@ -355,6 +361,21 @@ struct flow_filter_ops {
        int (*flow_nic_set_hasher_fields)(struct flow_nic_dev *ndev, int 
hsh_idx,
                struct nt_eth_rss_conf rss_conf);
        int (*hw_mod_hsh_rcp_flush)(struct flow_api_backend_s *be, int 
start_idx, int count);
+
+       int (*flow_get_aged_flows)(struct flow_eth_dev *dev,
+               uint16_t caller_id,
+               void **context,
+               uint32_t nb_contexts,
+               struct rte_flow_error *error);
+
+       int (*flow_info_get)(struct flow_eth_dev *dev, uint8_t caller_id,
+               struct rte_flow_port_info *port_info, struct 
rte_flow_queue_info *queue_info,
+               struct rte_flow_error *error);
+
+       int (*flow_configure)(struct flow_eth_dev *dev, uint8_t caller_id,
+               const struct rte_flow_port_attr *port_attr, uint16_t nb_queue,
+               const struct rte_flow_queue_attr *queue_attr[],
+               struct rte_flow_error *error);
 };
 
 void register_dev_flow_ops(const struct rte_flow_ops *ops);
-- 
2.45.0

Reply via email to