Commit bef6e97d authored by Pieter Jansen van Vuuren's avatar Pieter Jansen van Vuuren Committed by David S. Miller

nfp: flower: extend extack messaging for flower match and actions

Use extack messages in flower offload when compiling match and actions
messages that will configure hardware.
Signed-off-by: default avatarPieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 14179c4b
...@@ -156,7 +156,8 @@ nfp_fl_lag_find_group_for_master_with_lag(struct nfp_fl_lag *lag, ...@@ -156,7 +156,8 @@ nfp_fl_lag_find_group_for_master_with_lag(struct nfp_fl_lag *lag,
int nfp_flower_lag_populate_pre_action(struct nfp_app *app, int nfp_flower_lag_populate_pre_action(struct nfp_app *app,
struct net_device *master, struct net_device *master,
struct nfp_fl_pre_lag *pre_act) struct nfp_fl_pre_lag *pre_act,
struct netlink_ext_ack *extack)
{ {
struct nfp_flower_priv *priv = app->priv; struct nfp_flower_priv *priv = app->priv;
struct nfp_fl_lag_group *group = NULL; struct nfp_fl_lag_group *group = NULL;
...@@ -167,6 +168,7 @@ int nfp_flower_lag_populate_pre_action(struct nfp_app *app, ...@@ -167,6 +168,7 @@ int nfp_flower_lag_populate_pre_action(struct nfp_app *app,
master); master);
if (!group) { if (!group) {
mutex_unlock(&priv->nfp_lag.lock); mutex_unlock(&priv->nfp_lag.lock);
NL_SET_ERR_MSG_MOD(extack, "invalid entry: group does not exist for LAG action");
return -ENOENT; return -ENOENT;
} }
......
...@@ -347,15 +347,18 @@ int nfp_flower_compile_flow_match(struct nfp_app *app, ...@@ -347,15 +347,18 @@ int nfp_flower_compile_flow_match(struct nfp_app *app,
struct nfp_fl_key_ls *key_ls, struct nfp_fl_key_ls *key_ls,
struct net_device *netdev, struct net_device *netdev,
struct nfp_fl_payload *nfp_flow, struct nfp_fl_payload *nfp_flow,
enum nfp_flower_tun_type tun_type); enum nfp_flower_tun_type tun_type,
struct netlink_ext_ack *extack);
int nfp_flower_compile_action(struct nfp_app *app, int nfp_flower_compile_action(struct nfp_app *app,
struct tc_cls_flower_offload *flow, struct tc_cls_flower_offload *flow,
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);
int nfp_compile_flow_metadata(struct nfp_app *app, int nfp_compile_flow_metadata(struct nfp_app *app,
struct tc_cls_flower_offload *flow, struct tc_cls_flower_offload *flow,
struct nfp_fl_payload *nfp_flow, struct nfp_fl_payload *nfp_flow,
struct net_device *netdev); struct net_device *netdev,
struct netlink_ext_ack *extack);
void __nfp_modify_flow_metadata(struct nfp_flower_priv *priv, void __nfp_modify_flow_metadata(struct nfp_flower_priv *priv,
struct nfp_fl_payload *nfp_flow); struct nfp_fl_payload *nfp_flow);
int nfp_modify_flow_metadata(struct nfp_app *app, int nfp_modify_flow_metadata(struct nfp_app *app,
...@@ -389,7 +392,8 @@ int nfp_flower_lag_netdev_event(struct nfp_flower_priv *priv, ...@@ -389,7 +392,8 @@ int nfp_flower_lag_netdev_event(struct nfp_flower_priv *priv,
bool nfp_flower_lag_unprocessed_msg(struct nfp_app *app, struct sk_buff *skb); bool nfp_flower_lag_unprocessed_msg(struct nfp_app *app, struct sk_buff *skb);
int nfp_flower_lag_populate_pre_action(struct nfp_app *app, int nfp_flower_lag_populate_pre_action(struct nfp_app *app,
struct net_device *master, struct net_device *master,
struct nfp_fl_pre_lag *pre_act); struct nfp_fl_pre_lag *pre_act,
struct netlink_ext_ack *extack);
int nfp_flower_lag_get_output_id(struct nfp_app *app, int nfp_flower_lag_get_output_id(struct nfp_app *app,
struct net_device *master); struct net_device *master);
void nfp_flower_qos_init(struct nfp_app *app); void nfp_flower_qos_init(struct nfp_app *app);
......
...@@ -54,7 +54,8 @@ nfp_flower_compile_ext_meta(struct nfp_flower_ext_meta *frame, u32 key_ext) ...@@ -54,7 +54,8 @@ nfp_flower_compile_ext_meta(struct nfp_flower_ext_meta *frame, u32 key_ext)
static int static int
nfp_flower_compile_port(struct nfp_flower_in_port *frame, u32 cmsg_port, nfp_flower_compile_port(struct nfp_flower_in_port *frame, u32 cmsg_port,
bool mask_version, enum nfp_flower_tun_type tun_type) bool mask_version, enum nfp_flower_tun_type tun_type,
struct netlink_ext_ack *extack)
{ {
if (mask_version) { if (mask_version) {
frame->in_port = cpu_to_be32(~0); frame->in_port = cpu_to_be32(~0);
...@@ -64,8 +65,10 @@ nfp_flower_compile_port(struct nfp_flower_in_port *frame, u32 cmsg_port, ...@@ -64,8 +65,10 @@ nfp_flower_compile_port(struct nfp_flower_in_port *frame, u32 cmsg_port,
if (tun_type) { if (tun_type) {
frame->in_port = cpu_to_be32(NFP_FL_PORT_TYPE_TUN | tun_type); frame->in_port = cpu_to_be32(NFP_FL_PORT_TYPE_TUN | tun_type);
} else { } else {
if (!cmsg_port) if (!cmsg_port) {
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: invalid ingress interface for match offload");
return -EOPNOTSUPP; return -EOPNOTSUPP;
}
frame->in_port = cpu_to_be32(cmsg_port); frame->in_port = cpu_to_be32(cmsg_port);
} }
...@@ -324,7 +327,8 @@ int nfp_flower_compile_flow_match(struct nfp_app *app, ...@@ -324,7 +327,8 @@ int nfp_flower_compile_flow_match(struct nfp_app *app,
struct nfp_fl_key_ls *key_ls, struct nfp_fl_key_ls *key_ls,
struct net_device *netdev, struct net_device *netdev,
struct nfp_fl_payload *nfp_flow, struct nfp_fl_payload *nfp_flow,
enum nfp_flower_tun_type tun_type) enum nfp_flower_tun_type tun_type,
struct netlink_ext_ack *extack)
{ {
u32 port_id; u32 port_id;
int err; int err;
...@@ -357,13 +361,13 @@ int nfp_flower_compile_flow_match(struct nfp_app *app, ...@@ -357,13 +361,13 @@ int nfp_flower_compile_flow_match(struct nfp_app *app,
/* Populate Exact Port data. */ /* Populate Exact Port data. */
err = nfp_flower_compile_port((struct nfp_flower_in_port *)ext, err = nfp_flower_compile_port((struct nfp_flower_in_port *)ext,
port_id, false, tun_type); port_id, false, tun_type, extack);
if (err) if (err)
return err; return err;
/* Populate Mask Port Data. */ /* Populate Mask Port Data. */
err = nfp_flower_compile_port((struct nfp_flower_in_port *)msk, err = nfp_flower_compile_port((struct nfp_flower_in_port *)msk,
port_id, true, tun_type); port_id, true, tun_type, extack);
if (err) if (err)
return err; return err;
......
...@@ -292,7 +292,8 @@ nfp_check_mask_remove(struct nfp_app *app, char *mask_data, u32 mask_len, ...@@ -292,7 +292,8 @@ nfp_check_mask_remove(struct nfp_app *app, char *mask_data, u32 mask_len,
int nfp_compile_flow_metadata(struct nfp_app *app, int nfp_compile_flow_metadata(struct nfp_app *app,
struct tc_cls_flower_offload *flow, struct tc_cls_flower_offload *flow,
struct nfp_fl_payload *nfp_flow, struct nfp_fl_payload *nfp_flow,
struct net_device *netdev) struct net_device *netdev,
struct netlink_ext_ack *extack)
{ {
struct nfp_fl_stats_ctx_to_flow *ctx_entry; struct nfp_fl_stats_ctx_to_flow *ctx_entry;
struct nfp_flower_priv *priv = app->priv; struct nfp_flower_priv *priv = app->priv;
...@@ -302,8 +303,10 @@ int nfp_compile_flow_metadata(struct nfp_app *app, ...@@ -302,8 +303,10 @@ int nfp_compile_flow_metadata(struct nfp_app *app,
int err; int err;
err = nfp_get_stats_entry(app, &stats_cxt); err = nfp_get_stats_entry(app, &stats_cxt);
if (err) if (err) {
NL_SET_ERR_MSG_MOD(extack, "invalid entry: cannot allocate new stats context");
return err; return err;
}
nfp_flow->meta.host_ctx_id = cpu_to_be32(stats_cxt); nfp_flow->meta.host_ctx_id = cpu_to_be32(stats_cxt);
nfp_flow->meta.host_cookie = cpu_to_be64(flow->cookie); nfp_flow->meta.host_cookie = cpu_to_be64(flow->cookie);
...@@ -328,6 +331,12 @@ int nfp_compile_flow_metadata(struct nfp_app *app, ...@@ -328,6 +331,12 @@ int nfp_compile_flow_metadata(struct nfp_app *app,
if (!nfp_check_mask_add(app, nfp_flow->mask_data, if (!nfp_check_mask_add(app, nfp_flow->mask_data,
nfp_flow->meta.mask_len, nfp_flow->meta.mask_len,
&nfp_flow->meta.flags, &new_mask_id)) { &nfp_flow->meta.flags, &new_mask_id)) {
NL_SET_ERR_MSG_MOD(extack, "invalid entry: cannot allocate a new mask id");
if (nfp_release_stats_entry(app, stats_cxt)) {
NL_SET_ERR_MSG_MOD(extack, "invalid entry: cannot release stats context");
err = -EINVAL;
goto err_remove_rhash;
}
err = -ENOENT; err = -ENOENT;
goto err_remove_rhash; goto err_remove_rhash;
} }
...@@ -343,6 +352,21 @@ int nfp_compile_flow_metadata(struct nfp_app *app, ...@@ -343,6 +352,21 @@ int nfp_compile_flow_metadata(struct nfp_app *app,
check_entry = nfp_flower_search_fl_table(app, flow->cookie, netdev); check_entry = nfp_flower_search_fl_table(app, flow->cookie, netdev);
if (check_entry) { if (check_entry) {
NL_SET_ERR_MSG_MOD(extack, "invalid entry: cannot offload duplicate flow entry");
if (nfp_release_stats_entry(app, stats_cxt)) {
NL_SET_ERR_MSG_MOD(extack, "invalid entry: cannot release stats context");
err = -EINVAL;
goto err_remove_mask;
}
if (!nfp_check_mask_remove(app, nfp_flow->mask_data,
nfp_flow->meta.mask_len,
NULL, &new_mask_id)) {
NL_SET_ERR_MSG_MOD(extack, "invalid entry: cannot release mask id");
err = -EINVAL;
goto err_remove_mask;
}
err = -EEXIST; err = -EEXIST;
goto err_remove_mask; goto err_remove_mask;
} }
......
...@@ -825,12 +825,14 @@ int nfp_flower_merge_offloaded_flows(struct nfp_app *app, ...@@ -825,12 +825,14 @@ int nfp_flower_merge_offloaded_flows(struct nfp_app *app,
{ {
struct tc_cls_flower_offload merge_tc_off; struct tc_cls_flower_offload merge_tc_off;
struct nfp_flower_priv *priv = app->priv; struct nfp_flower_priv *priv = app->priv;
struct netlink_ext_ack *extack = NULL;
struct nfp_fl_payload *merge_flow; struct nfp_fl_payload *merge_flow;
struct nfp_fl_key_ls merge_key_ls; struct nfp_fl_key_ls merge_key_ls;
int err; int err;
ASSERT_RTNL(); ASSERT_RTNL();
extack = merge_tc_off.common.extack;
if (sub_flow1 == sub_flow2 || if (sub_flow1 == sub_flow2 ||
nfp_flower_is_merge_flow(sub_flow1) || nfp_flower_is_merge_flow(sub_flow1) ||
nfp_flower_is_merge_flow(sub_flow2)) nfp_flower_is_merge_flow(sub_flow2))
...@@ -868,7 +870,7 @@ int nfp_flower_merge_offloaded_flows(struct nfp_app *app, ...@@ -868,7 +870,7 @@ int nfp_flower_merge_offloaded_flows(struct nfp_app *app,
merge_tc_off.cookie = merge_flow->tc_flower_cookie; merge_tc_off.cookie = merge_flow->tc_flower_cookie;
err = nfp_compile_flow_metadata(app, &merge_tc_off, merge_flow, err = nfp_compile_flow_metadata(app, &merge_tc_off, merge_flow,
merge_flow->ingress_dev); merge_flow->ingress_dev, extack);
if (err) if (err)
goto err_unlink_sub_flow2; goto err_unlink_sub_flow2;
...@@ -947,15 +949,15 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, ...@@ -947,15 +949,15 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev,
} }
err = nfp_flower_compile_flow_match(app, flow, key_layer, netdev, err = nfp_flower_compile_flow_match(app, flow, key_layer, netdev,
flow_pay, tun_type); flow_pay, tun_type, extack);
if (err) if (err)
goto err_destroy_flow; goto err_destroy_flow;
err = nfp_flower_compile_action(app, flow, netdev, flow_pay); err = nfp_flower_compile_action(app, flow, netdev, flow_pay, extack);
if (err) if (err)
goto err_destroy_flow; goto err_destroy_flow;
err = nfp_compile_flow_metadata(app, flow, flow_pay, netdev); err = nfp_compile_flow_metadata(app, flow, flow_pay, netdev, 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