err = mlx5_query_ports_check(mdev, in, sizeof(in)); if (err) return err;
MLX5_SET(pcmr_reg, in, local_port, 1);
MLX5_SET(pcmr_reg, in, entropy_force, force);
MLX5_SET(pcmr_reg, in, entropy_calc, enable); return mlx5_set_ports_check(mdev, in, sizeof(in));
}
err = mlx5_query_ports_check(mdev, in, sizeof(in)); if (err) return err;
MLX5_SET(pcmr_reg, in, local_port, 1);
MLX5_SET(pcmr_reg, in, entropy_force, force);
MLX5_SET(pcmr_reg, in, entropy_gre_calc, enable); return mlx5_set_ports_check(mdev, in, sizeof(in));
}
staticint mlx5_set_entropy(struct mlx5_tun_entropy *tun_entropy, int reformat_type, bool enable)
{ struct mlx5_port_tun_entropy_flags entropy_flags; int err;
mlx5_query_port_tun_entropy(tun_entropy->mdev, &entropy_flags); /* Tunnel entropy calculation may be controlled either on port basis * for all tunneling protocols or specifically for GRE protocol. * Prioritize GRE protocol control (if capable) over global port * configuration.
*/ if (entropy_flags.gre_calc_supported &&
reformat_type == MLX5_REFORMAT_TYPE_L2_TO_NVGRE) { if (!entropy_flags.force_supported) return 0;
err = mlx5_set_port_gre_tun_entropy_calc(tun_entropy->mdev,
enable, !enable); if (err) return err;
} elseif (entropy_flags.calc_supported) { /* Other applications may change the global FW entropy * calculations settings. Check that the current entropy value * is the negative of the updated value.
*/ if (entropy_flags.force_enabled &&
enable == entropy_flags.calc_enabled) {
mlx5_core_warn(tun_entropy->mdev, "Unexpected entropy calc setting - expected %d",
!entropy_flags.calc_enabled); return -EOPNOTSUPP;
} /* GRE requires disabling entropy calculation. if there are * enabling entries (i.e VXLAN) we cannot turn it off for them, * thus fail.
*/ if (tun_entropy->num_enabling_entries) return -EOPNOTSUPP;
err = mlx5_set_port_tun_entropy_calc(tun_entropy->mdev, enable,
entropy_flags.force_supported); if (err) return err;
tun_entropy->enabled = enable; /* if we turn on the entropy we don't need to force it anymore */ if (entropy_flags.force_supported && enable) {
err = mlx5_set_port_tun_entropy_calc(tun_entropy->mdev, 1, 0); if (err) return err;
}
}
return 0;
}
/* the function manages the refcount for enabling/disabling tunnel types. * the return value indicates if the inc is successful or not, depending on * entropy capabilities and configuration.
*/ int mlx5_tun_entropy_refcount_inc(struct mlx5_tun_entropy *tun_entropy, int reformat_type)
{ int err = -EOPNOTSUPP;
mutex_lock(&tun_entropy->lock); if ((reformat_type == MLX5_REFORMAT_TYPE_L2_TO_VXLAN ||
reformat_type == MLX5_REFORMAT_TYPE_L2_TO_L3_TUNNEL) &&
tun_entropy->enabled) { /* in case entropy calculation is enabled for all tunneling * types, it is ok for VXLAN, so approve. * otherwise keep the error default.
*/
tun_entropy->num_enabling_entries++;
err = 0;
} elseif (reformat_type == MLX5_REFORMAT_TYPE_L2_TO_NVGRE) { /* turn off the entropy only for the first GRE rule. * for the next rules the entropy was already disabled * successfully.
*/ if (tun_entropy->num_disabling_entries == 0)
err = mlx5_set_entropy(tun_entropy, reformat_type, 0); else
err = 0; if (!err)
tun_entropy->num_disabling_entries++;
}
mutex_unlock(&tun_entropy->lock);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.