netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [NEXT PATCH 2/3] qlcnic: support rcv ring configuration through ethtool
  2011-04-28  0:43 ` [NEXT PATCH 2/3] qlcnic: support rcv ring configuration through ethtool Amit Kumar Salecha
@ 2011-04-28  0:02   ` Ben Hutchings
  2011-04-28 21:05     ` Amit Salecha
  2011-04-28 20:44   ` David Miller
  1 sibling, 1 reply; 9+ messages in thread
From: Ben Hutchings @ 2011-04-28  0:02 UTC (permalink / raw)
  To: Amit Kumar Salecha
  Cc: davem, netdev, ameen.rahman, anirban.chakraborty,
	Sucheta Chakraborty

On Wed, 2011-04-27 at 17:43 -0700, Amit Kumar Salecha wrote:
> From: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
> 
> o Support ethtool command ETHTOOL_GCHANNELS and ETHTOOL_SCHANNELS.
> o Number of rcv rings configuration depend upon number of msix vector.
[...]
> --- a/drivers/net/qlcnic/qlcnic_ethtool.c
> +++ b/drivers/net/qlcnic/qlcnic_ethtool.c
> @@ -474,6 +474,49 @@ qlcnic_set_ringparam(struct net_device *dev,
>  	return qlcnic_reset_context(adapter);
>  }
>  
> +static void qlcnic_get_channels(struct net_device *dev,
> +		struct ethtool_channels *channel)
> +{
> +	struct qlcnic_adapter *adapter = netdev_priv(dev);
> +
> +	channel->max_rx = rounddown_pow_of_two(min_t(int,
> +			adapter->max_rx_ques, num_online_cpus()));
> +	channel->max_tx = adapter->max_tx_ques;
> +
> +	channel->rx_count = adapter->max_sds_rings;
> +	channel->tx_count = QLCNIC_MIN_NUM_TX_DESC_RINGS;
> +}
> +
> +static int qlcnic_set_channels(struct net_device *dev,
> +		struct ethtool_channels *channel)
> +{
> +	struct qlcnic_adapter *adapter = netdev_priv(dev);
> +	int err;
> +
> +	if (channel->other_count || channel->combined_count)
> +		return -EOPNOTSUPP;

Should be -EINVAL.

> +	if (channel->tx_count &&
> +		(channel->tx_count != QLCNIC_MIN_NUM_TX_DESC_RINGS)) {
> +		netdev_info(dev, "valid value for tx_count 0x%x\n",
> +				QLCNIC_MIN_NUM_TX_DESC_RINGS);
> +		return -EINVAL;
> +	}
[...]

If tx_count cannot be changed, why does qlcnic_get_channels() set
tx_count and max_tx to different values?

Also I don't think you should treat tx_count == 0 as a special case; it
should be rejected as invalid.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [NEXT PATCH 0/3]qlcnic: updates
@ 2011-04-28  0:43 Amit Kumar Salecha
  2011-04-28  0:43 ` [NEXT PATCH 1/3] qlcnic: fix memory leak in qlcnic_blink_led Amit Kumar Salecha
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Amit Kumar Salecha @ 2011-04-28  0:43 UTC (permalink / raw)
  To: davem; +Cc: netdev, ameen.rahman, anirban.chakraborty


Hi,
   Series of 3 to update qlcnic driver. Apply this to net-next.

-Amit

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [NEXT PATCH 1/3] qlcnic: fix memory leak in qlcnic_blink_led.
  2011-04-28  0:43 [NEXT PATCH 0/3]qlcnic: updates Amit Kumar Salecha
@ 2011-04-28  0:43 ` Amit Kumar Salecha
  2011-04-28 20:44   ` David Miller
  2011-04-28  0:43 ` [NEXT PATCH 2/3] qlcnic: support rcv ring configuration through ethtool Amit Kumar Salecha
  2011-04-28  0:43 ` [NEXT PATCH 3/3] qlcnic: Support for GBE port settings Amit Kumar Salecha
  2 siblings, 1 reply; 9+ messages in thread
From: Amit Kumar Salecha @ 2011-04-28  0:43 UTC (permalink / raw)
  To: davem; +Cc: netdev, ameen.rahman, anirban.chakraborty, Sucheta Chakraborty

From: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>

o Memory allocated in ETHTOOL_ACTIVE mode, is not getting freed. So,
  in ETHTOOL_ID_INACTIVE mode, return after freeing allocated memory.
o Using set bit instead of blink_down field, as it is also required
  in internal Loopback test and etc.

Signed-off-by: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>
---
 drivers/net/qlcnic/qlcnic.h         |    2 +-
 drivers/net/qlcnic/qlcnic_ethtool.c |   12 +++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h
index fa5b15c..f7acb80 100644
--- a/drivers/net/qlcnic/qlcnic.h
+++ b/drivers/net/qlcnic/qlcnic.h
@@ -884,6 +884,7 @@ struct qlcnic_ipaddr {
 #define __QLCNIC_RESETTING		2
 #define __QLCNIC_START_FW 		4
 #define __QLCNIC_AER			5
+#define __QLCNIC_DIAG_RES_ALLOC		6
 
 #define QLCNIC_INTERRUPT_TEST		1
 #define QLCNIC_LOOPBACK_TEST		2
@@ -913,7 +914,6 @@ struct qlcnic_adapter {
 	struct net_device *netdev;
 	struct pci_dev *pdev;
 
-	bool 		blink_was_down;
 	unsigned long state;
 	u32 flags;
 
diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c
index 615a5ab..de65847 100644
--- a/drivers/net/qlcnic/qlcnic_ethtool.c
+++ b/drivers/net/qlcnic/qlcnic_ethtool.c
@@ -772,7 +772,6 @@ static int qlcnic_set_led(struct net_device *dev,
 
 	switch (state) {
 	case ETHTOOL_ID_ACTIVE:
-		adapter->blink_was_down = false;
 		if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) {
 			if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state))
 				return -EIO;
@@ -781,7 +780,7 @@ static int qlcnic_set_led(struct net_device *dev,
 				clear_bit(__QLCNIC_RESETTING, &adapter->state);
 				return -EIO;
 			}
-			adapter->blink_was_down = true;
+			set_bit(__QLCNIC_DIAG_RES_ALLOC, &adapter->state);
 		}
 
 		if (adapter->nic_ops->config_led(adapter, 1, 0xf) == 0)
@@ -792,18 +791,17 @@ static int qlcnic_set_led(struct net_device *dev,
 		break;
 
 	case ETHTOOL_ID_INACTIVE:
-		if (adapter->nic_ops->config_led(adapter, 0, 0xf) == 0)
-			return 0;
+		if (adapter->nic_ops->config_led(adapter, 0, 0xf))
+			dev_err(&adapter->pdev->dev,
+				"Failed to reset LED blink state.\n");
 
-		dev_err(&adapter->pdev->dev,
-			"Failed to reset LED blink state.\n");
 		break;
 
 	default:
 		return -EINVAL;
 	}
 
-	if (adapter->blink_was_down) {
+	if (test_and_clear_bit(__QLCNIC_DIAG_RES_ALLOC, &adapter->state)) {
 		qlcnic_diag_free_res(dev, max_sds_rings);
 		clear_bit(__QLCNIC_RESETTING, &adapter->state);
 	}
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [NEXT PATCH 2/3] qlcnic: support rcv ring configuration through ethtool
  2011-04-28  0:43 [NEXT PATCH 0/3]qlcnic: updates Amit Kumar Salecha
  2011-04-28  0:43 ` [NEXT PATCH 1/3] qlcnic: fix memory leak in qlcnic_blink_led Amit Kumar Salecha
@ 2011-04-28  0:43 ` Amit Kumar Salecha
  2011-04-28  0:02   ` Ben Hutchings
  2011-04-28 20:44   ` David Miller
  2011-04-28  0:43 ` [NEXT PATCH 3/3] qlcnic: Support for GBE port settings Amit Kumar Salecha
  2 siblings, 2 replies; 9+ messages in thread
From: Amit Kumar Salecha @ 2011-04-28  0:43 UTC (permalink / raw)
  To: davem; +Cc: netdev, ameen.rahman, anirban.chakraborty, Sucheta Chakraborty

From: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>

o Support ethtool command ETHTOOL_GCHANNELS and ETHTOOL_SCHANNELS.
o Number of rcv rings configuration depend upon number of msix vector.

Signed-off-by: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>
---
 drivers/net/qlcnic/qlcnic.h         |    9 ++-
 drivers/net/qlcnic/qlcnic_ethtool.c |   45 +++++++++++
 drivers/net/qlcnic/qlcnic_main.c    |  146 +++++++++++++++++++++++++++-------
 3 files changed, 167 insertions(+), 33 deletions(-)

diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h
index f7acb80..bdebbf5 100644
--- a/drivers/net/qlcnic/qlcnic.h
+++ b/drivers/net/qlcnic/qlcnic.h
@@ -118,7 +118,6 @@
 #define PHAN_PEG_RCV_INITIALIZED	0xff01
 
 #define NUM_RCV_DESC_RINGS	3
-#define NUM_STS_DESC_RINGS	4
 
 #define RCV_RING_NORMAL 0
 #define RCV_RING_JUMBO	1
@@ -871,7 +870,9 @@ struct qlcnic_ipaddr {
 #define QLCNIC_IS_MSI_FAMILY(adapter) \
 	((adapter)->flags & (QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED))
 
-#define MSIX_ENTRIES_PER_ADAPTER	NUM_STS_DESC_RINGS
+#define QLCNIC_DEF_NUM_STS_DESC_RINGS	4
+#define QLCNIC_MIN_NUM_RSS_RINGS	2
+#define QLCNIC_MIN_NUM_TX_DESC_RINGS	1
 #define QLCNIC_MSIX_TBL_SPACE		8192
 #define QLCNIC_PCI_REG_MSIX_TBL 	0x44
 #define QLCNIC_MSIX_TBL_PGSIZE		4096
@@ -987,7 +988,7 @@ struct qlcnic_adapter {
 	void __iomem	*crb_int_state_reg;
 	void __iomem	*isr_int_vec;
 
-	struct msix_entry msix_entries[MSIX_ENTRIES_PER_ADAPTER];
+	struct msix_entry *msix_entries;
 
 	struct delayed_work fw_work;
 
@@ -1262,6 +1263,8 @@ u32 qlcnic_issue_cmd(struct qlcnic_adapter *adapter,
 void qlcnic_diag_free_res(struct net_device *netdev, int max_sds_rings);
 int qlcnic_diag_alloc_res(struct net_device *netdev, int test);
 netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
+int qlcnic_validate_max_rss(struct net_device *netdev, u8 max_hw, u8 val);
+int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data);
 
 /* Management functions */
 int qlcnic_get_mac_address(struct qlcnic_adapter *, u8*);
diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c
index de65847..4f3a367 100644
--- a/drivers/net/qlcnic/qlcnic_ethtool.c
+++ b/drivers/net/qlcnic/qlcnic_ethtool.c
@@ -474,6 +474,49 @@ qlcnic_set_ringparam(struct net_device *dev,
 	return qlcnic_reset_context(adapter);
 }
 
+static void qlcnic_get_channels(struct net_device *dev,
+		struct ethtool_channels *channel)
+{
+	struct qlcnic_adapter *adapter = netdev_priv(dev);
+
+	channel->max_rx = rounddown_pow_of_two(min_t(int,
+			adapter->max_rx_ques, num_online_cpus()));
+	channel->max_tx = adapter->max_tx_ques;
+
+	channel->rx_count = adapter->max_sds_rings;
+	channel->tx_count = QLCNIC_MIN_NUM_TX_DESC_RINGS;
+}
+
+static int qlcnic_set_channels(struct net_device *dev,
+		struct ethtool_channels *channel)
+{
+	struct qlcnic_adapter *adapter = netdev_priv(dev);
+	int err;
+
+	if (channel->other_count || channel->combined_count)
+		return -EOPNOTSUPP;
+
+	if (channel->tx_count &&
+		(channel->tx_count != QLCNIC_MIN_NUM_TX_DESC_RINGS)) {
+		netdev_info(dev, "valid value for tx_count 0x%x\n",
+				QLCNIC_MIN_NUM_TX_DESC_RINGS);
+		return -EINVAL;
+	}
+
+	if (channel->rx_count == adapter->max_sds_rings)
+		return 0;
+
+
+	err = qlcnic_validate_max_rss(dev, channel->max_rx, channel->rx_count);
+	if (err)
+		return err;
+
+	err = qlcnic_set_max_rss(adapter, channel->rx_count);
+	netdev_info(dev, "allocated 0x%x sds rings\n",
+				 adapter->max_sds_rings);
+	return err;
+}
+
 static void
 qlcnic_get_pauseparam(struct net_device *netdev,
 			  struct ethtool_pauseparam *pause)
@@ -949,6 +992,8 @@ const struct ethtool_ops qlcnic_ethtool_ops = {
 	.get_eeprom = qlcnic_get_eeprom,
 	.get_ringparam = qlcnic_get_ringparam,
 	.set_ringparam = qlcnic_set_ringparam,
+	.get_channels = qlcnic_get_channels,
+	.set_channels = qlcnic_set_channels,
 	.get_pauseparam = qlcnic_get_pauseparam,
 	.set_pauseparam = qlcnic_set_pauseparam,
 	.get_wol = qlcnic_get_wol,
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index 6e61951..d6cc4d4 100644
--- a/drivers/net/qlcnic/qlcnic_main.c
+++ b/drivers/net/qlcnic/qlcnic_main.c
@@ -18,6 +18,7 @@
 #include <linux/inetdevice.h>
 #include <linux/sysfs.h>
 #include <linux/aer.h>
+#include <linux/log2.h>
 
 MODULE_DESCRIPTION("QLogic 1/10 GbE Converged/Intelligent Ethernet Driver");
 MODULE_LICENSE("GPL");
@@ -350,39 +351,17 @@ static struct qlcnic_nic_template qlcnic_vf_ops = {
 	.start_firmware = qlcnicvf_start_firmware
 };
 
-static void
-qlcnic_setup_intr(struct qlcnic_adapter *adapter)
+static int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix)
 {
-	const struct qlcnic_legacy_intr_set *legacy_intrp;
 	struct pci_dev *pdev = adapter->pdev;
-	int err, num_msix;
-
-	if (adapter->msix_supported) {
-		num_msix = (num_online_cpus() >= MSIX_ENTRIES_PER_ADAPTER) ?
-			MSIX_ENTRIES_PER_ADAPTER : 2;
-	} else
-		num_msix = 1;
+	int err = -1;
 
 	adapter->max_sds_rings = 1;
-
 	adapter->flags &= ~(QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED);
-
-	legacy_intrp = &legacy_intr[adapter->ahw->pci_func];
-
-	adapter->int_vec_bit = legacy_intrp->int_vec_bit;
-	adapter->tgt_status_reg = qlcnic_get_ioaddr(adapter,
-			legacy_intrp->tgt_status_reg);
-	adapter->tgt_mask_reg = qlcnic_get_ioaddr(adapter,
-			legacy_intrp->tgt_mask_reg);
-	adapter->isr_int_vec = qlcnic_get_ioaddr(adapter, ISR_INT_VECTOR);
-
-	adapter->crb_int_state_reg = qlcnic_get_ioaddr(adapter,
-			ISR_INT_STATE_REG);
-
 	qlcnic_set_msix_bit(pdev, 0);
 
 	if (adapter->msix_supported) {
-
+ enable_msix:
 		qlcnic_init_msix_entries(adapter, num_msix);
 		err = pci_enable_msix(pdev, adapter->msix_entries, num_msix);
 		if (err == 0) {
@@ -392,14 +371,22 @@ qlcnic_setup_intr(struct qlcnic_adapter *adapter)
 			adapter->max_sds_rings = num_msix;
 
 			dev_info(&pdev->dev, "using msi-x interrupts\n");
-			return;
+			return err;
 		}
+		if (err > 0) {
+			num_msix = rounddown_pow_of_two(err);
+			if (num_msix)
+				goto enable_msix;
+		}
+	}
+	return err;
+}
 
-		if (err > 0)
-			pci_disable_msix(pdev);
 
-		/* fall through for msi */
-	}
+static void qlcnic_enable_msi_legacy(struct qlcnic_adapter *adapter)
+{
+	const struct qlcnic_legacy_intr_set *legacy_intrp;
+	struct pci_dev *pdev = adapter->pdev;
 
 	if (use_msi && !pci_enable_msi(pdev)) {
 		adapter->flags |= QLCNIC_MSI_ENABLED;
@@ -410,11 +397,41 @@ qlcnic_setup_intr(struct qlcnic_adapter *adapter)
 		return;
 	}
 
+	legacy_intrp = &legacy_intr[adapter->ahw->pci_func];
+
+	adapter->int_vec_bit = legacy_intrp->int_vec_bit;
+	adapter->tgt_status_reg = qlcnic_get_ioaddr(adapter,
+			legacy_intrp->tgt_status_reg);
+	adapter->tgt_mask_reg = qlcnic_get_ioaddr(adapter,
+			legacy_intrp->tgt_mask_reg);
+	adapter->isr_int_vec = qlcnic_get_ioaddr(adapter, ISR_INT_VECTOR);
+
+	adapter->crb_int_state_reg = qlcnic_get_ioaddr(adapter,
+			ISR_INT_STATE_REG);
 	dev_info(&pdev->dev, "using legacy interrupts\n");
 	adapter->msix_entries[0].vector = pdev->irq;
 }
 
 static void
+qlcnic_setup_intr(struct qlcnic_adapter *adapter)
+{
+	int num_msix;
+
+	if (adapter->msix_supported) {
+		num_msix = (num_online_cpus() >=
+			QLCNIC_DEF_NUM_STS_DESC_RINGS) ?
+			QLCNIC_DEF_NUM_STS_DESC_RINGS :
+			QLCNIC_MIN_NUM_RSS_RINGS;
+	} else
+		num_msix = 1;
+
+	if (!qlcnic_enable_msix(adapter, num_msix))
+		return;
+
+	qlcnic_enable_msi_legacy(adapter);
+}
+
+static void
 qlcnic_teardown_intr(struct qlcnic_adapter *adapter)
 {
 	if (adapter->flags & QLCNIC_MSIX_ENABLED)
@@ -1493,6 +1510,19 @@ static int qlcnic_set_dma_mask(struct pci_dev *pdev, u8 *pci_using_dac)
 	return 0;
 }
 
+static int
+qlcnic_alloc_msix_entries(struct qlcnic_adapter *adapter, u16 count)
+{
+	adapter->msix_entries = kcalloc(count, sizeof(struct msix_entry),
+					GFP_KERNEL);
+
+	if (adapter->msix_entries)
+		return 0;
+
+	dev_err(&adapter->pdev->dev, "failed allocating msix_entries\n");
+	return -ENOMEM;
+}
+
 static int __devinit
 qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
@@ -1587,6 +1617,10 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	qlcnic_clear_stats(adapter);
 
+	err = qlcnic_alloc_msix_entries(adapter, adapter->max_rx_ques);
+	if (err)
+		goto err_out_decr_ref;
+
 	qlcnic_setup_intr(adapter);
 
 	err = qlcnic_setup_netdev(adapter, netdev, pci_using_dac);
@@ -1615,6 +1649,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 err_out_disable_msi:
 	qlcnic_teardown_intr(adapter);
+	kfree(adapter->msix_entries);
 
 err_out_decr_ref:
 	qlcnic_clr_all_drv_state(adapter, 0);
@@ -1666,6 +1701,7 @@ static void __devexit qlcnic_remove(struct pci_dev *pdev)
 	qlcnic_free_lb_filters_mem(adapter);
 
 	qlcnic_teardown_intr(adapter);
+	kfree(adapter->msix_entries);
 
 	qlcnic_remove_diag_entries(adapter);
 
@@ -3299,6 +3335,56 @@ static struct device_attribute dev_attr_diag_mode = {
 	.store = qlcnic_store_diag_mode,
 };
 
+int qlcnic_validate_max_rss(struct net_device *netdev, u8 max_hw, u8 val)
+{
+	if (!use_msi_x && !use_msi) {
+		netdev_info(netdev, "no msix or msi support, hence no rss\n");
+		return -EINVAL;
+	}
+
+	if ((val > max_hw) || (val <  2) || !is_power_of_2(val)) {
+		netdev_info(netdev, "rss_ring valid range [2 - %x] in "
+			" powers of 2\n", max_hw);
+		return -EINVAL;
+	}
+	return 0;
+
+}
+
+int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data)
+{
+	struct net_device *netdev = adapter->netdev;
+	int err = 0;
+
+	if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state))
+		return -EBUSY;
+
+	netif_device_detach(netdev);
+	if (netif_running(netdev))
+		__qlcnic_down(adapter, netdev);
+	qlcnic_detach(adapter);
+	qlcnic_teardown_intr(adapter);
+
+	if (qlcnic_enable_msix(adapter, data)) {
+		netdev_info(netdev, "failed setting max_rss; rss disabled\n");
+		qlcnic_enable_msi_legacy(adapter);
+	}
+
+	if (netif_running(netdev)) {
+		err = qlcnic_attach(adapter);
+		if (err)
+			goto done;
+		err = __qlcnic_up(adapter, netdev);
+		if (err)
+			goto done;
+		qlcnic_restore_indev_addr(netdev, NETDEV_UP);
+	}
+ done:
+	netif_device_attach(netdev);
+	clear_bit(__QLCNIC_RESETTING, &adapter->state);
+	return err;
+}
+
 static int
 qlcnic_sysfs_validate_crb(struct qlcnic_adapter *adapter,
 		loff_t offset, size_t size)
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [NEXT PATCH 3/3] qlcnic: Support for GBE port settings
  2011-04-28  0:43 [NEXT PATCH 0/3]qlcnic: updates Amit Kumar Salecha
  2011-04-28  0:43 ` [NEXT PATCH 1/3] qlcnic: fix memory leak in qlcnic_blink_led Amit Kumar Salecha
  2011-04-28  0:43 ` [NEXT PATCH 2/3] qlcnic: support rcv ring configuration through ethtool Amit Kumar Salecha
