Skip to content

Commit 5feaa7a

Browse files
Michal Swiatkowskianguy11
authored andcommitted
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: Przemek Kitszel <przemyslaw.kitszel@intel.com> Suggested-by: Alexander Lobakin <aleksander.lobakin@intel.com> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 0eb61b3 commit 5feaa7a

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

drivers/net/ethernet/intel/libie/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ config LIBIE
88
libie (Intel Ethernet library) is a common library built on top of
99
libeth and containing vendor-specific routines shared between several
1010
Intel Ethernet drivers.
11+
12+
config LIBIE_ADMINQ
13+
tristate
14+
help
15+
Helper functions used by Intel Ethernet drivers for administration
16+
queue command interface (aka adminq).

drivers/net/ethernet/intel/libie/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44
obj-$(CONFIG_LIBIE) += libie.o
55

66
libie-y := rx.o
7+
8+
obj-$(CONFIG_LIBIE_ADMINQ) += libie_adminq.o
9+
10+
libie_adminq-y := adminq.o
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/* Copyright (C) 2025 Intel Corporation */
3+
4+
#include <linux/module.h>
5+
#include <linux/net/intel/libie/adminq.h>
6+
7+
static const char * const libie_aq_str_arr[] = {
8+
#define LIBIE_AQ_STR(x) \
9+
[LIBIE_AQ_RC_##x] = "LIBIE_AQ_RC" #x
10+
LIBIE_AQ_STR(OK),
11+
LIBIE_AQ_STR(EPERM),
12+
LIBIE_AQ_STR(ENOENT),
13+
LIBIE_AQ_STR(ESRCH),
14+
LIBIE_AQ_STR(EIO),
15+
LIBIE_AQ_STR(EAGAIN),
16+
LIBIE_AQ_STR(ENOMEM),
17+
LIBIE_AQ_STR(EACCES),
18+
LIBIE_AQ_STR(EBUSY),
19+
LIBIE_AQ_STR(EEXIST),
20+
LIBIE_AQ_STR(EINVAL),
21+
LIBIE_AQ_STR(ENOSPC),
22+
LIBIE_AQ_STR(ENOSYS),
23+
LIBIE_AQ_STR(EMODE),
24+
LIBIE_AQ_STR(ENOSEC),
25+
LIBIE_AQ_STR(EBADSIG),
26+
LIBIE_AQ_STR(ESVN),
27+
LIBIE_AQ_STR(EBADMAN),
28+
LIBIE_AQ_STR(EBADBUF),
29+
#undef LIBIE_AQ_STR
30+
"LIBIE_AQ_RC_UNKNOWN",
31+
};
32+
33+
#define __LIBIE_AQ_STR_NUM (ARRAY_SIZE(libie_aq_str_arr) - 1)
34+
35+
/**
36+
* libie_aq_str - get error string based on aq error
37+
* @err: admin queue error type
38+
*
39+
* Return: error string for passed error code
40+
*/
41+
const char *libie_aq_str(enum libie_aq_err err)
42+
{
43+
if (err >= ARRAY_SIZE(libie_aq_str_arr) ||
44+
!libie_aq_str_arr[err])
45+
err = __LIBIE_AQ_STR_NUM;
46+
47+
return libie_aq_str_arr[err];
48+
}
49+
EXPORT_SYMBOL_NS_GPL(libie_aq_str, "LIBIE_ADMINQ");
50+
51+
MODULE_DESCRIPTION("Intel(R) Ethernet common library - adminq helpers");
52+
MODULE_LICENSE("GPL");

include/linux/net/intel/libie/adminq.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,6 @@ static inline void *libie_aq_raw(struct libie_aq_desc *desc)
303303
return &desc->params.raw;
304304
}
305305

306+
const char *libie_aq_str(enum libie_aq_err err);
307+
306308
#endif /* __LIBIE_ADMINQ_H */

0 commit comments

Comments
 (0)