int mlx5_core_roce_gid_set(struct mlx5_core_dev *dev, unsigned int index, u8 roce_version, u8 roce_l3_type, const u8 *gid, const u8 *mac, bool vlan, u16 vlan_id) { #define MLX5_SET_RA(p, f, v) MLX5_SET(roce_addr_layout, p, f, v) u32 in[MLX5_ST_SZ_DW(set_roce_address_in)] = {0}; u32 out[MLX5_ST_SZ_DW(set_roce_address_out)] = {0}; void *in_addr = MLX5_ADDR_OF(set_roce_address_in, in, roce_address); char *addr_l3_addr = MLX5_ADDR_OF(roce_addr_layout, in_addr, source_l3_address); void *addr_mac = MLX5_ADDR_OF(roce_addr_layout, in_addr, source_mac_47_32); int gidsz = MLX5_FLD_SZ_BYTES(roce_addr_layout, source_l3_address); if (MLX5_CAP_GEN(dev, port_type) != MLX5_CAP_PORT_TYPE_ETH) return -EINVAL; if (gid) { if (vlan) { MLX5_SET_RA(in_addr, vlan_valid, 1); MLX5_SET_RA(in_addr, vlan_id, vlan_id); } ether_addr_copy(addr_mac, mac); MLX5_SET_RA(in_addr, roce_version, roce_version); MLX5_SET_RA(in_addr, roce_l3_type, roce_l3_type); memcpy(addr_l3_addr, gid, gidsz); } MLX5_SET(set_roce_address_in, in, roce_address_index, index); MLX5_SET(set_roce_address_in, in, opcode, MLX5_CMD_OP_SET_ROCE_ADDRESS); return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); }
int mlx5_core_mad_ifc(struct mlx5_core_dev *dev, const void *inb, void *outb, u16 opmod, u8 port) { int outlen = MLX5_ST_SZ_BYTES(mad_ifc_out); int inlen = MLX5_ST_SZ_BYTES(mad_ifc_in); int err = -ENOMEM; void *data; void *resp; u32 *out; u32 *in; in = kzalloc(inlen, GFP_KERNEL); out = kzalloc(outlen, GFP_KERNEL); if (!in || !out) goto out; MLX5_SET(mad_ifc_in, in, opcode, MLX5_CMD_OP_MAD_IFC); MLX5_SET(mad_ifc_in, in, op_mod, opmod); MLX5_SET(mad_ifc_in, in, port, port); data = MLX5_ADDR_OF(mad_ifc_in, in, mad); memcpy(data, inb, MLX5_FLD_SZ_BYTES(mad_ifc_in, mad)); err = mlx5_cmd_exec(dev, in, inlen, out, outlen); if (err) goto out; resp = MLX5_ADDR_OF(mad_ifc_out, out, response_mad_packet); memcpy(outb, resp, MLX5_FLD_SZ_BYTES(mad_ifc_out, response_mad_packet)); out: kfree(out); kfree(in); return err; }
int mlx5_query_board_id(struct mlx5_core_dev *dev) { u32 *out; int outlen = MLX5_ST_SZ_BYTES(query_adapter_out); int err; out = kzalloc(outlen, GFP_KERNEL); err = mlx5_cmd_query_adapter(dev, out, outlen); if (err) goto out_out; memcpy(dev->board_id, MLX5_ADDR_OF(query_adapter_out, out, query_adapter_struct.vsd_contd_psid), MLX5_FLD_SZ_BYTES(query_adapter_out, query_adapter_struct.vsd_contd_psid)); out_out: kfree(out); return err; }