From: jbeulich@novell.com
Subject: conditionalize driverlink additions to Solarflare driver
Patch-mainline: n/a
References: FATE#303479

At once converted the EFX_TRACE() invocations after vetoed RX/TX
callbacks to ...LOG() ones, which is consistent with Solarflare's
current code according to David Riddoch (2008-09-12).

--- head-2009-11-06.orig/drivers/net/sfc/Kconfig	2009-04-21 11:02:22.000000000 +0200
+++ head-2009-11-06/drivers/net/sfc/Kconfig	2009-10-12 13:41:03.000000000 +0200
@@ -12,8 +12,12 @@ config SFC
 	  To compile this driver as a module, choose M here.  The module
 	  will be called sfc.
 
+config SFC_DRIVERLINK
+	bool
+
 config SFC_RESOURCE
 	depends on SFC && X86
+	select SFC_DRIVERLINK
 	tristate "Solarflare Solarstorm SFC4000 resource driver"
 	help
 	  This module provides the SFC resource manager driver.
--- head-2009-11-06.orig/drivers/net/sfc/Makefile	2009-02-06 12:42:18.000000000 +0100
+++ head-2009-11-06/drivers/net/sfc/Makefile	2009-10-12 13:41:03.000000000 +0200
@@ -1,7 +1,7 @@
 sfc-y			+= efx.o falcon.o tx.o rx.o falcon_gmac.o \
 			   falcon_xmac.o selftest.o ethtool.o xfp_phy.o \
-			   mdio_10g.o tenxpress.o boards.o sfe4001.o \
-			   driverlink.o
+			   mdio_10g.o tenxpress.o boards.o sfe4001.o
+sfc-$(CONFIG_SFC_DRIVERLINK) += driverlink.o
 sfc-$(CONFIG_SFC_MTD)	+= mtd.o
 
 obj-$(CONFIG_SFC)	+= sfc.o
--- head-2009-11-06.orig/drivers/net/sfc/driverlink.c	2009-07-28 10:04:25.000000000 +0200
+++ head-2009-11-06/drivers/net/sfc/driverlink.c	2009-10-12 13:41:03.000000000 +0200
@@ -14,7 +14,6 @@
 #include <linux/rtnetlink.h>
 #include "net_driver.h"
 #include "efx.h"
-#include "driverlink_api.h"
 #include "driverlink.h"
 
 /* Protects @efx_driverlink_lock and @efx_driver_list */
--- head-2009-11-06.orig/drivers/net/sfc/driverlink.h	2009-07-28 10:04:25.000000000 +0200
+++ head-2009-11-06/drivers/net/sfc/driverlink.h	2009-10-12 13:41:03.000000000 +0200
@@ -15,6 +15,10 @@
 struct efx_dl_device;
 struct efx_nic;
 
+#ifdef CONFIG_SFC_DRIVERLINK
+
+#include "driverlink_api.h"
+
 /* Efx callback devices
  *
  * A list of the devices that own each callback. The partner to
@@ -40,4 +44,23 @@ extern void efx_dl_unregister_nic(struct
 extern void efx_dl_reset_suspend(struct efx_nic *efx);
 extern void efx_dl_reset_resume(struct efx_nic *efx, int ok);
 
+#define EFX_DL_LOG EFX_LOG
+
+#else /* CONFIG_SFC_DRIVERLINK */
+
+enum efx_veto { EFX_ALLOW_PACKET = 0 };
+
+static inline int efx_nop_callback(struct efx_nic *efx) { return 0; }
+#define EFX_DL_CALLBACK(port, name, ...) efx_nop_callback(port)
+
+static inline int efx_dl_register_nic(struct efx_nic *efx) { return 0; }
+static inline void efx_dl_unregister_nic(struct efx_nic *efx) {}
+
+static inline void efx_dl_reset_suspend(struct efx_nic *efx) {}
+static inline void efx_dl_reset_resume(struct efx_nic *efx, int ok) {}
+
+#define EFX_DL_LOG(efx, fmt, args...) ((void)(efx))
+
+#endif /* CONFIG_SFC_DRIVERLINK */
+
 #endif /* EFX_DRIVERLINK_H */
