[PATCH v2] net/mlx4: Memcpy at slave_event should copy sizeof mlx4_eqe

2015-10-26 Thread clsoto
From: Carol L Soto 

If the caps.eqe_size is bigger than the struct mlx4_eqe then there
is a potential for corrupting data at the master context. We can see
the message "Master failed to generate an EQE for slave: X" when the
event_eqe array wraps and we can see potential oops at the function
mlx4_GEN_EQE. Also correct a memset of cmd_eqe to use the sizeof
mlx4_eqe instead of eqe_size. 

Fixes: 08ff32352d6f ('mlx4: 64-byte CQE/EQE support')
Signed-off-by: Carol L Soto 

---
 drivers/net/ethernet/mellanox/mlx4/cmd.c | 2 +-
 drivers/net/ethernet/mellanox/mlx4/eq.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c 
b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index 0a32020..2177e56 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -2398,7 +2398,7 @@ int mlx4_multi_func_init(struct mlx4_dev *dev)
}
}
 
-   memset(>mfunc.master.cmd_eqe, 0, dev->caps.eqe_size);
+   memset(>mfunc.master.cmd_eqe, 0, sizeof(struct mlx4_eqe));
priv->mfunc.master.cmd_eqe.type = MLX4_EVENT_TYPE_CMD;
INIT_WORK(>mfunc.master.comm_work,
  mlx4_master_comm_channel);
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c 
b/drivers/net/ethernet/mellanox/mlx4/eq.c
index c344884..603d1c3 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -196,7 +196,7 @@ static void slave_event(struct mlx4_dev *dev, u8 slave, 
struct mlx4_eqe *eqe)
return;
}
 
-   memcpy(s_eqe, eqe, dev->caps.eqe_size - 1);
+   memcpy(s_eqe, eqe, sizeof(struct mlx4_eqe) - 1);
s_eqe->slave_id = slave;
/* ensure all information is written before setting the ownersip bit */
dma_wmb();
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] net/mlx4: Memcpy at slave_event should copy sizeof mlx4_eqe

2015-10-23 Thread clsoto
From: Carol L Soto 

If the caps.eqe_size is bigger than the struct mlx4_eqe then there
is a potential for corrupting data at the master context. We can see
the message "Master failed to generate an EQE for slave: X" when the 
event_eqe array wraps and we can see potential oops at the function
mlx4_GEN_EQE. 

Signed-off-by: Carol L Soto 
---
 drivers/net/ethernet/mellanox/mlx4/eq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c 
b/drivers/net/ethernet/mellanox/mlx4/eq.c
index c344884..603d1c3 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -196,7 +196,7 @@ static void slave_event(struct mlx4_dev *dev, u8 slave, 
struct mlx4_eqe *eqe)
return;
}
 
-   memcpy(s_eqe, eqe, dev->caps.eqe_size - 1);
+   memcpy(s_eqe, eqe, sizeof(struct mlx4_eqe) - 1);
s_eqe->slave_id = slave;
/* ensure all information is written before setting the ownersip bit */
dma_wmb();
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net] net/mlx4: Remove shared_ports variable at mlx4_enable_msi_x

2015-10-07 Thread clsoto
From: Carol L Soto 

If we get MAX_MSIX interrupts would like to have each receive ring
with his own msix interrupt line. Do not need the shared_ports
variable at mlx4_enable_msix