@ 2011-04-28  0:43 ` Amit Kumar Salecha
  2011-04-28 20:44   ` David Miller
  2 siblings, 1 reply; 9+ messages in thread
From: Amit Kumar Salecha @ 2011-04-28  0:43 UTC (permalink / raw)
  To: davem; +Cc: netdev, ameen.rahman, anirban.chakraborty, Sony Chacko

From: Sony Chacko <sony.chacko@qlogic.com>

Enable setting speed and auto negotiation parameters for GbE ports.
Hardware do not support half duplex setting currently.

o Update driver version to 5.0.17.

Signed-off-by: Sony Chacko <sony.chacko@qlogic.com>
Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>
---
 drivers/net/qlcnic/qlcnic.h         |    9 ++--
 drivers/net/qlcnic/qlcnic_ctx.c     |   26 ++-----------
 drivers/net/qlcnic/qlcnic_ethtool.c |   72 ++++++++++++++++-------------------
 3 files changed, 42 insertions(+), 65 deletions(-)

diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h
index bdebbf5..3a3cbb8 100644
--- a/drivers/net/qlcnic/qlcnic.h
+++ b/drivers/net/qlcnic/qlcnic.h
@@ -36,8 +36,8 @@
 
 #define _QLCNIC_LINUX_MAJOR 5
 #define _QLCNIC_LINUX_MINOR 0
