From patchwork Wed Mar 12 06:24:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Swiatkowski X-Patchwork-Id: 14012902 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92DFD1E5B6F for ; Wed, 12 Mar 2025 06:24:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741760684; cv=none; b=mrkrnU/v2/ej7s47wvdp3suq9z6CeY/iL+k4XgdC5TC6qhQLGV3COu/j9NiywfrcIMlmXmScTpiqJK1eh4VvN4u9E1koMYBzggNg7abMONkGow6rT2sB957wmWW0fsFIyqYmWVlD4azbm1x4vvdylrY7rX/ZTsNiz2Pf6rTDaBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741760684; c=relaxed/simple; bh=ADt1S24yAb4bFEoVO+1u2kYic/syysss/A9jxbL1OEs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pcQ3IYVeD3YK2aW8XLV/W6CVcYYLqPk13FECYisLUK7gTfkNHAVnJ7xzHXN6RHvZLf6GcA6pXkPdYin/7Hxl8qmWl4dsLeOwnWlrwKi3J7SOhNo++CekI2enuBXGIhwfF8BO9lxUuS6yZJbkbF0j+Qqx0Q8jnh7+4yeBgXhNACE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=VfAtmDNR; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VfAtmDNR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741760683; x=1773296683; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ADt1S24yAb4bFEoVO+1u2kYic/syysss/A9jxbL1OEs=; b=VfAtmDNRKzUZPAycZjvKHe6GFcmVhhmzF7ySawYbNNHKaM1vSAK4ChOY ayu3KTecyj4Z2pMEG9jjI/fbzQPa90H2RNe/W8bCww3lVXL5EuaP6kJX0 ealuGMwK863kGmUv4Fp64A1DQtpd8jTEpBICTKuWpcj0UK+KSOTYWT8Rg TfjfrQGG2IxddSsSSj1bLS7nfD1LjXA12PAxwa0Q8bgnWrOmnM8sp75iY +sbl+ScaKVu1lCAyRZYSEUgJ3fyaJB+XgXX9UZefSaDumU3MvDor6Cc1A b9mpfTo+wguW2Ft41KAlHt0Jej697aJ/ozY6tSbn/qoCY4cpCJ9jL2GyP g==; X-CSE-ConnectionGUID: pF28ZkrxTiuzM/QWTU3ylg== X-CSE-MsgGUID: pPQ8PjL7TQ6jbJF9C5i4Pw== X-IronPort-AV: E=McAfee;i="6700,10204,11370"; a="43005565" X-IronPort-AV: E=Sophos;i="6.14,240,1736841600"; d="scan'208";a="43005565" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2025 23:24:43 -0700 X-CSE-ConnectionGUID: 3ZeUm6cDSkOljz7lUm703A== X-CSE-MsgGUID: Jd9K+Fs5QgCRK2LKDafC3w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,240,1736841600"; d="scan'208";a="120569519" Received: from gk3153-dr2-r750-36946.igk.intel.com ([10.102.20.192]) by fmviesa007.fm.intel.com with ESMTP; 11 Mar 2025 23:24:40 -0700 From: Michal Swiatkowski To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, aleksander.lobakin@intel.com, przemyslaw.kitszel@intel.com, piotr.kwapulinski@intel.com, aleksandr.loktionov@intel.com, jedrzej.jagielski@intel.com, larysa.zaremba@intel.com Subject: [iwl-next v1 5/8] libie: add adminq helper for converting err to str Date: Wed, 12 Mar 2025 07:24:23 +0100 Message-ID: <20250312062426.2544608-6-michal.swiatkowski@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20250312062426.2544608-1-michal.swiatkowski@linux.intel.com> References: <20250312062426.2544608-1-michal.swiatkowski@linux.intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org 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 Suggested-by: Alexander Lobakin Signed-off-by: Michal Swiatkowski --- drivers/net/ethernet/intel/libie/Kconfig | 6 +++ drivers/net/ethernet/intel/libie/Makefile | 4 ++ include/linux/net/intel/libie/adminq.h | 2 + drivers/net/ethernet/intel/libie/adminq.c | 50 +++++++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 drivers/net/ethernet/intel/libie/adminq.c diff --git a/drivers/net/ethernet/intel/libie/Kconfig b/drivers/net/ethernet/intel/libie/Kconfig index 33aff6bc8f81..e6072758e3d8 100644 --- a/drivers/net/ethernet/intel/libie/Kconfig +++ b/drivers/net/ethernet/intel/libie/Kconfig @@ -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). diff --git a/drivers/net/ethernet/intel/libie/Makefile b/drivers/net/ethernet/intel/libie/Makefile index ffd27fab916a..e98f00b865d3 100644 --- a/drivers/net/ethernet/intel/libie/Makefile +++ b/drivers/net/ethernet/intel/libie/Makefile @@ -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 diff --git a/include/linux/net/intel/libie/adminq.h b/include/linux/net/intel/libie/adminq.h index 684cc1c76107..5e9c8fe58692 100644 --- a/include/linux/net/intel/libie/adminq.h +++ b/include/linux/net/intel/libie/adminq.h @@ -304,4 +304,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 */ diff --git a/drivers/net/ethernet/intel/libie/adminq.c b/drivers/net/ethernet/intel/libie/adminq.c new file mode 100644 index 000000000000..6c95619d1f2b --- /dev/null +++ b/drivers/net/ethernet/intel/libie/adminq.c @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (C) 2025 Intel Corporation */ + +#include +#include + +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 + */ +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");