From patchwork Thu Dec 21 18:05:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 135485 X-Patchwork-Delegate: ajit.khaparde@broadcom.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 4FF2343752; Thu, 21 Dec 2023 19:07:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 15EAA42EB1; Thu, 21 Dec 2023 19:05:53 +0100 (CET) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mails.dpdk.org (Postfix) with ESMTP id 69CF342ECA for ; Thu, 21 Dec 2023 19:05:49 +0100 (CET) Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1d32c5ce32eso16017695ad.0 for ; Thu, 21 Dec 2023 10:05:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1703181948; x=1703786748; darn=dpdk.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=YymZtAb/ah8jliUDD8dQSttaioJ5qPNXKttH9FOr8Cs=; b=dqjvzaV+aphbbKMX8IA5MATe71gNhfBcxIPEw+SbTwzDuyMqmrnkvFfttXr1w+i9RN 6MxQtB1aohbYv1athqy+8K64oyzvGQjc9uWwvMEGADITHfBFfUrUm9jH1iPuftd43Ojv QywH9QebswxGPPvnzkRk279gLgkQ1/r5j3Z/o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703181948; x=1703786748; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YymZtAb/ah8jliUDD8dQSttaioJ5qPNXKttH9FOr8Cs=; b=gDpmu/bP1fA8zHBSgoSuiwwVFRYYXaxg2ZZzPUY17IFIY6znurNfi2cZRbzF31KQ7O aL7X30OL1ZqNqbpNvYNzrnS2j0YslYeTvItITOF5wFIN+xnA8jLOuR+UJepo+bdyk/sN 562PQCuTJWyIwKpjkEMkAkjok9+0QW6FN6w/XJbqDHrc5DwcA2YHtIV4tJgCctVaWljo R3i+mmHyWPqzTFDFO5DU7AS802OSPL+3na5+fXV5lisHHwLLuPIc6vNY+QEuwFVA53HR cuII8AkS4k3+kvc9M+mn0d+DUJzWcr7LZaLUER5yy+h4b496N1X6uOVmuQliCfEeTdUR KGtQ== X-Gm-Message-State: AOJu0YyynMY43iN2x6J7D5VqfqmkFlzerHWrrIsrpX2ym3tsQa6iBrNx DyMIquz+Pt6RV1jtovgFmrNx1OAnC7st0w+M3su9mE5XHVlo84CGw5Ut2fPp0Wrt1Tnw3vITRlA Bj++Bk757k8HsITrFAQDibM6+XBfGddOq+M7gYtN3oy5OMh3wRgdbVk+IdY3s34/tPkLZbVzL8O s= X-Google-Smtp-Source: AGHT+IE2axJH3Bw0CF739JIzLuJkXA8Rf2N4fK3QKuTFhxLrHzDa47nqyOfN4m5+BPj09wSiYeoJZQ== X-Received: by 2002:a17:902:7842:b0:1d3:dfef:52f2 with SMTP id e2-20020a170902784200b001d3dfef52f2mr85102pln.13.1703181947910; Thu, 21 Dec 2023 10:05:47 -0800 (PST) Received: from C02GC2QQMD6T.wifi.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j17-20020a170902da9100b001d3b3ac2d7bsm1916379plx.245.2023.12.21.10.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 10:05:47 -0800 (PST) From: Ajit Khaparde To: dev@dpdk.org Cc: Damodharam Ammepalli Subject: [PATCH 10/18] net/bnxt: add flow query callback Date: Thu, 21 Dec 2023 10:05:21 -0800 Message-Id: <20231221180529.18687-11-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20231221180529.18687-1-ajit.khaparde@broadcom.com> References: <20231221180529.18687-1-ajit.khaparde@broadcom.com> MIME-Version: 1.0 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 From: Damodharam Ammepalli This patch addsbnxt query callback to rte_flow_ops in non TruFlow mode. At this point only the RSS hash function type is displayed. Signed-off-by: Damodharam Ammepalli Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_flow.c | 61 ++++++++++++++++++++++++++++++++++++ drivers/net/bnxt/bnxt_vnic.c | 11 +++++++ drivers/net/bnxt/bnxt_vnic.h | 2 ++ 3 files changed, 74 insertions(+) diff --git a/drivers/net/bnxt/bnxt_flow.c b/drivers/net/bnxt/bnxt_flow.c index 2d707b48d2..f25bc6ff78 100644 --- a/drivers/net/bnxt/bnxt_flow.c +++ b/drivers/net/bnxt/bnxt_flow.c @@ -1917,6 +1917,66 @@ void bnxt_flow_cnt_alarm_cb(void *arg) (void *)bp); } +/* Query an requested flow rule. */ +static int +bnxt_flow_query_all(struct rte_flow *flow, + const struct rte_flow_action *actions, void *data, + struct rte_flow_error *error) +{ + struct rte_flow_action_rss *rss_conf; + struct bnxt_vnic_info *vnic; + + vnic = flow->vnic; + if (vnic == NULL) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_HANDLE, flow, + "Invalid flow: failed to query flow."); + + for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { + switch (actions->type) { + case RTE_FLOW_ACTION_TYPE_VOID: + break; + case RTE_FLOW_ACTION_TYPE_COUNT: + break; + case RTE_FLOW_ACTION_TYPE_RSS: + /* Full details of rte_flow_action_rss not available yet TBD*/ + rss_conf = (struct rte_flow_action_rss *)data; + + /* toeplitz is default */ + if (vnic->ring_select_mode == + HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_TOEPLITZ) + rss_conf->func = vnic->hash_f_local; + else + rss_conf->func = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; + + break; + default: + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ACTION, actions, + "action is not supported"); + } + } + + return 0; +} + +static int +bnxt_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow, + const struct rte_flow_action *actions, void *data, + struct rte_flow_error *error) +{ + struct bnxt *bp = dev->data->dev_private; + int ret = 0; + + if (bp == NULL) + return -ENODEV; + + bnxt_acquire_flow_lock(bp); + ret = bnxt_flow_query_all(flow, actions, data, error); + bnxt_release_flow_lock(bp); + + return ret; +} static struct rte_flow * bnxt_flow_create(struct rte_eth_dev *dev, @@ -2374,4 +2434,5 @@ const struct rte_flow_ops bnxt_flow_ops = { .create = bnxt_flow_create, .destroy = bnxt_flow_destroy, .flush = bnxt_flow_flush, + .query = bnxt_flow_query, }; diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c index 6a57f85ea7..bf1f0ea09f 100644 --- a/drivers/net/bnxt/bnxt_vnic.c +++ b/drivers/net/bnxt/bnxt_vnic.c @@ -1335,6 +1335,9 @@ int bnxt_rte_flow_to_hwrm_ring_select_mode(enum rte_eth_hash_function hash_f, } vnic->ring_select_mode = _bnxt_rte_to_hwrm_ring_select_mode(hash_f); + vnic->hash_f_local = hash_f; + /* shadow copy types as !hash_f is always true with default func */ + vnic->rss_types_local = types; return 0; } @@ -1359,6 +1362,8 @@ int bnxt_rte_eth_to_hwrm_ring_select_mode(struct bnxt *bp, uint64_t types, */ vnic->ring_select_mode = HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_TOEPLITZ; + vnic->hash_f_local = + HWRM_VNIC_RSS_CFG_INPUT_RING_SELECT_MODE_TOEPLITZ; return 0; } @@ -1367,6 +1372,12 @@ void bnxt_hwrm_rss_to_rte_hash_conf(struct bnxt_vnic_info *vnic, { uint32_t hash_types; + /* check for local shadow rte types */ + if (vnic->rss_types_local != 0) { + *rss_conf = vnic->rss_types_local; + return; + } + hash_types = vnic->hash_type; *rss_conf = 0; if (hash_types & HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4) diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h index d01c9ebdb4..93155648e2 100644 --- a/drivers/net/bnxt/bnxt_vnic.h +++ b/drivers/net/bnxt/bnxt_vnic.h @@ -79,6 +79,8 @@ struct bnxt_vnic_info { STAILQ_HEAD(, bnxt_filter_info) filter; STAILQ_HEAD(, rte_flow) flow_list; uint8_t ring_select_mode; + enum rte_eth_hash_function hash_f_local; + uint64_t rss_types_local; }; struct bnxt_vnic_queue_db {