-#define _QLCNIC_LINUX_SUBVERSION 16
-#define QLCNIC_LINUX_VERSIONID  "5.0.16"
+#define _QLCNIC_LINUX_SUBVERSION 17
+#define QLCNIC_LINUX_VERSIONID  "5.0.17"
 #define QLCNIC_DRV_IDC_VER  0x01
 #define QLCNIC_DRIVER_VERSION  ((_QLCNIC_LINUX_MAJOR << 16) |\
 		 (_QLCNIC_LINUX_MINOR << 8) | (_QLCNIC_LINUX_SUBVERSION))
@@ -573,8 +573,10 @@ struct qlcnic_recv_context {
 #define QLCNIC_CDRP_CMD_CONFIGURE_ESWITCH	0x00000028
 #define QLCNIC_CDRP_CMD_GET_ESWITCH_PORT_CONFIG	0x00000029
 #define QLCNIC_CDRP_CMD_GET_ESWITCH_STATS	0x0000002a
+#define QLCNIC_CDRP_CMD_CONFIG_PORT		0x0000002E
 
 #define QLCNIC_RCODE_SUCCESS		0
+#define QLCNIC_RCODE_NOT_SUPPORTED	9
 #define QLCNIC_RCODE_TIMEOUT		17
 #define QLCNIC_DESTROY_CTX_RESET	0
 
@@ -1156,8 +1158,7 @@ struct qlcnic_esw_statistics {
 	struct __qlcnic_esw_statistics tx;
 };
 
-int qlcnic_fw_cmd_query_phy(struct qlcnic_adapter *adapter, u32 reg, u32 *val);
-int qlcnic_fw_cmd_set_phy(struct qlcnic_adapter *adapter, u32 reg, u32 val);
+int qlcnic_fw_cmd_set_port(struct qlcnic_adapter *adapter, u32 config);
 
 u32 qlcnic_hw_read_wx_2M(struct qlcnic_adapter *adapter, ulong off);
 int qlcnic_hw_write_wx_2M(struct qlcnic_adapter *, ulong off, u32 data);
diff --git a/drivers/net/qlcnic/qlcnic_ctx.c b/drivers/net/qlcnic/qlcnic_ctx.c
index 050fa5a..3a99886 100644
--- a/drivers/net/qlcnic/qlcnic_ctx.c
+++ b/drivers/net/qlcnic/qlcnic_ctx.c
@@ -359,33 +359,15 @@ qlcnic_fw_cmd_destroy_tx_ctx(struct qlcnic_adapter *adapter)
 }
 
 int
