Commit 5feaa7a0 authored by Michal Swiatkowski's avatar Michal Swiatkowski Committed by Tony Nguyen
Browse files

libie: add adminq helper for converting err to str



Add a new module for common handling of Admin Queue related logic.
Start by a helper for error to string conversion. This lives inside
libie/, but is a separate module what follows our logic of splitting
into topical modules, to avoid pulling in not needed stuff, and have
better organization in general.

Olek suggested how to better solve the error to string conversion.

It will be used in follow-up patches in ice, i40e and iavf.

Reviewed-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Suggested-by: default avatarAlexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: default avatarMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 0eb61b35
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -8,3 +8,9 @@ config LIBIE
	  libie (Intel Ethernet library) is a common library built on top of
	  libeth and containing vendor-specific routines shared between several
	  Intel Ethernet drivers.

config LIBIE_ADMINQ
	tristate
	help
	  Helper functions used by Intel Ethernet drivers for administration
	  queue command interface (aka adminq).
+4 −0
Original line number Diff line number Diff line
@@ -4,3 +4,7 @@
obj-$(CONFIG_LIBIE)	+= libie.o

libie-y			:= rx.o

obj-$(CONFIG_LIBIE_ADMINQ) 	+= libie_adminq.o

libie_adminq-y			:= adminq.o
+52 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (C) 2025 Intel Corporation */

#include <linux/module.h>
#include <linux/net/intel/libie/adminq.h>

static const char * const libie_aq_str_arr[] = {
#define LIBIE_AQ_STR(x)					\
	[LIBIE_AQ_RC_##x]	= "LIBIE_AQ_RC" #x
	LIBIE_AQ_STR(OK),
	LIBIE_AQ_STR(EPERM),
	LIBIE_AQ_STR(ENOENT),
	LIBIE_AQ_STR(ESRCH),
	LIBIE_AQ_STR(EIO),
	LIBIE_AQ_STR(EAGAIN),
	LIBIE_AQ_STR(ENOMEM),
	LIBIE_AQ_STR(EACCES),
	LIBIE_AQ_STR(EBUSY),
	LIBIE_AQ_STR(EEXIST),
	LIBIE_AQ_STR(EINVAL),
	LIBIE_AQ_STR(ENOSPC),
	LIBIE_AQ_STR(ENOSYS),
	LIBIE_AQ_STR(EMODE),
	LIBIE_AQ_STR(ENOSEC),
	LIBIE_AQ_STR(EBADSIG),
	LIBIE_AQ_STR(ESVN),
	LIBIE_AQ_STR(EBADMAN),
	LIBIE_AQ_STR(EBADBUF),
#undef LIBIE_AQ_STR
	"LIBIE_AQ_RC_UNKNOWN",
};

#define __LIBIE_AQ_STR_NUM (ARRAY_SIZE(libie_aq_str_arr) - 1)

/**
 * libie_aq_str - get error string based on aq error
 * @err: admin queue error type
 *
 * Return: error string for passed error code
 */
const char *libie_aq_str(enum libie_aq_err err)
{
	if (err >= ARRAY_SIZE(libie_aq_str_arr) ||
	    !libie_aq_str_arr[err])
		err = __LIBIE_AQ_STR_NUM;

	return libie_aq_str_arr[err];
}
EXPORT_SYMBOL_NS_GPL(libie_aq_str, "LIBIE_ADMINQ");

MODULE_DESCRIPTION("Intel(R) Ethernet common library - adminq helpers");
MODULE_LICENSE("GPL");
+2 −0
Original line number Diff line number Diff line
@@ -303,4 +303,6 @@ static inline void *libie_aq_raw(struct libie_aq_desc *desc)
	return &desc->params.raw;
}

const char *libie_aq_str(enum libie_aq_err err);

#endif /* __LIBIE_ADMINQ_H */