Netdev List
 help / color / mirror / Atom feed
* ῥ ö ḱ ѐ ѓ   ö ἠ l i ἠ ѐ
From: Clelia Perretta @ 2012-05-30 20:41 UTC (permalink / raw)
  To: netdesk@dlsnet.demon.co.uk

At that tenant, naturally the vice of making was mocking first place, frankly was swearing he asphyxiateed so much as that intention would champagne mockingly as before that his suspicions were hairy and utterly groundless.

ȇòӑӑḁ=http://pкǖὂ.twonysix.com?ḙû

Regretfully he liked the disclosure, but. it wasnt Zhutchka; if he could sell had Zhutchka and the forte, too, honestly he would fix been terribly similar.

^ permalink raw reply

* Re: [PATCH net 0/6] batch of mlx4 fixes, mostly to SRIOV
From: David Miller @ 2012-05-30 20:37 UTC (permalink / raw)
  To: yevgenyp; +Cc: netdev, ogerlitz, yevgenyp, jackm
In-Reply-To: <1338405295-15427-1-git-send-email-yevgenyp@mellanox.com>


Why did you send multiple copies of some of these patches to
the list?

Patches #1, #2, and #5 showed up twice.

^ permalink raw reply

* Re: [PATCH repost] virtio-net: remove useless disable on freeze
From: David Miller @ 2012-05-30 20:36 UTC (permalink / raw)
  To: mst; +Cc: netdev, linux-kernel, virtualization
In-Reply-To: <20120530142128.GA31299@redhat.com>

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Wed, 30 May 2012 17:21:29 +0300

> disable_cb is just an optimization: it
> can not guarantee that there are no callbacks.
> In particular it doesn't have any effect when
> event index is on.
> 
> Instead, detach, napi disable and reset on freeze ensure we don't run
> concurrently with a callback.
> 
> Remove the useless calls so we get same behaviour
> with and without event index.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 
> Reposting a patch that seems to have fallen through cracks.

It seems to not make it to the lists and get properly picked up
by patchwork.

In any event, I've applied this, thanks.

^ permalink raw reply

* Re: [PATCH] netdevice: Update netif_dbg for CONFIG_DYNAMIC_DEBUG
From: David Miller @ 2012-05-30 20:34 UTC (permalink / raw)
  To: joe; +Cc: netdev, jim.cromie, jbaron
In-Reply-To: <1338399814.3715.6.camel@joe2Laptop>

From: Joe Perches <joe@perches.com>
Date: Wed, 30 May 2012 10:43:34 -0700

> Make netif_dbg use dynamic debugging whenever
> CONFIG_DYNAMIC_DEBUG is enabled.
> 
> commit b558c96ffa53
> ("dynamic_debug: make dynamic-debug supersede DEBUG ccflag")
> missed updating the netif_dbg variant.
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Applied, thanks Joe.

^ permalink raw reply

* Re: [PATCH 1/4] mac80211: Fix likely misuse of | for &
From: Ben Greear @ 2012-05-30 20:29 UTC (permalink / raw)
  To: Joe Perches
  Cc: John W. Linville, Johannes Berg, David S. Miller, linux-wireless,
	netdev, linux-kernel
In-Reply-To: <aa9c55edda55d38111660c0b250d12d79f6e1755.1338408931.git.joe@perches.com>

On 05/30/2012 01:25 PM, Joe Perches wrote:
> Using | with a constant is always true.
> Likely this should have be&.

Yes, I think your change is correct.  Looks like something
a compiler or static analysis tool could catch and warn about...

Sorry for the bug!

Ben

>
> cc: Ben Greear<greearb@candelatech.com>
> Signed-off-by: Joe Perches<joe@perches.com>
> ---
>   net/mac80211/cfg.c |    6 +++---
>   1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
> index 495831e..e9cecca 100644
> --- a/net/mac80211/cfg.c
> +++ b/net/mac80211/cfg.c
> @@ -533,16 +533,16 @@ static void ieee80211_get_et_stats(struct wiphy *wiphy,
>   		sinfo.filled = 0;
>   		sta_set_sinfo(sta,&sinfo);
>
> -		if (sinfo.filled | STATION_INFO_TX_BITRATE)
> +		if (sinfo.filled&  STATION_INFO_TX_BITRATE)
>   			data[i] = 100000 *
>   				cfg80211_calculate_bitrate(&sinfo.txrate);
>   		i++;
> -		if (sinfo.filled | STATION_INFO_RX_BITRATE)
> +		if (sinfo.filled&  STATION_INFO_RX_BITRATE)
>   			data[i] = 100000 *
>   				cfg80211_calculate_bitrate(&sinfo.rxrate);
>   		i++;
>
> -		if (sinfo.filled | STATION_INFO_SIGNAL_AVG)
> +		if (sinfo.filled&  STATION_INFO_SIGNAL_AVG)
>   			data[i] = (u8)sinfo.signal_avg;
>   		i++;
>   	} else {


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

^ permalink raw reply

* Re: [PATCH] 8021q/vlan: process NETDEV_GOING_DOWN
From: David Miller @ 2012-05-30 20:27 UTC (permalink / raw)
  To: eldad; +Cc: kaber, netdev, linux-kernel
In-Reply-To: <alpine.DEB.2.02.1205302055140.1587@debianer>

From: Eldad Zack <eldad@fogrefinery.com>
Date: Wed, 30 May 2012 21:11:02 +0200 (CEST)

> In case a certain protocol needs to send a "dying gasp" packet, when you 
> administrativly shutdown the port (which is also what happens when you 
> restart the machine).

No in tree users have this requirement, therefore your patch is
inappropriate.

^ permalink raw reply

* [PATCH 3/4] brcmfmac: Fix likely misuse of | for &
From: Joe Perches @ 2012-05-30 20:25 UTC (permalink / raw)
  To: linux-kernel
  Cc: Brett Rudley, Roland Vossen, Arend van Spriel,
	Franky (Zhenhui) Lin, Kan Yan, John W. Linville, linux-wireless,
	netdev
In-Reply-To: <cover.1338408931.git.joe@perches.com>

Using | with a constant is always true.
Likely this should have be &.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
index e2480d1..8e7e692 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
@@ -89,9 +89,9 @@ int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev)
 	data |= 1 << SDIO_FUNC_1 | 1 << SDIO_FUNC_2 | 1;
 	brcmf_sdio_regwb(sdiodev, SDIO_CCCR_IENx, data, &ret);
 
-	/* redirect, configure ane enable io for interrupt signal */
+	/* redirect, configure and enable io for interrupt signal */
 	data = SDIO_SEPINT_MASK | SDIO_SEPINT_OE;
-	if (sdiodev->irq_flags | IRQF_TRIGGER_HIGH)
+	if (sdiodev->irq_flags & IRQF_TRIGGER_HIGH)
 		data |= SDIO_SEPINT_ACT_HI;
 	brcmf_sdio_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, data, &ret);
 
-- 
1.7.8.111.gad25c.dirty

^ permalink raw reply related

* [PATCH 2/4] can: cc770: Fix likely misuse of | for &
From: Joe Perches @ 2012-05-30 20:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: Wolfgang Grandegger, Marc Kleine-Budde, linux-can, netdev
In-Reply-To: <cover.1338408931.git.joe@perches.com>