--- head-2009-11-06.orig/drivers/net/sfc/efx.c	2009-10-12 13:40:25.000000000 +0200
+++ head-2009-11-06/drivers/net/sfc/efx.c	2009-10-12 13:41:03.000000000 +0200
@@ -1689,6 +1689,7 @@ static void efx_unregister_netdev(struct
  * Device reset and suspend
  *
  **************************************************************************/
+#ifdef CONFIG_SFC_DRIVERLINK
 /* Serialise access to the driverlink callbacks, by quiescing event processing
  * (without flushing the descriptor queues), and acquiring the rtnl_lock */
 void efx_suspend(struct efx_nic *efx)
@@ -1706,6 +1707,7 @@ void efx_resume(struct efx_nic *efx)
 	efx_start_all(efx);
 	rtnl_unlock();
 }
+#endif
 
 /* Tears down the entire software state and most of the hardware state
  * before reset.  */
@@ -1978,9 +1980,11 @@ static int efx_init_struct(struct efx_ni
 	efx->mac_op = &efx_dummy_mac_operations;
 	efx->phy_op = &efx_dummy_phy_operations;
 	efx->mdio.dev = net_dev;
+#ifdef CONFIG_SFC_DRIVERLINK
 	INIT_LIST_HEAD(&efx->dl_node);
 	INIT_LIST_HEAD(&efx->dl_device_list);
 	efx->dl_cb = efx_default_callbacks;
+#endif
 	INIT_WORK(&efx->phy_work, efx_phy_work);
 	INIT_WORK(&efx->mac_work, efx_mac_work);
 	atomic_set(&efx->netif_stop_count, 1);
--- head-2009-11-06.orig/drivers/net/sfc/falcon.c	2009-07-28 10:04:25.000000000 +0200
+++ head-2009-11-06/drivers/net/sfc/falcon.c	2009-10-12 13:41:03.000000000 +0200
@@ -36,6 +36,7 @@
 
 /**
  * struct falcon_nic_data - Falcon NIC state
+ * @next_buffer_table: First available buffer table id
  * @resources: Resource information for driverlink client
  * @pci_dev2: The secondary PCI device if present
  * @i2c_data: Operations and state for I2C bit-bashing algorithm
@@ -43,7 +44,11 @@
  * @int_error_expire: Time at which error count will be expired
  */
 struct falcon_nic_data {
+#ifndef CONFIG_SFC_DRIVERLINK
+	unsigned next_buffer_table;
+#else
 	struct efx_dl_falcon_resources resources;
+#endif
 	struct pci_dev *pci_dev2;
 	struct i2c_algo_bit_data i2c_data;
 
@@ -336,8 +341,13 @@ static int falcon_alloc_special_buffer(s
 	memset(buffer->addr, 0xff, len);
 
 	/* Select new buffer ID */
+#ifndef CONFIG_SFC_DRIVERLINK
+	buffer->index = nic_data->next_buffer_table;
+	nic_data->next_buffer_table += buffer->entries;
+#else
 	buffer->index = nic_data->resources.buffer_table_min;
 	nic_data->resources.buffer_table_min += buffer->entries;
+#endif
 
 	EFX_LOG(efx, "allocating special buffers %d-%d at %llx+%x "
 		"(virt %p phys %llx)\n", buffer->index,
@@ -2755,6 +2765,7 @@ static int falcon_probe_nvconfig(struct 
  * should live. */
 static int falcon_dimension_resources(struct efx_nic *efx)
 {
+#ifdef CONFIG_SFC_DRIVERLINK
 	unsigned internal_dcs_entries;
 	struct falcon_nic_data *nic_data = efx->nic_data;
 	struct efx_dl_falcon_resources *res = &nic_data->resources;
@@ -2799,6 +2810,7 @@ static int falcon_dimension_resources(st
 
 	if (EFX_INT_MODE_USE_MSI(efx))
 		res->flags |= EFX_DL_FALCON_USE_MSI;
+#endif
 
 	return 0;
 }
@@ -2962,7 +2974,9 @@ int falcon_probe_nic(struct efx_nic *efx
 	return 0;
 
  fail6:
+#ifdef CONFIG_SFC_DRIVERLINK
 	efx->dl_info = NULL;
+#endif
  fail5:
 	falcon_remove_spi_devices(efx);
 	falcon_free_buffer(efx, &efx->irq_status);
@@ -3150,7 +3164,9 @@ void falcon_remove_nic(struct efx_nic *e
 	/* Tear down the private nic state */
 	kfree(efx->nic_data);
 	efx->nic_data = NULL;
+#ifdef CONFIG_SFC_DRIVERLINK
 	efx->dl_info = NULL;
+#endif
 }
 
 void falcon_update_nic_stats(struct efx_nic *efx)
--- head-2009-11-06.orig/drivers/net/sfc/net_driver.h	2009-07-28 10:04:25.000000000 +0200
+++ head-2009-11-06/drivers/net/sfc/net_driver.h	2009-10-12 13:41:03.000000000 +0200
@@ -29,7 +29,6 @@
 
 #include "enum.h"
 #include "bitfield.h"
-#include "driverlink_api.h"
 #include "driverlink.h"
 
 /**************************************************************************
@@ -854,11 +853,13 @@ struct efx_nic {
 	void *loopback_selftest;
 
 	const char *silicon_rev;
+#ifdef CONFIG_SFC_DRIVERLINK
 	struct efx_dl_device_info *dl_info;
 	struct list_head dl_node;
 	struct list_head dl_device_list;
 	struct efx_dl_callbacks dl_cb;
 	struct efx_dl_cb_devices dl_cb_dev;
+#endif
 };
 
 static inline int efx_dev_registered(struct efx_nic *efx)
--- head-2009-11-06.orig/drivers/net/sfc/rx.c	2009-11-06 10:32:03.000000000 +0100
+++ head-2009-11-06/drivers/net/sfc/rx.c	2009-11-06 10:32:24.000000000 +0100
@@ -456,8 +456,8 @@ static void efx_rx_packet_lro(struct efx
 	 * an obvious interface to this, so veto packets before LRO */
 	veto = EFX_DL_CALLBACK(efx, rx_packet, rx_buf->data, rx_buf->len);
 	if (unlikely(veto)) {
-		EFX_TRACE(efx, "LRO RX vetoed by driverlink %s driver\n",
-			  efx->dl_cb_dev.rx_packet->driver->name);
+		EFX_DL_LOG(efx, "LRO RX vetoed by driverlink %s driver\n",
+			   efx->dl_cb_dev.rx_packet->driver->name);
 		/* Free the buffer now */
 		efx_free_rx_buffer(efx, rx_buf);
 		return;
@@ -579,8 +579,8 @@ void __efx_rx_packet(struct efx_channel 
 	/* Allow callback to veto the packet */
 	veto = EFX_DL_CALLBACK(efx, rx_packet, rx_buf->data, rx_buf->len);
 	if (unlikely(veto)) {
-		EFX_LOG(efx, "RX vetoed by driverlink %s driver\n",
-			efx->dl_cb_dev.rx_packet->driver->name);
+		EFX_DL_LOG(efx, "RX vetoed by driverlink %s driver\n",
+			   efx->dl_cb_dev.rx_packet->driver->name);
 		/* Free the buffer now */
 		efx_free_rx_buffer(efx, rx_buf);
 		goto done;
--- head-2009-11-06.orig/drivers/net/sfc/tx.c	2009-10-12 13:40:32.000000000 +0200
+++ head-2009-11-06/drivers/net/sfc/tx.c	2009-10-12 13:41:03.000000000 +0200
@@ -387,9 +387,9 @@ netdev_tx_t efx_hard_start_xmit(struct s
 	/* See if driverlink wants to veto the packet. */
 	veto = EFX_DL_CALLBACK(efx, tx_packet, skb);
 	if (unlikely(veto)) {
-		EFX_TRACE(efx, "TX queue %d packet vetoed by "
-			  "driverlink %s driver\n", tx_queue->queue,
-			  efx->dl_cb_dev.tx_packet->driver->name);
+		EFX_DL_LOG(efx, "TX queue %d packet vetoed by "
+			   "driverlink %s driver\n", tx_queue->queue,
+			   efx->dl_cb_dev.tx_packet->driver->name);
 		/* Free the skb; nothing else will do it */
 		dev_kfree_skb_any(skb);
 		return NETDEV_TX_OK;