-qlcnic_fw_cmd_query_phy(struct qlcnic_adapter *adapter, u32 reg, u32 *val)
-{
-
-	if (qlcnic_issue_cmd(adapter,
-			adapter->ahw->pci_func,
-			adapter->fw_hal_version,
-			reg,
-			0,
-			0,
-			QLCNIC_CDRP_CMD_READ_PHY)) {
-
-		return -EIO;
-	}
-
-	return QLCRD32(adapter, QLCNIC_ARG1_CRB_OFFSET);
-}
-
-int
-qlcnic_fw_cmd_set_phy(struct qlcnic_adapter *adapter, u32 reg, u32 val)
+qlcnic_fw_cmd_set_port(struct qlcnic_adapter *adapter, u32 config)
 {
 	return qlcnic_issue_cmd(adapter,
 			adapter->ahw->pci_func,
 			adapter->fw_hal_version,
-			reg,
-			val,
+			config,
+			0,
 			0,
-			QLCNIC_CDRP_CMD_WRITE_PHY);
+			QLCNIC_CDRP_CMD_CONFIG_PORT);
 }
 
 int qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter)
diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c
index 4f3a367..d34ab7d 100644
--- a/drivers/net/qlcnic/qlcnic_ethtool.c
+++ b/drivers/net/qlcnic/qlcnic_ethtool.c
@@ -284,50 +284,44 @@ skip:
 static int
 qlcnic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
+	u32 config = 0;
+	u32 ret = 0;
 	struct qlcnic_adapter *adapter = netdev_priv(dev);
-	__u32 status;
+
+	if (adapter->ahw->port_type != QLCNIC_GBE)
+		return -EOPNOTSUPP;
 
 	/* read which mode */
-	if (adapter->ahw->port_type == QLCNIC_GBE) {
-		/* autonegotiation */
-		if (qlcnic_fw_cmd_set_phy(adapter,
-			       QLCNIC_NIU_GB_MII_MGMT_ADDR_AUTONEG,
-			       ecmd->autoneg) != 0)
-			return -EIO;
-		else
-			adapter->link_autoneg = ecmd->autoneg;
+	if (ecmd->duplex)
+		config |= 0x1;
 
-		if (qlcnic_fw_cmd_query_phy(adapter,
-			      QLCNIC_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
-			      &status) != 0)
-			return -EIO;
+	if (ecmd->autoneg)
+		config |= 0x2;
 
-		switch (ecmd->speed) {
-		case SPEED_10:
-			qlcnic_set_phy_speed(status, 0);
-			break;
-		case SPEED_100:
-			qlcnic_set_phy_speed(status, 1);
-			break;
-		case SPEED_1000:
-			qlcnic_set_phy_speed(status, 2);
-			break;
-		}
+	switch (ethtool_cmd_speed(ecmd)) {
+	case SPEED_10:
+		config |= (0 << 8);
+		break;
+	case SPEED_100:
+		config |= (1 << 8);
+		break;
+	case SPEED_1000:
+		config |= (10 << 8);
+		break;
+	default:
+		return -EIO;
+	}
 
-		if (ecmd->duplex == DUPLEX_HALF)
-			qlcnic_clear_phy_duplex(status);
-		if (ecmd->duplex == DUPLEX_FULL)
-			qlcnic_set_phy_duplex(status);
-		if (qlcnic_fw_cmd_set_phy(adapter,
-			       QLCNIC_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
-			       *((int *)&status)) != 0)
-			return -EIO;
-		else {
-			adapter->link_speed = ecmd->speed;
-			adapter->link_duplex = ecmd->duplex;
-		}
-	} else
+	ret = qlcnic_fw_cmd_set_port(adapter, config);
+
+	if (ret == QLCNIC_RCODE_NOT_SUPPORTED)
 		return -EOPNOTSUPP;
