/* * Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.
*/
MLX5_SET(query_vport_state_in, in, opcode,
MLX5_CMD_OP_QUERY_VPORT_STATE);
MLX5_SET(query_vport_state_in, in, op_mod, opmod);
MLX5_SET(query_vport_state_in, in, vport_number, vport); if (vport)
MLX5_SET(query_vport_state_in, in, other_vport, 1);
err = mlx5_cmd_exec_inout(mdev, query_vport_state, in, out); if (err) return 0;
MLX5_SET(modify_vport_state_in, in, opcode,
MLX5_CMD_OP_MODIFY_VPORT_STATE);
MLX5_SET(modify_vport_state_in, in, op_mod, opmod);
MLX5_SET(modify_vport_state_in, in, vport_number, vport);
MLX5_SET(modify_vport_state_in, in, other_vport, other_vport);
MLX5_SET(modify_vport_state_in, in, admin_state, state);
MLX5_SET(query_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT);
MLX5_SET(query_nic_vport_context_in, in, vport_number, vport); if (vport)
MLX5_SET(query_nic_vport_context_in, in, other_vport, 1);
return mlx5_cmd_exec_inout(mdev, query_nic_vport_context, in, out);
}
int mlx5_query_nic_vport_min_inline(struct mlx5_core_dev *mdev,
u16 vport, u8 *min_inline)
{
u32 out[MLX5_ST_SZ_DW(query_nic_vport_context_out)] = {}; int err;
MLX5_SET(modify_nic_vport_context_in, in,
field_select.min_inline, 1);
MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport);
MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1);
nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in,
in, nic_vport_context);
MLX5_SET(nic_vport_context, nic_vport_ctx,
min_wqe_inline_mode, min_inline);
MLX5_SET(modify_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
MLX5_SET(query_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT);
MLX5_SET(query_nic_vport_context_in, in, vport_number, vport);
MLX5_SET(query_nic_vport_context_in, in, other_vport, other);
err = mlx5_cmd_exec_inout(mdev, query_nic_vport_context, in, out); if (!err)
ether_addr_copy(addr, &out_addr[2]);
int mlx5_modify_nic_vport_mac_address(struct mlx5_core_dev *mdev,
u16 vport, const u8 *addr)
{ void *in; int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in); int err; void *nic_vport_ctx;
u8 *perm_mac;
in = kvzalloc(inlen, GFP_KERNEL); if (!in) return -ENOMEM;
MLX5_SET(modify_nic_vport_context_in, in,
field_select.permanent_address, 1);
MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport);
MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1);
nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in,
in, nic_vport_context);
perm_mac = MLX5_ADDR_OF(nic_vport_context, nic_vport_ctx,
permanent_address);
ether_addr_copy(&perm_mac[2], addr);
MLX5_SET(modify_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
int mlx5_modify_nic_vport_mtu(struct mlx5_core_dev *mdev, u16 mtu)
{ int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in); void *in; int err;
in = kvzalloc(inlen, GFP_KERNEL); if (!in) return -ENOMEM;
MLX5_SET(modify_nic_vport_context_in, in, field_select.mtu, 1);
MLX5_SET(modify_nic_vport_context_in, in, nic_vport_context.mtu, mtu);
MLX5_SET(modify_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
int mlx5_query_nic_vport_mac_list(struct mlx5_core_dev *dev,
u16 vport, enum mlx5_list_type list_type,
u8 addr_list[][ETH_ALEN], int *list_size)
{
u32 in[MLX5_ST_SZ_DW(query_nic_vport_context_in)] = {0}; void *nic_vport_ctx; int max_list_size; int req_list_size; int out_sz; void *out; int err; int i;
out = kvzalloc(out_sz, GFP_KERNEL); if (!out) return -ENOMEM;
MLX5_SET(query_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_QUERY_NIC_VPORT_CONTEXT);
MLX5_SET(query_nic_vport_context_in, in, allowed_list_type, list_type);
MLX5_SET(query_nic_vport_context_in, in, vport_number, vport); if (vport || mlx5_core_is_ecpf(dev))
MLX5_SET(query_nic_vport_context_in, in, other_vport, 1);
err = mlx5_cmd_exec(dev, in, sizeof(in), out, out_sz); if (err) goto out;
*list_size = req_list_size; for (i = 0; i < req_list_size; i++) {
u8 *mac_addr = MLX5_ADDR_OF(nic_vport_context,
nic_vport_ctx,
current_uc_mac_address[i]) + 2;
ether_addr_copy(addr_list[i], mac_addr);
}
out:
kvfree(out); return err;
}
EXPORT_SYMBOL_GPL(mlx5_query_nic_vport_mac_list);
int mlx5_modify_nic_vport_mac_list(struct mlx5_core_dev *dev, enum mlx5_list_type list_type,
u8 addr_list[][ETH_ALEN], int list_size)
{
u32 out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)] = {}; void *nic_vport_ctx; int max_list_size; int in_sz; void *in; int err; int i;
in = kvzalloc(in_sz, GFP_KERNEL); if (!in) return -ENOMEM;
MLX5_SET(modify_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
MLX5_SET(modify_nic_vport_context_in, in,
field_select.addresses_list, 1);
nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, in,
nic_vport_context);
int mlx5_modify_nic_vport_vlans(struct mlx5_core_dev *dev,
u16 vlans[], int list_size)
{
u32 out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)]; void *nic_vport_ctx; int max_list_size; int in_sz; void *in; int err; int i;
memset(out, 0, sizeof(out));
in = kvzalloc(in_sz, GFP_KERNEL); if (!in) return -ENOMEM;
MLX5_SET(modify_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
MLX5_SET(modify_nic_vport_context_in, in,
field_select.addresses_list, 1);
nic_vport_ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, in,
nic_vport_context);
int mlx5_query_nic_vport_system_image_guid(struct mlx5_core_dev *mdev,
u64 *system_image_guid)
{
u32 *out; int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out); int err;
out = kvzalloc(outlen, GFP_KERNEL); if (!out) return -ENOMEM;
err = mlx5_query_nic_vport_context(mdev, 0, out); if (err) goto out;
int mlx5_query_nic_vport_sd_group(struct mlx5_core_dev *mdev, u8 *sd_group)
{ int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out);
u32 *out; int err;
out = kvzalloc(outlen, GFP_KERNEL); if (!out) return -ENOMEM;
err = mlx5_query_nic_vport_context(mdev, 0, out); if (err) goto out;
int mlx5_query_nic_vport_node_guid(struct mlx5_core_dev *mdev, u64 *node_guid)
{
u32 *out; int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out); int err;
out = kvzalloc(outlen, GFP_KERNEL); if (!out) return -ENOMEM;
err = mlx5_query_nic_vport_context(mdev, 0, out); if (err) goto out;
int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev,
u16 vport, u64 node_guid)
{ int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in); void *nic_vport_context; void *in; int err;
if (!MLX5_CAP_GEN(mdev, vport_group_manager)) return -EACCES;
in = kvzalloc(inlen, GFP_KERNEL); if (!in) return -ENOMEM;
MLX5_SET(modify_nic_vport_context_in, in,
field_select.node_guid, 1);
MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport);
MLX5_SET(modify_nic_vport_context_in, in, other_vport, 1);
nic_vport_context = MLX5_ADDR_OF(modify_nic_vport_context_in,
in, nic_vport_context);
MLX5_SET64(nic_vport_context, nic_vport_context, node_guid, node_guid);
MLX5_SET(modify_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
int mlx5_query_nic_vport_qkey_viol_cntr(struct mlx5_core_dev *mdev,
u16 *qkey_viol_cntr)
{
u32 *out; int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out); int err;
out = kvzalloc(outlen, GFP_KERNEL); if (!out) return -ENOMEM;
err = mlx5_query_nic_vport_context(mdev, 0, out); if (err) goto out;
int mlx5_query_hca_vport_gid(struct mlx5_core_dev *dev, u8 other_vport,
u8 port_num, u16 vf_num, u16 gid_index, union ib_gid *gid)
{ int in_sz = MLX5_ST_SZ_BYTES(query_hca_vport_gid_in); int out_sz = MLX5_ST_SZ_BYTES(query_hca_vport_gid_out); int is_group_manager; void *out = NULL; void *in = NULL; union ib_gid *tmp; int tbsz; int nout; int err;
int mlx5_query_nic_vport_promisc(struct mlx5_core_dev *mdev,
u16 vport, int *promisc_uc, int *promisc_mc, int *promisc_all)
{
u32 *out; int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out); int err;
out = kvzalloc(outlen, GFP_KERNEL); if (!out) return -ENOMEM;
err = mlx5_query_nic_vport_context(mdev, vport, out); if (err) goto out;
int mlx5_modify_nic_vport_promisc(struct mlx5_core_dev *mdev, int promisc_uc, int promisc_mc, int promisc_all)
{ void *in; int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in); int err;
in = kvzalloc(inlen, GFP_KERNEL); if (!in) return -ENOMEM;
MLX5_SET(modify_nic_vport_context_in, in, field_select.promisc, 1);
MLX5_SET(modify_nic_vport_context_in, in,
nic_vport_context.promisc_uc, promisc_uc);
MLX5_SET(modify_nic_vport_context_in, in,
nic_vport_context.promisc_mc, promisc_mc);
MLX5_SET(modify_nic_vport_context_in, in,
nic_vport_context.promisc_all, promisc_all);
MLX5_SET(modify_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
int mlx5_nic_vport_update_local_lb(struct mlx5_core_dev *mdev, bool enable)
{ int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in); void *in; int err;
if (!MLX5_CAP_GEN(mdev, disable_local_lb_mc) &&
!MLX5_CAP_GEN(mdev, disable_local_lb_uc)) return 0;
in = kvzalloc(inlen, GFP_KERNEL); if (!in) return -ENOMEM;
MLX5_SET(modify_nic_vport_context_in, in,
nic_vport_context.disable_mc_local_lb, !enable);
MLX5_SET(modify_nic_vport_context_in, in,
nic_vport_context.disable_uc_local_lb, !enable);
if (MLX5_CAP_GEN(mdev, disable_local_lb_mc))
MLX5_SET(modify_nic_vport_context_in, in,
field_select.disable_mc_local_lb, 1);
if (MLX5_CAP_GEN(mdev, disable_local_lb_uc))
MLX5_SET(modify_nic_vport_context_in, in,
field_select.disable_uc_local_lb, 1);
MLX5_SET(modify_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
int mlx5_nic_vport_query_local_lb(struct mlx5_core_dev *mdev, bool *status)
{ int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out);
u32 *out; int value; int err;
out = kvzalloc(outlen, GFP_KERNEL); if (!out) return -ENOMEM;
err = mlx5_query_nic_vport_context(mdev, 0, out); if (err) goto out;
value = MLX5_GET(query_nic_vport_context_out, out,
nic_vport_context.disable_mc_local_lb) << MC_LOCAL_LB;
value |= MLX5_GET(query_nic_vport_context_out, out,
nic_vport_context.disable_uc_local_lb) << UC_LOCAL_LB;
staticint mlx5_nic_vport_update_roce_state(struct mlx5_core_dev *mdev, enum mlx5_vport_roce_state state)
{ void *in; int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in); int err;
in = kvzalloc(inlen, GFP_KERNEL); if (!in) return -ENOMEM;
MLX5_SET(modify_nic_vport_context_in, in, field_select.roce_en, 1);
MLX5_SET(modify_nic_vport_context_in, in, nic_vport_context.roce_en,
state);
MLX5_SET(modify_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
int mlx5_nic_vport_disable_roce(struct mlx5_core_dev *mdev)
{ int err = 0;
mutex_lock(&mlx5_roce_en_lock); if (mdev->roce.roce_en) {
mdev->roce.roce_en--; if (mdev->roce.roce_en == 0)
err = mlx5_nic_vport_update_roce_state(mdev, MLX5_VPORT_ROCE_DISABLED);
if (err)
mdev->roce.roce_en++;
}
mutex_unlock(&mlx5_roce_en_lock); return err;
}
EXPORT_SYMBOL(mlx5_nic_vport_disable_roce);
int mlx5_core_query_vport_counter(struct mlx5_core_dev *dev, u8 other_vport, int vf, u8 port_num, void *out)
{ int in_sz = MLX5_ST_SZ_BYTES(query_vport_counter_in); int is_group_manager; void *in; int err;
is_group_manager = MLX5_CAP_GEN(dev, vport_group_manager);
in = kvzalloc(in_sz, GFP_KERNEL); if (!in) {
err = -ENOMEM; return err;
}
MLX5_SET(query_vport_counter_in, in, opcode,
MLX5_CMD_OP_QUERY_VPORT_COUNTER); if (other_vport) { if (is_group_manager) {
MLX5_SET(query_vport_counter_in, in, other_vport, 1);
MLX5_SET(query_vport_counter_in, in, vport_number, vf + 1);
} else {
err = -EPERM; goto free;
}
} if (MLX5_CAP_GEN(dev, num_ports) == 2)
MLX5_SET(query_vport_counter_in, in, port_num, port_num);
MLX5_SET(query_vnic_env_in, in, opcode,
MLX5_CMD_OP_QUERY_VNIC_ENV);
MLX5_SET(query_vnic_env_in, in, op_mod, 0);
MLX5_SET(query_vnic_env_in, in, vport_number, vport);
MLX5_SET(query_vnic_env_in, in, other_vport, other_vport);
err = mlx5_cmd_exec_inout(mdev, query_vnic_env, in, out); if (err) return err;
int mlx5_nic_vport_affiliate_multiport(struct mlx5_core_dev *master_mdev, struct mlx5_core_dev *port_mdev)
{ int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in); void *in; int err;
in = kvzalloc(inlen, GFP_KERNEL); if (!in) return -ENOMEM;
err = mlx5_nic_vport_enable_roce(port_mdev); if (err) goto free;
MLX5_SET(modify_nic_vport_context_in, in, field_select.affiliation, 1); if (MLX5_CAP_GEN_2(master_mdev, sw_vhca_id_valid)) {
MLX5_SET(modify_nic_vport_context_in, in,
nic_vport_context.vhca_id_type, VHCA_ID_TYPE_SW);
MLX5_SET(modify_nic_vport_context_in, in,
nic_vport_context.affiliated_vhca_id,
MLX5_CAP_GEN_2(master_mdev, sw_vhca_id));
} else {
MLX5_SET(modify_nic_vport_context_in, in,
nic_vport_context.affiliated_vhca_id,
MLX5_CAP_GEN(master_mdev, vhca_id));
}
MLX5_SET(modify_nic_vport_context_in, in,
nic_vport_context.affiliation_criteria,
MLX5_CAP_GEN(port_mdev, affiliate_nic_vport_criteria));
MLX5_SET(modify_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
err = mlx5_cmd_exec_in(port_mdev, modify_nic_vport_context, in); if (err)
mlx5_nic_vport_disable_roce(port_mdev);
int mlx5_nic_vport_unaffiliate_multiport(struct mlx5_core_dev *port_mdev)
{ int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in); void *in; int err;
in = kvzalloc(inlen, GFP_KERNEL); if (!in) return -ENOMEM;
MLX5_SET(modify_nic_vport_context_in, in, field_select.affiliation, 1);
MLX5_SET(modify_nic_vport_context_in, in,
nic_vport_context.affiliated_vhca_id, 0);
MLX5_SET(modify_nic_vport_context_in, in,
nic_vport_context.affiliation_criteria, 0);
MLX5_SET(modify_nic_vport_context_in, in, opcode,
MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
err = mlx5_cmd_exec_in(port_mdev, modify_nic_vport_context, in); if (!err)
mlx5_nic_vport_disable_roce(port_mdev);
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.