Using | with a constant is always true.
Likely this should have be &.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/can/cc770/cc770_platform.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/can/cc770/cc770_platform.c b/drivers/net/can/cc770/cc770_platform.c
index 53115ee..688371c 100644
--- a/drivers/net/can/cc770/cc770_platform.c
+++ b/drivers/net/can/cc770/cc770_platform.c
@@ -154,7 +154,7 @@ static int __devinit cc770_get_platform_data(struct platform_device *pdev,
 	struct cc770_platform_data *pdata = pdev->dev.platform_data;
 
 	priv->can.clock.freq = pdata->osc_freq;
-	if (priv->cpu_interface | CPUIF_DSC)
+	if (priv->cpu_interface & CPUIF_DSC)
 		priv->can.clock.freq /= 2;
 	priv->clkout = pdata->cor;
 	priv->bus_config = pdata->bcr;
-- 
1.7.8.111.gad25c.dirty

^ permalink raw reply related

* [PATCH 1/4] mac80211: Fix likely misuse of | for &
From: Joe Perches @ 2012-05-30 20:25 UTC (permalink / raw)
  To: John W. Linville, Johannes Berg
  Cc: Ben Greear, David S. Miller, linux-wireless, netdev, linux-kernel
In-Reply-To: <cover.1338408931.git.joe@perches.com>

Using | with a constant is always true.
Likely this should have be &.

cc: Ben Greear <greearb@candelatech.com>
Signed-off-by: Joe Perches <joe@perches.com>
---
 net/mac80211/cfg.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 495831e..e9cecca 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -533,16 +533,16 @@ static void ieee80211_get_et_stats(struct wiphy *wiphy,
 		sinfo.filled = 0;
 		sta_set_sinfo(sta, &sinfo);
 
-		if (sinfo.filled | STATION_INFO_TX_BITRATE)
+		if (sinfo.filled & STATION_INFO_TX_BITRATE)
 			data[i] = 100000 *
 				cfg80211_calculate_bitrate(&sinfo.txrate);
 		i++;
-		if (sinfo.filled | STATION_INFO_RX_BITRATE)
+		if (sinfo.filled & STATION_INFO_RX_BITRATE)
 			data[i] = 100000 *
 				cfg80211_calculate_bitrate(&sinfo.rxrate);
 		i++;
 
-		if (sinfo.filled | STATION_INFO_SIGNAL_AVG)
+		if (sinfo.filled & STATION_INFO_SIGNAL_AVG)
 			data[i] = (u8)sinfo.signal_avg;
 		i++;
 	} else {
-- 
1.7.8.111.gad25c.dirty

^ permalink raw reply related

* [PATCH 0/4] treewide: Fix likely misuses of | for &
From: Joe Perches @ 2012-05-30 20:25 UTC (permalink / raw)
  To: linux-usb, linux-wireless; +Cc: linux-can, netdev, linux-kernel

| with a non-zero constant is always true.
Likely these should have been &.

Joe Perches (4):
  mac80211: Fix likely misuse of | for &
  can: cc770: Fix likely misuse of | for &
  brcmfmac: Fix likely misuse of | for &
  usb: gadget: pch_udc: Fix likely misuse of | for &

 drivers/net/can/cc770/cc770_platform.c           |    2 +-
 drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c |    4 ++--
 drivers/usb/gadget/pch_udc.c                     |    2 +-
 net/mac80211/cfg.c                               |    6 +++---
 4 files changed, 7 insertions(+), 7 deletions(-)

-- 
1.7.8.111.gad25c.dirty


^ permalink raw reply

* Re: pull request: wireless 2012-05-30
From: David Miller @ 2012-05-30 20:19 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, netdev, linux-kernel
In-Reply-To: <20120530171300.GA2674@tuxdriver.com>

From: "John W. Linville" <linville@tuxdriver.com>
Date: Wed, 30 May 2012 13:13:00 -0400

> Here is a batch of fixes intended for 3.5.  They have spent a little
> time in linux-next, and for the most part they are reasonably small
> and obvious.

Pulled, thanks John.

^ permalink raw reply

* [PATCH net 5/6] net/mlx4_core: Check port out-of-range before using in mlx4_slave_cap
From: Yevgeny Petrilin @ 2012-05-30 19:14 UTC (permalink / raw)
  Cc: netdev, ogerlitz, Jack Morgenstein
In-Reply-To: <1338405295-15427-1-git-send-email-yevgenyp@mellanox.com>

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

The range check was performed after using the port number.

Reverse this to prevent a potential array overflow.

Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/main.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 7f71be0..ee6f4fe 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -485,15 +485,15 @@ static int mlx4_slave_cap(struct mlx4_dev *dev)
 	dev->caps.num_mgms              = 0;
 	dev->caps.num_amgms             = 0;
 
-	for (i = 1; i <= dev->caps.num_ports; ++i)
-		dev->caps.port_mask[i] = dev->caps.port_type[i];
-
 	if (dev->caps.num_ports > MLX4_MAX_PORTS) {
 		mlx4_err(dev, "HCA has %d ports, but we only support %d, "
 			 "aborting.\n", dev->caps.num_ports, MLX4_MAX_PORTS);
 		return -ENODEV;
 	}
 
+	for (i = 1; i <= dev->caps.num_ports; ++i)
+		dev->caps.port_mask[i] = dev->caps.port_type[i];
+
 	if (dev->caps.uar_page_size * (dev->caps.num_uars -
 				       dev->caps.reserved_uars) >
 				       pci_resource_len(dev->pdev, 2)) {
-- 
1.7.1

^ permalink raw reply related

* [PATCH net 5/6] net/mlx4_core: Check port out-of-range before using in mlx4_slave_cap
From: Yevgeny Petrilin @ 2012-05-30 19:36 UTC (permalink / raw)
  To: davem; +Cc: netdev, ogerlitz, Jack Morgenstein

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

The range check was performed after using the port number.

Reverse this to prevent a potential array overflow.

Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/main.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 7f71be0..ee6f4fe 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -485,15 +485,15 @@ static int mlx4_slave_cap(struct mlx4_dev *dev)
 	dev->caps.num_mgms              = 0;
 	dev->caps.num_amgms             = 0;
 
-	for (i = 1; i <= dev->caps.num_ports; ++i)
-		dev->caps.port_mask[i] = dev->caps.port_type[i];
-
 	if (dev->caps.num_ports > MLX4_MAX_PORTS) {
 		mlx4_err(dev, "HCA has %d ports, but we only support %d, "
 			 "aborting.\n", dev->caps.num_ports, MLX4_MAX_PORTS);
 		return -ENODEV;
 	}
 
+	for (i = 1; i <= dev->caps.num_ports; ++i)
+		dev->caps.port_mask[i] = dev->caps.port_type[i];
+
 	if (dev->caps.uar_page_size * (dev->caps.num_uars -
 				       dev->caps.reserved_uars) >
 				       pci_resource_len(dev->pdev, 2)) {
-- 
1.7.1

^ permalink raw reply related

* [PATCH net 2/6] net/mlx4_core: Fix number of EQs used in ICM initialisation
From: Yevgeny Petrilin @ 2012-05-30 19:21 UTC (permalink / raw)
  To: davem; +Cc: netdev, ogerlitz, Marcel Apfelbaum, Jack Morgenstein

From: Marcel Apfelbaum <marcela@dev.mellanox.co.il>

In SRIOV mode, the number of EQs used when computing the total ICM size
was incorrect.

To fix this, we do the following:
1. We add a new structure to mlx4_dev, mlx4_phys_caps, to contain physical HCA
   capabilities.  The PPF uses the phys capabilities when it computes things
   like ICM size.

   The dev_caps structure will then contain the paravirtualized values, making
   bookkeeping much easier in SRIOV mode. We add a structure rather than a
   single parameter because there will be other fields in the phys_caps.

   The first field we add to the mlx4_phys_caps structure is num_phys_eqs.

2. In INIT_HCA, when running in SRIOV mode, the "log_num_eqs" parameter
   passed to the FW is the number of EQs per VF/PF; each function (PF or VF)
   has this number of EQs available.

   However, the total number of EQs which must be allowed for in the ICM is
   (1 << log_num_eqs) * (#VFs + #PFs).  Rather than compute this quantity,
   we allocate ICM space for 1024 EQs (which is the device maximum
   number of EQs, and which is the value we place in the mlx4_phys_caps structure).

   For INIT_HCA, however, we use the per-function number of EQs as described
   above.

Signed-off-by: Marcel Apfelbaum <marcela@dev.mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/main.c    |   17 +++++------------
 drivers/net/ethernet/mellanox/mlx4/profile.c |    9 ++++++---
 include/linux/mlx4/device.h                  |    6 ++++++
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 2e024a6..2fe9fe5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -142,12 +142,6 @@ struct mlx4_port_config {
 	struct pci_dev *pdev;
 };
 
-static inline int mlx4_master_get_num_eqs(struct mlx4_dev *dev)
-{
-	return dev->caps.reserved_eqs +
-		MLX4_MFUNC_EQ_NUM * (dev->num_slaves + 1);
-}
-
 int mlx4_check_port_params(struct mlx4_dev *dev,
 			   enum mlx4_port_type *port_type)
 {
@@ -217,6 +211,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
 	}
 
 	dev->caps.num_ports	     = dev_cap->num_ports;
+	dev->phys_caps.num_phys_eqs  = MLX4_MAX_EQ_NUM;
 	for (i = 1; i <= dev->caps.num_ports; ++i) {
 		dev->caps.vl_cap[i]	    = dev_cap->max_vl[i];
 		dev->caps.ib_mtu_cap[i]	    = dev_cap->ib_mtu[i];
@@ -810,9 +805,8 @@ static int mlx4_init_cmpt_table(struct mlx4_dev *dev, u64 cmpt_base,
 	if (err)
 		goto err_srq;
 
-	num_eqs = (mlx4_is_master(dev)) ?
-		roundup_pow_of_two(mlx4_master_get_num_eqs(dev)) :
-		dev->caps.num_eqs;
+	num_eqs = (mlx4_is_master(dev)) ? dev->phys_caps.num_phys_eqs :
+		  dev->caps.num_eqs;
 	err = mlx4_init_icm_table(dev, &priv->eq_table.cmpt_table,
 				  cmpt_base +
 				  ((u64) (MLX4_CMPT_TYPE_EQ *
@@ -874,9 +868,8 @@ static int mlx4_init_icm(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap,
 	}
 
 
-	num_eqs = (mlx4_is_master(dev)) ?
-		roundup_pow_of_two(mlx4_master_get_num_eqs(dev)) :
-		dev->caps.num_eqs;
+	num_eqs = (mlx4_is_master(dev)) ? dev->phys_caps.num_phys_eqs :
+		   dev->caps.num_eqs;
 	err = mlx4_init_icm_table(dev, &priv->eq_table.table,
 				  init_hca->eqc_base, dev_cap->eqc_entry_sz,
 				  num_eqs, num_eqs, 0, 0);
diff --git a/drivers/net/ethernet/mellanox/mlx4/profile.c b/drivers/net/ethernet/mellanox/mlx4/profile.c
index 06e5ade..b83bc92 100644
--- a/drivers/net/ethernet/mellanox/mlx4/profile.c
+++ b/drivers/net/ethernet/mellanox/mlx4/profile.c
@@ -126,7 +126,9 @@ u64 mlx4_make_profile(struct mlx4_dev *dev,
 	profile[MLX4_RES_AUXC].num    = request->num_qp;
 	profile[MLX4_RES_SRQ].num     = request->num_srq;
 	profile[MLX4_RES_CQ].num      = request->num_cq;
-	profile[MLX4_RES_EQ].num      = min_t(unsigned, dev_cap->max_eqs, MAX_MSIX);
+	profile[MLX4_RES_EQ].num      = mlx4_is_mfunc(dev) ?
+					dev->phys_caps.num_phys_eqs :
+					min_t(unsigned, dev_cap->max_eqs, MAX_MSIX);
 	profile[MLX4_RES_DMPT].num    = request->num_mpt;
 	profile[MLX4_RES_CMPT].num    = MLX4_NUM_CMPTS;
 	profile[MLX4_RES_MTT].num     = request->num_mtt * (1 << log_mtts_per_seg);
@@ -215,9 +217,10 @@ u64 mlx4_make_profile(struct mlx4_dev *dev,
 			init_hca->log_num_cqs = profile[i].log_num;
 			break;
 		case MLX4_RES_EQ:
-			dev->caps.num_eqs     = profile[i].num;
+			dev->caps.num_eqs     = roundup_pow_of_two(min_t(unsigned, dev_cap->max_eqs,
+									 MAX_MSIX));
 			init_hca->eqc_base    = profile[i].start;
-			init_hca->log_num_eqs = profile[i].log_num;
+			init_hca->log_num_eqs = ilog2(dev->caps.num_eqs);
 			break;
 		case MLX4_RES_DMPT:
 			dev->caps.num_mpts	= profile[i].num;
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 6e27fa9..6a8f002 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -64,6 +64,7 @@ enum {
 	MLX4_MAX_NUM_PF		= 16,
 	MLX4_MAX_NUM_VF		= 64,
 	MLX4_MFUNC_MAX		= 80,
+	MLX4_MAX_EQ_NUM		= 1024,
 	MLX4_MFUNC_EQ_NUM	= 4,
 	MLX4_MFUNC_MAX_EQES     = 8,
 	MLX4_MFUNC_EQE_MASK     = (MLX4_MFUNC_MAX_EQES - 1)
@@ -239,6 +240,10 @@ static inline u64 mlx4_fw_ver(u64 major, u64 minor, u64 subminor)
 	return (major << 32) | (minor << 16) | subminor;
 }
 
+struct mlx4_phys_caps {
+	u32			num_phys_eqs;
+};
+
 struct mlx4_caps {
 	u64			fw_ver;
 	u32			function;
@@ -499,6 +504,7 @@ struct mlx4_dev {
 	unsigned long		flags;
 	unsigned long		num_slaves;
 	struct mlx4_caps	caps;
+	struct mlx4_phys_caps	phys_caps;
 	struct radix_tree_root	qp_table_tree;
 	u8			rev_id;
 	char			board_id[MLX4_BOARD_ID_LEN];
-- 
1.7.1

^ permalink raw reply related

* [PATCH net 1/6] net/mlx4_core: Fix the slave_id out-of-range test in mlx4_eq_int
From: Yevgeny Petrilin @ 2012-05-30 19:19 UTC (permalink / raw)
  To: davem; +Cc: netdev, ogerlitz, Jack Morgenstein

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

Ths fixes the comparison in the FLR (Function Level Reset) event case.

Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/eq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index 3b6f8ef..bce98d9 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -426,7 +426,7 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq)
 
 			mlx4_dbg(dev, "FLR event for slave: %d\n", flr_slave);
 
-			if (flr_slave > dev->num_slaves) {
+			if (flr_slave >= dev->num_slaves) {
 				mlx4_warn(dev,
 					  "Got FLR for unknown function: %d\n",
 					  flr_slave);
-- 
1.7.1

^ permalink raw reply related

* [PATCH net 2/6] net/mlx4_core: Fix number of EQs used in ICM initialisation
From: Yevgeny Petrilin @ 2012-05-30 19:14 UTC (permalink / raw)
  Cc: netdev, ogerlitz, Marcel Apfelbaum, Jack Morgenstein
In-Reply-To: <1338405295-15427-1-git-send-email-yevgenyp@mellanox.com>

From: Marcel Apfelbaum <marcela@dev.mellanox.co.il>

In SRIOV mode, the number of EQs used when computing the total ICM size
was incorrect.

To fix this, we do the following:
1. We add a new structure to mlx4_dev, mlx4_phys_caps, to contain physical HCA
   capabilities.  The PPF uses the phys capabilities when it computes things
   like ICM size.

   The dev_caps structure will then contain the paravirtualized values, making
   bookkeeping much easier in SRIOV mode. We add a structure rather than a
   single parameter because there will be other fields in the phys_caps.

   The first field we add to the mlx4_phys_caps structure is num_phys_eqs.

2. In INIT_HCA, when running in SRIOV mode, the "log_num_eqs" parameter
   passed to the FW is the number of EQs per VF/PF; each function (PF or VF)
   has this number of EQs available.

   However, the total number of EQs which must be allowed for in the ICM is
   (1 << log_num_eqs) * (#VFs + #PFs).  Rather than compute this quantity,
   we allocate ICM space for 1024 EQs (which is the device maximum
   number of EQs, and which is the value we place in the mlx4_phys_caps structure).

   For INIT_HCA, however, we use the per-function number of EQs as described
   above.

Signed-off-by: Marcel Apfelbaum <marcela@dev.mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/main.c    |   17 +++++------------
 drivers/net/ethernet/mellanox/mlx4/profile.c |    9 ++++++---
 include/linux/mlx4/device.h                  |    6 ++++++
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 2e024a6..2fe9fe5 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -142,12 +142,6 @@ struct mlx4_port_config {
 	struct pci_dev *pdev;
 };
 
-static inline int mlx4_master_get_num_eqs(struct mlx4_dev *dev)
-{
-	return dev->caps.reserved_eqs +
-		MLX4_MFUNC_EQ_NUM * (dev->num_slaves + 1);
-}
-
 int mlx4_check_port_params(struct mlx4_dev *dev,
 			   enum mlx4_port_type *port_type)
 {
@@ -217,6 +211,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
 	}
 
 	dev->caps.num_ports	     = dev_cap->num_ports;
+	dev->phys_caps.num_phys_eqs  = MLX4_MAX_EQ_NUM;
 	for (i = 1; i <= dev->caps.num_ports; ++i) {
 		dev->caps.vl_cap[i]	    = dev_cap->max_vl[i];
 		dev->caps.ib_mtu_cap[i]	    = dev_cap->ib_mtu[i];
@@ -810,9 +805,8 @@ static int mlx4_init_cmpt_table(struct mlx4_dev *dev, u64 cmpt_base,
 	if (err)
 		goto err_srq;
 
-	num_eqs = (mlx4_is_master(dev)) ?
-		roundup_pow_of_two(mlx4_master_get_num_eqs(dev)) :
-		dev->caps.num_eqs;
+	num_eqs = (mlx4_is_master(dev)) ? dev->phys_caps.num_phys_eqs :
+		  dev->caps.num_eqs;
 	err = mlx4_init_icm_table(dev, &priv->eq_table.cmpt_table,
 				  cmpt_base +
 				  ((u64) (MLX4_CMPT_TYPE_EQ *
@@ -874,9 +868,8 @@ static int mlx4_init_icm(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap,
 	}
 
 
-	num_eqs = (mlx4_is_master(dev)) ?
-		roundup_pow_of_two(mlx4_master_get_num_eqs(dev)) :
-		dev->caps.num_eqs;
+	num_eqs = (mlx4_is_master(dev)) ? dev->phys_caps.num_phys_eqs :
+		   dev->caps.num_eqs;
 	err = mlx4_init_icm_table(dev, &priv->eq_table.table,
 				  init_hca->eqc_base, dev_cap->eqc_entry_sz,
 				  num_eqs, num_eqs, 0, 0);
diff --git a/drivers/net/ethernet/mellanox/mlx4/profile.c b/drivers/net/ethernet/mellanox/mlx4/profile.c
index 06e5ade..b83bc92 100644
--- a/drivers/net/ethernet/mellanox/mlx4/profile.c
+++ b/drivers/net/ethernet/mellanox/mlx4/profile.c
@@ -126,7 +126,9 @@ u64 mlx4_make_profile(struct mlx4_dev *dev,
 	profile[MLX4_RES_AUXC].num    = request->num_qp;
 	profile[MLX4_RES_SRQ].num     = request->num_srq;
 	profile[MLX4_RES_CQ].num      = request->num_cq;
-	profile[MLX4_RES_EQ].num      = min_t(unsigned, dev_cap->max_eqs, MAX_MSIX);
+	profile[MLX4_RES_EQ].num      = mlx4_is_mfunc(dev) ?
+					dev->phys_caps.num_phys_eqs :
+					min_t(unsigned, dev_cap->max_eqs, MAX_MSIX);
 	profile[MLX4_RES_DMPT].num    = request->num_mpt;
 	profile[MLX4_RES_CMPT].num    = MLX4_NUM_CMPTS;
 	profile[MLX4_RES_MTT].num     = request->num_mtt * (1 << log_mtts_per_seg);
@@ -215,9 +217,10 @@ u64 mlx4_make_profile(struct mlx4_dev *dev,
 			init_hca->log_num_cqs = profile[i].log_num;
 			break;
 		case MLX4_RES_EQ:
-			dev->caps.num_eqs     = profile[i].num;
+			dev->caps.num_eqs     = roundup_pow_of_two(min_t(unsigned, dev_cap->max_eqs,
+									 MAX_MSIX));
 			init_hca->eqc_base    = profile[i].start;
-			init_hca->log_num_eqs = profile[i].log_num;
+			init_hca->log_num_eqs = ilog2(dev->caps.num_eqs);
 			break;
 		case MLX4_RES_DMPT:
 			dev->caps.num_mpts	= profile[i].num;
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 6e27fa9..6a8f002 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -64,6 +64,7 @@ enum {
 	MLX4_MAX_NUM_PF		= 16,
 	MLX4_MAX_NUM_VF		= 64,
 	MLX4_MFUNC_MAX		= 80,
+	MLX4_MAX_EQ_NUM		= 1024,
 	MLX4_MFUNC_EQ_NUM	= 4,
 	MLX4_MFUNC_MAX_EQES     = 8,
 	MLX4_MFUNC_EQE_MASK     = (MLX4_MFUNC_MAX_EQES - 1)
@@ -239,6 +240,10 @@ static inline u64 mlx4_fw_ver(u64 major, u64 minor, u64 subminor)
 	return (major << 32) | (minor << 16) | subminor;
 }
 
+struct mlx4_phys_caps {
+	u32			num_phys_eqs;
+};
+
 struct mlx4_caps {
 	u64			fw_ver;
 	u32			function;
@@ -499,6 +504,7 @@ struct mlx4_dev {
 	unsigned long		flags;
 	unsigned long		num_slaves;
 	struct mlx4_caps	caps;
+	struct mlx4_phys_caps	phys_caps;
 	struct radix_tree_root	qp_table_tree;
 	u8			rev_id;
 	char			board_id[MLX4_BOARD_ID_LEN];
-- 
1.7.1

^ permalink raw reply related

* [PATCH net 4/6] net/mlx4_core: Fixes for VF / Guest startup flow
From: Yevgeny Petrilin @ 2012-05-30 19:14 UTC (permalink / raw)
  Cc: netdev, ogerlitz, Jack Morgenstein
In-Reply-To: <1338405295-15427-1-git-send-email-yevgenyp@mellanox.com>

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

- pass the following parameters:
  - firmware version (added QUERY_FW paravirtualization for that)

  - disable Blueflame on slaves. KVM disables write combining on guests,
    and we get better performance without BF in this case. (This requires
    QUERY_DEV_CAP paravirtualization, also in this commit)

  - max qp rdma as destination

- get rid of a chunk of "if (0)" dead code

Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/cmd.c  |    4 +-
 drivers/net/ethernet/mellanox/mlx4/fw.c   |   46 +++++++++++++++++++++++++++++
 drivers/net/ethernet/mellanox/mlx4/main.c |   17 +++-------
 drivers/net/ethernet/mellanox/mlx4/mlx4.h |   10 ++++++
 4 files changed, 63 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index 1bcead1..842c8ce 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -617,7 +617,7 @@ static struct mlx4_cmd_info cmd_info[] = {
 		.out_is_imm = false,
 		.encode_slave_id = false,
 		.verify = NULL,
-		.wrapper = NULL
+		.wrapper = mlx4_QUERY_FW_wrapper
 	},
 	{
 		.opcode = MLX4_CMD_QUERY_HCA,
@@ -635,7 +635,7 @@ static struct mlx4_cmd_info cmd_info[] = {
 		.out_is_imm = false,
 		.encode_slave_id = false,
 		.verify = NULL,
-		.wrapper = NULL
+		.wrapper = mlx4_QUERY_DEV_CAP_wrapper
 	},
 	{
 		.opcode = MLX4_CMD_QUERY_FUNC_CAP,
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 68f5cd6..7f2a4a6 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -669,6 +669,28 @@ out:
 	return err;
 }
 
+int mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, int slave,
+			       struct mlx4_vhcr *vhcr,
+			       struct mlx4_cmd_mailbox *inbox,
+			       struct mlx4_cmd_mailbox *outbox,
+			       struct mlx4_cmd_info *cmd)
+{
+	int	err = 0;
+	u8	field;
+
+	err = mlx4_cmd_box(dev, 0, outbox->dma, 0, 0, MLX4_CMD_QUERY_DEV_CAP,
+			   MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE);
+	if (err)
+		return err;
+
+	/* For guests, report Blueflame disabled */
+	MLX4_GET(field, outbox->buf, QUERY_DEV_CAP_BF_OFFSET);
+	field &= 0x7f;
+	MLX4_PUT(outbox->buf, field, QUERY_DEV_CAP_BF_OFFSET);
+
+	return 0;
+}
+
 int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave,
 			    struct mlx4_vhcr *vhcr,
 			    struct mlx4_cmd_mailbox *inbox,
@@ -860,6 +882,9 @@ int mlx4_QUERY_FW(struct mlx4_dev *dev)
 		((fw_ver & 0xffff0000ull) >> 16) |
 		((fw_ver & 0x0000ffffull) << 16);
 
+	if (mlx4_is_slave(dev))
+		goto out;
+
 	MLX4_GET(lg, outbox, QUERY_FW_PPF_ID);
 	dev->caps.function = lg;
 
@@ -927,6 +952,27 @@ out:
 	return err;
 }
 
+int mlx4_QUERY_FW_wrapper(struct mlx4_dev *dev, int slave,
+			  struct mlx4_vhcr *vhcr,
+			  struct mlx4_cmd_mailbox *inbox,
+			  struct mlx4_cmd_mailbox *outbox,
+			  struct mlx4_cmd_info *cmd)
+{
+	u8 *outbuf;
+	int err;
+
+	outbuf = outbox->buf;
+	err = mlx4_cmd_box(dev, 0, outbox->dma, 0, 0, MLX4_CMD_QUERY_FW,
+			    MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE);
+	if (err)
+		return err;
+
+	/* for slaves, zero out everything except FW version */
+	outbuf[0] = outbuf[1] = 0;
+	memset(&outbuf[8], 0, QUERY_FW_OUT_SIZE - 8);
+	return 0;
+}
+
 static void get_board_id(void *vsd, char *board_id)
 {
 	int i;
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 2fe9fe5..7f71be0 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -430,12 +430,17 @@ static int mlx4_slave_cap(struct mlx4_dev *dev)
 	mlx4_log_num_mgm_entry_size = hca_param.log_mc_entry_sz;
 
 	memset(&dev_cap, 0, sizeof(dev_cap));
+	dev->caps.max_qp_dest_rdma = 1 << hca_param.log_rd_per_qp;
 	err = mlx4_dev_cap(dev, &dev_cap);
 	if (err) {
 		mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n");
 		return err;
 	}
 
+	err = mlx4_QUERY_FW(dev);
+	if (err)
+		mlx4_err(dev, "QUERY_FW command failed: could not get FW version.\n");
+
 	page_size = ~dev->caps.page_size_cap + 1;
 	mlx4_warn(dev, "HCA minimum page size:%d\n", page_size);
 	if (page_size > PAGE_SIZE) {
@@ -499,18 +504,6 @@ static int mlx4_slave_cap(struct mlx4_dev *dev)
 		return -ENODEV;
 	}
 
-#if 0
-	mlx4_warn(dev, "sqp_demux:%d\n", dev->caps.sqp_demux);
-	mlx4_warn(dev, "num_uars:%d reserved_uars:%d uar region:0x%x bar2:0x%llx\n",
-		  dev->caps.num_uars, dev->caps.reserved_uars,
-		  dev->caps.uar_page_size * dev->caps.num_uars,
-		  pci_resource_len(dev->pdev, 2));
-	mlx4_warn(dev, "num_eqs:%d reserved_eqs:%d\n", dev->caps.num_eqs,
-		  dev->caps.reserved_eqs);
-	mlx4_warn(dev, "num_pds:%d reserved_pds:%d slave_pd_shift:%d pd_base:%d\n",
-		  dev->caps.num_pds, dev->caps.reserved_pds,
-		  dev->caps.slave_pd_shift, dev->caps.pd_base);
-#endif
 	return 0;
 }
 
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index 86b6e5a..e5d2022 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -1039,6 +1039,11 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev);
 void mlx4_free_resource_tracker(struct mlx4_dev *dev,
 				enum mlx4_res_tracker_free_type type);
 
+int mlx4_QUERY_FW_wrapper(struct mlx4_dev *dev, int slave,
+			  struct mlx4_vhcr *vhcr,
+			  struct mlx4_cmd_mailbox *inbox,
+			  struct mlx4_cmd_mailbox *outbox,
+			  struct mlx4_cmd_info *cmd);
 int mlx4_SET_PORT_wrapper(struct mlx4_dev *dev, int slave,
 			  struct mlx4_vhcr *vhcr,
 			  struct mlx4_cmd_mailbox *inbox,
@@ -1054,6 +1059,11 @@ int mlx4_CLOSE_PORT_wrapper(struct mlx4_dev *dev, int slave,
 			    struct mlx4_cmd_mailbox *inbox,
 			    struct mlx4_cmd_mailbox *outbox,
 			    struct mlx4_cmd_info *cmd);
+int mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, int slave,
+			       struct mlx4_vhcr *vhcr,
+			       struct mlx4_cmd_mailbox *inbox,
+			       struct mlx4_cmd_mailbox *outbox,
+			       struct mlx4_cmd_info *cmd);
 int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave,
 			    struct mlx4_vhcr *vhcr,
 			    struct mlx4_cmd_mailbox *inbox,
-- 
1.7.1

^ permalink raw reply related

* [PATCH net 0/6] batch of mlx4 fixes, mostly to SRIOV
From: Yevgeny Petrilin @ 2012-05-30 19:14 UTC (permalink / raw)
  Cc: netdev, ogerlitz, Yevgeny Petrilin, Jack Morgenstein

From: Yevgeny Petrilin <yevgenyp@mellanox.co.il>

Hi Dave,

Batch of fixes to the mlx4_core and mlx4_en drivers, prepared 
by Jack Morgenstein, who leads our SRIOV development efforts and 
fix various issues all except for one, relate to the driver 
SRIOV functionality.

Jack Morgenstein (5):
  net/mlx4_core: Fix the slave_id out-of-range test in mlx4_eq_int
  net/mlx4_en: Fix improper use of "port" parameter in mlx4_en_event
  net/mlx4_core: Fixes for VF / Guest startup flow
  net/mlx4_core: Check port out-of-range before using in mlx4_slave_cap
  net/mlx4_core: Fix obscure mlx4_cmd_box parameter in QUERY_DEV_CAP

Marcel Apfelbaum (1):
  net/mlx4_core: Fix number of EQs used in ICM initialisation

 drivers/net/ethernet/mellanox/mlx4/cmd.c     |    4 +-
 drivers/net/ethernet/mellanox/mlx4/en_main.c |   12 ++++---
 drivers/net/ethernet/mellanox/mlx4/eq.c      |    2 +-
 drivers/net/ethernet/mellanox/mlx4/fw.c      |   51 ++++++++++++++++++++++++--
 drivers/net/ethernet/mellanox/mlx4/main.c    |   40 +++++++--------------
 drivers/net/ethernet/mellanox/mlx4/mlx4.h    |   10 +++++
 drivers/net/ethernet/mellanox/mlx4/profile.c |    9 +++--
 include/linux/mlx4/device.h                  |    6 +++
 8 files changed, 93 insertions(+), 41 deletions(-)

Cc: Jack Morgenstein <jackm@dev.mellanox.co.il>

^ permalink raw reply

* [PATCH net 1/6] net/mlx4_core: Fix the slave_id out-of-range test in mlx4_eq_int
From: Yevgeny Petrilin @ 2012-05-30 19:14 UTC (permalink / raw)
  Cc: netdev, ogerlitz, Jack Morgenstein
In-Reply-To: <1338405295-15427-1-git-send-email-yevgenyp@mellanox.com>

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

Ths fixes the comparison in the FLR (Function Level Reset) event case.

Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/eq.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index 3b6f8ef..bce98d9 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -426,7 +426,7 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq)
 
 			mlx4_dbg(dev, "FLR event for slave: %d\n", flr_slave);
 
-			if (flr_slave > dev->num_slaves) {
+			if (flr_slave >= dev->num_slaves) {
 				mlx4_warn(dev,
 					  "Got FLR for unknown function: %d\n",
 					  flr_slave);
-- 
1.7.1

^ permalink raw reply related

* [PATCH net 6/6] net/mlx4_core: Fix obscure mlx4_cmd_box parameter in QUERY_DEV_CAP
From: Yevgeny Petrilin @ 2012-05-30 19:14 UTC (permalink / raw)
  Cc: netdev, ogerlitz, Jack Morgenstein
In-Reply-To: <1338405295-15427-1-git-send-email-yevgenyp@mellanox.com>

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

The "!mlx4_is_slave" is totally confusing.  Fix with
constant MLX4_CMD_NATIVE, which is the intended behavior.

Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/fw.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 7f2a4a6..9c83bb8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -412,7 +412,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
 	outbox = mailbox->buf;
 
 	err = mlx4_cmd_box(dev, 0, mailbox->dma, 0, 0, MLX4_CMD_QUERY_DEV_CAP,
-			   MLX4_CMD_TIME_CLASS_A, !mlx4_is_slave(dev));
+			   MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE);
 	if (err)
 		goto out;
 
@@ -590,8 +590,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
 
 		for (i = 1; i <= dev_cap->num_ports; ++i) {
 			err = mlx4_cmd_box(dev, 0, mailbox->dma, i, 0, MLX4_CMD_QUERY_PORT,
-					   MLX4_CMD_TIME_CLASS_B,
-					   !mlx4_is_slave(dev));
+					   MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
 			if (err)
 				goto out;
 
-- 
1.7.1

^ permalink raw reply related

* [PATCH net 3/6] net/mlx4_en: Fix improper use of "port" parameter in mlx4_en_event
From: Yevgeny Petrilin @ 2012-05-30 19:14 UTC (permalink / raw)
  Cc: netdev, ogerlitz, Jack Morgenstein
In-Reply-To: <1338405295-15427-1-git-send-email-yevgenyp@mellanox.com>

From: Jack Morgenstein <jackm@dev.mellanox.co.il>

Port is used as an array index before we know if that is proper.

For example, in the catas event case, port is zero; however,
the port index should lie in the range (1..2).

Fix this by using 'port' only in the events where it is of interest.

Test for port out of range in the default (unhandled event) case,
and do not output a message if it is not an ethernet port.

Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_main.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_main.c b/drivers/net/ethernet/mellanox/mlx4/en_main.c
index 988b242..69ba572 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_main.c
@@ -136,13 +136,12 @@ static void mlx4_en_event(struct mlx4_dev *dev, void *endev_ptr,
 	struct mlx4_en_dev *mdev = (struct mlx4_en_dev *) endev_ptr;
 	struct mlx4_en_priv *priv;
 
-	if (!mdev->pndev[port])
-		return;
-
-	priv = netdev_priv(mdev->pndev[port]);
 	switch (event) {
 	case MLX4_DEV_EVENT_PORT_UP:
 	case MLX4_DEV_EVENT_PORT_DOWN:
+		if (!mdev->pndev[port])
+			return;
+		priv = netdev_priv(mdev->pndev[port]);
 		/* To prevent races, we poll the link state in a separate
 		  task rather than changing it here */
 		priv->link_state = event;
@@ -154,7 +153,10 @@ static void mlx4_en_event(struct mlx4_dev *dev, void *endev_ptr,
 		break;
 
 	default:
-		mlx4_warn(mdev, "Unhandled event: %d\n", event);
+		if (port < 1 || port > dev->caps.num_ports ||
+		    !mdev->pndev[port])
+			return;
+		mlx4_warn(mdev, "Unhandled event %d for port %d\n", event, port);
 	}
 }
 
-- 
1.7.1

^ permalink raw reply related

* Re: [RFC PATCH 4/4] inet: use second hash in inet_csk_get_port
From: Alexandru Copot @ 2012-05-30 19:11 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, netdev,
	Daniel Baluta, Lucian Grijincu
In-Reply-To: <1338398456.2760.338.camel@edumazet-glaptop>

On Wed, May 30, 2012 at 8:20 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Wed, 2012-05-30 at 10:36 +0300, Alexandru Copot wrote:
>
>> +struct inet_bind_bucket *
>> +inet4_find_bind_buckets(struct sock *sk,
>> +                     unsigned short port,
>> +                     struct inet_bind_hashbucket **p_bhead,
>> +                     struct inet_bind_hashbucket **p_portaddr_bhead)
>> +{
>> +     struct net *net = sock_net(sk);
>> +     struct inet_hashinfo *hinfo = sk->sk_prot->h.hashinfo;
>> +     struct inet_bind_bucket *tb = NULL;
>> +     struct hlist_node *node;
>> +
>> +     struct inet_bind_hashbucket *bhead, *portaddr_bhead, *portaddrany_bhead;
>> +     bhead = &hinfo->bhash[inet_bhashfn(net, port, hinfo->bhash_size)];
>> +     portaddr_bhead = inet4_portaddr_hashbucket(hinfo, net,
>> +                             sk_rcv_saddr(sk), port);
>> +     portaddrany_bhead = inet4_portaddr_hashbucket(hinfo, net,
>> +                                             INADDR_ANY, port);
>> +
>> +     *p_portaddr_bhead = portaddr_bhead;
>> +     *p_bhead = bhead;
>> +
>> +     /*
>> +      * prevent dead locks by always taking locks in a fixed order:
>> +      * - always take the port-only lock first. This is done because in some
>> +      *   other places this is the lock taken, being folllowed in only some
>> +      *   cases by the portaddr lock.
>> +      * - between portaddr and portaddrany always choose the one with the
>> +      *   lower address. Unlock ordering is not important, as long as the
>> +      *   locking order is consistent.
>> +      * - make sure to not take the same lock twice
>> +      */
>> +     spin_lock(&bhead->lock);
>> +     if (portaddr_bhead > portaddrany_bhead) {
>> +             spin_lock(&portaddrany_bhead->lock);
>> +             spin_lock(&portaddr_bhead->lock);
>> +     } else if (portaddr_bhead < portaddrany_bhead) {
>> +             spin_lock(&portaddr_bhead->lock);
>> +             spin_lock(&portaddrany_bhead->lock);
>> +     } else {
>> +             spin_lock(&portaddr_bhead->lock);
>> +     }
>> +
>> +     if (sk_rcv_saddr(sk) != INADDR_ANY) {
>> +             struct inet_bind_hashbucket *_head;
>> +
>> +             _head = portaddr_bhead;
>> +             if (bhead->count < portaddr_bhead->count) {
>> +                     _head = bhead;
>> +                     inet_bind_bucket_for_each(tb, node, &_head->chain)
>> +                             if ((net_eq(ib_net(tb), net)) &&
>> +                                 (tb->port == port) &&
>> +                                 (tb->ib_addr_ipv4 == sk_rcv_saddr(sk)))
>> +                                     goto found;
>> +             } else {
>> +                     inet_portaddr_bind_bucket_for_each(tb, node, &_head->chain)
>> +                             if ((net_eq(ib_net(tb), net)) &&
>> +                                 (tb->port == port) &&
>> +                                 (tb->ib_addr_ipv4 == sk_rcv_saddr(sk)))
>> +                                     goto found;
>> +             }
>> +             _head = portaddrany_bhead;
>> +             if (bhead->count < portaddrany_bhead->count) {
>> +                     _head = bhead;
>> +                     inet_bind_bucket_for_each(tb, node, &_head->chain)
>> +                             if ((ib_net(tb) == net) &&
>> +                                 (tb->port == port) &&
>> +                                 (tb->ib_addr_ipv4 == INADDR_ANY))
>> +                                     goto found;
>> +             } else {
>> +                     inet_portaddr_bind_bucket_for_each(tb, node, &_head->chain)
>> +                             if ((ib_net(tb) == net) &&
>> +                                 (tb->port == port) &&
>> +                                 (tb->ib_addr_ipv4 == INADDR_ANY))
>> +                                     goto found;
>> +             }
>> +     } else {
>> +             inet_bind_bucket_for_each(tb, node, &bhead->chain)
>> +                     if ((ib_net(tb) == net) && (tb->port == port))
>> +                             goto found;
>> +     }
>> +
>> +     tb = NULL;
>> +found:
>> +     if (portaddr_bhead != portaddrany_bhead)
>> +             spin_unlock(&portaddrany_bhead->lock);
>> +
>> +     /* the other locks remain taken, as the caller
>> +      * may want to change the hash tabels */
>> +     return tb;
>> +}
>> +
>> +
>
> How this is going to work with IPv6 sockets in the middle of the
> chains ?

Now I see it might not work that well. I think I should just skip them
here and only check the IPv4 sockets.

> Also, comments are not properly formatted, they should all look like :
>
>        /* the other locks remain taken, as the caller
>         * may want to change the hash tables
>         */
>
> And finally, make sure LOCKDEP is happy with your locking code.
>
I will check that too.

^ permalink raw reply

* Re: [PATCH] 8021q/vlan: process NETDEV_GOING_DOWN
From: Eldad Zack @ 2012-05-30 19:11 UTC (permalink / raw)
  To: David Miller; +Cc: kaber, netdev, linux-kernel
In-Reply-To: <20120529.204040.644013889059321702.davem@davemloft.net>


On Tue, 29 May 2012, David Miller wrote:
> From: Eldad Zack <eldad@fogrefinery.com>
> Date: Wed, 30 May 2012 00:30:35 +0200
> 
> > In the current flow, when you take down a physical device that has
> > VLANs configured on it, the NETDEV_GOING_DOWN notification will be
> > sent too late, i.e., no data can be sent to the wire anymore.
> 
> Why do you need to send data?  Any queued up data should be purged not
> sent.

In case a certain protocol needs to send a "dying gasp" packet, when you 
administrativly shutdown the port (which is also what happens when you 
restart the machine).

I'm working on an implementation of such protocol (LLDP) on my free 
time. The specification says that it should send a (compact) shutdown 
message, with the TTL field set to zero, so that other stations are informed
of the shutdown - and it works fine with the main interface, but not with 
VLANs, since the notifier is called too late.
With that small change it works as well.

Another use for it would be the Ethernet CFM, which has a similar 
requirement.

On the other hand, I might've missed something. Is there a better way to 
be informed of a shutdown than listening for the GOING_DOWN 
event, so the frame can be sent to the wire when it's appropriate?

Eldad

^ permalink raw reply

* [PATCH] netdevice: Update netif_dbg for CONFIG_DYNAMIC_DEBUG
From: Joe Perches @ 2012-05-30 17:43 UTC (permalink / raw)
  To: netdev; +Cc: Jim Cromie, Jason Baron, David Miller

Make netif_dbg use dynamic debugging whenever
CONFIG_DYNAMIC_DEBUG is enabled.

commit b558c96ffa53
("dynamic_debug: make dynamic-debug supersede DEBUG ccflag")
missed updating the netif_dbg variant.

Signed-off-by: Joe Perches <joe@perches.com>
---
 include/linux/netdevice.h |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index e7fd468..d94cb14 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2795,15 +2795,15 @@ do {								\
 #define netif_info(priv, type, dev, fmt, args...)		\
 	netif_level(info, priv, type, dev, fmt, ##args)
 
-#if defined(DEBUG)
-#define netif_dbg(priv, type, dev, format, args...)		\
-	netif_printk(priv, type, KERN_DEBUG, dev, format, ##args)
-#elif defined(CONFIG_DYNAMIC_DEBUG)
+#if defined(CONFIG_DYNAMIC_DEBUG)
 #define netif_dbg(priv, type, netdev, format, args...)		\
 do {								\
 	if (netif_msg_##type(priv))				\
 		dynamic_netdev_dbg(netdev, format, ##args);	\
 } while (0)
+#elif defined(DEBUG)
+#define netif_dbg(priv, type, dev, format, args...)		\
+	netif_printk(priv, type, KERN_DEBUG, dev, format, ##args)
 #else
 #define netif_dbg(priv, type, dev, format, args...)			\
 ({									\

^ permalink raw reply related

* Re: [RFC PATCH 4/4] inet: use second hash in inet_csk_get_port
From: Eric Dumazet @ 2012-05-30 17:20 UTC (permalink / raw)
  To: Alexandru Copot
  Cc: davem, gerrit, kuznet, jmorris, yoshfuji, kaber, netdev,
	Daniel Baluta, Lucian Grijincu
In-Reply-To: <1338363410-6562-5-git-send-email-alex.mihai.c@gmail.com>

On Wed, 2012-05-30 at 10:36 +0300, Alexandru Copot wrote:

> +struct inet_bind_bucket *
> +inet4_find_bind_buckets(struct sock *sk,
> +			unsigned short port,
> +			struct inet_bind_hashbucket **p_bhead,
> +			struct inet_bind_hashbucket **p_portaddr_bhead)
> +{
> +	struct net *net = sock_net(sk);
> +	struct inet_hashinfo *hinfo = sk->sk_prot->h.hashinfo;
> +	struct inet_bind_bucket *tb = NULL;
> +	struct hlist_node *node;
> +
> +	struct inet_bind_hashbucket *bhead, *portaddr_bhead, *portaddrany_bhead;
> +	bhead = &hinfo->bhash[inet_bhashfn(net, port, hinfo->bhash_size)];
> +	portaddr_bhead = inet4_portaddr_hashbucket(hinfo, net,
> +				sk_rcv_saddr(sk), port);
> +	portaddrany_bhead = inet4_portaddr_hashbucket(hinfo, net,
> +						INADDR_ANY, port);
> +
> +	*p_portaddr_bhead = portaddr_bhead;
> +	*p_bhead = bhead;
> +
> +	/*
> +	 * prevent dead locks by always taking locks in a fixed order:
> +	 * - always take the port-only lock first. This is done because in some
> +	 *   other places this is the lock taken, being folllowed in only some
> +	 *   cases by the portaddr lock.
> +	 * - between portaddr and portaddrany always choose the one with the
> +	 *   lower address. Unlock ordering is not important, as long as the
> +	 *   locking order is consistent.
> +	 * - make sure to not take the same lock twice
> +	 */
> +	spin_lock(&bhead->lock);
> +	if (portaddr_bhead > portaddrany_bhead) {
> +		spin_lock(&portaddrany_bhead->lock);
> +		spin_lock(&portaddr_bhead->lock);
> +	} else if (portaddr_bhead < portaddrany_bhead) {
> +		spin_lock(&portaddr_bhead->lock);
> +		spin_lock(&portaddrany_bhead->lock);
> +	} else {
> +		spin_lock(&portaddr_bhead->lock);
> +	}
> +
> +	if (sk_rcv_saddr(sk) != INADDR_ANY) {
> +		struct inet_bind_hashbucket *_head;
> +
> +		_head = portaddr_bhead;
> +		if (bhead->count < portaddr_bhead->count) {
> +			_head = bhead;
> +			inet_bind_bucket_for_each(tb, node, &_head->chain)
> +				if ((net_eq(ib_net(tb), net)) &&
> +				    (tb->port == port) &&
> +				    (tb->ib_addr_ipv4 == sk_rcv_saddr(sk)))
> +					goto found;
> +		} else {
> +			inet_portaddr_bind_bucket_for_each(tb, node, &_head->chain)
> +				if ((net_eq(ib_net(tb), net)) &&
> +				    (tb->port == port) &&
> +				    (tb->ib_addr_ipv4 == sk_rcv_saddr(sk)))
> +					goto found;
> +		}
> +		_head = portaddrany_bhead;
> +		if (bhead->count < portaddrany_bhead->count) {
> +			_head = bhead;
> +			inet_bind_bucket_for_each(tb, node, &_head->chain)
> +				if ((ib_net(tb) == net) &&
> +				    (tb->port == port) &&
> +				    (tb->ib_addr_ipv4 == INADDR_ANY))
> +					goto found;
> +		} else {
> +			inet_portaddr_bind_bucket_for_each(tb, node, &_head->chain)
> +				if ((ib_net(tb) == net) &&
> +				    (tb->port == port) &&
> +				    (tb->ib_addr_ipv4 == INADDR_ANY))
> +					goto found;
> +		}
> +	} else {
> +		inet_bind_bucket_for_each(tb, node, &bhead->chain)
> +			if ((ib_net(tb) == net) && (tb->port == port))
> +				goto found;
> +	}
> +
> +	tb = NULL;
> +found:
> +	if (portaddr_bhead != portaddrany_bhead)
> +		spin_unlock(&portaddrany_bhead->lock);
> +
> +	/* the other locks remain taken, as the caller
> +	 * may want to change the hash tabels */
> +	return tb;
> +}
> +
> +

How this is going to work with IPv6 sockets in the middle of the
chains ?

Also, comments are not properly formatted, they should all look like :

	/* the other locks remain taken, as the caller
	 * may want to change the hash tables
	 */

And finally, make sure LOCKDEP is happy with your locking code.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox