Commit c73c8b1e authored by Eran Ben Elisha's avatar Eran Ben Elisha Committed by David S. Miller

net/mlx4_core: Dynamically allocate structs at mlx4_slave_cap

In order to avoid temporary large structs on the stack,
allocate them dynamically.
Signed-off-by: default avatarEran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: default avatarTal Alon <talal@mellanox.com>
Signed-off-by: default avatarTariq Toukan <tariqt@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b74fd306
...@@ -145,8 +145,8 @@ static int is_sqp(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp) ...@@ -145,8 +145,8 @@ static int is_sqp(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp)
/* VF or PF -- proxy SQP */ /* VF or PF -- proxy SQP */
if (mlx4_is_mfunc(dev->dev)) { if (mlx4_is_mfunc(dev->dev)) {
for (i = 0; i < dev->dev->caps.num_ports; i++) { for (i = 0; i < dev->dev->caps.num_ports; i++) {
if (qp->mqp.qpn == dev->dev->caps.qp0_proxy[i] || if (qp->mqp.qpn == dev->dev->caps.spec_qps[i].qp0_proxy ||
qp->mqp.qpn == dev->dev->caps.qp1_proxy[i]) { qp->mqp.qpn == dev->dev->caps.spec_qps[i].qp1_proxy) {
proxy_sqp = 1; proxy_sqp = 1;
break; break;
} }
...@@ -173,7 +173,7 @@ static int is_qp0(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp) ...@@ -173,7 +173,7 @@ static int is_qp0(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp)
/* VF or PF -- proxy QP0 */ /* VF or PF -- proxy QP0 */
if (mlx4_is_mfunc(dev->dev)) { if (mlx4_is_mfunc(dev->dev)) {
for (i = 0; i < dev->dev->caps.num_ports; i++) { for (i = 0; i < dev->dev->caps.num_ports; i++) {
if (qp->mqp.qpn == dev->dev->caps.qp0_proxy[i]) { if (qp->mqp.qpn == dev->dev->caps.spec_qps[i].qp0_proxy) {
proxy_qp0 = 1; proxy_qp0 = 1;
break; break;
} }
...@@ -614,8 +614,8 @@ static int qp0_enabled_vf(struct mlx4_dev *dev, int qpn) ...@@ -614,8 +614,8 @@ static int qp0_enabled_vf(struct mlx4_dev *dev, int qpn)
{ {
int i; int i;
for (i = 0; i < dev->caps.num_ports; i++) { for (i = 0; i < dev->caps.num_ports; i++) {
if (qpn == dev->caps.qp0_proxy[i]) if (qpn == dev->caps.spec_qps[i].qp0_proxy)
return !!dev->caps.qp0_qkey[i]; return !!dev->caps.spec_qps[i].qp0_qkey;
} }
return 0; return 0;
} }
...@@ -1114,9 +1114,9 @@ static u32 get_sqp_num(struct mlx4_ib_dev *dev, struct ib_qp_init_attr *attr) ...@@ -1114,9 +1114,9 @@ static u32 get_sqp_num(struct mlx4_ib_dev *dev, struct ib_qp_init_attr *attr)
} }
/* PF or VF -- creating proxies */ /* PF or VF -- creating proxies */
if (attr->qp_type == IB_QPT_SMI) if (attr->qp_type == IB_QPT_SMI)
return dev->dev->caps.qp0_proxy[attr->port_num - 1]; return dev->dev->caps.spec_qps[attr->port_num - 1].qp0_proxy;
else else
return dev->dev->caps.qp1_proxy[attr->port_num - 1]; return dev->dev->caps.spec_qps[attr->port_num - 1].qp1_proxy;
} }
static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd, static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd,
...@@ -2277,9 +2277,9 @@ static int vf_get_qp0_qkey(struct mlx4_dev *dev, int qpn, u32 *qkey) ...@@ -2277,9 +2277,9 @@ static int vf_get_qp0_qkey(struct mlx4_dev *dev, int qpn, u32 *qkey)
{ {
int i; int i;
for (i = 0; i < dev->caps.num_ports; i++) { for (i = 0; i < dev->caps.num_ports; i++) {
if (qpn == dev->caps.qp0_proxy[i] || if (qpn == dev->caps.spec_qps[i].qp0_proxy ||
qpn == dev->caps.qp0_tunnel[i]) { qpn == dev->caps.spec_qps[i].qp0_tunnel) {
*qkey = dev->caps.qp0_qkey[i]; *qkey = dev->caps.spec_qps[i].qp0_qkey;
return 0; return 0;
} }
} }
...@@ -2340,7 +2340,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp, ...@@ -2340,7 +2340,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
sqp->ud_header.bth.destination_qpn = cpu_to_be32(wr->remote_qpn); sqp->ud_header.bth.destination_qpn = cpu_to_be32(wr->remote_qpn);
else else
sqp->ud_header.bth.destination_qpn = sqp->ud_header.bth.destination_qpn =
cpu_to_be32(mdev->dev->caps.qp0_tunnel[sqp->qp.port - 1]); cpu_to_be32(mdev->dev->caps.spec_qps[sqp->qp.port - 1].qp0_tunnel);
sqp->ud_header.bth.psn = cpu_to_be32((sqp->send_psn++) & ((1 << 24) - 1)); sqp->ud_header.bth.psn = cpu_to_be32((sqp->send_psn++) & ((1 << 24) - 1));
if (mlx4_is_master(mdev->dev)) { if (mlx4_is_master(mdev->dev)) {
...@@ -2800,9 +2800,9 @@ static void set_tunnel_datagram_seg(struct mlx4_ib_dev *dev, ...@@ -2800,9 +2800,9 @@ static void set_tunnel_datagram_seg(struct mlx4_ib_dev *dev,
memcpy(dseg->av, &sqp_av, sizeof (struct mlx4_av)); memcpy(dseg->av, &sqp_av, sizeof (struct mlx4_av));
if (qpt == MLX4_IB_QPT_PROXY_GSI) if (qpt == MLX4_IB_QPT_PROXY_GSI)
dseg->dqpn = cpu_to_be32(dev->dev->caps.qp1_tunnel[port - 1]); dseg->dqpn = cpu_to_be32(dev->dev->caps.spec_qps[port - 1].qp1_tunnel);
else else
dseg->dqpn = cpu_to_be32(dev->dev->caps.qp0_tunnel[port - 1]); dseg->dqpn = cpu_to_be32(dev->dev->caps.spec_qps[port - 1].qp0_tunnel);
/* Use QKEY from the QP context, which is set by master */ /* Use QKEY from the QP context, which is set by master */
dseg->qkey = cpu_to_be32(IB_QP_SET_QKEY); dseg->qkey = cpu_to_be32(IB_QP_SET_QKEY);
} }
......
...@@ -679,22 +679,22 @@ int mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, u8 gen_or_port, ...@@ -679,22 +679,22 @@ int mlx4_QUERY_FUNC_CAP(struct mlx4_dev *dev, u8 gen_or_port,
if (func_cap->flags1 & QUERY_FUNC_CAP_VF_ENABLE_QP0) { if (func_cap->flags1 & QUERY_FUNC_CAP_VF_ENABLE_QP0) {
MLX4_GET(qkey, outbox, QUERY_FUNC_CAP_PRIV_VF_QKEY_OFFSET); MLX4_GET(qkey, outbox, QUERY_FUNC_CAP_PRIV_VF_QKEY_OFFSET);
func_cap->qp0_qkey = qkey; func_cap->spec_qps.qp0_qkey = qkey;
} else { } else {
func_cap->qp0_qkey = 0; func_cap->spec_qps.qp0_qkey = 0;
} }
MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP0_TUNNEL); MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP0_TUNNEL);
func_cap->qp0_tunnel_qpn = size & 0xFFFFFF; func_cap->spec_qps.qp0_tunnel = size & 0xFFFFFF;
MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP0_PROXY); MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP0_PROXY);
func_cap->qp0_proxy_qpn = size & 0xFFFFFF; func_cap->spec_qps.qp0_proxy = size & 0xFFFFFF;
MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP1_TUNNEL); MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP1_TUNNEL);
func_cap->qp1_tunnel_qpn = size & 0xFFFFFF; func_cap->spec_qps.qp1_tunnel = size & 0xFFFFFF;
MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP1_PROXY); MLX4_GET(size, outbox, QUERY_FUNC_CAP_QP1_PROXY);
func_cap->qp1_proxy_qpn = size & 0xFFFFFF; func_cap->spec_qps.qp1_proxy = size & 0xFFFFFF;
if (func_cap->flags1 & QUERY_FUNC_CAP_FLAGS1_NIC_INFO) if (func_cap->flags1 & QUERY_FUNC_CAP_FLAGS1_NIC_INFO)
MLX4_GET(func_cap->phys_port_id, outbox, MLX4_GET(func_cap->phys_port_id, outbox,
......
...@@ -144,11 +144,7 @@ struct mlx4_func_cap { ...@@ -144,11 +144,7 @@ struct mlx4_func_cap {
int max_eq; int max_eq;
int reserved_eq; int reserved_eq;
int mcg_quota; int mcg_quota;
u32 qp0_qkey; struct mlx4_spec_qps spec_qps;
u32 qp0_tunnel_qpn;
u32 qp0_proxy_qpn;
u32 qp1_tunnel_qpn;
u32 qp1_proxy_qpn;
u32 reserved_lkey; u32 reserved_lkey;
u8 physical_port; u8 physical_port;
u8 flags0; u8 flags0;
......
This diff is collapsed.
...@@ -844,24 +844,20 @@ int mlx4_init_qp_table(struct mlx4_dev *dev) ...@@ -844,24 +844,20 @@ int mlx4_init_qp_table(struct mlx4_dev *dev)
/* In mfunc, calculate proxy and tunnel qp offsets for the PF here, /* In mfunc, calculate proxy and tunnel qp offsets for the PF here,
* since the PF does not call mlx4_slave_caps */ * since the PF does not call mlx4_slave_caps */
dev->caps.qp0_tunnel = kcalloc(dev->caps.num_ports, sizeof(u32), GFP_KERNEL); dev->caps.spec_qps = kcalloc(dev->caps.num_ports, sizeof(dev->caps.spec_qps), GFP_KERNEL);
dev->caps.qp0_proxy = kcalloc(dev->caps.num_ports, sizeof(u32), GFP_KERNEL);
dev->caps.qp1_tunnel = kcalloc(dev->caps.num_ports, sizeof(u32), GFP_KERNEL);
dev->caps.qp1_proxy = kcalloc(dev->caps.num_ports, sizeof(u32), GFP_KERNEL);
if (!dev->caps.qp0_tunnel || !dev->caps.qp0_proxy || if (!dev->caps.spec_qps) {
!dev->caps.qp1_tunnel || !dev->caps.qp1_proxy) {
err = -ENOMEM; err = -ENOMEM;
goto err_mem; goto err_mem;
} }
for (k = 0; k < dev->caps.num_ports; k++) { for (k = 0; k < dev->caps.num_ports; k++) {
dev->caps.qp0_proxy[k] = dev->phys_caps.base_proxy_sqpn + dev->caps.spec_qps[k].qp0_proxy = dev->phys_caps.base_proxy_sqpn +
8 * mlx4_master_func_num(dev) + k; 8 * mlx4_master_func_num(dev) + k;
dev->caps.qp0_tunnel[k] = dev->caps.qp0_proxy[k] + 8 * MLX4_MFUNC_MAX; dev->caps.spec_qps[k].qp0_tunnel = dev->caps.spec_qps[k].qp0_proxy + 8 * MLX4_MFUNC_MAX;
dev->caps.qp1_proxy[k] = dev->phys_caps.base_proxy_sqpn + dev->caps.spec_qps[k].qp1_proxy = dev->phys_caps.base_proxy_sqpn +
8 * mlx4_master_func_num(dev) + MLX4_MAX_PORTS + k; 8 * mlx4_master_func_num(dev) + MLX4_MAX_PORTS + k;
dev->caps.qp1_tunnel[k] = dev->caps.qp1_proxy[k] + 8 * MLX4_MFUNC_MAX; dev->caps.spec_qps[k].qp1_tunnel = dev->caps.spec_qps[k].qp1_proxy + 8 * MLX4_MFUNC_MAX;
} }
} }
...@@ -873,12 +869,8 @@ int mlx4_init_qp_table(struct mlx4_dev *dev) ...@@ -873,12 +869,8 @@ int mlx4_init_qp_table(struct mlx4_dev *dev)
return err; return err;
err_mem: err_mem:
kfree(dev->caps.qp0_tunnel); kfree(dev->caps.spec_qps);
kfree(dev->caps.qp0_proxy); dev->caps.spec_qps = NULL;
kfree(dev->caps.qp1_tunnel);
kfree(dev->caps.qp1_proxy);
dev->caps.qp0_tunnel = dev->caps.qp0_proxy =
dev->caps.qp1_tunnel = dev->caps.qp1_proxy = NULL;
mlx4_cleanup_qp_zones(dev); mlx4_cleanup_qp_zones(dev);
return err; return err;
} }
......
...@@ -518,6 +518,14 @@ struct mlx4_phys_caps { ...@@ -518,6 +518,14 @@ struct mlx4_phys_caps {
u32 base_tunnel_sqpn; u32 base_tunnel_sqpn;
}; };
struct mlx4_spec_qps {
u32 qp0_qkey;
u32 qp0_proxy;
u32 qp0_tunnel;
u32 qp1_proxy;
u32 qp1_tunnel;
};
struct mlx4_caps { struct mlx4_caps {
u64 fw_ver; u64 fw_ver;
u32 function; u32 function;
...@@ -547,11 +555,7 @@ struct mlx4_caps { ...@@ -547,11 +555,7 @@ struct mlx4_caps {
int max_qp_init_rdma; int max_qp_init_rdma;
int max_qp_dest_rdma; int max_qp_dest_rdma;
int max_tc_eth; int max_tc_eth;
u32 *qp0_qkey; struct mlx4_spec_qps *spec_qps;
u32 *qp0_proxy;
u32 *qp1_proxy;
u32 *qp0_tunnel;
u32 *qp1_tunnel;
int num_srqs; int num_srqs;
int max_srq_wqes; int max_srq_wqes;
int max_srq_sge; int max_srq_sge;
......
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