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 310C7A0352; Thu, 14 May 2020 15:43:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C07C11D943; Thu, 14 May 2020 15:43:27 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-eopbgr770082.outbound.protection.outlook.com [40.107.77.82]) by dpdk.org (Postfix) with ESMTP id 01FED1D907 for ; Thu, 14 May 2020 15:43:25 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h4IolMqbEWBOnsqZ5k8Gs8lM4EIfL6LCm5G+nwaqnZ7Q0fcJnvZ9ickkviN0kka/4Y7xA5LQ/FDC3yi9/4j+6shv9bTQlxjB7xFP1wvHaUjAo7KiaQ5EtRWIhupJlba4e3pkNU0O6Te+UfZbI8yzxMU0yixVzH027Ewvjn/b6H2GjeNFW/GNxdmcAh9PI96yJdRbmpI1q45IsDuIjrFNJ2luhehexamYxxSf+SSqWFfkaitQ6/FHZFkIQ2cv6lEDIeoD0NF8sv+YR5B5e2cGeqq352tQKH+rYZcaQd+VMcSM/6qx+hdQB9EgguIXiTh+VJaqL+j7mchxGi2f0bkLHQ== 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=uBoSKm0sdzmQqHiqHj+M6o2p1FY0vwlXxcvSmZYJzvg=; b=N8Umzkb0+CqB5IM8hQqsKH4+ueZF5aPg0e2l2HdzT/xDtDFunfgtCQSfgQMFfuZiuCbkP85kOv5NVxVHjseyQc7oVhKe+k+lLjAJbuM07uqOQEOhzaqMi0QmETjYKJHKXAv+k6Zl4ACm+eNPzEa2UQoaDSfflRXZfksk7hGCqRPuMCrfHx8YS32Qmqj7l7ePhMBPZsMsTN6urmoAcQzjNyn8CvB63oedODs8wO6jq/qQwEcCFPvxOeGslBtdw0WDgiBCHS9dtQnFFWxs/jzyiErZJ4wojgCKqKoBTlFtUVFSgSxXY4JOaUPPWgQt94VA3Yrf7fvdpJ8sEJgGwQqdAQ== 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=uBoSKm0sdzmQqHiqHj+M6o2p1FY0vwlXxcvSmZYJzvg=; b=TTGz106OBLG538kebMio+xCT/D9DXacREsWqegUx9n2MgELgi6/w1Ft1vvTuADKg9ABaMMTuMTU+VOftLBuB4Mqf2VIlUhN2z/V8gtir0yHBlrQB0KvcGBOoT/pH8V1CriLI6YLVbjIT5sTwCwxDstRpUpvNs/EPIB7pUJhPMW0= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=amd.com; Received: from MN2PR12MB3504.namprd12.prod.outlook.com (2603:10b6:208:d1::10) by MN2PR12MB4287.namprd12.prod.outlook.com (2603:10b6:208:1dd::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.26; Thu, 14 May 2020 13:43:23 +0000 Received: from MN2PR12MB3504.namprd12.prod.outlook.com ([fe80::1031:ffa7:f772:6298]) by MN2PR12MB3504.namprd12.prod.outlook.com ([fe80::1031:ffa7:f772:6298%5]) with mapi id 15.20.3000.022; Thu, 14 May 2020 13:43:23 +0000 From: asomalap@amd.com To: dev@dpdk.org Cc: asomalap@amd.com Date: Thu, 14 May 2020 19:13:02 +0530 Message-Id: <20200514134302.29118-1-asomalap@amd.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: MAXPR0101CA0070.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::32) To MN2PR12MB3504.namprd12.prod.outlook.com (2603:10b6:208:d1::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from cae-Bilby-RV1.amd.com (165.204.156.251) by MAXPR0101CA0070.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.25 via Frontend Transport; Thu, 14 May 2020 13:43:22 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.156.251] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 63f2a55b-a926-43c0-d3c7-08d7f80cc58f X-MS-TrafficTypeDiagnostic: MN2PR12MB4287: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 040359335D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sDzS8/jfERAsG0jR0GfNKruWwZbH3EAENPCcpxtalH9E16sY4KslWFx7jZ7WUahzXunJrvXlQ4fqh/b7UMLNbcswuUwOvNIdJYWqe1G8Eooy1QSXcoTslcGmFZMrxw6AKVj3SZAk6zVtuTAOoen9+X+oJVlTiOg0kT42W1adtN46xUn5lxtAS3fo3N0UyWFkg6uYeI4DXslgD8LobG9n/RyE6oANBJYukiFINznpVsQsHH/RkPgBLflSBuHZMMQbuYMigy7GURnNu3GiyM+PZ3Qg9dUOAtkKDHG9h2KLWrRwWqaae3B+mQDlAIJA+NAcfMVIpI2xwnnMCPGi4dfcYo5S4VwoEon5bWRM/VG5UUnlJaNhmExPta+QNxQGwsSs7sNYuK+6/OdVLLUvjDZWWJrM5qy3Xnkm6gimT0UbF6ntjeDNxzwqQaVi4u4DhbCc X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR12MB3504.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(376002)(136003)(346002)(396003)(366004)(2906002)(9686003)(36756003)(5660300002)(478600001)(6916009)(956004)(4326008)(2616005)(1076003)(66556008)(66946007)(7696005)(66476007)(52116002)(186003)(16526019)(6486002)(8936002)(8676002)(6666004)(26005)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 1tIeuSEv94U0UAr6fkkXwhgJNQewkFaXWX8FdCC9CFv8VB0WCoOXOoLRbf0lubDS4Q7Rycd53qxYIJyPDKuvePdgyO5Bkt2sYumvW13+p+JEk7lhqubWWdnycMRKewDjvBW2paNNLJAhrwBbPF5kjenaDo+PSO7GYPKgYFkefQdtlyAxnN9Mx0vs3XB8x2HodelL52YlflTc8I38xXQPxGMgnOjX6zcxi4fIbWiSyzy8iZUM+lvaFzBVpUbf0l99LoQpDLtHrIx5S+EL18XSmxbzs2UbUpPbdS5JjbQBFA/7XGVsJttPTQFa9ShL144aaC/4+cW9ArD1YgcFPzZsiBDOVCjqvNDLN9OYsJLucdmPHIEk0nkL369jZPpjSdEuRBkQXTd75EdMyhCI5P6M3B1hQwIYctQGc5iStudAMkXz9CVCyhTJffTj7Bv2+B0ztSZpt1HnzRCl7wsxnjZpcgbWG/vDeeC86XCesaOcNftKnMRiO50b7PK8yrYE+G3+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63f2a55b-a926-43c0-d3c7-08d7f80cc58f X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2020 13:43:23.6626 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BnjgYpYx2/pItw3mjZgZw/aj7a4F8aT8Wa1DlY8DBJT8PRFggxlzf97Pc7vzPIstMLRMLwWsvmzbsM5JvoJQHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4287 Subject: [dpdk-dev] [PATCH v1] 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. 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 | 107 +++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+) diff --git a/doc/guides/nics/features/axgbe.ini b/doc/guides/nics/features/axgbe.ini index 0becaa097..80a3bcee1 100644 --- a/doc/guides/nics/features/axgbe.ini +++ b/doc/guides/nics/features/axgbe.ini @@ -18,3 +18,4 @@ Basic stats = Y Linux UIO = Y x86-32 = Y x86-64 = Y +Module EEPROM dump = Y diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index 867058845..ea2f9bba1 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -214,6 +214,8 @@ static const struct eth_dev_ops axgbe_eth_dev_ops = { .dev_supported_ptypes_get = axgbe_dev_supported_ptypes_get, .rx_descriptor_status = axgbe_dev_rx_descriptor_status, .tx_descriptor_status = axgbe_dev_tx_descriptor_status, + .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..53716071f 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[256]; +}; + #define AXGBE_BEL_FUSE_VENDOR "BEL-FUSE" #define AXGBE_BEL_FUSE_PARTNO "1GBT-SFP06" @@ -734,6 +740,106 @@ 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"); + return ret; + } + + 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 0; +} + +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) + return -EINVAL; + + ret = axgbe_phy_sfp_get_mux(pdata); + if (ret) { + PMD_DRV_LOG(ERR, "I2C error setting SFP MUX\n"); + return ret; + } + + 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 0; +} + static void axgbe_phy_sfp_signals(struct axgbe_port *pdata) { struct axgbe_phy_data *phy_data = pdata->phy_data; @@ -741,6 +847,7 @@ static void axgbe_phy_sfp_signals(struct axgbe_port *pdata) u8 gpio_reg, gpio_ports[2]; int ret; + /* Read the input port registers */ gpio_reg = 0; ret = axgbe_phy_i2c_read(pdata, phy_data->sfp_gpio_address, -- 2.17.1