+	else if (ret)
+		return -EIO;
+
+	adapter->link_speed = ethtool_cmd_speed(ecmd);
+	adapter->link_duplex = ecmd->duplex;
+	adapter->link_autoneg = ecmd->autoneg;
 
 	if (!netif_running(dev))
 		return 0;
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [NEXT PATCH 1/3] qlcnic: fix memory leak in qlcnic_blink_led.
  2011-04-28  0:43 ` [NEXT PATCH 1/3] qlcnic: fix memory leak in qlcnic_blink_led Amit Kumar Salecha
@ 2011-04-28 20:44   ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2011-04-28 20:44 UTC (permalink / raw)
  To: amit.salecha
  Cc: netdev, ameen.rahman, anirban.chakraborty, sucheta.chakraborty

From: Amit Kumar Salecha <amit.salecha@qlogic.com>
Date: Wed, 27 Apr 2011 17:43:44 -0700

> From: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
> 
> o Memory allocated in ETHTOOL_ACTIVE mode, is not getting freed. So,
>   in ETHTOOL_ID_INACTIVE mode, return after freeing allocated memory.
> o Using set bit instead of blink_down field, as it is also required
>   in internal Loopback test and etc.
> 
> Signed-off-by: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
> Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>

Applied.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [NEXT PATCH 2/3] qlcnic: support rcv ring configuration through ethtool
  2011-04-28  0:43 ` [NEXT PATCH 2/3] qlcnic: support rcv ring configuration through ethtool Amit Kumar Salecha
  2011-04-28  0:02   ` Ben Hutchings
@ 2011-04-28 20:44   ` David Miller
  1 sibling, 0 replies; 9+ messages in thread
