[dpdk-dev] [RFC] net/mlx5: add DV flow support

Ori Kam orika at mellanox.com
Wed Aug 22 12:12:49 CEST 2018


Currently the flow steering in MLX5 is done using 2 external APIs (drivers)
the verbs API to control the NIC flows and TC API to control the ESWITCH flows.
Also in the current implementation some functions are called number
of times and each time with different job to do.

In order to support advance steering option Mellanox exposed a new set of
APIs to control NIC flows. Since this new API will be only supported on new
kernels or ones that are using OFED there is a need to support 2 different
NIC APIs.

This RFC address this issue by separating the MLX5 flow engine into shared
and dedicated functions for each API (driver).
It is also split the functions that have several tasks into functions 
that implementing only one task.
The call to the specific API will be done via function pointers.


mlx5_flow.h:
.......
struct mlx5_ind_table {
                LIST_ENTRY next;
                rte_atomic32_t refcnt;
                void *ind_table; /* Pointer to the ind table created by the driver*/
                uint32_t queues_n; /* Number of queues in list */
                uint16_t queues[]; /* Queue list */
}

struct mlx5_hrxq {
                LIST_ENTERY next;
                rte_atomic32_t refcnt;
                struct mlx5_ind_table *ind_table;
                union {
                                struct mlx5_ibv_qp *qp;
                }
                uint64_t hash_fields; /* hash key length in bytes */
                uint32_t rss_key_len; /* hash key length in bytes */
                uint8_t rss_key[]; /* hash key */
}

struct mlx5_flow_verbs {
                unsigned int size; /* Size of the attr */
                struct {
                                struct ibv_flow_attr *attr;
                                uint8_t *specs;
                }
                struct ibv_flow *flow;
                struct mlx5_hrxq *hrxq;
	/**< Fields that participate in the hash. */
	uint64_t hash_fields; 
}

struct mlx5_flow_dv {
 	uint64_t hash_fields; /**< Fields that participate in the hash. */
        	struct mlx5_hrxq *hrxq; /**< Hash Rx queues. */
        	/* Flow DV api: */
        	struct mlx5_flow_matcher *matcher; /**< Cache to matcher. */
        	size_t size; /**< size of match value. */
        	uint32_t match_value[MLX5_ST_SZ_DW(fte_match_param)];
        	/**< Matcher value. */
        	struct ibv_flow *flow; /**< Installed flow. */
        	/**< Action list. */
        	struct mlx5dv_flow_action_attr actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS];
        	int actions_n; /**< number of actions. */
};

/* Holds data for one rule */
struct mlx5_flow {
                LIST_ENTREY() next;
                union {
                                struct mlx5_flow_verbs verbs;
                                struct mlx5_flow_dv dv;
                }
}

struct rte_flow {
                TAILQ_ENTERY() next;
                uint8_t flow_type; /* verbs / tc / dv */
                LIST_HEAD(mlx5_flow) flow;
                struct flow_counter *counter;
}


typedef int (*validate_t)(struct priv *priv,
                                                struct rte_flow_attr *attr,
                                                struct rte_flow_item items[],
                                                struct rte_flow_action actions[],
                                                struct rte_flow_error *error);


typedef mlx5_flow * (*prepare_t)(struct rte_flow_attr *attr,
                                                struct rte_flow_items items[],
                                                struct rte_flow_actions actions[],
                                                struct rte_flow_error *error);

typedef int (*translate_t)(struct priv *priv,
                                                                struct mlx5_flow *flow,
                                                                struct rte_flow_attr *attr,
                                                                struct rte_flow_item *items[],
                                                                struct rte_flow_action actions[],
                                                                struct rte_flow_error *error);
/* insert the rule to the nic */
typedef int (*apply_t)(struct priv *priv,
                                                struct mlx5_flow *flow);

/* remove the rule from the nic */
typedef int (*remove_t)(struct priv *priv,
                                                struct mlx5_flow *flow);

/* delete the rule from memory */
typedef int (*delete_t)(struct priv *priv,
                                                struct mlx5_flow *flow);


struct driver_ops {
                validate_t validate;
                prepare_t prepare;
                translate_t translate;
                apply_t apply;
                remove_t remove;
                delete_t delete;
}
.......


Signed-off-by: Ori Kam <orika at mellanox.com>


More information about the dev mailing list