mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-11 13:04:03 +08:00
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: Louis Peens <louis.peens@corigine.com> Signed-off-by: Yinjun Zhang <yinjun.zhang@corigine.com> Signed-off-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
4b15fb1876
commit
e75dc26507
@ -262,10 +262,10 @@ nfp_fl_output(struct nfp_app *app, struct nfp_fl_output *output,
|
||||
}
|
||||
|
||||
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;
|
||||
int num_act = flow->rule->action.num_entries;
|
||||
struct flow_action_entry *act = rule->action.entries;
|
||||
int num_act = rule->action.num_entries;
|
||||
int act_idx;
|
||||
|
||||
/* 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
|
||||
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 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
|
||||
* 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;
|
||||
|
||||
switch (tun->key.tp_dst) {
|
||||
@ -788,11 +788,10 @@ struct nfp_flower_pedit_acts {
|
||||
};
|
||||
|
||||
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,
|
||||
u32 *csum_updated)
|
||||
{
|
||||
struct flow_rule *rule = flow_cls_offload_flow_rule(flow);
|
||||
size_t act_size = 0;
|
||||
u8 ip_proto = 0;
|
||||
|
||||
@ -890,7 +889,7 @@ nfp_fl_commit_mangle(struct flow_cls_offload *flow, char *nfp_action,
|
||||
|
||||
static int
|
||||
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,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
@ -977,7 +976,7 @@ nfp_flower_output_action(struct nfp_app *app,
|
||||
|
||||
static int
|
||||
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 net_device *netdev,
|
||||
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: {
|
||||
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) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported tunnel type in action list");
|
||||
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. */
|
||||
return 0;
|
||||
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))
|
||||
return -EOPNOTSUPP;
|
||||
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,
|
||||
struct flow_cls_offload *flow,
|
||||
struct flow_rule *rule,
|
||||
struct net_device *netdev,
|
||||
struct nfp_fl_payload *nfp_flow,
|
||||
struct netlink_ext_ack *extack)
|
||||
@ -1207,7 +1206,7 @@ int nfp_flower_compile_action(struct nfp_app *app,
|
||||
bool pkt_host = false;
|
||||
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))
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
@ -1219,18 +1218,18 @@ int nfp_flower_compile_action(struct nfp_app *app,
|
||||
tun_out_cnt = 0;
|
||||
out_cnt = 0;
|
||||
|
||||
flow_action_for_each(i, act, &flow->rule->action) {
|
||||
if (nfp_fl_check_mangle_start(&flow->rule->action, i))
|
||||
flow_action_for_each(i, act, &rule->action) {
|
||||
if (nfp_fl_check_mangle_start(&rule->action, i))
|
||||
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,
|
||||
&out_cnt, &csum_updated,
|
||||
&set_act, &pkt_host, extack, i);
|
||||
if (err)
|
||||
return err;
|
||||
act_cnt++;
|
||||
if (nfp_fl_check_mangle_end(&flow->rule->action, i))
|
||||
nfp_fl_commit_mangle(flow,
|
||||
if (nfp_fl_check_mangle_end(&rule->action, i))
|
||||
nfp_fl_commit_mangle(rule,
|
||||
&nfp_flow->action_data[act_len],
|
||||
&act_len, &set_act, &csum_updated);
|
||||
}
|
||||
|
@ -475,7 +475,7 @@ int nfp_flower_compile_flow_match(struct nfp_app *app,
|
||||
enum nfp_flower_tun_type tun_type,
|
||||
struct netlink_ext_ack *extack);
|
||||
int nfp_flower_compile_action(struct nfp_app *app,
|
||||
struct flow_cls_offload *flow,
|
||||
struct flow_rule *rule,
|
||||
struct net_device *netdev,
|
||||
struct nfp_fl_payload *nfp_flow,
|
||||
struct netlink_ext_ack *extack);
|
||||
|
@ -1338,7 +1338,7 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev,
|
||||
if (err)
|
||||
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)
|
||||
goto err_destroy_flow;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user