Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a114e44f authored by Jinesh K. Jayakumar's avatar Jinesh K. Jayakumar
Browse files

msm: ipa: IPC logging support in ethernet offload sub-system



Add support for IPC logging for use by IPA ethernet offload sub-system
and its clients.

CRs-Fixed: 2304918
Change-Id: I8d1336b5136add26f3652f3d3a055291b6c95d35
Signed-off-by: default avatarJinesh K. Jayakumar <jineshk@codeaurora.org>
parent 681f798f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -31,3 +31,13 @@ config AQC_IPA_PROXY_HOST
	  need to be available and configured to receive the MSI.

endchoice

config AQC_IPA_DEBUG
	bool "Aquantia IPA Ethernet Offload Driver Debugging Support"
	depends on AQC_IPA
	help
	  Enable various debug features provided by Aquantia IPA
	  offload driver. Using this feature may add a lot of
	  additional log messages and panic on bugs. Enable this
	  option with caution.
	  If unsure, say N.
+73 −3
Original line number Diff line number Diff line
@@ -30,10 +30,14 @@ static LIST_HEAD(ipa_eth_devices);
static DEFINE_MUTEX(ipa_eth_devices_lock);

static bool ipa_eth_noauto = IPA_ETH_NOAUTO_DEFAULT;
module_param(ipa_eth_noauto, bool, 0644);
module_param(ipa_eth_noauto, bool, 0444);
MODULE_PARM_DESC(ipa_eth_noauto,
	"Disable automatic offload initialization of interfaces");

static bool ipa_eth_ipc_logdbg = IPA_ETH_IPC_LOGDBG_DEFAULT;
module_param(ipa_eth_ipc_logdbg, bool, 0444);
MODULE_PARM_DESC(ipa_eth_ipc_logdbg, "Log debug IPC messages");

static inline bool ipa_eth_ready(void)
{
	return ipa_eth_is_ready &&
@@ -570,6 +574,8 @@ int ipa_eth_register_device(struct ipa_eth_device *eth_dev)

	list_add(&eth_dev->device_list, &ipa_eth_devices);

	ipa_eth_dev_log(eth_dev, "Registered new device");

	(void) __ipa_eth_pair_device(eth_dev);

	mutex_unlock(&ipa_eth_devices_lock);
@@ -584,6 +590,8 @@ void ipa_eth_unregister_device(struct ipa_eth_device *eth_dev)
	__ipa_eth_unpair_device(eth_dev);
	list_del(&eth_dev->device_list);

	ipa_eth_dev_log(eth_dev, "Unregistered device");

	mutex_unlock(&ipa_eth_devices_lock);
}

@@ -727,7 +735,15 @@ int ipa_eth_iommu_unmap(struct iommu_domain *domain,
 */
int ipa_eth_register_net_driver(struct ipa_eth_net_driver *nd)
{
	return ipa_eth_bus_register_driver(nd);
	int rc;

	rc = ipa_eth_bus_register_driver(nd);
	if (rc)
		ipa_eth_err("Failed to register network driver %s", nd->name);
	else
		ipa_eth_log("Registered network driver %s", nd->name);

	return rc;
}
EXPORT_SYMBOL(ipa_eth_register_net_driver);

@@ -737,7 +753,7 @@ EXPORT_SYMBOL(ipa_eth_register_net_driver);
 */
void ipa_eth_unregister_net_driver(struct ipa_eth_net_driver *nd)
{
	return ipa_eth_bus_unregister_driver(nd);
	ipa_eth_bus_unregister_driver(nd);
}
EXPORT_SYMBOL(ipa_eth_unregister_net_driver);

@@ -758,6 +774,8 @@ int ipa_eth_register_offload_driver(struct ipa_eth_offload_driver *od)
		return rc;
	}

	ipa_eth_log("Registered offload driver %s", od->name);

	ipa_eth_pair_devices();

	return 0;
@@ -772,6 +790,8 @@ void ipa_eth_unregister_offload_driver(struct ipa_eth_offload_driver *od)
{
	ipa_eth_unpair_devices(od);
	ipa_eth_offload_unregister_driver(od);

	ipa_eth_log("Unregistered offload driver %s", od->name);
}
EXPORT_SYMBOL(ipa_eth_unregister_offload_driver);

@@ -826,6 +846,12 @@ static int ipa_eth_debugfs_init(void)
	(void) debugfs_create_bool("uc_ready", 0444,
				   ipa_eth_debugfs, &ipa_eth_ipa_uc_is_ready);

	(void) debugfs_create_bool("no_auto", 0644,
				   ipa_eth_debugfs, &ipa_eth_noauto);

	(void) debugfs_create_bool("ipc_logdbg", 0644,
				   ipa_eth_debugfs, &ipa_eth_ipc_logdbg);

	return 0;

err_exit:
@@ -833,12 +859,53 @@ static int ipa_eth_debugfs_init(void)
	return rc;
}

static void *ipa_eth_ipc_logbuf;

void *ipa_eth_get_ipc_logbuf(void)
{
	return ipa_eth_ipc_logbuf;
}
EXPORT_SYMBOL(ipa_eth_get_ipc_logbuf);

void *ipa_eth_get_ipc_logbuf_dbg(void)
{
	return ipa_eth_ipc_logdbg ? ipa_eth_ipc_logbuf : NULL;
}
EXPORT_SYMBOL(ipa_eth_get_ipc_logbuf_dbg);

