From patchwork Thu Jan 25 11:21:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hariprasad Kelam X-Patchwork-Id: 192012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp1570615dyi; Thu, 25 Jan 2024 03:29:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEq/vpJ1VMsjZt8JE0pgEh3Z9ZdCXW83q+dm7CSt85te6D3PEdOEjGSUOvGxIUjEZumNwF3 X-Received: by 2002:a17:902:7ed0:b0:1d7:2a07:7841 with SMTP id p16-20020a1709027ed000b001d72a077841mr806958plb.27.1706182145670; Thu, 25 Jan 2024 03:29:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706182145; cv=pass; d=google.com; s=arc-20160816; b=H8w+kdzUA+p27SELC98LejLWPtow6SM7azCjAh6FnxR1jR/3tu+lYOjw5Pwc3Padte zgT1hdDw4t70pWzT3F8ItBuC1tTDT42IM+CAu57mahwAu13P7W5fh94B8JP1clOV9hFc gcLhHhqkx4HNb34XO2HOoilNiG+UYDFlV+ZwA6mfmBRNsEoiskzt720bFAcm/RNT3m5n grx9Hl05Tox6qE1enCSVzKXpfhBm6h4tSdSnkfX/weAiU56r+MikGzDX9LSqVrX2Pl5I jnpho5mk99q/CqsOLc26cj3wyTta6B2qSKw9mA/t53/HCkBxiOpKo0Hn/UG3MODcapFY 52Ww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from:dkim-signature; bh=fXkopoE1vDo6nTbf5yAboxI/984BJBBIUflwlsaQrIs=; fh=GZAvylyH0tRiHgo6YjmDcBXEp4BNes+PAA6FwyYO73Y=; b=gNiBeZMxmLJuFIZTP8F65L77vsm7OOLd4i3PEza5IS8kOxwtBh0lBhzvjpKt/MA0US W4QovqqcyZdyLDU4vEQapEGPvnR+0vZLcg+KIU9R3DyK/0/VKmzZLDgVt9e6LBu+du4m QQgjs/bkufch3C9vP10PHEwwFW9ZIvwJ6p66jw9HdUVC0Thp7/CCuwPuDNH52FFxOlpO MeI6Xd7Zr6B45FSzefvLGDOBdxT0hsfhBeHrF6FAmiXXb9EzLalMOou/ZuRtGPwZAmYs l5CFnc7eoYMaBDV9mYWQoyaVPj9XR4zFskU+U+3fpZSSi/VzH7ysmR+tQPBcyADb9oDf abFg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=ksFqiTwE; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-38497-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38497-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s7-20020a170902b18700b001d7852b9acdsi2595188plr.386.2024.01.25.03.29.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 03:29:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38497-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=ksFqiTwE; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-38497-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38497-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9A03D28EEBA for ; Thu, 25 Jan 2024 11:22:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 500D431743; Thu, 25 Jan 2024 11:22:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="ksFqiTwE" Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B1151CAAE; Thu, 25 Jan 2024 11:21:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181720; cv=none; b=CxmpbZBdTOnMH8RRwrXgM7cSY1Q7wpILLTszPieZWV7VapU1PxlvTePYSBZJTt1c7C8eSyyIlK112wonVxCCNJirHuPGBmzdChSTYHkOcwhgDJN2oeenDe1i+1RvwRD+1VYcx8wI4j9PmoY8RPcn9J3JZlhWZWcgHPCpiMNuFFI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706181720; c=relaxed/simple; bh=3UJsTPYOcBuLCUS/AoSNIE0q49JbYk1tipQ/7awvQm4=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=cR96S6Qz1vVAaHlTX42rX+lC1YtynVOqzTkdZN8u2lvmWT9PKf/NIm0F0RRh4VCJhgUErbwZh0DnQeGFfIT43lYdXnOB3hexUEyFe1vLv66uX+Dyf0xBqdjldVoDVc/hKqks4NRlgek52odS063pnNT16qSh8dDehDQVvCa/hU0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=ksFqiTwE; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40P8veXf008478; Thu, 25 Jan 2024 03:21:51 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:mime-version:content-type; s= pfpt0220; bh=fXkopoE1vDo6nTbf5yAboxI/984BJBBIUflwlsaQrIs=; b=ksF qiTwEEOqoKrq9gY1jtjMl7VPu0nPt6CDQMjfV1erDZcuTWyjeHWQDIcFW1HjPC8E +pQgnrOQJG3dFiv6vC2IV5o1Q07oHYz0P9691kBSWH36862xeo2JrFHi2TmCxD2S 2tUoVhvZVnddUVCCmNwce1Ho08FPeKpJaS3igbdjhmkoNakVSKqC8LZbLNlcCa66 VYLFR2Kq7uPrI83rLDX/YDZv90RCVrIw0BeaxqU34PIFINnMu2ZxwBkcYdUkFGx2 KoNcaQJ4MO4qBUjDK4eIp33b8uMemBNxvLyfaPPdz5Twdi9Fg8B07ZmTJw8YNIBO T1IQwaHocWb8I8MH2lA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3vumk90cqn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 25 Jan 2024 03:21:51 -0800 (PST) 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.48; Thu, 25 Jan 2024 03:21:37 -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.48 via Frontend Transport; Thu, 25 Jan 2024 03:21:37 -0800 Received: from hyd1soter3.marvell.com (unknown [10.29.37.12]) by maili.marvell.com (Postfix) with ESMTP id 0EF4E3F7082; Thu, 25 Jan 2024 03:21:34 -0800 (PST) From: Hariprasad Kelam To: , CC: , , , , , , Subject: [net-next PATCH] octeontx2-pf: Add support to read eeprom information Date: Thu, 25 Jan 2024 16:51:33 +0530 Message-ID: <20240125112133.8483-1-hkelam@marvell.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: jiRCFEXdqvLs-pdKTnxH8gPY9UkgKTWQ X-Proofpoint-GUID: jiRCFEXdqvLs-pdKTnxH8gPY9UkgKTWQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-25_06,2024-01-25_01,2023-05-22_02 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789061649438924118 X-GMAIL-MSGID: 1789061649438924118 Add support to read/decode EEPROM module information using ethtool. Usage: ethtool -m Signed-off-by: Christina Jacob Signed-off-by: Hariprasad Kelam Signed-off-by: Sunil Goutham --- .../marvell/octeontx2/nic/otx2_ethtool.c | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c index 2928898c7f8d..8e4e22a2817b 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c @@ -1185,6 +1185,37 @@ static void otx2_get_link_mode_info(u64 link_mode_bmap, otx2_link_modes); } +static int otx2_get_module_info(struct net_device *netdev, + struct ethtool_modinfo *modinfo) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + struct cgx_fw_data *rsp; + + rsp = otx2_get_fwdata(pfvf); + if (IS_ERR(rsp)) + return PTR_ERR(rsp); + + modinfo->type = rsp->fwdata.sfp_eeprom.sff_id; + modinfo->eeprom_len = SFP_EEPROM_SIZE; + return 0; +} + +static int otx2_get_module_eeprom(struct net_device *netdev, + struct ethtool_eeprom *ee, + u8 *data) +{ + struct otx2_nic *pfvf = netdev_priv(netdev); + struct cgx_fw_data *rsp; + + rsp = otx2_get_fwdata(pfvf); + if (IS_ERR(rsp)) + return PTR_ERR(rsp); + + memcpy(data, &rsp->fwdata.sfp_eeprom.buf, ee->len); + + return 0; +} + static int otx2_get_link_ksettings(struct net_device *netdev, struct ethtool_link_ksettings *cmd) { @@ -1343,6 +1374,8 @@ static const struct ethtool_ops otx2_ethtool_ops = { .set_fecparam = otx2_set_fecparam, .get_link_ksettings = otx2_get_link_ksettings, .set_link_ksettings = otx2_set_link_ksettings, + .get_module_info = otx2_get_module_info, + .get_module_eeprom = otx2_get_module_eeprom, }; void otx2_set_ethtool_ops(struct net_device *netdev)