From patchwork Thu Oct 7 18:43:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 100774 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3EC69A034F; Fri, 8 Oct 2021 12:56:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C4BD041149; Fri, 8 Oct 2021 12:56:03 +0200 (CEST) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mails.dpdk.org (Postfix) with ESMTP id 3BB32411E0 for ; Thu, 7 Oct 2021 20:44:30 +0200 (CEST) Received: by mail-pl1-f182.google.com with SMTP id w14so4539464pll.2 for ; Thu, 07 Oct 2021 11:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+zmttJFKMm6EkDb0+rcX8RQxCWzD8OccSX79PjTDFjs=; b=Szh7gtg2eyJBrpIw911tD6vl6Sv+3rWqyRlU49An1wp1HmJlC+Pd39Z29VA4yyrgth qzPH8DZo6B/8Q3p7uYfyW7AdwteHfvdK0evxiwLg4m4WJ3YtTuwqNbdvl/V/n+9IVJL/ DQFmEjoRUGWS6AyI2+/SSVPYFY/aMhycvJ/FE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+zmttJFKMm6EkDb0+rcX8RQxCWzD8OccSX79PjTDFjs=; b=bUU/bv9vyB9a0VQUcqlRUC0HoIK+EGe6168JA+FYGxMkduM5cmHpK3mW8s5OWL5PUg 5At4i3EsQAqr68+OEcYqfma/JsjOCyYAecVsHRlCVN2FxRnmnuICUm32c6h0nYdXx/Qu 4Q7fPSA9IcnK6hCTUQM7KTYUNL4dPk0eZRlJnzPKbnLgZRIumniqPHz6O+QMAZ/Spmy+ qWtT2Jpwn+Kvb1Zu4/9fKhGPiWIJiAD2ddXqurqEp0KqBg7yUXtPXYKnqHwRtX9z5D3V p7jPxWgyn2mOPctANJe9nvyL7LXQTAWzzv63VfmthsffAbzITHiP4rqutp4c3GDjKBZA YdAw== X-Gm-Message-State: AOAM5304918sq8ZW7phWW8rBpH+Cduia6dzs1/3KpxsuCQYZBmOHjNGX MnSEkox2BUZWbGPaPq/E5hvprg== X-Google-Smtp-Source: ABdhPJxcPlP79RwZqYE7hrUJkYTxlgqA6dvLwvosa6YizcVO7m7EZevTD6BiwlUvcK//L/V5eBtfaw== X-Received: by 2002:a17:90a:d254:: with SMTP id o20mr7155053pjw.226.1633632269523; Thu, 07 Oct 2021 11:44:29 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([136.185.113.102]) by smtp.gmail.com with ESMTPSA id c11sm3311586pji.38.2021.10.07.11.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 11:44:29 -0700 (PDT) From: Srikanth Kaka To: Matan Azrad , Viacheslav Ovsiienko Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Fri, 8 Oct 2021 00:13:15 +0530 Message-Id: <20211007184350.73858-7-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211007184350.73858-1-srikanth.k@oneconvergence.com> References: <20211007184350.73858-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 08 Oct 2021 12:55:54 +0200 Subject: [dpdk-dev] [PATCH v2 06/41] net/mlx5: implement device attribute getter 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 Sender: "dev" Adds FreeBSD version of mlx5_os_get_dev_attr. It is same as the Linux definition Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/net/mlx5/freebsd/mlx5_os.c | 87 ++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 drivers/net/mlx5/freebsd/mlx5_os.c diff --git a/drivers/net/mlx5/freebsd/mlx5_os.c b/drivers/net/mlx5/freebsd/mlx5_os.c new file mode 100644 index 0000000000..39356f548f --- /dev/null +++ b/drivers/net/mlx5/freebsd/mlx5_os.c @@ -0,0 +1,87 @@ + +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2015 6WIND S.A. + * Copyright 2020 Mellanox Technologies, Ltd + */ + +#include +#include +#include +#include + +#include +#include + +#include "mlx5_defs.h" +#include "mlx5.h" +#include "mlx5_autoconf.h" + +/** + * Get mlx5 device attributes. The glue function query_device_ex() is called + * with out parameter of type 'struct ibv_device_attr_ex *'. Then fill in mlx5 + * device attributes from the glue out parameter. + * + * @param dev + * Pointer to ibv context. + * + * @param device_attr + * Pointer to mlx5 device attributes. + * + * @return + * 0 on success, non zero error number otherwise + */ +int +mlx5_os_get_dev_attr(void *ctx, struct mlx5_dev_attr *device_attr) +{ + int err; + struct ibv_device_attr_ex attr_ex; + memset(device_attr, 0, sizeof(*device_attr)); + err = mlx5_glue->query_device_ex(ctx, NULL, &attr_ex); + if (err) + return err; + + device_attr->device_cap_flags_ex = attr_ex.device_cap_flags_ex; + device_attr->max_qp_wr = attr_ex.orig_attr.max_qp_wr; + device_attr->max_sge = attr_ex.orig_attr.max_sge; + device_attr->max_cq = attr_ex.orig_attr.max_cq; + device_attr->max_cqe = attr_ex.orig_attr.max_cqe; + device_attr->max_mr = attr_ex.orig_attr.max_mr; + device_attr->max_pd = attr_ex.orig_attr.max_pd; + device_attr->max_qp = attr_ex.orig_attr.max_qp; + device_attr->max_srq = attr_ex.orig_attr.max_srq; + device_attr->max_srq_wr = attr_ex.orig_attr.max_srq_wr; + device_attr->raw_packet_caps = attr_ex.raw_packet_caps; + device_attr->max_rwq_indirection_table_size = + attr_ex.rss_caps.max_rwq_indirection_table_size; + device_attr->max_tso = attr_ex.tso_caps.max_tso; + device_attr->tso_supported_qpts = attr_ex.tso_caps.supported_qpts; + + struct mlx5dv_context dv_attr = { .comp_mask = 0 }; + err = mlx5_glue->dv_query_device(ctx, &dv_attr); + if (err) + return err; + + device_attr->flags = dv_attr.flags; + device_attr->comp_mask = dv_attr.comp_mask; +#ifdef HAVE_IBV_MLX5_MOD_SWP + device_attr->sw_parsing_offloads = + dv_attr.sw_parsing_caps.sw_parsing_offloads; +#endif + device_attr->min_single_stride_log_num_of_bytes = + dv_attr.striding_rq_caps.min_single_stride_log_num_of_bytes; + device_attr->max_single_stride_log_num_of_bytes = + dv_attr.striding_rq_caps.max_single_stride_log_num_of_bytes; + device_attr->min_single_wqe_log_num_of_strides = + dv_attr.striding_rq_caps.min_single_wqe_log_num_of_strides; + device_attr->max_single_wqe_log_num_of_strides = + dv_attr.striding_rq_caps.max_single_wqe_log_num_of_strides; + device_attr->stride_supported_qpts = + dv_attr.striding_rq_caps.supported_qpts; +#ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT + device_attr->tunnel_offloads_caps = dv_attr.tunnel_offloads_caps; +#endif + strlcpy(device_attr->fw_ver, attr_ex.orig_attr.fw_ver, + sizeof(device_attr->fw_ver)); + + return err; +}