From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 65775A04B5; Tue, 12 Jan 2021 06:31:12 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1EDF5140DD9; Tue, 12 Jan 2021 06:31:12 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2070.outbound.protection.outlook.com [40.107.237.70]) by mails.dpdk.org (Postfix) with ESMTP id 423C6140DD7 for ; Tue, 12 Jan 2021 06:31:11 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RQYibL3CFrMXTvpd0vokPQpITFilCdtWg7HoF86ErlMALAh+bRPppIQE2gZKr39JQNXaoWnhnIAQdFuZz2Oz1+v/OVmd6Na55FsVObEAAx9UiHDr82yjN5O583XEpkv0nmNmUMRe+JRLc2EcGrcLReLc55FomodksgpA8zqquggPacuuyMfATi4u8k2B0ZoyGBtOg67vREJJSTbSIR2R8eLazIC0MnMFpJ2imJ6L8daI0BOUXReE4aTlB7EedROsasI0RvBhAG8NMZpfSsH7cgH06r2QoFNHbXXPosiPo6yRQsIOXA5byByESy0tcBBudmp8rPkt18HYyoFBdD4FPQ== 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=x8WDezQTdbdxwrRDcAoAAQVtr9bgNxjv2RYCHc85WJE=; b=Ia/bAoDKeH10Du9DmwYdDWaMLmcEL/Ar7EUrlZaoW1G6Fp7fJRpzMTo9cwjhYAruDIQUZynkO4H4XgSupmZAhCrht8hssKeB2dsI6xPdmPWU73FyMLk207vT8sRCm+/S3CDUSEAfRCGp+ge498X3XlvWPtk4itX5+/btdlOus1voN5jzI2x7C0L3sPXO/JECcScqJ5OQNv1PAxgU2MOGSLSVOadR5i9Af5IC3LZQ2tVlZRKOCtUSt23KMqpHLtV2Yyq0BKcOePDe/TB+iaOeJ+zDDkoSk0hDq8x0OTb7PNo5HLH5Y7SAWLWD1JuUceDt/oLRPFqliePJDUlQvyki7g== 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=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x8WDezQTdbdxwrRDcAoAAQVtr9bgNxjv2RYCHc85WJE=; b=392ypW1xO6cYZnNnzGnE6cSGLy/UQnPKKTq6ur649SeEInkhVSFoqXeNTaTcv48+jn+bDmUciBYUfrs53EU+9xV33XWOF4wEilGx5EkOC8wkkkskV4wFH3QRaAvsQ7qnXJ8SOksIIaH5vELWZdjuN4zr+tHrk8wMQf14wSLt/Gc= 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 BY5PR12MB4163.namprd12.prod.outlook.com (2603:10b6:a03:202::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 12 Jan 2021 05:31:08 +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.3742.012; Tue, 12 Jan 2021 05:31:08 +0000 From: asomalap@amd.com To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Tue, 12 Jan 2021 10:58:32 +0530 Message-Id: <20210112052833.1799783-1-asomalap@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201222070157.521188-1-asomalap@amd.com> References: <20201222070157.521188-1-asomalap@amd.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [165.204.157.251] X-ClientProxiedBy: MA1PR01CA0110.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::26) 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 MA1PR01CA0110.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 12 Jan 2021 05:31:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7e9dd3ba-f3dd-4113-c306-08d8b6bb43d8 X-MS-TrafficTypeDiagnostic: BY5PR12MB4163: 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: 5qjXZ5gwbs+lRJfC52aJ+U8T1n/DX0LvPjLihwkG4HQ0xaRtHDlMA5V7NYwtnVU/vAIHrk8lspnzR5m72/LBxyg9II/vgPdEMmT5lVhtPLcIQTF0YkZw+c0CPSSNKUsfyKvtAKRjSRsl0rnZAnjI0e81SNgpQUvp9lWjlyqrlnGTIl4dJQhm2FijeFhJUkxTst9wVHuTUSMMZZd7AlDn7i6nup0SIvbqxTPt1B2JhVAAnpIV1/VnEE/dqrGvHUGgZV8ms5GIwTRjZbR84EKfmmwvU36/2+NFs0Ad4YCLwzaIioRTXhxZEU9I8x9qyfyjoUB0wpAAhJzpZARV4HxCWB69geG59jTrj3Y+r9ORK2PAFHsuWnpz+LSuOEnYIpR8tuPuFhPk+Q9SuZAQIYOlVg== 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)(376002)(39860400002)(366004)(136003)(396003)(346002)(66476007)(8676002)(6916009)(36756003)(1076003)(52116002)(26005)(16526019)(186003)(8936002)(2906002)(5660300002)(2616005)(956004)(316002)(7696005)(478600001)(4326008)(6486002)(9686003)(66946007)(66556008)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?KwH74OEW+PRAuY131DyNz6BoBbQQdj4nDNxrd9aspOUKf5FiZATNpvDMqC9k?= =?us-ascii?Q?FDZtYd42ufZEvEDZkAuodpI0CaOUepvAhvdFDMr0Fu+lOew4BvAfhis7s8JM?= =?us-ascii?Q?sLnqM+isJaoajJkN8UaGNdT5zODabXnr8pGiTUiUPmcBGImjCPdjZhP2oft4?= =?us-ascii?Q?Tcch/cOx855Cx7WTu+YYJEshKI1XBQDUZOiq8UfrqYFPF5C77yHua+zwpFz6?= =?us-ascii?Q?6n3No1/cU5+Zn5wKNDm9nW7PeTbJdq8foI/wqIGZ6O1EKw5ws+2LrrKQRP/1?= =?us-ascii?Q?x+hZUpy0kAHpAnV9EBM12eXawDy7zX0225tRosD5GXD7jgmRuxXb2M8+Ttl1?= =?us-ascii?Q?tfjLEC0tSAN7jDAhlmfvurmN2zHbu6gnrjoPIeI26T22oVmWuHDa5xtJvTEm?= =?us-ascii?Q?48F+f6ACiNONr8mIkofD/ZVwpO/itj7jVPJs1iEC2YQArdAi9Gzk8QD3KFhY?= =?us-ascii?Q?42Y5EfxXNnqZti1fzcFsU8OGJykfO3jX75mL3hkMfwv5VnQrEjkAKn/aHAC1?= =?us-ascii?Q?TLamfs4rvh63ZExHffNEsgIutA7UApL6XEoMWBUFatd5/l9ImgnbG4If25YF?= =?us-ascii?Q?tg82HDfNqAA9ciIk0VN51/wbw1jveq6haVjJmvvqSZOHwT+mTq5xXR8xqAMM?= =?us-ascii?Q?2IjOHNwhXW0z2BhgkU3CmFzekBjMsTFEAERs/lcDSr5wqyjMpZW6RbQTw2jd?= =?us-ascii?Q?lLq4NTeF30igZqZF2gnR8FQcWdKYvZ3eEdPweCOy8VbNxWKH2omQ1xeffYdW?= =?us-ascii?Q?OTW0SFVxOfvsBXhDGCqkLVLPErANJ3yQ7TxDWfrOSZ68iySne8F/5l06ytjV?= =?us-ascii?Q?5yT/qlAztMAq9SPzoAPn8h4vnvcRr6N/X9+MOYbjDeP6ryS5xB7qfr0sFG+E?= =?us-ascii?Q?Snk/n7478Fnphh1yuDyFNIcVOlrXkVf9kgIeS6QsRUWBUBEfBhbj0HC0rn5i?= =?us-ascii?Q?IlZaxzqC+95kq0LFcaojQrnyxDjpLXGb2yn3XZj4/l1bhuPLf3qHl1a946QG?= =?us-ascii?Q?by4F?= 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: 12 Jan 2021 05:31:08.5384 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-Network-Message-Id: 7e9dd3ba-f3dd-4113-c306-08d8b6bb43d8 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mNhvPnl7a5/LrxJrIqz3AElM69QwyLEM3ohk5ZWq752bObFfDpwy95ZpuKEwVrgWPvicYwdHu/4azVMNxyuINg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4163 Subject: [dpdk-dev] [PATCH v5] net/axgbe: support sfp module EEPROM X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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. 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 | 114 +++++++++++++++++++++++++++++ 4 files changed, 121 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..e60f51ede 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,114 @@ 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 { + ret = -EIO; + goto put; + } + } + +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; + + if (!info || !info->length || !info->data) { + axgbe_phy_put_comm_ownership(pdata); + return -EINVAL; + } + + 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; + } + + data = info->data; + + /* for AXGBE_SFP_SERIAL_ID_ADDRESS */ + if (info->length > AXGBE_SFP_EEPROM_PAGE_SIZE) + 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 */ + if (info->length > AXGBE_SFP_EEPROM_PAGE_SIZE) + 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