#define IPA_ETH_IPC_LOG_PAGES 50

static int ipa_eth_ipc_log_init(void)
{
	if (ipa_eth_ipc_logbuf)
		return 0;

	ipa_eth_ipc_logbuf = ipc_log_context_create(
				IPA_ETH_IPC_LOG_PAGES, IPA_ETH_SUBSYS, 0);

	return ipa_eth_ipc_logbuf ? 0 : -EFAULT;
}

static void ipa_eth_ipc_log_cleanup(void)
{
	if (ipa_eth_ipc_logbuf) {
		ipc_log_context_destroy(ipa_eth_ipc_logbuf);
		ipa_eth_ipc_logbuf = NULL;
	}
}

int ipa_eth_init(void)
{
	int rc;

	ipa_eth_dbg("Initializing IPA Ethernet Offload Sub-System");

	rc = ipa_eth_ipc_log_init();
	if (rc) {
		ipa_eth_err("Failed to initialize IPC logging");
		goto err_ipclog;
	}

	rc = ipa_eth_debugfs_init();
	if (rc) {
		ipa_eth_err("Failed to initialize debugfs");
@@ -884,6 +951,8 @@ int ipa_eth_init(void)
err_bus:
	ipa_eth_debugfs_cleanup();
err_dbgfs:
	ipa_eth_ipc_log_cleanup();
err_ipclog:
	return rc;
}

@@ -899,4 +968,5 @@ void ipa_eth_exit(void)
	ipa_eth_offload_modexit();
	ipa_eth_bus_modexit();
	ipa_eth_debugfs_cleanup();
	ipa_eth_ipc_log_cleanup();
}
+9 −10
Original line number Diff line number Diff line
@@ -24,6 +24,12 @@
#define IPA_ETH_NOAUTO_DEFAULT false
#endif

#ifdef DEBUG
#define IPA_ETH_IPC_LOGDBG_DEFAULT true
#else
#define IPA_ETH_IPC_LOGDBG_DEFAULT false
#endif

#define IPA_ETH_PFDEV (ipa3_ctx ? ipa3_ctx->pdev : NULL)
#define IPA_ETH_SUBSYS "ipa_eth"

@@ -32,10 +38,7 @@
		dev_err(IPA_ETH_PFDEV, \
			IPA_ETH_SUBSYS " %s:%d ERROR: " fmt "\n", \
			__func__, __LINE__, ## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf(), \
			IPA_ETH_SUBSYS " %s:%d ERROR: " fmt "\n", ## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
			IPA_ETH_SUBSYS " %s:%d ERROR: " fmt "\n", ## args); \
		ipa_eth_ipc_log("ERROR: " fmt, ## args); \
	} while (0)

#define ipa_eth_log(fmt, args...) \
@@ -43,10 +46,7 @@
		dev_dbg(IPA_ETH_PFDEV, \
			IPA_ETH_SUBSYS " %s:%d " fmt "\n", \
			__func__, __LINE__, ## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf(), \
			IPA_ETH_SUBSYS " %s:%d " fmt "\n", ## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
			IPA_ETH_SUBSYS " %s:%d " fmt "\n", ## args); \
		ipa_eth_ipc_log(fmt, ## args); \
	} while (0)

#define ipa_eth_dbg(fmt, args...) \
@@ -54,8 +54,7 @@
		dev_dbg(IPA_ETH_PFDEV, \
			IPA_ETH_SUBSYS " %s:%d " fmt "\n", \
			__func__, __LINE__, ## args); \
		IPA_IPC_LOGGING(ipa_get_ipc_logbuf_low(), \
			IPA_ETH_SUBSYS " %s:%d DEBUG: " fmt "\n", ## args); \
		ipa_eth_ipc_dbg("ERROR: " fmt, ## args); \
	} while (0)

#define ipa_eth_dev_err(edev, fmt, args...) \
+25 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <linux/types.h>
#include <linux/bitops.h>
#include <linux/debugfs.h>
#include <linux/ipc_logging.h>

#include <linux/netdevice.h>
#include <linux/netdev_features.h>
@@ -707,4 +708,28 @@ int ipa_eth_uc_iommu_vamap(dma_addr_t daddr, void *vaddr,
	size_t size, int prot, bool split);
int ipa_eth_uc_iommu_unmap(dma_addr_t daddr, size_t size, bool split);

/* IPC logging interface */

#define ipa_eth_ipc_do_log(ipcbuf, fmt, args...) \
	do { \
		void *__buf = (ipcbuf); \
		if (__buf) \
			ipc_log_string(__buf, " %s:%d " fmt "\n", \
				__func__, __LINE__, ## args); \
	} while (0)

#define ipa_eth_ipc_log(fmt, args...) \
	do { \
		void *ipa_eth_get_ipc_logbuf(void); \
		ipa_eth_ipc_do_log(ipa_eth_get_ipc_logbuf(), \
					fmt, ## args); \
	} while (0)

#define ipa_eth_ipc_dbg(fmt, args...) \
	do { \
		void *ipa_eth_get_ipc_logbuf_dbg(void); \
		ipa_eth_ipc_do_log(ipa_eth_get_ipc_logbuf_dbg(), \
					fmt, ## args); \
	} while (0)

#endif // _IPA_ETH_H_