From patchwork Tue Oct 5 17:15:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Subbaraya Sundeep X-Patchwork-Id: 12537343 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71C01C433FE for ; Tue, 5 Oct 2021 17:15:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B06F6117A for ; Tue, 5 Oct 2021 17:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236729AbhJERRp (ORCPT ); Tue, 5 Oct 2021 13:17:45 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:10942 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236711AbhJERRo (ORCPT ); Tue, 5 Oct 2021 13:17:44 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 195Fub5D026710; Tue, 5 Oct 2021 10:15:53 -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=Um9s9/TLHNrNMcB2c9SFF6AaxMvdu82WG4m2JK9f+8k=; b=OQp4WDQxAoFHeA/ybo1cMav78PdqH/mjDzJYr44wXKckjqXA+2jcPXPRVgtMEBcNof// Pmw5y0f9eK+rUuppmeiANDDEFpkwsaSIujStsny591pqaa92ODWV6OvD+r/pjSWvuTUV V6x4ls0H0Zvyua+OuYRGOSwlFpnWUYcKyqxonPGITU7WEpxkcoO9Ut4fgUEhFCVtGAFF av9l11TbaIa9Q5dgm3G7UMe49wMr1AxcLS4L/BlswgSdq2VbwDsmSf0zYNj6fghqUYxp FAWS8DGSqfwyBteFPQps4kEWRB9j6LrZ/3IykIjAB1RGNFNcDRYWxIT6jY5S0HvNme1C wQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 3bgmv5t497-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 05 Oct 2021 10:15:52 -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.18; Tue, 5 Oct 2021 10:15:51 -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; Tue, 5 Oct 2021 10:15:51 -0700 Received: from hyd1358.marvell.com (unknown [10.29.37.11]) by maili.marvell.com (Postfix) with ESMTP id 2D13D3F707C; Tue, 5 Oct 2021 10:15:48 -0700 (PDT) From: Subbaraya Sundeep To: , , CC: , , , Subbaraya Sundeep Subject: [net-next PATCH 3/3] octeontx2-pf: Add devlink param to vary rbuf size Date: Tue, 5 Oct 2021 22:45:36 +0530 Message-ID: <1633454136-14679-4-git-send-email-sbhatta@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1633454136-14679-1-git-send-email-sbhatta@marvell.com> References: <1633454136-14679-1-git-send-email-sbhatta@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: vwQlzVhR040hVQKN4MCDYFcHbshzwvpI X-Proofpoint-ORIG-GUID: vwQlzVhR040hVQKN4MCDYFcHbshzwvpI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-10-05_03,2021-10-04_01,2020-04-07_01 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The size of receive buffers for receiving packets is calculated based on the mtu of interface. This patch adds devlink parameter to utilize user given size for receive buffers instead. By changing CQE descriptor size and receive buffer sizes the number of buffer pointers used by hardware for a large packet can be configured. Signed-off-by: Subbaraya Sundeep Signed-off-by: Sunil Goutham --- .../ethernet/marvell/octeontx2/nic/otx2_common.h | 1 + .../ethernet/marvell/octeontx2/nic/otx2_devlink.c | 60 ++++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 7 +++ .../net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 5 ++ 4 files changed, 73 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h index 6e0d1ac..f885abe 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h @@ -178,6 +178,7 @@ struct otx2_hw { u16 rqpool_cnt; u16 sqpool_cnt; u16 xqe_size; + u16 rbuf_fixed_size; /* NPA */ u32 stack_pg_ptrs; /* No of ptrs per stack page */ diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c index 98450e1..0fc7e32 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c @@ -64,6 +64,60 @@ static int otx2_dl_mcam_count_get(struct devlink *devlink, u32 id, return 0; } +static int otx2_dl_rbuf_size_validate(struct devlink *devlink, u32 id, + union devlink_param_value val, + struct netlink_ext_ack *extack) +{ + /* Hardware supports max size of 32k for a receive buffer + * and 1536 is typical ethernet frame size. + */ + if (val.vu16 < 1536 || val.vu16 > 32768) { + NL_SET_ERR_MSG_MOD(extack, + "Receive buffer range is 1536 - 32768"); + return -EINVAL; + } + + return 0; +} + +static int otx2_dl_rbuf_size_set(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct otx2_devlink *otx2_dl = devlink_priv(devlink); + struct otx2_nic *pfvf = otx2_dl->pfvf; + struct net_device *netdev; + int err = 0; + bool if_up; + + rtnl_lock(); + + netdev = pfvf->netdev; + if_up = netif_running(netdev); + if (if_up) + netdev->netdev_ops->ndo_stop(netdev); + + pfvf->hw.rbuf_fixed_size = ALIGN(ctx->val.vu16, OTX2_ALIGN) + + OTX2_HEAD_ROOM; + + if (if_up) + err = netdev->netdev_ops->ndo_open(netdev); + + rtnl_unlock(); + + return err; +} + +static int otx2_dl_rbuf_size_get(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct otx2_devlink *otx2_dl = devlink_priv(devlink); + struct otx2_nic *pfvf = otx2_dl->pfvf; + + ctx->val.vu16 = pfvf->hw.rbuf_fixed_size; + + return 0; +} + static int otx2_dl_cqe_size_validate(struct devlink *devlink, u32 id, union devlink_param_value val, struct netlink_ext_ack *extack) @@ -118,6 +172,7 @@ enum otx2_dl_param_id { OTX2_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX, OTX2_DEVLINK_PARAM_ID_MCAM_COUNT, OTX2_DEVLINK_PARAM_ID_CQE_SIZE, + OTX2_DEVLINK_PARAM_ID_RBUF_SIZE, }; static const struct devlink_param otx2_dl_params[] = { @@ -131,6 +186,11 @@ static const struct devlink_param otx2_dl_params[] = { BIT(DEVLINK_PARAM_CMODE_RUNTIME), otx2_dl_cqe_size_get, otx2_dl_cqe_size_set, otx2_dl_cqe_size_validate), + DEVLINK_PARAM_DRIVER(OTX2_DEVLINK_PARAM_ID_RBUF_SIZE, + "receive_buffer_size", DEVLINK_PARAM_TYPE_U16, + BIT(DEVLINK_PARAM_CMODE_RUNTIME), + otx2_dl_rbuf_size_get, otx2_dl_rbuf_size_set, + otx2_dl_rbuf_size_validate), }; /* Devlink OPs */ diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c index 8618cf7..1be524d3 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c @@ -65,6 +65,10 @@ static int otx2_change_mtu(struct net_device *netdev, int new_mtu) netdev_info(netdev, "Changing MTU from %d to %d\n", netdev->mtu, new_mtu); netdev->mtu = new_mtu; + /* Modify receive buffer size based on MTU and do not + * use the fixed size set. + */ + pf->hw.rbuf_fixed_size = 0; if (if_up) err = otx2_open(netdev); @@ -1306,6 +1310,9 @@ static int otx2_get_rbuf_size(struct otx2_nic *pf, int mtu) int total_size; int rbuf_size; + if (pf->hw.rbuf_fixed_size) + return pf->hw.rbuf_fixed_size; + /* The data transferred by NIX to memory consists of actual packet * plus additional data which has timestamp and/or EDSA/HIGIG2 * headers if interface is configured in corresponding modes. diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c index 672be05..229d051 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c @@ -439,6 +439,7 @@ static void otx2vf_do_set_rx_mode(struct work_struct *work) static int otx2vf_change_mtu(struct net_device *netdev, int new_mtu) { + struct otx2_nic *vf = netdev_priv(netdev); bool if_up = netif_running(netdev); int err = 0; @@ -448,6 +449,10 @@ static int otx2vf_change_mtu(struct net_device *netdev, int new_mtu) netdev_info(netdev, "Changing MTU from %d to %d\n", netdev->mtu, new_mtu); netdev->mtu = new_mtu; + /* Modify receive buffer size based on MTU and do not + * use the fixed size set. + */ + vf->hw.rbuf_fixed_size = 0; if (if_up) err = otx2vf_open(netdev);