Commit e75dc265 authored by Louis Peens's avatar Louis Peens Committed by David S. Miller

nfp: flower: refactor action offload code slightly

Change the action related offload functions to take in flow_rule *
as input instead of flow_cls_offload * as input. The flow_rule
parts of flow_cls_offload is the only part that is used in any
case, and this is required for more conntrack offload patches
which will follow later.
Signed-off-by: default avatarLouis Peens <louis.peens@corigine.com>
Signed-off-by: default avatarYinjun Zhang <yinjun.zhang@corigine.com>
Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4b15fb18
...@@ -262,10 +262,10 @@ nfp_fl_output(struct nfp_app *app, struct nfp_fl_output *output, ...@@ -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) ...@@ -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, ...@@ -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 { ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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);
} }
......
...@@ -475,7 +475,7 @@ int nfp_flower_compile_flow_match(struct nfp_app *app, ...@@ -475,7 +475,7 @@ int nfp_flower_compile_flow_match(struct nfp_app *app,
enum nfp_flower_tun_type tun_type, enum nfp_flower_tun_type tun_type,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
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);
......
...@@ -1338,7 +1338,7 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, ...@@ -1338,7 +1338,7 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev,
if (err) if (err)
goto err_destroy_flow; goto err_destroy_flow;
err = nfp_flower_compile_action(app, flow, netdev, flow_pay, extack); err = nfp_flower_compile_action(app, rule, netdev, flow_pay, extack);
if (err) if (err)
goto err_destroy_flow; goto err_destroy_flow;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment