From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 55D84A052A; Tue, 22 Dec 2020 08:03:51 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 57AE2CA8B; Tue, 22 Dec 2020 08:03:49 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2053.outbound.protection.outlook.com [40.107.236.53]) by dpdk.org (Postfix) with ESMTP id 860B2CA60 for ; Tue, 22 Dec 2020 08:03:46 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kQHyXZcJwL/YCE6wMEnBVeBHPep10QocVwUg8QfZ02HmoNdjBlpa7DcBAx6glpjaDXarVxdg/vbkPiXm5GBw40inTsKZYzb00DZhHfmo8xbS9v4/UMhdldwoaqZGiK54M+2guwv6UJXrJ+oh+UTjtvFyFDh30kF5VYbZgpD/opTOkpAmXPPj+jluUqSiRb5bDjdWoDvuJRRcG/+41pZCW77nkVZPKz0xCfTJ5ofOPLUdFVSmQFqbTgXTWHhxmHoGDVFkrLKfu5j2P3N/Y7aOIWeV0Q3RQQiiuVjyR+tAnyyHmTEFGl0gambtv44I/zBrrcJm4GVHwPVh4u1liyKJbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ycnnXpgUwtDC5eTxJu+u5VGqjk6LxZtC1lkaRs8iFOE=; b=fr/LjbWDeMF/iE4onlY5di+74nwfbN1f7DgtsKxZbQgvqquug6sXo2qtwA4NlsB/Z3Vum6weGsJDczX7UCey1hS/gRzGQsMcezNY1rgwuBKOl/3Zj/pQYZy4+n4ppjw1FZLjS0UB84eTmKAc6t+0evEZY1pKSuEU9CcOlQxExlNLG6uQflxFwqFo/YoEXe1WZzasZK4g0KiTQ5y7X5V5rvzABau49+8XbqMVI8HL7ch9S7TKg4w0u8fjwNlF+oXBE2M94K68EtMoXYykE8a+eFFTETaiUF8eboTX0slPTL3i5m0WdbpGRMkLxYPFr5Mmxql5L1Xb6T43YHhdOk6Icg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ycnnXpgUwtDC5eTxJu+u5VGqjk6LxZtC1lkaRs8iFOE=; b=QRd3A4URFyEKLpuKWqMDOSpt9lIwxalBLnQVPHhqjkKByRsZeamkVejCa6ehJ39t5MV5kPOksVQW8bKOS3XI8J1XYipk3DdQATb9nsOEyN5Ne38qJyXP6aRAZfCLz/NrqDnm6rSPypReZJZof+N3O2enTT6LcYA4PK+aUzE9M/g= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=amd.com; Received: from BYAPR12MB2821.namprd12.prod.outlook.com (2603:10b6:a03:9b::30) by BY5PR12MB4306.namprd12.prod.outlook.com (2603:10b6:a03:206::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.26; Tue, 22 Dec 2020 07:03:43 +0000 Received: from BYAPR12MB2821.namprd12.prod.outlook.com ([fe80::c9e:efb6:8cd1:5a6d]) by BYAPR12MB2821.namprd12.prod.outlook.com ([fe80::c9e:efb6:8cd1:5a6d%4]) with mapi id 15.20.3676.033; Tue, 22 Dec 2020 07:03:43 +0000 From: asomalap@amd.com To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 22 Dec 2020 12:31:57 +0530 Message-Id: <20201222070157.521188-1-asomalap@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [165.204.157.251] X-ClientProxiedBy: MAXPR01CA0117.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::35) To BYAPR12MB2821.namprd12.prod.outlook.com (2603:10b6:a03:9b::30) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from cae-Wallaby.amd.com (165.204.157.251) by MAXPR01CA0117.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.28 via Frontend Transport; Tue, 22 Dec 2020 07:03:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2d4e55ab-9dd8-4608-6548-08d8a647b80f X-MS-TrafficTypeDiagnostic: BY5PR12MB4306: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DrYwzmw4lL+qW1/gLbG/MSqct+xEI462lt4BInzHV0endYl4Rkl0hmaYnaaj8S5DVSsNekPMSFGl27dDzsREM+HWqMXOfTB0E5XMef0ALsdGe7sJ3zHaHM94HBsiDtIOfY9Ctb2SZxiOQbR7wu3SSrNdd2TL4OFdUw2yHiX+AeqmYBgVDIKUxrKkCcOtAhlTAky4zoLc5BFDSzk0tn9thvCcb/oFvTHCguSb4uQhOLHf9YoQ0tovWZ+H1Xf3KpIzsMpX2gGA59B1c0+qedoEy1iAVr5WDpLP7WjZoeQ4OQ0rgMw3cDZSOTPYEKklo3gbk2UY/wqejSVx+/vR3MxV9g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR12MB2821.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(396003)(366004)(136003)(346002)(376002)(2906002)(6666004)(66556008)(6916009)(66476007)(8676002)(16526019)(9686003)(478600001)(956004)(2616005)(36756003)(6486002)(8936002)(26005)(186003)(4326008)(66946007)(52116002)(5660300002)(1076003)(316002)(7696005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?U+543NYGf+H34Suv7wmt3m2vW9M5HrWLYaq0DUT+XLqsjib7U9Rg8FfAqjeA?= =?us-ascii?Q?5MHJc+zx6UEA7fHQO6QSlCW8OrKNk/+gzcWb7qkGsAEXA1or1WinWiKhyYw1?= =?us-ascii?Q?Lb3wBSEg/v/tJBi52CzzQLCdTrBNpcyiIThMxmUoqOATlNBdUNmhNJeoClT/?= =?us-ascii?Q?R8519b4ewM/fa8MDSocZQBdUnMyoQjdAicclXhADCuoMkT5qZl5stXjKzTsH?= =?us-ascii?Q?wvaqPBYdcfLC9vppPriZuWCwbeYy+W0+PRehvp6R3sNxGFKhQlvaFm1eIYOu?= =?us-ascii?Q?nBipFqyJj5Q+hvrAqdcUNKEeOg95EYmGOK7jul8kynFXXxteT7Sh7TnhtLRN?= =?us-ascii?Q?WdFxnFbEirwzHWKvnqGgTbhAnLR9GbwMGBENS6jl7G6YVN7+2EWhJAyJB2TQ?= =?us-ascii?Q?Ws2qP7BIMt9+eHQKaYHGv0JYPYfWwATUR/4johEbX42OHNyvwWXVMxzDyfrq?= =?us-ascii?Q?fHoh7mqsVKpilUEaenCiewNEQ7mbClZ5HAf+rveX5qON50nMmyzIKz+lK20B?= =?us-ascii?Q?ntm3DX0V4Vi9gXne37QcEHVUir6XjRAOwYgqjqfXoe4DhsA8t4nd6FlKDwOM?= =?us-ascii?Q?rbI0jA8eaji1wH2geopKKSuGcFAeXW3+jbE+C7DYV2KzKdEIZD7tlKlWchT7?= =?us-ascii?Q?bQjNuRXxEeKwqqwqhMeu43IAG57eY3hcMBUF1J7MYN7FfZWl+Pe83dRUu5BE?= =?us-ascii?Q?t0rL3vxh/7Y4gX0vUU2R2fWmJMmxPWDz152uJEMdbMXXCEqfnymMJ8PeJ7bX?= =?us-ascii?Q?WLbOuVsglljSlBkAkjDAfuLrVimIDcBIQkEuT7ggg+8L9XWtp/6Bu6m69w0j?= =?us-ascii?Q?hLkWCSkaMwoukUFJd91UmIu5Kv/as/IGYkJ9c3r024g2uhjE6Ga8v9mhemT7?= =?us-ascii?Q?6YZuUbS+QxJ+SQ9y5Bf2Fec3fZyUTTS8g1TPT6ilOOzhvoUFWZ1yXHMPAsyT?= =?us-ascii?Q?XAKXC9et/qoyUXE9dh2EaeKPc5OFS1V3Z/sal0xur3c4c2FSQ1+F3cQmMYti?= =?us-ascii?Q?7kSd?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2821.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2020 07:03:43.2151 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-Network-Message-Id: 2d4e55ab-9dd8-4608-6548-08d8a647b80f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gzTxIf/TXuqZ883EknOWmFp/xi92rDcKNZf5avDs6X1Ewx2fb96GVUr/pLa1BglEz2CyOx2t8Js7nt4Pc50dfA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4306 Subject: [dpdk-dev] [PATCH v4] net/axgbe: support sfp module EEPROM X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Amaranath Somalapuram Adding API for get_module_eeprom and get_module_info.wq Signed-off-by: Amaranath Somalapuram --- doc/guides/nics/features/axgbe.ini | 1 + drivers/net/axgbe/axgbe_ethdev.c | 2 + drivers/net/axgbe/axgbe_phy.h | 4 ++ drivers/net/axgbe/axgbe_phy_impl.c | 108 +++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+) diff --git a/doc/guides/nics/features/axgbe.ini b/doc/guides/nics/features/axgbe.ini index 34df0d1ee..3a090183e 100644 --- a/doc/guides/nics/features/axgbe.ini +++ b/doc/guides/nics/features/axgbe.ini @@ -17,6 +17,7 @@ CRC offload = Y L3 checksum offload = Y L4 checksum offload = Y Basic stats = Y +Module EEPROM dump = Y Linux UIO = Y x86-32 = Y x86-64 = Y diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index cfe6aba73..22e05e8cb 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -257,6 +257,8 @@ static const struct eth_dev_ops axgbe_eth_dev_ops = { .timesync_adjust_time = axgbe_timesync_adjust_time, .timesync_read_time = axgbe_timesync_read_time, .timesync_write_time = axgbe_timesync_write_time, + .get_module_info = axgbe_get_module_info, + .get_module_eeprom = axgbe_get_module_eeprom, }; static int axgbe_phy_reset(struct axgbe_port *pdata) diff --git a/drivers/net/axgbe/axgbe_phy.h b/drivers/net/axgbe/axgbe_phy.h index 77ee20a31..d9d7fde41 100644 --- a/drivers/net/axgbe/axgbe_phy.h +++ b/drivers/net/axgbe/axgbe_phy.h @@ -188,5 +188,9 @@ #define DUPLEX_FULL 0x01 #define DUPLEX_UNKNOWN 0xff +int axgbe_get_module_info(struct rte_eth_dev *dev, + struct rte_eth_dev_module_info *modinfo); +int axgbe_get_module_eeprom(struct rte_eth_dev *dev, + struct rte_dev_eeprom_info *info); #endif /* PHY */ diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c index 02236ec19..af18a8d51 100644 --- a/drivers/net/axgbe/axgbe_phy_impl.c +++ b/drivers/net/axgbe/axgbe_phy_impl.c @@ -141,12 +141,18 @@ enum axgbe_sfp_speed { #define AXGBE_SFP_EXTD_CC 31 +#define AXGBE_SFP_EEPROM_PAGE_SIZE 256 + struct axgbe_sfp_eeprom { u8 base[64]; u8 extd[32]; u8 vendor[32]; }; +struct axgbe_sfp_eeprom_module { + u8 base[AXGBE_SFP_EEPROM_PAGE_SIZE]; +}; + #define AXGBE_BEL_FUSE_VENDOR "BEL-FUSE" #define AXGBE_BEL_FUSE_PARTNO "1GBT-SFP06" @@ -734,6 +740,108 @@ static int axgbe_phy_sfp_read_eeprom(struct axgbe_port *pdata) return ret; } +int axgbe_get_module_info(struct rte_eth_dev *dev, + struct rte_eth_dev_module_info *modinfo) +{ + struct axgbe_port *pdata = dev->data->dev_private; + struct axgbe_sfp_eeprom sfp_eeprom; + uint8_t eeprom_addr; + int ret; + + ret = axgbe_phy_get_comm_ownership(pdata); + + if (ret) + return -EIO; + + ret = axgbe_phy_sfp_get_mux(pdata); + + if (ret) { + PMD_DRV_LOG(ERR, "I2C error setting SFP MUX\n"); + goto put; + } + + eeprom_addr = 0; + ret = axgbe_phy_i2c_read(pdata, AXGBE_SFP_SERIAL_ID_ADDRESS, + &eeprom_addr, sizeof(eeprom_addr), + &sfp_eeprom, sizeof(sfp_eeprom)); + + if (ret) { + PMD_DRV_LOG(ERR, "I2C error reading SFP EEPROM\n"); + goto put; + } + + if (sfp_eeprom.extd[AXGBE_SFP_EXTD_SFF_8472] != 0xff) { + if (sfp_eeprom.extd[AXGBE_SFP_EXTD_SFF_8472] == 0) { + modinfo->type = RTE_ETH_MODULE_SFF_8079; + modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8079_LEN; + } else { + modinfo->type = RTE_ETH_MODULE_SFF_8472; + modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8472_LEN; + } + } + +put: + axgbe_phy_sfp_put_mux(pdata); + axgbe_phy_put_comm_ownership(pdata); + return ret; +} + +int axgbe_get_module_eeprom(struct rte_eth_dev *dev, + struct rte_dev_eeprom_info *info) +{ + struct axgbe_port *pdata = dev->data->dev_private; + struct axgbe_sfp_eeprom_module sfp_eeprom; + uint8_t eeprom_addr; + uint8_t *data; + uint32_t i; + int ret; + + ret = axgbe_phy_get_comm_ownership(pdata); + + if (ret) + return -EIO; + + if (!info || !info->length || !info->data) { + axgbe_phy_put_comm_ownership(pdata); + return -EINVAL; + } + + ret = axgbe_phy_sfp_get_mux(pdata); + if (ret) { + PMD_DRV_LOG(ERR, "I2C error setting SFP MUX\n"); + goto put; + } + + eeprom_addr = 0; + ret = axgbe_phy_i2c_read(pdata, AXGBE_SFP_SERIAL_ID_ADDRESS, + &eeprom_addr, sizeof(eeprom_addr), + &sfp_eeprom, sizeof(sfp_eeprom)); + if (ret) { + PMD_DRV_LOG(ERR, "I2C error reading SFP EEPROM\n"); + goto put; + } + data = info->data; + + /* for AXGBE_SFP_SERIAL_ID_ADDRESS */ + for (i = 0; i < AXGBE_SFP_EEPROM_PAGE_SIZE; i++) + data[i] = sfp_eeprom.base[i]; + + eeprom_addr = 0; + ret = axgbe_phy_i2c_read(pdata, AXGBE_SFP_DIAG_INFO_ADDRESS, + &eeprom_addr, sizeof(eeprom_addr), + &sfp_eeprom, sizeof(sfp_eeprom)); + + /* for AXGBE_SFP_DIAG_INFO_ADDRESS */ + for (i = 0; i < info->length - AXGBE_SFP_EEPROM_PAGE_SIZE; i++) + data[i + AXGBE_SFP_EEPROM_PAGE_SIZE] = sfp_eeprom.base[i]; + +put: + axgbe_phy_sfp_put_mux(pdata); + axgbe_phy_put_comm_ownership(pdata); + return ret; +} + + static void axgbe_phy_sfp_signals(struct axgbe_port *pdata) { struct axgbe_phy_data *phy_data = pdata->phy_data; -- 2.25.1