From: David Miller @ 2011-04-28 20:44 UTC (permalink / raw)
  To: amit.salecha
  Cc: netdev, ameen.rahman, anirban.chakraborty, sucheta.chakraborty

From: Amit Kumar Salecha <amit.salecha@qlogic.com>
Date: Wed, 27 Apr 2011 17:43:45 -0700

> From: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
> 
> o Support ethtool command ETHTOOL_GCHANNELS and ETHTOOL_SCHANNELS.
> o Number of rcv rings configuration depend upon number of msix vector.
> 
> Signed-off-by: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
> Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>

Please address Ben's feedback and resubmit this.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [NEXT PATCH 3/3] qlcnic: Support for GBE port settings
  2011-04-28  0:43 ` [NEXT PATCH 3/3] qlcnic: Support for GBE port settings Amit Kumar Salecha
@ 2011-04-28 20:44   ` David Miller
  0 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2011-04-28 20:44 UTC (permalink / raw)
  To: amit.salecha; +Cc: netdev, ameen.rahman, anirban.chakraborty, sony.chacko

From: Amit Kumar Salecha <amit.salecha@qlogic.com>
Date: Wed, 27 Apr 2011 17:43:46 -0700

> From: Sony Chacko <sony.chacko@qlogic.com>
> 
> Enable setting speed and auto negotiation parameters for GbE ports.
> Hardware do not support half duplex setting currently.
> 
> o Update driver version to 5.0.17.
> 
> Signed-off-by: Sony Chacko <sony.chacko@qlogic.com>
> Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>

