From patchwork Wed Jun 16 12:51:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri Goutham X-Patchwork-Id: 12325091 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35C35C48BE8 for ; Wed, 16 Jun 2021 12:51:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1555660FE9 for ; Wed, 16 Jun 2021 12:51:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233046AbhFPMxp (ORCPT ); Wed, 16 Jun 2021 08:53:45 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:33282 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232879AbhFPMxi (ORCPT ); Wed, 16 Jun 2021 08:53:38 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15GCkGiI009776; Wed, 16 Jun 2021 05:51:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=sUpszw/kwM5wbYGbfoDfIcwxUEGoEUigSXp3GDhc4D0=; b=GEZMq7Nm2bNhDh1nN6Hvg9OaQKhsOJZUWWtJ9vOdQdOZ9M54gceZhwxo+fEyimOcbGnJ jnzHrXtqkAyNoONbhjPxgE49yHOxImInehsO0zkW0X+selaTOMFEMk59wqPOBHE2WhP/ 1EGhafYnSAQ3By+6SuXPEar755E/Q0VcMjHJYet9bPj93ty+I0RZcVUSvKOMKkxJlXQa H4h6SobG2h/uJGzps6eELx8wWUGtkj3XTyu8J1YYvF4BUEQgOzYGc62fsXuNJl27MH8/ 2Yld7cKRpLii7YQK286L6mLzfSzYGXPD+fEEXrVifAsJvC5qvs9kWQAANS1HALK8C6z/ kw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 397auvhkkc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 16 Jun 2021 05:51:31 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 16 Jun 2021 05:51:30 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Wed, 16 Jun 2021 05:51:30 -0700 Received: from machine421.marvell.com (unknown [10.29.37.2]) by maili.marvell.com (Postfix) with ESMTP id D4E643F7061; Wed, 16 Jun 2021 05:51:28 -0700 (PDT) From: To: , , CC: Sunil Goutham Subject: [PATCH net-next 1/2] net: ethtool: Support setting ntuple rule count Date: Wed, 16 Jun 2021 18:21:21 +0530 Message-ID: <1623847882-16744-2-git-send-email-sgoutham@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623847882-16744-1-git-send-email-sgoutham@marvell.com> References: <1623847882-16744-1-git-send-email-sgoutham@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: slvbzS4HPMbEjN9877gBf1Tt3Rn8wuIl X-Proofpoint-GUID: slvbzS4HPMbEjN9877gBf1Tt3Rn8wuIl X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-06-16_07:2021-06-15,2021-06-16 signatures=0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Sunil Goutham Some NICs share resources like packet filters across multiple interfaces they support. From HW point of view it is possible to use all filters for a single interface. Currently ethtool doesn't support modifying filter count so that user can allocate more filters to a interface and less to others. This patch adds ETHTOOL_SRXCLSRLCNT ioctl command for modifying filter count. example command: ./ethtool -U eth0 rule-count 256 Signed-off-by: Sunil Goutham --- include/uapi/linux/ethtool.h | 1 + net/ethtool/ioctl.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h index cfef6b0..2f16a07 100644 --- a/include/uapi/linux/ethtool.h +++ b/include/uapi/linux/ethtool.h @@ -1552,6 +1552,7 @@ enum ethtool_fec_config_bits { #define ETHTOOL_PHY_STUNABLE 0x0000004f /* Set PHY tunable configuration */ #define ETHTOOL_GFECPARAM 0x00000050 /* Get FEC settings */ #define ETHTOOL_SFECPARAM 0x00000051 /* Set FEC settings */ +#define ETHTOOL_SRXCLSRLCNT 0x00000052 /* Set RX class rule count */ /* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 3fa7a39..ced4a02 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2759,6 +2759,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr) case ETHTOOL_SRXFH: case ETHTOOL_SRXCLSRLDEL: case ETHTOOL_SRXCLSRLINS: + case ETHTOOL_SRXCLSRLCNT: rc = ethtool_set_rxnfc(dev, ethcmd, useraddr); break; case ETHTOOL_FLASHDEV: From patchwork Wed Jun 16 12:51:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri Goutham X-Patchwork-Id: 12325093 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC775C48BE6 for ; Wed, 16 Jun 2021 12:51:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B65A560FE9 for ; Wed, 16 Jun 2021 12:51:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233071AbhFPMxq (ORCPT ); Wed, 16 Jun 2021 08:53:46 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:17080 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S233065AbhFPMxk (ORCPT ); Wed, 16 Jun 2021 08:53:40 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15GCkGCA009765; Wed, 16 Jun 2021 05:51:33 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=ht6NUbClPoYToQ+eOLOkoGv/Ugfew8ZjdTNfLSNODP4=; b=gTxV9sdmhD8+kDOxHPpKmmfL1p7RfnmcGbHqV/W6lUmuh461FWt/PfW/hbenZLP7htU6 JL4qJX95mFss4Md/LL2RAp04XPbImdXQGIwallN8uWydRDj/ecal9EWmJRu/jgoIRPcD X/+gmBLQyn1kxq7KCfFiTfFHvOqzWPJPDI0x45XkZk7UZpS83TrKhP80eMBmcj9iXoh5 iE7oLphMW/fQkY90pvhwjJ6UjZ/XtyxRkcU03VNu8Xr8RnPtIFbvxjDy/ds8EdzbyVDH ex8wj+TuPXmVhnKhuBhkMn6vMnHOSyBEr/bTY0SRXPEmCjoNxFTRV5wQh5q8JwmPlHnu BA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 397auvhkkf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 16 Jun 2021 05:51:33 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 16 Jun 2021 05:51:32 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 16 Jun 2021 05:51:32 -0700 Received: from machine421.marvell.com (unknown [10.29.37.2]) by maili.marvell.com (Postfix) with ESMTP id C09803F704B; Wed, 16 Jun 2021 05:51:30 -0700 (PDT) From: To: , , CC: Sunil Goutham Subject: [PATCH net-next 2/2] octeontx2-pf: Support setting ntuple rule count Date: Wed, 16 Jun 2021 18:21:22 +0530 Message-ID: <1623847882-16744-3-git-send-email-sgoutham@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623847882-16744-1-git-send-email-sgoutham@marvell.com> References: <1623847882-16744-1-git-send-email-sgoutham@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: ezARarr-4vhRHwopheetFMlDKk0cFPdZ X-Proofpoint-GUID: ezARarr-4vhRHwopheetFMlDKk0cFPdZ X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-06-16_07:2021-06-15,2021-06-16 signatures=0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Sunil Goutham Added support for changing ethtool ntuple filter count. Rule count change is supported only when there are no ntuple filters installed. Signed-off-by: Sunil Goutham --- .../ethernet/marvell/octeontx2/nic/otx2_common.h | 1 + .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 3 +++ .../ethernet/marvell/octeontx2/nic/otx2_flows.c | 27 ++++++++++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h index 234b330..5420aca 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h @@ -820,6 +820,7 @@ int otx2_get_all_flows(struct otx2_nic *pfvf, int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc); int otx2_remove_flow(struct otx2_nic *pfvf, u32 location); +int otx2_set_flow_rule_count(struct otx2_nic *pfvf, int count); int otx2_prepare_flow_request(struct ethtool_rx_flow_spec *fsp, struct npc_install_flow_req *req); void otx2_rss_ctx_flow_del(struct otx2_nic *pfvf, int ctx_id); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c index 8df748e..753a8cf 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c @@ -690,6 +690,9 @@ static int otx2_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *nfc) if (netif_running(dev) && ntuple) ret = otx2_remove_flow(pfvf, nfc->fs.location); break; + case ETHTOOL_SRXCLSRLCNT: + ret = otx2_set_flow_rule_count(pfvf, nfc->rule_cnt); + break; default: break; } diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c index 8c97106..61530c8 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c @@ -117,12 +117,29 @@ static int otx2_alloc_ntuple_mcam_entries(struct otx2_nic *pfvf, u16 count) if (allocated != count) netdev_info(pfvf->netdev, - "Unable to allocate %d MCAM entries for ntuple, got %d\n", - count, allocated); + "Unable to allocate %d MCAM entries above default rules " + "start index %d, got only %d\n", + count, flow_cfg->def_ent[0], allocated); return allocated; } +int otx2_set_flow_rule_count(struct otx2_nic *pfvf, int count) +{ + struct otx2_flow_config *flow_cfg = pfvf->flow_cfg; + + if (!flow_cfg) + return 0; + + if (flow_cfg->nr_flows) { + netdev_err(pfvf->netdev, + "Cannot change count when there are active rules\n"); + return 0; + } + + return otx2_alloc_ntuple_mcam_entries(pfvf, count); +} + int otx2_alloc_mcam_entries(struct otx2_nic *pfvf) { struct otx2_flow_config *flow_cfg = pfvf->flow_cfg; @@ -827,6 +844,12 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc) u32 ring; int err; + if (!flow_cfg->ntuple_max_flows) { + netdev_err(pfvf->netdev, + "Ntuple rule count is 0, allocate and retry\n"); + return -EINVAL; + } + ring = ethtool_get_flow_spec_ring(fsp->ring_cookie); if (!(pfvf->flags & OTX2_FLAG_NTUPLE_SUPPORT)) return -ENOMEM;