From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 159FAA0543; Fri, 8 Jul 2022 02:16:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5249042826; Fri, 8 Jul 2022 02:16:09 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 343A640041 for ; Fri, 8 Jul 2022 02:16:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657239366; x=1688775366; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=4Tt08NPmJjgBCMcuYTy9FvBdHOok+xlE5efOSBB/9uM=; b=jDeQhhNIphWF7Y8SM/J4IuXf8o9QglfYBkIibIFdZDFaywajW2ncH3Il cqIub0+1EJxJdatY8ksqadrWq8KR1z8TlnZict6q0KJt4m+73Cn4p88ue hEjGo+xMtxya2oz+K0QT6IewL5NaBw8v4Hi1ZLV+MWCte/Ij18qAF16VM 9Y1FCpvBO5VgGafBEMzJh/iGrPFu7L7wQ/jz3thNN1twQ35Qjg5YK2O2O z9KzsphVTRqK0SFE8+WabWMmLvuwJ0t184OFVRAhTPfNq8CwBXmx2DP1+ ISFExn3PXMiwq9JGC39sVV0PiKiohgoSKHoMIZGytMsmXgbW6UqttCmCI A==; X-IronPort-AV: E=McAfee;i="6400,9594,10401"; a="264563078" X-IronPort-AV: E=Sophos;i="5.92,253,1650956400"; d="scan'208";a="264563078" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2022 17:16:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,253,1650956400"; d="scan'208";a="591387530" Received: from skx-5gnr-sc12-4.sc.intel.com ([172.25.69.210]) by orsmga007.jf.intel.com with ESMTP; 07 Jul 2022 17:16:03 -0700 From: Nicolas Chautru To: dev@dpdk.org, thomas@monjalon.net, gakhil@marvell.com, hemant.agrawal@nxp.com, trix@redhat.com Cc: maxime.coquelin@redhat.com, mdr@ashroe.eu, bruce.richardson@intel.com, david.marchand@redhat.com, stephen@networkplumber.org, Nicolas Chautru Subject: [PATCH v1 03/10] baseband/acc200: add info get function Date: Thu, 7 Jul 2022 17:01:36 -0700 Message-Id: <1657238503-143836-4-git-send-email-nicolas.chautru@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1657238503-143836-1-git-send-email-nicolas.chautru@intel.com> References: <1657238503-143836-1-git-send-email-nicolas.chautru@intel.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add support for info_get to allow to query the device. Null capability exposed. Signed-off-by: Nicolas Chautru --- drivers/baseband/acc200/acc200_pmd.h | 2 + drivers/baseband/acc200/rte_acc200_cfg.h | 94 ++++++++++++ drivers/baseband/acc200/rte_acc200_pmd.c | 256 +++++++++++++++++++++++++++++++ 3 files changed, 352 insertions(+) create mode 100644 drivers/baseband/acc200/rte_acc200_cfg.h diff --git a/drivers/baseband/acc200/acc200_pmd.h b/drivers/baseband/acc200/acc200_pmd.h index b420524..91e0798 100644 --- a/drivers/baseband/acc200/acc200_pmd.h +++ b/drivers/baseband/acc200/acc200_pmd.h @@ -7,6 +7,7 @@ #include "acc200_pf_enum.h" #include "acc200_vf_enum.h" +#include "rte_acc200_cfg.h" /* Helper macro for logging */ #define rte_bbdev_log(level, fmt, ...) \ @@ -619,6 +620,7 @@ struct acc200_registry_addr { struct acc200_device { void *mmio_base; /**< Base address of MMIO registers (BAR0) */ uint32_t ddr_size; /* Size in kB */ + struct rte_acc200_conf acc200_conf; /* ACC200 Initial configuration */ bool pf_device; /**< True if this is a PF ACC200 device */ bool configured; /**< True if this ACC200 device is configured */ }; diff --git a/drivers/baseband/acc200/rte_acc200_cfg.h b/drivers/baseband/acc200/rte_acc200_cfg.h new file mode 100644 index 0000000..fcccfbf --- /dev/null +++ b/drivers/baseband/acc200/rte_acc200_cfg.h @@ -0,0 +1,94 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2021 Intel Corporation + */ + +#ifndef _RTE_ACC200_CFG_H_ +#define _RTE_ACC200_CFG_H_ + +/** + * @file rte_acc200_cfg.h + * + * Functions for configuring ACC200 HW, exposed directly to applications. + * Configuration related to encoding/decoding is done through the + * librte_bbdev library. + * + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +/**< Number of Virtual Functions ACC200 supports */ +#define RTE_ACC200_NUM_VFS 16 + +/** + * Definition of Queue Topology for ACC200 Configuration + * Some level of details is abstracted out to expose a clean interface + * given that comprehensive flexibility is not required + */ +struct rte_acc200_queue_topology { + /** Number of QGroups in incremental order of priority */ + uint16_t num_qgroups; + /** + * All QGroups have the same number of AQs here. + * Note : Could be made a 16-array if more flexibility is really + * required + */ + uint16_t num_aqs_per_groups; + /** + * Depth of the AQs is the same of all QGroups here. Log2 Enum : 2^N + * Note : Could be made a 16-array if more flexibility is really + * required + */ + uint16_t aq_depth_log2; + /** + * Index of the first Queue Group Index - assuming contiguity + * Initialized as -1 + */ + int8_t first_qgroup_index; +}; + +/** + * Definition of Arbitration related parameters for ACC200 Configuration + */ +struct rte_acc200_arbitration { + /** Default Weight for VF Fairness Arbitration */ + uint16_t round_robin_weight; + uint32_t gbr_threshold1; /**< Guaranteed Bitrate Threshold 1 */ + uint32_t gbr_threshold2; /**< Guaranteed Bitrate Threshold 2 */ +}; + +/** + * Structure to pass ACC200 configuration. + * Note: all VF Bundles will have the same configuration. + */ +struct rte_acc200_conf { + bool pf_mode_en; /**< 1 if PF is used for dataplane, 0 for VFs */ + /** 1 if input '1' bit is represented by a positive LLR value, 0 if '1' + * bit is represented by a negative value. + */ + bool input_pos_llr_1_bit; + /** 1 if output '1' bit is represented by a positive value, 0 if '1' + * bit is represented by a negative value. + */ + bool output_pos_llr_1_bit; + uint16_t num_vf_bundles; /**< Number of VF bundles to setup */ + /** Queue topology for each operation type */ + struct rte_acc200_queue_topology q_ul_4g; + struct rte_acc200_queue_topology q_dl_4g; + struct rte_acc200_queue_topology q_ul_5g; + struct rte_acc200_queue_topology q_dl_5g; + struct rte_acc200_queue_topology q_fft; + /** Arbitration configuration for each operation type */ + struct rte_acc200_arbitration arb_ul_4g[RTE_ACC200_NUM_VFS]; + struct rte_acc200_arbitration arb_dl_4g[RTE_ACC200_NUM_VFS]; + struct rte_acc200_arbitration arb_ul_5g[RTE_ACC200_NUM_VFS]; + struct rte_acc200_arbitration arb_dl_5g[RTE_ACC200_NUM_VFS]; + struct rte_acc200_arbitration arb_fft[RTE_ACC200_NUM_VFS]; +}; + +#endif /* _RTE_ACC200_CFG_H_ */ diff --git a/drivers/baseband/acc200/rte_acc200_pmd.c b/drivers/baseband/acc200/rte_acc200_pmd.c index 70b6cc5..ce72654 100644 --- a/drivers/baseband/acc200/rte_acc200_pmd.c +++ b/drivers/baseband/acc200/rte_acc200_pmd.c @@ -29,6 +29,207 @@ RTE_LOG_REGISTER_DEFAULT(acc200_logtype, NOTICE); #endif +/* Read a register of a ACC200 device */ +static inline uint32_t +acc200_reg_read(struct acc200_device *d, uint32_t offset) +{ + + void *reg_addr = RTE_PTR_ADD(d->mmio_base, offset); + uint32_t ret = *((volatile uint32_t *)(reg_addr)); + return rte_le_to_cpu_32(ret); +} + +/* Calculate the offset of the enqueue register */ +static inline uint32_t +queue_offset(bool pf_device, uint8_t vf_id, uint8_t qgrp_id, uint16_t aq_id) +{ + if (pf_device) + return ((vf_id << 12) + (qgrp_id << 7) + (aq_id << 3) + + HWPfQmgrIngressAq); + else + return ((qgrp_id << 7) + (aq_id << 3) + + HWVfQmgrIngressAq); +} + +enum {UL_4G = 0, UL_5G, DL_4G, DL_5G, FFT, NUM_ACC}; + +/* Return the queue topology for a Queue Group Index */ +static inline void +qtopFromAcc(struct rte_acc200_queue_topology **qtop, int acc_enum, + struct rte_acc200_conf *acc200_conf) +{ + struct rte_acc200_queue_topology *p_qtop; + p_qtop = NULL; + switch (acc_enum) { + case UL_4G: + p_qtop = &(acc200_conf->q_ul_4g); + break; + case UL_5G: + p_qtop = &(acc200_conf->q_ul_5g); + break; + case DL_4G: + p_qtop = &(acc200_conf->q_dl_4g); + break; + case DL_5G: + p_qtop = &(acc200_conf->q_dl_5g); + break; + case FFT: + p_qtop = &(acc200_conf->q_fft); + break; + default: + /* NOTREACHED */ + rte_bbdev_log(ERR, "Unexpected error evaluating qtopFromAcc %d", + acc_enum); + break; + } + *qtop = p_qtop; +} + +static void +initQTop(struct rte_acc200_conf *acc200_conf) +{ + acc200_conf->q_ul_4g.num_aqs_per_groups = 0; + acc200_conf->q_ul_4g.num_qgroups = 0; + acc200_conf->q_ul_4g.first_qgroup_index = -1; + acc200_conf->q_ul_5g.num_aqs_per_groups = 0; + acc200_conf->q_ul_5g.num_qgroups = 0; + acc200_conf->q_ul_5g.first_qgroup_index = -1; + acc200_conf->q_dl_4g.num_aqs_per_groups = 0; + acc200_conf->q_dl_4g.num_qgroups = 0; + acc200_conf->q_dl_4g.first_qgroup_index = -1; + acc200_conf->q_dl_5g.num_aqs_per_groups = 0; + acc200_conf->q_dl_5g.num_qgroups = 0; + acc200_conf->q_dl_5g.first_qgroup_index = -1; + acc200_conf->q_fft.num_aqs_per_groups = 0; + acc200_conf->q_fft.num_qgroups = 0; + acc200_conf->q_fft.first_qgroup_index = -1; +} + +static inline void +updateQtop(uint8_t acc, uint8_t qg, struct rte_acc200_conf *acc200_conf, + struct acc200_device *d) { + uint32_t reg; + struct rte_acc200_queue_topology *q_top = NULL; + qtopFromAcc(&q_top, acc, acc200_conf); + if (unlikely(q_top == NULL)) + return; + uint16_t aq; + q_top->num_qgroups++; + if (q_top->first_qgroup_index == -1) { + q_top->first_qgroup_index = qg; + /* Can be optimized to assume all are enabled by default */ + reg = acc200_reg_read(d, queue_offset(d->pf_device, + 0, qg, ACC200_NUM_AQS - 1)); + if (reg & ACC200_QUEUE_ENABLE) { + q_top->num_aqs_per_groups = ACC200_NUM_AQS; + return; + } + q_top->num_aqs_per_groups = 0; + for (aq = 0; aq < ACC200_NUM_AQS; aq++) { + reg = acc200_reg_read(d, queue_offset(d->pf_device, + 0, qg, aq)); + if (reg & ACC200_QUEUE_ENABLE) + q_top->num_aqs_per_groups++; + } + } +} + +/* Fetch configuration enabled for the PF/VF using MMIO Read (slow) */ +static inline void +fetch_acc200_config(struct rte_bbdev *dev) +{ + struct acc200_device *d = dev->data->dev_private; + struct rte_acc200_conf *acc200_conf = &d->acc200_conf; + const struct acc200_registry_addr *reg_addr; + uint8_t acc, qg; + uint32_t reg_aq, reg_len0, reg_len1, reg0, reg1; + uint32_t reg_mode, idx; + + /* No need to retrieve the configuration is already done */ + if (d->configured) + return; + + /* Choose correct registry addresses for the device type */ + if (d->pf_device) + reg_addr = &pf_reg_addr; + else + reg_addr = &vf_reg_addr; + + d->ddr_size = 0; + + /* Single VF Bundle by VF */ + acc200_conf->num_vf_bundles = 1; + initQTop(acc200_conf); + + struct rte_acc200_queue_topology *q_top = NULL; + int qman_func_id[ACC200_NUM_ACCS] = {ACC200_ACCMAP_0, ACC200_ACCMAP_1, + ACC200_ACCMAP_2, ACC200_ACCMAP_3, ACC200_ACCMAP_4}; + reg0 = acc200_reg_read(d, reg_addr->qman_group_func); + reg1 = acc200_reg_read(d, reg_addr->qman_group_func + 4); + for (qg = 0; qg < ACC200_NUM_QGRPS; qg++) { + reg_aq = acc200_reg_read(d, + queue_offset(d->pf_device, 0, qg, 0)); + if (reg_aq & ACC200_QUEUE_ENABLE) { + /* printf("Qg enabled %d %x\n", qg, reg_aq); */ + if (qg < ACC200_NUM_QGRPS_PER_WORD) + idx = (reg0 >> (qg * 4)) & 0x7; + else + idx = (reg1 >> ((qg - + ACC200_NUM_QGRPS_PER_WORD) * 4)) & 0x7; + if (idx < ACC200_NUM_ACCS) { + acc = qman_func_id[idx]; + updateQtop(acc, qg, acc200_conf, d); + } + } + } + + /* Check the depth of the AQs*/ + reg_len0 = acc200_reg_read(d, reg_addr->depth_log0_offset); + reg_len1 = acc200_reg_read(d, reg_addr->depth_log1_offset); + for (acc = 0; acc < NUM_ACC; acc++) { + qtopFromAcc(&q_top, acc, acc200_conf); + if (q_top->first_qgroup_index < ACC200_NUM_QGRPS_PER_WORD) + q_top->aq_depth_log2 = (reg_len0 >> + (q_top->first_qgroup_index * 4)) + & 0xF; + else + q_top->aq_depth_log2 = (reg_len1 >> + ((q_top->first_qgroup_index - + ACC200_NUM_QGRPS_PER_WORD) * 4)) + & 0xF; + } + + /* Read PF mode */ + if (d->pf_device) { + reg_mode = acc200_reg_read(d, HWPfHiPfMode); + acc200_conf->pf_mode_en = (reg_mode == ACC200_PF_VAL) ? 1 : 0; + } else { + reg_mode = acc200_reg_read(d, reg_addr->hi_mode); + acc200_conf->pf_mode_en = reg_mode & 1; + } + + rte_bbdev_log_debug( + "%s Config LLR SIGN IN/OUT %s %s QG %u %u %u %u %u AQ %u %u %u %u %u Len %u %u %u %u %u\n", + (d->pf_device) ? "PF" : "VF", + (acc200_conf->input_pos_llr_1_bit) ? "POS" : "NEG", + (acc200_conf->output_pos_llr_1_bit) ? "POS" : "NEG", + acc200_conf->q_ul_4g.num_qgroups, + acc200_conf->q_dl_4g.num_qgroups, + acc200_conf->q_ul_5g.num_qgroups, + acc200_conf->q_dl_5g.num_qgroups, + acc200_conf->q_fft.num_qgroups, + acc200_conf->q_ul_4g.num_aqs_per_groups, + acc200_conf->q_dl_4g.num_aqs_per_groups, + acc200_conf->q_ul_5g.num_aqs_per_groups, + acc200_conf->q_dl_5g.num_aqs_per_groups, + acc200_conf->q_fft.num_aqs_per_groups, + acc200_conf->q_ul_4g.aq_depth_log2, + acc200_conf->q_dl_4g.aq_depth_log2, + acc200_conf->q_ul_5g.aq_depth_log2, + acc200_conf->q_dl_5g.aq_depth_log2, + acc200_conf->q_fft.aq_depth_log2); +} + /* Free memory used for software rings */ static int acc200_dev_close(struct rte_bbdev *dev) @@ -39,9 +240,57 @@ return 0; } +/* Get ACC200 device info */ +static void +acc200_dev_info_get(struct rte_bbdev *dev, + struct rte_bbdev_driver_info *dev_info) +{ + struct acc200_device *d = dev->data->dev_private; + int i; + static const struct rte_bbdev_op_cap bbdev_capabilities[] = { + RTE_BBDEV_END_OF_CAPABILITIES_LIST() + }; + + static struct rte_bbdev_queue_conf default_queue_conf; + default_queue_conf.socket = dev->data->socket_id; + default_queue_conf.queue_size = ACC200_MAX_QUEUE_DEPTH; + + dev_info->driver_name = dev->device->driver->name; + + /* Read and save the populated config from ACC200 registers */ + fetch_acc200_config(dev); + + /* Exposed number of queues */ + dev_info->num_queues[RTE_BBDEV_OP_NONE] = 0; + dev_info->num_queues[RTE_BBDEV_OP_TURBO_DEC] = 0; + dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = 0; + dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = 0; + dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = 0; + dev_info->num_queues[RTE_BBDEV_OP_FFT] = 0; + dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = 0; + dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] = 0; + dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = 0; + dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = 0; + dev_info->queue_priority[RTE_BBDEV_OP_FFT] = 0; + dev_info->max_num_queues = 0; + for (i = RTE_BBDEV_OP_NONE; i <= RTE_BBDEV_OP_FFT; i++) + dev_info->max_num_queues += dev_info->num_queues[i]; + dev_info->queue_size_lim = ACC200_MAX_QUEUE_DEPTH; + dev_info->hardware_accelerated = true; + dev_info->max_dl_queue_priority = + d->acc200_conf.q_dl_4g.num_qgroups - 1; + dev_info->max_ul_queue_priority = + d->acc200_conf.q_ul_4g.num_qgroups - 1; + dev_info->default_queue_conf = default_queue_conf; + dev_info->cpu_flag_reqs = NULL; + dev_info->min_alignment = 1; + dev_info->capabilities = bbdev_capabilities; + dev_info->harq_buffer_size = 0; +} static const struct rte_bbdev_ops acc200_bbdev_ops = { .close = acc200_dev_close, + .info_get = acc200_dev_info_get, }; /* ACC200 PCI PF address map */ @@ -60,6 +309,13 @@ {.device_id = 0}, }; +/* Read flag value 0/1 from bitmap */ +static inline bool +check_bit(uint32_t bitmap, uint32_t bitmask) +{ + return bitmap & bitmask; +} + /* Initialization Function */ static void acc200_bbdev_init(struct rte_bbdev *dev, struct rte_pci_driver *drv) -- 1.8.3.1