From patchwork Sat Nov 12 04:31:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hariprasad Kelam X-Patchwork-Id: 19110 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1109915wru; Fri, 11 Nov 2022 20:44:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf4xf6mb4PLg3JhZGuwR5DSIRaxqBRYeXDN+n3USFSIiaHW/a8i53kaq7ao2K7xvW0GiiJdJ X-Received: by 2002:a63:5d02:0:b0:459:5661:611a with SMTP id r2-20020a635d02000000b004595661611amr4105756pgb.335.1668228245963; Fri, 11 Nov 2022 20:44:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668228245; cv=none; d=google.com; s=arc-20160816; b=XZl/jVUbPioVO34juGkiejKVCXN0IF6YvuBfktQs6YPlAHIoQrM+9hew1BPK2hb1Ia J16I9aWLwaOFM4peQ4iKkfYSiSLQfnfUp+ekGHcWnk9D/YlJLJEH/MiIi3UbYl2l48lo kMJv9LMihUqu6b/gbbyohrU1qo1anDJHdY8nGNRtw9c5kF5p99McpGH7K0+VcO/xD8JL lxyWlOtSsC2UzB7UedvNRsAvxY2vK7S3Hmrwhxs4HqP7VqfVHsIy9QpKYqYAAU1Gv81r WAZMK41QtCEypXYTPZIefOUnY2uNjS8te2BmbD7ioE2BfU/cI4tP4dtjbwXPhKIyWBmv k+Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QoK7Ceat/Zk5IcsFJLduL9+StA7lF8EbzsV4nxurJg0=; b=K0xoBU2CQ41+Uvobkyx0KZOmKJL8YmrDhs5V2Bvo8VC/Y8tq96hIOlVPHRM/SYmZu4 3MUO/2wWgBamnfl5Lbtkth3XLqvCvJDdqm2JtgV3pHLQMWM2H8yd7QKe7NkX0v9IocoY MR00XL1207grpQ9GVthB83ROjECUBa4m533PtABNTXpxykVh/+xdBIcJTHwSIWnyPOiR ID1aPD9BOrjLz/ETZyvBaHdBkuMWsp6dbXr/oMBfRX5UCVW0YvdV7ttKKLXXJ3up8uh6 n6vTCkXwLwR9l6Yfl4Z5JesuEIe2B/BLT03TT+wpsny7h4vFvHfBthyZhXMIc8aYOFiJ NMag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=in31PWm7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r14-20020a63ec4e000000b00450b99448b0si4590211pgj.341.2022.11.11.20.43.51; Fri, 11 Nov 2022 20:44:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=in31PWm7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234051AbiKLEdk (ORCPT + 99 others); Fri, 11 Nov 2022 23:33:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234480AbiKLEcd (ORCPT ); Fri, 11 Nov 2022 23:32:33 -0500 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75BA0606BD; Fri, 11 Nov 2022 20:32:26 -0800 (PST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AC1FX9C018810; Fri, 11 Nov 2022 20:32:21 -0800 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=QoK7Ceat/Zk5IcsFJLduL9+StA7lF8EbzsV4nxurJg0=; b=in31PWm72L38BTPPBgCB6z8iS+VMWNShWJilgDrldd+i0LfPojRB+rgs2yCksqFAKXbV JyTf+pDBBlrHhvCmzc4/9GAyOFVzeHt4JW03x9Qgi/7Wej52av6lvvRQnAVY8uaq3K8+ H9gjQdlAWDuKe7iI5TzLbo4CHB2H2f1gHg+py9nb6CSYtK5uEUnioVEK+U4qEV31U4HT t7boTcVPziQZXRpjNg4Ysv85z6Nl25BKyK5iC4xKvQpb3zKf8IHS/bU3yhxMTmjO22ST 2o64GxlrtNj5II/J19zyklOmIadeQ93lUHR9RKQhupmnrGBK/DwStZ7Y8lVmBTm7YB09 aQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3kt1nv0bf0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 20:32:21 -0800 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; Fri, 11 Nov 2022 20:32:19 -0800 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; Fri, 11 Nov 2022 20:32:19 -0800 Received: from hyd1soter3.marvell.com (unknown [10.29.37.12]) by maili.marvell.com (Postfix) with ESMTP id F1EFA3F7054; Fri, 11 Nov 2022 20:32:14 -0800 (PST) From: Hariprasad Kelam To: , CC: , , , , , , , , Subject: [net-next PATCH 8/9] octeontx2-af: physical link state change Date: Sat, 12 Nov 2022 10:01:40 +0530 Message-ID: <20221112043141.13291-9-hkelam@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221112043141.13291-1-hkelam@marvell.com> References: <20221112043141.13291-1-hkelam@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 4tbqJ5GHFZEXfTAfKnNHI2LhhXSlyvBT X-Proofpoint-GUID: 4tbqJ5GHFZEXfTAfKnNHI2LhhXSlyvBT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-12_02,2022-11-11_01,2022-06-22_01 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749264100904421537?= X-GMAIL-MSGID: =?utf-8?q?1749264100904421537?= From: Vamsi Attunuru There are few scenarios where physical link change is required. This patch adds mailbox support for the same such that PF and VF netdevices can request for link change. Signed-off-by: Vamsi Attunuru Signed-off-by: Hariprasad Kelam Signed-off-by: Sunil Kovvuri Goutham --- .../net/ethernet/marvell/octeontx2/af/cgx.c | 10 ++++++++ .../net/ethernet/marvell/octeontx2/af/cgx.h | 1 + .../net/ethernet/marvell/octeontx2/af/mbox.h | 7 ++++++ .../ethernet/marvell/octeontx2/af/rvu_cgx.c | 24 +++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c index 1383d1636cbe..33d1bd6734ea 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c @@ -1587,6 +1587,16 @@ static void cgx_lmac_linkup_work(struct work_struct *work) } } +int cgx_set_link_state(void *cgxd, int lmac_id, bool enable) +{ + struct cgx *cgx = cgxd; + + if (!cgx) + return -ENODEV; + + return cgx_fwi_link_change(cgx, lmac_id, enable); +} + int cgx_lmac_linkup_start(void *cgxd) { struct cgx *cgx = cgxd; diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.h b/drivers/net/ethernet/marvell/octeontx2/af/cgx.h index a34f45367d82..f62d033a511d 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.h @@ -163,6 +163,7 @@ int cgx_lmac_get_pause_frm(void *cgxd, int lmac_id, int cgx_lmac_set_pause_frm(void *cgxd, int lmac_id, u8 tx_pause, u8 rx_pause); void cgx_lmac_ptp_config(void *cgxd, int lmac_id, bool enable); +int cgx_set_link_state(void *cgxd, int lmac_id, bool enable); u8 cgx_lmac_get_p2x(int cgx_id, int lmac_id); int cgx_set_fec(u64 fec, int cgx_id, int lmac_id); int cgx_get_fec_stats(void *cgxd, int lmac_id, struct cgx_fec_stats_rsp *rsp); diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h index 260c48ba2c98..fb895ace2b0d 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h @@ -162,6 +162,8 @@ M(CGX_MAC_ADDR_DEL, 0x212, cgx_mac_addr_del, cgx_mac_addr_del_req, \ msg_rsp) \ M(CGX_MAC_MAX_ENTRIES_GET, 0x213, cgx_mac_max_entries_get, msg_req, \ cgx_max_dmac_entries_get_rsp) \ +M(CGX_SET_LINK_STATE, 0x214, cgx_set_link_state, \ + cgx_set_link_state_msg, msg_rsp) \ M(CGX_FEC_STATS, 0x217, cgx_fec_stats, msg_req, cgx_fec_stats_rsp) \ M(CGX_SET_LINK_MODE, 0x218, cgx_set_link_mode, cgx_set_link_mode_req,\ cgx_set_link_mode_rsp) \ @@ -713,6 +715,11 @@ struct npc_set_pkind { u8 shift_dir; /* shift direction to get length of the header at var_len_off */ }; +struct cgx_set_link_state_msg { + struct mbox_msghdr hdr; + u8 enable; /* '1' for link up, '0' for link down */ +}; + /* NPA mbox message formats */ /* NPA mailbox error codes diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c index b603fcb8673f..60c77db3ba6d 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c @@ -1137,6 +1137,30 @@ int rvu_mbox_handler_cgx_set_fec_param(struct rvu *rvu, return 0; } +int rvu_mbox_handler_cgx_set_link_state(struct rvu *rvu, + struct cgx_set_link_state_msg *req, + struct msg_rsp *rsp) +{ + u16 pcifunc = req->hdr.pcifunc; + u8 cgx_id, lmac_id; + int pf, err; + + pf = rvu_get_pf(pcifunc); + + if (!is_cgx_config_permitted(rvu, pcifunc)) + return LMAC_AF_ERR_PERM_DENIED; + + rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); + + err = cgx_set_link_state(rvu_cgx_pdata(cgx_id, rvu), lmac_id, + !!req->enable); + if (err) + dev_warn(rvu->dev, "Cannot set link state to %s, err %d\n", + (req->enable) ? "enable" : "disable", err); + + return err; +} + int rvu_mbox_handler_cgx_get_aux_link_info(struct rvu *rvu, struct msg_req *req, struct cgx_fw_data *rsp) {