Please resubmit this when you redo patch #2.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [NEXT PATCH 2/3] qlcnic: support rcv ring configuration through ethtool
  2011-04-28  0:02   ` Ben Hutchings
@ 2011-04-28 21:05     ` Amit Salecha
  0 siblings, 0 replies; 9+ messages in thread
From: Amit Salecha @ 2011-04-28 21:05 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: David Miller, netdev, Ameen Rahman, Anirban Chakraborty,
	Sucheta Chakraborty

> From: Ben Hutchings [mailto:bhutchings@solarflare.com]
> Sent: Wednesday, April 27, 2011 5:03 PM
> To: Amit Salecha
> Cc: David Miller; netdev; Ameen Rahman; Anirban Chakraborty; Sucheta
> Chakraborty
> Subject: Re: [NEXT PATCH 2/3] qlcnic: support rcv ring configuration
> through ethtool
> 
> > +	if (channel->other_count || channel->combined_count)
> > +		return -EOPNOTSUPP;
> 
> Should be -EINVAL.
> 
> > +	if (channel->tx_count &&
> > +		(channel->tx_count != QLCNIC_MIN_NUM_TX_DESC_RINGS)) {
> > +		netdev_info(dev, "valid value for tx_count 0x%x\n",
> > +				QLCNIC_MIN_NUM_TX_DESC_RINGS);
> > +		return -EINVAL;
> > +	}
> [...]
> 
> If tx_count cannot be changed, why does qlcnic_get_channels() set
> tx_count and max_tx to different values?
>

Internally both are same values. But I will resubmit the patch to reduce this ambiguity.
 
> Also I don't think you should treat tx_count == 0 as a special case; it
> should be rejected as invalid.
> 
Will fix this.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-04-28 21:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-28  0:43 [NEXT PATCH 0/3]qlcnic: updates Amit Kumar Salecha
2011-04-28  0:43 ` [NEXT PATCH 1/3] qlcnic: fix memory leak in qlcnic_blink_led Amit Kumar Salecha
2011-04-28 20:44   ` David Miller
2011-04-28  0:43 ` [NEXT PATCH 2/3] qlcnic: support rcv ring configuration through ethtool Amit Kumar Salecha
2011-04-28  0:02   ` Ben Hutchings
2011-04-28 21:05     ` Amit Salecha
2011-04-28 20:44   ` David Miller
2011-04-28  0:43 ` [NEXT PATCH 3/3] qlcnic: Support for GBE port settings Amit Kumar Salecha
2011-04-28 20:44   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).