Commit 552a2a3f authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'nfp-flower-ct-offload'



Simon Horman says:

====================
nfp: flower: conntrack offload

Louis Peens says:

This series takes the preparation from previous two series
and finally creates the structures and control messages
to offload the conntrack flows to the card. First we
do a bit of refactoring in the existing functions
to make them re-usable for the conntrack implementation,
after which the control messages are compiled and
transmitted to the card. Lastly we add stats handling
for the conntrack flows.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 802a76af 40c10bd9
Loading
Loading
Loading
Loading
+17 −18
Original line number Original line Diff line number Diff line
@@ -262,10 +262,10 @@ nfp_fl_output(struct nfp_app *app, struct nfp_fl_output *output,
}
}


static bool
static bool
nfp_flower_tun_is_gre(struct flow_cls_offload *flow, int start_idx)
nfp_flower_tun_is_gre(struct flow_rule *rule, int start_idx)
{
{
	struct flow_action_entry *act = flow->rule->action.entries;
	struct flow_action_entry *act = rule->action.entries;
	int num_act = flow->rule->action.num_entries;
	int num_act = rule->action.num_entries;
	int act_idx;
	int act_idx;


	/* Preparse action list for next mirred or redirect action */
	/* Preparse action list for next mirred or redirect action */
@@ -279,7 +279,7 @@ nfp_flower_tun_is_gre(struct flow_cls_offload *flow, int start_idx)


static enum nfp_flower_tun_type
static enum nfp_flower_tun_type
nfp_fl_get_tun_from_act(struct nfp_app *app,
nfp_fl_get_tun_from_act(struct nfp_app *app,
			struct flow_cls_offload *flow,
			struct flow_rule *rule,
			const struct flow_action_entry *act, int act_idx)
			const struct flow_action_entry *act, int act_idx)
{
{
	const struct ip_tunnel_info *tun = act->tunnel;
	const struct ip_tunnel_info *tun = act->tunnel;
@@ -288,7 +288,7 @@ nfp_fl_get_tun_from_act(struct nfp_app *app,
	/* Determine the tunnel type based on the egress netdev
	/* Determine the tunnel type based on the egress netdev
	 * in the mirred action for tunnels without l4.
	 * in the mirred action for tunnels without l4.
	 */
	 */
	if (nfp_flower_tun_is_gre(flow, act_idx))
	if (nfp_flower_tun_is_gre(rule, act_idx))
		return NFP_FL_TUNNEL_GRE;
		return NFP_FL_TUNNEL_GRE;


	switch (tun->key.tp_dst) {
	switch (tun->key.tp_dst) {
@@ -788,11 +788,10 @@ struct nfp_flower_pedit_acts {
};
};


static int
static int
nfp_fl_commit_mangle(struct flow_cls_offload *flow, char *nfp_action,
nfp_fl_commit_mangle(struct flow_rule *rule, char *nfp_action,
		     int *a_len, struct nfp_flower_pedit_acts *set_act,
		     int *a_len, struct nfp_flower_pedit_acts *set_act,
		     u32 *csum_updated)
		     u32 *csum_updated)
{
{
	struct flow_rule *rule = flow_cls_offload_flow_rule(flow);
	size_t act_size = 0;
	size_t act_size = 0;
	u8 ip_proto = 0;
	u8 ip_proto = 0;


@@ -890,7 +889,7 @@ nfp_fl_commit_mangle(struct flow_cls_offload *flow, char *nfp_action,


static int
static int
nfp_fl_pedit(const struct flow_action_entry *act,
nfp_fl_pedit(const struct flow_action_entry *act,
	     struct flow_cls_offload *flow, char *nfp_action, int *a_len,
	     char *nfp_action, int *a_len,
	     u32 *csum_updated, struct nfp_flower_pedit_acts *set_act,
	     u32 *csum_updated, struct nfp_flower_pedit_acts *set_act,
	     struct netlink_ext_ack *extack)
	     struct netlink_ext_ack *extack)
{
{
@@ -977,7 +976,7 @@ nfp_flower_output_action(struct nfp_app *app,


static int
static int
nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
		       struct flow_cls_offload *flow,
		       struct flow_rule *rule,
		       struct nfp_fl_payload *nfp_fl, int *a_len,
		       struct nfp_fl_payload *nfp_fl, int *a_len,
		       struct net_device *netdev,
		       struct net_device *netdev,
		       enum nfp_flower_tun_type *tun_type, int *tun_out_cnt,
		       enum nfp_flower_tun_type *tun_type, int *tun_out_cnt,
@@ -1045,7 +1044,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
	case FLOW_ACTION_TUNNEL_ENCAP: {
	case FLOW_ACTION_TUNNEL_ENCAP: {
		const struct ip_tunnel_info *ip_tun = act->tunnel;
		const struct ip_tunnel_info *ip_tun = act->tunnel;


		*tun_type = nfp_fl_get_tun_from_act(app, flow, act, act_idx);
		*tun_type = nfp_fl_get_tun_from_act(app, rule, act, act_idx);
		if (*tun_type == NFP_FL_TUNNEL_NONE) {
		if (*tun_type == NFP_FL_TUNNEL_NONE) {
			NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported tunnel type in action list");
			NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported tunnel type in action list");
			return -EOPNOTSUPP;
			return -EOPNOTSUPP;
@@ -1086,7 +1085,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
		/* Tunnel decap is handled by default so accept action. */
		/* Tunnel decap is handled by default so accept action. */
		return 0;
		return 0;
	case FLOW_ACTION_MANGLE:
	case FLOW_ACTION_MANGLE:
		if (nfp_fl_pedit(act, flow, &nfp_fl->action_data[*a_len],
		if (nfp_fl_pedit(act, &nfp_fl->action_data[*a_len],
				 a_len, csum_updated, set_act, extack))
				 a_len, csum_updated, set_act, extack))
			return -EOPNOTSUPP;
			return -EOPNOTSUPP;
		break;
		break;
@@ -1195,7 +1194,7 @@ static bool nfp_fl_check_mangle_end(struct flow_action *flow_act,
}
}


int nfp_flower_compile_action(struct nfp_app *app,
int nfp_flower_compile_action(struct nfp_app *app,
			      struct flow_cls_offload *flow,
			      struct flow_rule *rule,
			      struct net_device *netdev,
			      struct net_device *netdev,
			      struct nfp_fl_payload *nfp_flow,
			      struct nfp_fl_payload *nfp_flow,
			      struct netlink_ext_ack *extack)
			      struct netlink_ext_ack *extack)
@@ -1207,7 +1206,7 @@ int nfp_flower_compile_action(struct nfp_app *app,
	bool pkt_host = false;
	bool pkt_host = false;
	u32 csum_updated = 0;
	u32 csum_updated = 0;


	if (!flow_action_hw_stats_check(&flow->rule->action, extack,
	if (!flow_action_hw_stats_check(&rule->action, extack,
					FLOW_ACTION_HW_STATS_DELAYED_BIT))
					FLOW_ACTION_HW_STATS_DELAYED_BIT))
		return -EOPNOTSUPP;
		return -EOPNOTSUPP;


@@ -1219,18 +1218,18 @@ int nfp_flower_compile_action(struct nfp_app *app,
	tun_out_cnt = 0;
	tun_out_cnt = 0;
	out_cnt = 0;
	out_cnt = 0;


	flow_action_for_each(i, act, &flow->rule->action) {
	flow_action_for_each(i, act, &rule->action) {
		if (nfp_fl_check_mangle_start(&flow->rule->action, i))
		if (nfp_fl_check_mangle_start(&rule->action, i))
			memset(&set_act, 0, sizeof(set_act));
			memset(&set_act, 0, sizeof(set_act));
		err = nfp_flower_loop_action(app, act, flow, nfp_flow, &act_len,
		err = nfp_flower_loop_action(app, act, rule, nfp_flow, &act_len,
					     netdev, &tun_type, &tun_out_cnt,
					     netdev, &tun_type, &tun_out_cnt,
					     &out_cnt, &csum_updated,
					     &out_cnt, &csum_updated,
					     &set_act, &pkt_host, extack, i);
					     &set_act, &pkt_host, extack, i);
		if (err)
		if (err)
			return err;
			return err;
		act_cnt++;
		act_cnt++;
		if (nfp_fl_check_mangle_end(&flow->rule->action, i))
		if (nfp_fl_check_mangle_end(&rule->action, i))
			nfp_fl_commit_mangle(flow,
			nfp_fl_commit_mangle(rule,
					     &nfp_flow->action_data[act_len],
					     &nfp_flow->action_data[act_len],
					     &act_len, &set_act, &csum_updated);
					     &act_len, &set_act, &csum_updated);
	}
	}
+613 −3

File changed.

Preview size limit exceeded, changes collapsed.

+26 −0
Original line number Original line Diff line number Diff line
@@ -83,6 +83,24 @@ enum ct_entry_type {
	CT_TYPE_PRE_CT,
	CT_TYPE_PRE_CT,
	CT_TYPE_NFT,
	CT_TYPE_NFT,
	CT_TYPE_POST_CT,
	CT_TYPE_POST_CT,
	_CT_TYPE_MAX,
};

enum nfp_nfp_layer_name {
	FLOW_PAY_META_TCI =    0,
	FLOW_PAY_INPORT,
	FLOW_PAY_EXT_META,
	FLOW_PAY_MAC_MPLS,
	FLOW_PAY_L4,
	FLOW_PAY_IPV4,
	FLOW_PAY_IPV6,
	FLOW_PAY_CT,
	FLOW_PAY_GRE,
	FLOW_PAY_QINQ,
	FLOW_PAY_UDP_TUN,
	FLOW_PAY_GENEVE_OPT,

	_FLOW_PAY_LAYERS_MAX
};
};


/**
/**
@@ -228,4 +246,12 @@ int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent);
 */
 */
int nfp_fl_ct_handle_nft_flow(enum tc_setup_type type, void *type_data,
int nfp_fl_ct_handle_nft_flow(enum tc_setup_type type, void *type_data,
			      void *cb_priv);
			      void *cb_priv);

/**
 * nfp_fl_ct_stats() - Handle flower stats callbacks for ct flows
 * @flow:	TC flower classifier offload structure.
 * @ct_map_ent:	ct map entry for the flow that needs deleting
 */
int nfp_fl_ct_stats(struct flow_cls_offload *flow,
		    struct nfp_fl_ct_map_entry *ct_map_ent);
#endif
#endif
+75 −4

File changed.

Preview size limit exceeded, changes collapsed.

+186 −147

File changed.

Preview size limit exceeded, changes collapsed.

Loading