|
@@ -329,25 +329,23 @@ __esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u32 vport, bool rx_rule,
|
|
|
MLX5_MATCH_OUTER_HEADERS);
|
|
|
struct mlx5_flow_rule *flow_rule = NULL;
|
|
|
struct mlx5_flow_destination dest;
|
|
|
+ struct mlx5_flow_spec *spec;
|
|
|
void *mv_misc = NULL;
|
|
|
void *mc_misc = NULL;
|
|
|
u8 *dmac_v = NULL;
|
|
|
u8 *dmac_c = NULL;
|
|
|
- u32 *match_v;
|
|
|
- u32 *match_c;
|
|
|
|
|
|
if (rx_rule)
|
|
|
match_header |= MLX5_MATCH_MISC_PARAMETERS;
|
|
|
- match_v = kzalloc(MLX5_ST_SZ_BYTES(fte_match_param), GFP_KERNEL);
|
|
|
- match_c = kzalloc(MLX5_ST_SZ_BYTES(fte_match_param), GFP_KERNEL);
|
|
|
- if (!match_v || !match_c) {
|
|
|
+
|
|
|
+ spec = mlx5_vzalloc(sizeof(*spec));
|
|
|
+ if (!spec) {
|
|
|
pr_warn("FDB: Failed to alloc match parameters\n");
|
|
|
- goto out;
|
|
|
+ return NULL;
|
|
|
}
|
|
|
-
|
|
|
- dmac_v = MLX5_ADDR_OF(fte_match_param, match_v,
|
|
|
+ dmac_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
|
|
|
outer_headers.dmac_47_16);
|
|
|
- dmac_c = MLX5_ADDR_OF(fte_match_param, match_c,
|
|
|
+ dmac_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
|
|
|
outer_headers.dmac_47_16);
|
|
|
|
|
|
if (match_header & MLX5_MATCH_OUTER_HEADERS) {
|
|
@@ -356,8 +354,10 @@ __esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u32 vport, bool rx_rule,
|
|
|
}
|
|
|
|
|
|
if (match_header & MLX5_MATCH_MISC_PARAMETERS) {
|
|
|
- mv_misc = MLX5_ADDR_OF(fte_match_param, match_v, misc_parameters);
|
|
|
- mc_misc = MLX5_ADDR_OF(fte_match_param, match_c, misc_parameters);
|
|
|
+ mv_misc = MLX5_ADDR_OF(fte_match_param, spec->match_value,
|
|
|
+ misc_parameters);
|
|
|
+ mc_misc = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
|
|
|
+ misc_parameters);
|
|
|
MLX5_SET(fte_match_set_misc, mv_misc, source_port, UPLINK_VPORT);
|
|
|
MLX5_SET_TO_ONES(fte_match_set_misc, mc_misc, source_port);
|
|
|
}
|
|
@@ -368,11 +368,9 @@ __esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u32 vport, bool rx_rule,
|
|
|
esw_debug(esw->dev,
|
|
|
"\tFDB add rule dmac_v(%pM) dmac_c(%pM) -> vport(%d)\n",
|
|
|
dmac_v, dmac_c, vport);
|
|
|
+ spec->match_criteria_enable = match_header;
|
|
|
flow_rule =
|
|
|
- mlx5_add_flow_rule(esw->fdb_table.fdb,
|
|
|
- match_header,
|
|
|
- match_c,
|
|
|
- match_v,
|
|
|
+ mlx5_add_flow_rule(esw->fdb_table.fdb, spec,
|
|
|
MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,
|
|
|
0, &dest);
|
|
|
if (IS_ERR(flow_rule)) {
|
|
@@ -381,9 +379,8 @@ __esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u32 vport, bool rx_rule,
|
|
|
dmac_v, dmac_c, vport, PTR_ERR(flow_rule));
|
|
|
flow_rule = NULL;
|
|
|
}
|
|
|
-out:
|
|
|
- kfree(match_v);
|
|
|
- kfree(match_c);
|
|
|
+
|
|
|
+ kvfree(spec);
|
|
|
return flow_rule;
|
|
|
}
|
|
|
|
|
@@ -1293,9 +1290,8 @@ static void esw_vport_disable_ingress_acl(struct mlx5_eswitch *esw,
|
|
|
static int esw_vport_ingress_config(struct mlx5_eswitch *esw,
|
|
|
struct mlx5_vport *vport)
|
|
|
{
|
|
|
+ struct mlx5_flow_spec *spec;
|
|
|
u8 smac[ETH_ALEN];
|
|
|
- u32 *match_v;
|
|
|
- u32 *match_c;
|
|
|
int err = 0;
|
|
|
u8 *smac_v;
|
|
|
|
|
@@ -1329,9 +1325,8 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw,
|
|
|
"vport[%d] configure ingress rules, vlan(%d) qos(%d)\n",
|
|
|
vport->vport, vport->vlan, vport->qos);
|
|
|
|
|
|
- match_v = kzalloc(MLX5_ST_SZ_BYTES(fte_match_param), GFP_KERNEL);
|
|
|
- match_c = kzalloc(MLX5_ST_SZ_BYTES(fte_match_param), GFP_KERNEL);
|
|
|
- if (!match_v || !match_c) {
|
|
|
+ spec = mlx5_vzalloc(sizeof(*spec));
|
|
|
+ if (!spec) {
|
|
|
err = -ENOMEM;
|
|
|
esw_warn(esw->dev, "vport[%d] configure ingress rules failed, err(%d)\n",
|
|
|
vport->vport, err);
|
|
@@ -1339,22 +1334,20 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw,
|
|
|
}
|
|
|
|
|
|
if (vport->vlan || vport->qos)
|
|
|
- MLX5_SET_TO_ONES(fte_match_param, match_c, outer_headers.vlan_tag);
|
|
|
+ MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.vlan_tag);
|
|
|
|
|
|
if (vport->spoofchk) {
|
|
|
- MLX5_SET_TO_ONES(fte_match_param, match_c, outer_headers.smac_47_16);
|
|
|
- MLX5_SET_TO_ONES(fte_match_param, match_c, outer_headers.smac_15_0);
|
|
|
+ MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.smac_47_16);
|
|
|
+ MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.smac_15_0);
|
|
|
smac_v = MLX5_ADDR_OF(fte_match_param,
|
|
|
- match_v,
|
|
|
+ spec->match_value,
|
|
|
outer_headers.smac_47_16);
|
|
|
ether_addr_copy(smac_v, smac);
|
|
|
}
|
|
|
|
|
|
+ spec->match_criteria_enable = MLX5_MATCH_OUTER_HEADERS;
|
|
|
vport->ingress.allow_rule =
|
|
|
- mlx5_add_flow_rule(vport->ingress.acl,
|
|
|
- MLX5_MATCH_OUTER_HEADERS,
|
|
|
- match_c,
|
|
|
- match_v,
|
|
|
+ mlx5_add_flow_rule(vport->ingress.acl, spec,
|
|
|
MLX5_FLOW_CONTEXT_ACTION_ALLOW,
|
|
|
0, NULL);
|
|
|
if (IS_ERR(vport->ingress.allow_rule)) {
|
|
@@ -1365,13 +1358,9 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw,
|
|
|
goto out;
|
|
|
}
|
|
|
|
|
|
- memset(match_c, 0, MLX5_ST_SZ_BYTES(fte_match_param));
|
|
|
- memset(match_v, 0, MLX5_ST_SZ_BYTES(fte_match_param));
|
|
|
+ memset(spec, 0, sizeof(*spec));
|
|
|
vport->ingress.drop_rule =
|
|
|
- mlx5_add_flow_rule(vport->ingress.acl,
|
|
|
- 0,
|
|
|
- match_c,
|
|
|
- match_v,
|
|
|
+ mlx5_add_flow_rule(vport->ingress.acl, spec,
|
|
|
MLX5_FLOW_CONTEXT_ACTION_DROP,
|
|
|
0, NULL);
|
|
|
if (IS_ERR(vport->ingress.drop_rule)) {
|
|
@@ -1385,17 +1374,14 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw,
|
|
|
out:
|
|
|
if (err)
|
|
|
esw_vport_cleanup_ingress_rules(esw, vport);
|
|
|
-
|
|
|
- kfree(match_v);
|
|
|
- kfree(match_c);
|
|
|
+ kvfree(spec);
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
static int esw_vport_egress_config(struct mlx5_eswitch *esw,
|
|
|
struct mlx5_vport *vport)
|
|
|
{
|
|
|
- u32 *match_v;
|
|
|
- u32 *match_c;
|
|
|
+ struct mlx5_flow_spec *spec;
|
|
|
int err = 0;
|
|
|
|
|
|
esw_vport_cleanup_egress_rules(esw, vport);
|
|
@@ -1411,9 +1397,8 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw,
|
|
|
"vport[%d] configure egress rules, vlan(%d) qos(%d)\n",
|
|
|
vport->vport, vport->vlan, vport->qos);
|
|
|
|
|
|
- match_v = kzalloc(MLX5_ST_SZ_BYTES(fte_match_param), GFP_KERNEL);
|
|
|
- match_c = kzalloc(MLX5_ST_SZ_BYTES(fte_match_param), GFP_KERNEL);
|
|
|
- if (!match_v || !match_c) {
|
|
|
+ spec = mlx5_vzalloc(sizeof(*spec));
|
|
|
+ if (!spec) {
|
|
|
err = -ENOMEM;
|
|
|
esw_warn(esw->dev, "vport[%d] configure egress rules failed, err(%d)\n",
|
|
|
vport->vport, err);
|
|
@@ -1421,16 +1406,14 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw,
|
|
|
}
|
|
|
|
|
|
/* Allowed vlan rule */
|
|
|
- MLX5_SET_TO_ONES(fte_match_param, match_c, outer_headers.vlan_tag);
|
|
|
- MLX5_SET_TO_ONES(fte_match_param, match_v, outer_headers.vlan_tag);
|
|
|
- MLX5_SET_TO_ONES(fte_match_param, match_c, outer_headers.first_vid);
|
|
|
- MLX5_SET(fte_match_param, match_v, outer_headers.first_vid, vport->vlan);
|
|
|
+ MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.vlan_tag);
|
|
|
+ MLX5_SET_TO_ONES(fte_match_param, spec->match_value, outer_headers.vlan_tag);
|
|
|
+ MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, outer_headers.first_vid);
|
|
|
+ MLX5_SET(fte_match_param, spec->match_value, outer_headers.first_vid, vport->vlan);
|
|
|
|
|
|
+ spec->match_criteria_enable = MLX5_MATCH_OUTER_HEADERS;
|
|
|
vport->egress.allowed_vlan =
|
|
|
- mlx5_add_flow_rule(vport->egress.acl,
|
|
|
- MLX5_MATCH_OUTER_HEADERS,
|
|
|
- match_c,
|
|
|
- match_v,
|
|
|
+ mlx5_add_flow_rule(vport->egress.acl, spec,
|
|
|
MLX5_FLOW_CONTEXT_ACTION_ALLOW,
|
|
|
0, NULL);
|
|
|
if (IS_ERR(vport->egress.allowed_vlan)) {
|
|
@@ -1442,13 +1425,9 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw,
|
|
|
}
|
|
|
|
|
|
/* Drop others rule (star rule) */
|
|
|
- memset(match_c, 0, MLX5_ST_SZ_BYTES(fte_match_param));
|
|
|
- memset(match_v, 0, MLX5_ST_SZ_BYTES(fte_match_param));
|
|
|
+ memset(spec, 0, sizeof(*spec));
|
|
|
vport->egress.drop_rule =
|
|
|
- mlx5_add_flow_rule(vport->egress.acl,
|
|
|
- 0,
|
|
|
- match_c,
|
|
|
- match_v,
|
|
|
+ mlx5_add_flow_rule(vport->egress.acl, spec,
|
|
|
MLX5_FLOW_CONTEXT_ACTION_DROP,
|
|
|
0, NULL);
|
|
|
if (IS_ERR(vport->egress.drop_rule)) {
|
|
@@ -1458,8 +1437,7 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw,
|
|
|
vport->egress.drop_rule = NULL;
|
|
|
}
|
|
|
out:
|
|
|
- kfree(match_v);
|
|
|
- kfree(match_c);
|
|
|
+ kvfree(spec);
|
|
|
return err;
|
|
|
}
|
|
|
|