From patchwork Sat Dec 9 08:14:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 176146 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5937688vqy; Sat, 9 Dec 2023 00:16:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0jw8/mctc1+cKVNeBdonnTGlShHxb6RpYyX01TXxS64PLxeamIm0lcsMEovZijRxJni08 X-Received: by 2002:a05:6871:5c6:b0:1fb:75b:2fd0 with SMTP id v6-20020a05687105c600b001fb075b2fd0mr1757544oan.103.1702109780859; Sat, 09 Dec 2023 00:16:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702109780; cv=none; d=google.com; s=arc-20160816; b=plCNPZzXlkabQBBALxjdUBAaXSTkKxK0LS/NYaGzZiNRUOlOVanqqKXPeKAhEpsKsa V27mrY0NghQnvzvIBo1d33z5Ss2nlovqM5vcvXXCRkGG+ngrVYEVk9dT+I4mEHVTj7HR 00zUrdn8Bq2iXwdViLgoVqtjEBIfblAeXaLG7EzNl5aZ8iEggk0Ef8rL8JkBBbc8btC/ Uyg/TPdAv1GskvWW1YQd9TABcgLkTPVnChjTo3DqVZWEh3QHcNm7Ikn9loFr7417TTZD y6tiIraMJJ5W1cRE+iWcdVViSi76ETZ2XzOkTDJPdOApdKjd2FYJ2Y1nIuM8kZzha3lO mwTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EVcOrvA1I3aNP1SHeVpDUNayuysOpaFv6oAonAxyMJA=; fh=7SseUGK9VIpM0U5I48hZPzu1gSvnt1oPt4OqFvN72gk=; b=nF0PAJx8M8HwQMTuvuOfQcKt3OanQdczb+uEBo6xxYS4WwV/x2SQVcdtkQ4r6BcFwe VzlYejkpSRBiU3ay02Uwt097aOSwnY6oU0fM5Htu/ge11EEd86nU4E/BhKv44TBBHuZ0 IQnvmtE/xd67BC7tK/QEHvwqroe2lVdvYEd8KUDh79Sic7KVChRRT+/T7k0roFu2p7UD WoVR11aCHAdqkUKL5LZmPVEeK5F4R5UfOLp+WnUIsCw6/hIVZxEcUBuAnlyHzmLVGvFA NGCWSHjPkGt9BqTcrAK9lsQ3zPfHdHyVjevk/fus3gP8OTgVpDKulvCoEs84cLugxvaQ EwIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b="A/kVLwQI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id m128-20020a632686000000b005c66e00ffccsi2799471pgm.260.2023.12.09.00.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 00:16:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b="A/kVLwQI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B953E8078676; Sat, 9 Dec 2023 00:15:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234556AbjLIIPP (ORCPT + 99 others); Sat, 9 Dec 2023 03:15:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234535AbjLIIPM (ORCPT ); Sat, 9 Dec 2023 03:15:12 -0500 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F319137; Sat, 9 Dec 2023 00:15:18 -0800 (PST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B984onV022969; Sat, 9 Dec 2023 00:15:11 -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-transfer-encoding : content-type; s=pfpt0220; bh=EVcOrvA1I3aNP1SHeVpDUNayuysOpaFv6oAonAxyMJA=; b=A/kVLwQIlveq8EVPnFqlvEsG95kxhlK6s6jUTm+S1l09HCzGQMWDqKsQWhUmrBhJHEBO QxKpAxEQfJ/LG5KNRC1Vg2bD8O+Vshd8uHRbqzOEUhdBEu5o+gcPjHB93yEPVaggOujs KWequEw9YSlwFAgKqp01//IwyYHJ7p1nQK4Ps50Hf6K9GY7Vw9eRSpja1XVmfiJ43/Sr ujKcW1S86GVTGIpELQ7bkSJQZg+IlehdmVg+KabRreFeStuS4PPCmjP+phB1/ixQS+YK MuY8j2jDbTDcXew6Minhc0jqz69iLw//iuHGFjL0lRBKH0s9f+KJy48BTKxo9y1i7rZj Dg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3uubddfkhp-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 09 Dec 2023 00:15:11 -0800 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.48; Sat, 9 Dec 2023 00:15:03 -0800 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.48 via Frontend Transport; Sat, 9 Dec 2023 00:15:02 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 5CA0B3F70CD; Sat, 9 Dec 2023 00:15:02 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , , , Shinas Rasheed , Veerasenareddy Burru , "Sathesh Edara" , Eric Dumazet Subject: [PATCH net-next v2 4/4] octeon_ep: support firmware notifications for VFs Date: Sat, 9 Dec 2023 00:14:50 -0800 Message-ID: <20231209081450.2613561-5-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231209081450.2613561-1-srasheed@marvell.com> References: <20231209081450.2613561-1-srasheed@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: VdLjfmQdxx_8RMUtG-LkekZ_u_CHeh9H X-Proofpoint-GUID: VdLjfmQdxx_8RMUtG-LkekZ_u_CHeh9H X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sat, 09 Dec 2023 00:15:36 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784791465368535800 X-GMAIL-MSGID: 1784791465368535800 Notifications from firmware to vf has to pass through PF control mbox and via PF-VF mailboxes. The notifications have to be parsed out from the control mbox and passed to the PF-VF mailbox in order to reach the corresponding VF. Version compatibility should also be checked before messages are passed to the mailboxes. Signed-off-by: Shinas Rasheed --- V2: - No changes V1: https://lore.kernel.org/all/20231208070352.2606192-5-srasheed@marvell.com/ .../marvell/octeon_ep/octep_ctrl_net.c | 6 ++ .../marvell/octeon_ep/octep_pfvf_mbox.c | 58 +++++++++++++++++++ .../marvell/octeon_ep/octep_pfvf_mbox.h | 2 + 3 files changed, 66 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c b/drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c index 9dff2166dbb7..01b7be154c38 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_ctrl_net.c @@ -13,6 +13,7 @@ #include "octep_config.h" #include "octep_main.h" #include "octep_ctrl_net.h" +#include "octep_pfvf_mbox.h" /* Control plane version */ #define OCTEP_CP_VERSION_CURRENT OCTEP_CP_VERSION(1, 0, 0) @@ -329,6 +330,11 @@ static int process_mbox_notify(struct octep_device *oct, octep_ctrl_net_f2h_cmd_versions[cmd] < OCTEP_CP_VERSION_CURRENT) return -EOPNOTSUPP; + if (msg->hdr.s.is_vf) { + octep_pfvf_notify(oct, msg); + return 0; + } + switch (cmd) { case OCTEP_CTRL_NET_F2H_CMD_LINK_STATUS: if (netif_running(netdev)) { diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.c b/drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.c index 57e0184840c2..387a07456f54 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.c @@ -22,6 +22,15 @@ #include "octep_pfvf_mbox.h" #include "octep_ctrl_net.h" +/* When a new command is implemented, the below table should be updated + * with new command and it's version info. + */ +static u32 pfvf_cmd_versions[OCTEP_PFVF_MBOX_CMD_MAX] = { + [0 ... OCTEP_PFVF_MBOX_CMD_DEV_REMOVE] = OCTEP_PFVF_MBOX_VERSION_V1, + [OCTEP_PFVF_MBOX_CMD_GET_FW_INFO ... OCTEP_PFVF_MBOX_NOTIF_LINK_STATUS] = + OCTEP_PFVF_MBOX_VERSION_V2 +}; + static void octep_pfvf_validate_version(struct octep_device *oct, u32 vf_id, union octep_pfvf_mbox_word cmd, union octep_pfvf_mbox_word *rsp) @@ -88,6 +97,34 @@ static void octep_pfvf_set_rx_state(struct octep_device *oct, u32 vf_id, rsp->s_link_state.type = OCTEP_PFVF_MBOX_TYPE_RSP_ACK; } +static int octep_send_notification(struct octep_device *oct, u32 vf_id, + union octep_pfvf_mbox_word cmd) +{ + u32 max_rings_per_vf, vf_mbox_queue; + struct octep_mbox *mbox; + + /* check if VF PF Mailbox is compatible for this notification */ + if (pfvf_cmd_versions[cmd.s.opcode] > oct->vf_info[vf_id].mbox_version) { + dev_dbg(&oct->pdev->dev, "VF Mbox doesn't support Notification:%d on VF ver:%d\n", + cmd.s.opcode, oct->vf_info[vf_id].mbox_version); + return -EOPNOTSUPP; + } + + max_rings_per_vf = CFG_GET_MAX_RPVF(oct->conf); + vf_mbox_queue = vf_id * max_rings_per_vf; + if (!oct->mbox[vf_mbox_queue]) { + dev_err(&oct->pdev->dev, "Notif obtained for bad mbox vf %d\n", vf_id); + return -EINVAL; + } + mbox = oct->mbox[vf_mbox_queue]; + + mutex_lock(&mbox->lock); + writeq(cmd.u64, mbox->pf_vf_data_reg); + mutex_unlock(&mbox->lock); + + return 0; +} + static void octep_pfvf_set_mtu(struct octep_device *oct, u32 vf_id, union octep_pfvf_mbox_word cmd, union octep_pfvf_mbox_word *rsp) @@ -327,6 +364,27 @@ static void octep_pfvf_pf_get_data(struct octep_device *oct, } } +void octep_pfvf_notify(struct octep_device *oct, struct octep_ctrl_mbox_msg *msg) +{ + union octep_pfvf_mbox_word notif = { 0 }; + struct octep_ctrl_net_f2h_req *req; + + req = (struct octep_ctrl_net_f2h_req *)msg->sg_list[0].msg; + switch (req->hdr.s.cmd) { + case OCTEP_CTRL_NET_F2H_CMD_LINK_STATUS: + notif.s_link_status.opcode = OCTEP_PFVF_MBOX_NOTIF_LINK_STATUS; + notif.s_link_status.status = req->link.state; + break; + default: + pr_info("Unknown mbox notif for vf: %u\n", + req->hdr.s.cmd); + return; + } + + notif.s.type = OCTEP_PFVF_MBOX_TYPE_CMD; + octep_send_notification(oct, msg->hdr.s.vf_idx, notif); +} + void octep_pfvf_mbox_work(struct work_struct *work) { struct octep_pfvf_mbox_wk *wk = container_of(work, struct octep_pfvf_mbox_wk, work); diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.h b/drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.h index c18a9f26fc31..0dc6eead292a 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.h +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_pfvf_mbox.h @@ -37,6 +37,7 @@ enum octep_pfvf_mbox_opcode { OCTEP_PFVF_MBOX_CMD_DEV_REMOVE, OCTEP_PFVF_MBOX_CMD_GET_FW_INFO, OCTEP_PFVF_MBOX_CMD_SET_OFFLOADS, + OCTEP_PFVF_MBOX_NOTIF_LINK_STATUS, OCTEP_PFVF_MBOX_CMD_MAX, }; @@ -162,4 +163,5 @@ union octep_pfvf_mbox_word { void octep_pfvf_mbox_work(struct work_struct *work); int octep_setup_pfvf_mbox(struct octep_device *oct); void octep_delete_pfvf_mbox(struct octep_device *oct); +void octep_pfvf_notify(struct octep_device *oct, struct octep_ctrl_mbox_msg *msg); #endif