Fixes: 9293267a3e2a ('net/mlx4_core: Capping number of requested MSIXs to 
MAX_MSIX')
Signed-off-by: Carol L Soto 
Acked-by: Matan Barak 

---
 drivers/net/ethernet/mellanox/mlx4/main.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index 006757f..cc3a989 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2669,14 +2669,11 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
 
if (msi_x) {
int nreq = dev->caps.num_ports * num_online_cpus() + 1;
-   bool shared_ports = false;
 
nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
 nreq);
-   if (nreq > MAX_MSIX) {
+   if (nreq > MAX_MSIX)
nreq = MAX_MSIX;
-   shared_ports = true;
-   }
 
entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
if (!entries)
@@ -2699,9 +2696,6 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
bitmap_zero(priv->eq_table.eq[MLX4_EQ_ASYNC].actv_ports.ports,
dev->caps.num_ports);
 
-   if (MLX4_IS_LEGACY_EQ_MODE(dev->caps))
-   shared_ports = true;
-
for (i = 0; i < dev->caps.num_comp_vectors + 1; i++) {
if (i == MLX4_EQ_ASYNC)
continue;
@@ -2709,7 +2703,7 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
priv->eq_table.eq[i].irq =
entries[i + 1 - !!(i > MLX4_EQ_ASYNC)].vector;
 
-   if (shared_ports) {
+   if (MLX4_IS_LEGACY_EQ_MODE(dev->caps)) {

bitmap_fill(priv->eq_table.eq[i].actv_ports.ports,
dev->caps.num_ports);
/* We don't set affinity hint when there
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] Do not set shared_ports when nreq > MAX_MSIX

2015-10-06 Thread clsoto
From: Carol L Soto 

If we get MAX_MSIX interrupts would like to have each receive ring
with his own msix interrupt line.

Fixes: 9293267a3e2a ('net/mlx4_core: Capping number of requested MSIXs to 
MAX_MSIX')
Signed-off-by: Carol L Soto 

---
 drivers/net/ethernet/mellanox/mlx4/main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index 006757f..f03f513 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2673,10 +2673,8 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
 
nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
 nreq);
-   if (nreq > MAX_MSIX) {
+   if (nreq > MAX_MSIX)
nreq = MAX_MSIX;
-   shared_ports = true;
-   }
 
entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
if (!entries)
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2 net] net/mlx4_core: Test interrupts fail if not all comp vectors called request_irq

2015-10-06 Thread clsoto
From: Carol L Soto 

Test interrupts fails if not all completion vectors called
request_irq. This case can happen if only mlx4_en loads and
we have more completion vectors than rx rings. 

Fixes: c66fa19c405a ('net/mlx4: Add EQ pool')
Acked-by: Matan Barak 
Signed-off-by: Carol L Soto 

---
 drivers/net/ethernet/mellanox/mlx4/eq.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c 
b/drivers/net/ethernet/mellanox/mlx4/eq.c
index 8e81e53..c344884 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -1364,6 +1364,10 @@ int mlx4_test_interrupts(struct mlx4_dev *dev)
 * and performing a NOP command
 */
for(i = 0; !err && (i < dev->caps.num_comp_vectors); ++i) {
+   /* Make sure request_irq was called */
+   if (!priv->eq_table.eq[i].have_irq)
+   continue;
+
/* Temporary use polling for command completions */
mlx4_cmd_use_polling(dev);
 
-- 
Can we push this patch to 4.2-stable as the bug was introduced in 4.2-rc1 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next] net/mlx4_core: Test interrupts fail if not all comp vectors called request_irq

2015-09-29 Thread clsoto
From: Carol L Soto 

Test interrupts fails if not all completion vectors called
request_irq. This case can happen if only mlx4_en loads and
we have more completion vectors than rx rings.

Signed-off-by: Carol L Soto 
---
 drivers/net/ethernet/mellanox/mlx4/eq.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c 
b/drivers/net/ethernet/mellanox/mlx4/eq.c
index 8e81e53..c344884 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -1364,6 +1364,10 @@ int mlx4_test_interrupts(struct mlx4_dev *dev)
 * and performing a NOP command
 */
for(i = 0; !err && (i < dev->caps.num_comp_vectors); ++i) {
+   /* Make sure request_irq was called */
+   if (!priv->eq_table.eq[i].have_irq)
+   continue;
+
/* Temporary use polling for command completions */
mlx4_cmd_use_polling(dev);
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next] net/mlx4_en: Fix IPv6 csum calculation

2015-08-28 Thread clsoto
From: Carol L Soto cls...@linux.vnet.ibm.com

Seeing this message with mlx4_eni with IPv6: hw csum failure

Changing IPv6 csum calculation to be based on OFED 2.4 code.
When calculate IPv6 csum based also on source and destination
addresses.

Signed-off-by: Muhammad Mahajna muhamm...@mellanox.com
Signed-off-by: Carol L Soto cls...@linux.vnet.ibm.com
---
 drivers/net/ethernet/mellanox/mlx4/en_rx.c | 46 +-
 1 file changed, 33 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c 
b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 4402a1e..d43c512 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -693,26 +693,46 @@ static void get_fixed_ipv4_csum(__wsum hw_checksum, 
struct sk_buff *skb,
 }
 
 #if IS_ENABLED(CONFIG_IPV6)
-/* In IPv6 packets, besides subtracting the pseudo header checksum,
- * we also compute/add the IP header checksum which
- * is not added by the HW.
- */
+static __wsum csum_ipv6_magic_nofold(const struct in6_addr *saddr,
+const struct in6_addr *daddr,
+__u32 len, unsigned short proto)
+{
+   __wsum res = 0;
+
+   res = csum_add(res, saddr-in6_u.u6_addr32[0]);
+   res = csum_add(res, saddr-in6_u.u6_addr32[1]);
+   res = csum_add(res, saddr-in6_u.u6_addr32[2]);
+   res = csum_add(res, saddr-in6_u.u6_addr32[3]);
+   res = csum_add(res, daddr-in6_u.u6_addr32[0]);
+   res = csum_add(res, daddr-in6_u.u6_addr32[1]);
+   res = csum_add(res, daddr-in6_u.u6_addr32[2]);
+   res = csum_add(res, daddr-in6_u.u6_addr32[3]);
+   res = csum_add(res, len);
+   res = csum_add(res, htonl(proto));
+
+   return res;
+}
+
 static int get_fixed_ipv6_csum(__wsum hw_checksum, struct sk_buff *skb,
   struct ipv6hdr *ipv6h)
 {
-   __wsum csum_pseudo_hdr = 0;
+   __wsum csum_pseudo_header = 0;
 
-   if (ipv6h-nexthdr == IPPROTO_FRAGMENT || ipv6h-nexthdr == 
IPPROTO_HOPOPTS)
+   if (ipv6h-nexthdr == IPPROTO_FRAGMENT ||
+   ipv6h-nexthdr == IPPROTO_HOPOPTS)
return -1;
-   hw_checksum = csum_add(hw_checksum, (__force __wsum)(ipv6h-nexthdr  
8));
 
-   csum_pseudo_hdr = csum_partial(ipv6h-saddr,
-  sizeof(ipv6h-saddr) + 
sizeof(ipv6h-daddr), 0);
-   csum_pseudo_hdr = csum_add(csum_pseudo_hdr, (__force 
__wsum)ipv6h-payload_len);
-   csum_pseudo_hdr = csum_add(csum_pseudo_hdr, (__force 
__wsum)ntohs(ipv6h-nexthdr));
+   hw_checksum = csum_add(hw_checksum, cpu_to_be16(ipv6h-nexthdr));
+   csum_pseudo_header = csum_ipv6_magic_nofold(ipv6h-saddr,
+   ipv6h-daddr,
+   ipv6h-payload_len,
+   ipv6h-nexthdr);
+   hw_checksum = csum_sub(hw_checksum, csum_pseudo_header);
+   hw_checksum = csum_partial(ipv6h, sizeof(struct ipv6hdr), hw_checksum);
+   if (!hw_checksum)
+   return -1;
 
-   skb-csum = csum_sub(hw_checksum, csum_pseudo_hdr);
-   skb-csum = csum_add(skb-csum, csum_partial(ipv6h, sizeof(struct 
ipv6hdr), 0));
+   skb-csum = hw_checksum;
return 0;
 }
 #endif
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 2/2] net/mlx4_core: Fix unintialized variable used in error path

2015-08-27 Thread clsoto
From: Carol L Soto cls...@linux.vnet.ibm.com

The uninitialized value name in mlx4_en_activate_cq was used in order
to print an error message. Fixing it by replacing it with cq-vector.

Signed-off-by: Matan Barak mat...@mellanox.com
Signed-off-by: Carol L Soto cls...@linux.vnet.ibm.com
---
 drivers/net/ethernet/mellanox/mlx4/en_cq.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_cq.c 
b/drivers/net/ethernet/mellanox/mlx4/en_cq.c
index 63769df..a1918e2 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_cq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_cq.c
@@ -100,7 +100,6 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct 
mlx4_en_cq *cq,
 {
struct mlx4_en_dev *mdev = priv-mdev;
int err = 0;
-   char name[25];
int timestamp_en = 0;
bool assigned_eq = false;
 
@@ -119,8 +118,8 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct 
mlx4_en_cq *cq,
err = mlx4_assign_eq(mdev-dev, priv-port,
 cq-vector);
if (err) {
-   mlx4_err(mdev, Failed assigning an EQ to %s\n,
-name);
+   mlx4_err(mdev, Failed assigning an EQ to CQ 
vector %d\n,
+cq-vector);
goto free_eq;
}
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 1/2] net/mlx4_core: Capping number of requested MSIXs to MAX_MSIX

2015-08-27 Thread clsoto
From: Carol L Soto cls...@linux.vnet.ibm.com

We currently manage IRQs in pool_bm which is a bit field
of MAX_MSIX bits. Thus, allocating more than MAX_MSIX
interrupts can't be managed in pool_bm.
Fixing this by capping number of requested MSIXs to
MAX_MSIX.

Signed-off-by: Matan Barak mat...@mellanox.com
Signed-off-by: Carol L Soto cls...@linux.vnet.ibm.com
---
 drivers/net/ethernet/mellanox/mlx4/main.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index 121c579..006757f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2669,9 +2669,14 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
 
if (msi_x) {
int nreq = dev-caps.num_ports * num_online_cpus() + 1;
+   bool shared_ports = false;
 
nreq = min_t(int, dev-caps.num_eqs - dev-caps.reserved_eqs,
 nreq);
+   if (nreq  MAX_MSIX) {
+   nreq = MAX_MSIX;
+   shared_ports = true;
+   }
 
entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
if (!entries)
@@ -2694,6 +2699,9 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
bitmap_zero(priv-eq_table.eq[MLX4_EQ_ASYNC].actv_ports.ports,
dev-caps.num_ports);
 
+   if (MLX4_IS_LEGACY_EQ_MODE(dev-caps))
+   shared_ports = true;
+
for (i = 0; i  dev-caps.num_comp_vectors + 1; i++) {
if (i == MLX4_EQ_ASYNC)
continue;
@@ -2701,7 +2709,7 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
priv-eq_table.eq[i].irq =
entries[i + 1 - !!(i  MLX4_EQ_ASYNC)].vector;
 
-   if (MLX4_IS_LEGACY_EQ_MODE(dev-caps)) {
+   if (shared_ports) {

bitmap_fill(priv-eq_table.eq[i].actv_ports.ports,
dev-caps.num_ports);
/* We don't set affinity hint when there
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next] net/mlx5_core: Set log_uar_page_sz for non 4K page size architecture

2015-08-05 Thread clsoto
From: Carol L Soto cls...@linux.vnet.ibm.com

failed to configure the page size for architectures with page size
different than 4K.

Signed-off-by: Carol L Soto cls...@linux.vnet.ibm.com
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c 
b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 603a8b0..03aabdd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -391,6 +391,8 @@ static int handle_hca_cap(struct mlx5_core_dev *dev)
/* disable cmdif checksum */
MLX5_SET(cmd_hca_cap, set_hca_cap, cmdif_checksum, 0);
 
+   MLX5_SET(cmd_hca_cap, set_hca_cap, log_uar_page_sz, PAGE_SHIFT - 12);
+
err = set_caps(dev, set_ctx, set_sz);
 
 query_ex:
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] net/bonding: Add function bond_remove_proc_entry at __bond_release_one

2015-07-13 Thread clsoto
From: Carol L Soto cls...@linux.vnet.ibm.com

Add function bond_remove_proc_entry at __bond_release_one to avoid stack 
trace at rmmod bonding.

[68830.202239] remove_proc_entry: removing non-empty directory
'net/bonding', leaking at least 'bond0'
[68830.202257] [ cut here ]
[68830.202260] WARNING: at fs/proc/generic.c:562
[68830.202412] NIP [c02abf6c] .remove_proc_entry+0x1fc/0x240
[68830.202416] LR [c02abf68] .remove_proc_entry+0x1f8/0x240
[68830.202419] PACATMSCRATCH [80009032]
[68830.202421] Call Trace:
[68830.202424] [c00179277940] [c02abf68] 
.remove_proc_entry+0x1f8/0x240 (unreliable)
[68830.202434] [c001792779f0] [d53229a4] 
.bond_destroy_proc_dir+0x34/0x54 [bonding]
[68830.202440] [c00179277a70] [d53130e0] 
.bond_net_exit+0x90/0x120 [bonding]
[68830.202445] [c00179277b10] [c059944c] 
.ops_exit_list.isra.0+0x6c/0xd0
[68830.202450] [c00179277ba0] [c0599774] 
.unregister_pernet_operations+0x94/0x100
[68830.202454] [c00179277c40] [c0599814] 
.unregister_pernet_subsys+0x34/0x60
[68830.202460] [c00179277cc0] [d5323758] 
.bonding_exit+0x48/0x2328 [bonding]
[68830.202466] [c00179277d30] [c010dcc4] 
.SyS_delete_module+0x1f4/0x340
[68830.202471] [c00179277e30] [c0009e7c] 
syscall_exit+0x0/0x7c
[68830.202491] ---[ end trace 9bd1d810219c9875 ]---

Signed-off-by: Carol L Soto cls...@linux.vnet.ibm.com
---
 drivers/net/bonding/bond_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 19eb990..ace105a 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1870,6 +1870,8 @@ static int __bond_release_one(struct net_device *bond_dev,
dev_set_mac_address(slave_dev, addr);
}
 
+   bond_remove_proc_entry(bond);
+
dev_set_mtu(slave_dev, slave-original_mtu);
 
slave_dev-priv_flags = ~IFF_BONDING;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next] net/mlx4_core: Add extra check for total vfs for SRIOV

2015-07-06 Thread clsoto
From: Carol Soto cls...@linux.vnet.ibm.com

Add extra check for total vfs for SRIOV to check if that value is 
bigger than total vfs in pci SRIOV capabalities. Fix a check and 
print of the number of maximum vfs that hw can handle. Fix a check 
and print of the number of maximum vfs per port that driver can handle. 

Signed-off-by: Carol L Soto cls...@linux.vnet.ibm.com
---
 drivers/net/ethernet/mellanox/mlx4/main.c | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index 12fbfcb..d76f425 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2907,6 +2907,8 @@ static u64 mlx4_enable_sriov(struct mlx4_dev *dev, struct 
pci_dev *pdev,
 {
u64 dev_flags = dev-flags;
int err = 0;
+   int fw_enabled_sriov_vfs = min(pci_sriov_get_totalvfs(pdev),
+   MLX4_MAX_NUM_VF);
 
if (reset_flow) {
dev-dev_vfs = kcalloc(total_vfs, sizeof(*dev-dev_vfs),
@@ -2932,6 +2934,12 @@ static u64 mlx4_enable_sriov(struct mlx4_dev *dev, 
struct pci_dev *pdev,
}
 
if (!(dev-flags   MLX4_FLAG_SRIOV)) {
+   if (total_vfs  fw_enabled_sriov_vfs) {
+   mlx4_err(dev, requested vfs (%d)  available vfs (%d). 
Continuing without SR_IOV\n,
+total_vfs, fw_enabled_sriov_vfs);
+   err = -ENOMEM;
+   goto disable_sriov;
+   }
mlx4_warn(dev, Enabling SR-IOV with %d VFs\n, total_vfs);
err = pci_enable_sriov(pdev, total_vfs);
}
@@ -3413,20 +3421,20 @@ static int __mlx4_init_one(struct pci_dev *pdev, int 
pci_dev_data,
goto err_disable_pdev;
}
}
-   if (total_vfs = MLX4_MAX_NUM_VF) {
+   if (total_vfs  MLX4_MAX_NUM_VF) {
dev_err(pdev-dev,
-   Requested more VF's (%d) than allowed (%d)\n,
-   total_vfs, MLX4_MAX_NUM_VF - 1);
+   Requested more VF's (%d) than allowed by hw (%d)\n,
+   total_vfs, MLX4_MAX_NUM_VF);
err = -EINVAL;
goto err_disable_pdev;
}
 
for (i = 0; i  MLX4_MAX_PORTS; i++) {
-   if (nvfs[i] + nvfs[2] = MLX4_MAX_NUM_VF_P_PORT) {
+   if (nvfs[i] + nvfs[2]  MLX4_MAX_NUM_VF_P_PORT) {
dev_err(pdev-dev,
-   Requested more VF's (%d) for port (%d) than 
allowed (%d)\n,
+   Requested more VF's (%d) for port (%d) than 
allowed by driver (%d)\n,
nvfs[i] + nvfs[2], i + 1,
-   MLX4_MAX_NUM_VF_P_PORT - 1);
+   MLX4_MAX_NUM_VF_P_PORT);
err = -EINVAL;
goto err_disable_pdev;
}
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 3/3] net/mlx4_core: fix typo in mlx4_set_vf_mac

2015-06-02 Thread clsoto
From: Carol Soto cls...@linux.vnet.ibm.com

fix typo in mlx4_set_vf_mac

Acked-by: Or Gerlitz ogerl...@mellanox.com
Signed-off-by: Carol L Soto cls...@linux.vnet.ibm.com
---
 drivers/net/ethernet/mellanox/mlx4/cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c 
b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index 91d8344..68ae765 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -2917,7 +2917,7 @@ int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int 
vf, u64 mac)
port = mlx4_slaves_closest_port(dev, slave, port);
s_info = priv-mfunc.master.vf_admin[slave].vport[port];
s_info-mac = mac;
-   mlx4_info(dev, default mac on vf %d port %d to %llX will take afect 
only after vf restart\n,
+   mlx4_info(dev, default mac on vf %d port %d to %llX will take effect 
only after vf restart\n,
  vf, port, s_info-mac);
return 0;
 }
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 2/3] net/mlx4_core: need to call close fw if alloc icm is called twice

2015-06-02 Thread clsoto
From: Carol Soto cls...@linux.vnet.ibm.com

If mlx4_enable_sriov is called by adapter without this
feature MLX4_DEV_CAP_FLAG2_SYS_EQS then during this path the function alloc
icm is called twice without freeing the structures from the first time.

Acked-by: Or Gerlitz ogerl...@mellanox.com
Signed-off-by: Carol L Soto cls...@linux.vnet.ibm.com
---
 drivers/net/ethernet/mellanox/mlx4/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index 9485cbe..7d5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2976,6 +2976,7 @@ slave_start:
  existing_vfs,
  reset_flow);
 
+   mlx4_close_fw(dev);
mlx4_cmd_cleanup(dev, MLX4_CMD_CLEANUP_ALL);
dev-flags = dev_flags;
if (!SRIOV_VALID_STATE(dev-flags)) {
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net-next 1/3] net/mlx4_core: double free of dev_vfs

2015-06-02 Thread clsoto
From: Carol L Soto cls...@linux.vnet.ibm.com

If user loads mlx4_core with num_vfs greater than
supported then variable dev-dev_vfs is freed 2 times after unloading the
driver.

Acked-by: Or Gerlitz ogerl...@mellanox.com
Signed-off-by: Carol L Soto cls...@linux.vnet.ibm.com
---
 drivers/net/ethernet/mellanox/mlx4/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c 
b/drivers/net/ethernet/mellanox/mlx4/main.c
index 0dbd704..9485cbe 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2824,6 +2824,7 @@ disable_sriov:
 free_mem:
dev-persist-num_vfs = 0;
kfree(dev-dev_vfs);
+dev-dev_vfs = NULL;
return dev_flags  ~MLX4_FLAG_MASTER;
 }
 
-- 
1.8.3.1

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net] net/mlx4: fix typo in mlx4_set_vf_mac

2015-06-01 Thread clsoto
fix typo in mlx4_set_vf_mac

Signed-off-by: Carol L Soto cls...@linux.vnet.ibm.com
---
 drivers/net/ethernet/mellanox/mlx4/cmd.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -2687,7 +2687,7 @@ int mlx4_set_vf_mac(struct mlx4_dev *dev
port = mlx4_slaves_closest_port(dev, slave, port);
s_info = priv-mfunc.master.vf_admin[slave].vport[port];
s_info-mac = mac;
-   mlx4_info(dev, default mac on vf %d port %d to %llX will take afect 
only after vf restart\n,
+   mlx4_info(dev, default mac on vf %d port %d to %llX will take effect 
only after vf restart\n,
  vf, port, s_info-mac);
return 0;
 }

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net] net/mlx4: double free of dev_vfs

2015-06-01 Thread clsoto
If user loads mlx4_core with num_vfs greater than supported
then variable dev-dev_vfs is freed 2 times after unloading
the driver.

Signed-off-by: Carol L Soto cls...@linux.vnet.ibm.com
---
 drivers/net/ethernet/mellanox/mlx4/main.c |1 +
 1 file changed, 1 insertion(+)

--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2685,6 +2685,7 @@ disable_sriov:
 free_mem:
dev-persist-num_vfs = 0;
kfree(dev-dev_vfs);
+   dev-dev_vfs = NULL;
return dev_flags  ~MLX4_FLAG_MASTER;
 }
 

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH net] net/mlx4: need to call close fw if alloc icm is called twice

2015-06-01 Thread clsoto
If mlx4_enable_sriov is called by adapter without this
feature MLX4_DEV_CAP_FLAG2_SYS_EQS then during this
path the function alloc icm is called twice without 
freeing the structures from the first time.

Signed-off-by: Carol L Soto cls...@linux.vnet.ibm.com
---
 drivers/net/ethernet/mellanox/mlx4/main.c |1 +
 1 file changed, 1 insertion(+)

--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2837,6 +2837,7 @@ slave_start:
  existing_vfs,
  reset_flow);
 
+   mlx4_close_fw(dev);
mlx4_cmd_cleanup(dev, MLX4_CMD_CLEANUP_ALL);
dev-flags = dev_flags;
if (!SRIOV_VALID_STATE(dev-flags)) {

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html