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 736FBA0597; Wed, 8 Apr 2020 09:08:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1C3981BFBA; Wed, 8 Apr 2020 09:08:30 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2073.outbound.protection.outlook.com [40.107.243.73]) by dpdk.org (Postfix) with ESMTP id 6AD3D1BF9D for ; Wed, 8 Apr 2020 09:08:29 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n5es0Ox8BjYzypuOqkljo+wDkGSjSY7PxbhUCUPVMdDjjA+9DR3r+Lro2hFgUCMxBkYlmfg521JzCRiUOqMrHJ3jCUO0sQnf6ZVg8My366VqfcGukiCpR2Ku7TCpfyQJIZb3/DC3EeeX5A0n/VUw064DwQV5O5k213n0f2cstPrtD9TJ2OotE1zMzs+XpNcojXgapszNCuhgEXznH6hfCCfxPs2EIId6YKeReNW7RO/kKBc+B4AO3tyfxNzQTiZWEsiX7tVdc9RLTnV8MCZAviPu/Kc1TNV4R765UXNDD4YsPOSV6ZaO6XxaBeQssj2yRhDc0BL+gcXQ+oS00BoBmA== 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=Lv3r6QYIfjbxlKAB0Rgzmcc+0reX9onikX5WkQkVJwU=; b=UHRfqrBZvzDRyV95OkNGUt9AufScmZpSC2WqURsBINF1Z/Z4siC4RbvHp027uQ8dkTjXyg2TcN++R70yF4MBozN6yzeNYSTVzAQOVrRkC6OIKFvgNseghRg+n2c6e7aKU9E6noeuw8UJQbcZYtKGyP7i871+uSQZeuGlRfPluAwRH1nbcWTwtfbF8auqJl/EzDWApeKN8HAYg58I50xvnNrvClpY2HmFE3iwQt1fQ9nUW0wjd46Kg7KWm4YjpAPgfNC4bMl4315B8KQFlR63kPx3ROHjFujrXOfsKvMBLSfkzn84NHvvNmYiMYpEsQuyzKeHasapXSaFM3hp/W522w== 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=Lv3r6QYIfjbxlKAB0Rgzmcc+0reX9onikX5WkQkVJwU=; b=OvPdA9kDplgc/ANLXwdqYM1tjsreFN7La8P/9NAlLrfrEbdj4etjnqcS/S0ekaAxItrycT1Y2fESutdaJJ/p9QQPrvQcF0qoUNbCAbIGvEZxPwt2vjyAp0ljXYxskfJfd4ua1kVOpMua5eEL6G9X/swCDEIsbe/lBUkELFGR2AI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Amaranath.Somalapuram@amd.com; Received: from MN2PR12MB3504.namprd12.prod.outlook.com (2603:10b6:208:d1::10) by MN2PR12MB3424.namprd12.prod.outlook.com (2603:10b6:208:cc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.20; Wed, 8 Apr 2020 07:08:25 +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.2878.018; Wed, 8 Apr 2020 07:08:25 +0000 From: asomalap@amd.com To: dev@dpdk.org Cc: Ravi1.Kumar@amd.com Date: Wed, 8 Apr 2020 12:38:03 +0530 Message-Id: <20200408070803.32051-1-asomalap@amd.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: MAXPR01CA0071.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:49::13) 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 MAXPR01CA0071.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:49::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15 via Frontend Transport; Wed, 8 Apr 2020 07:08:24 +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: 8cf5e588-4c1d-4520-92d5-08d7db8ba18b X-MS-TrafficTypeDiagnostic: MN2PR12MB3424:|MN2PR12MB3424: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 0367A50BB1 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:(10009020)(4636009)(366004)(52116002)(7696005)(6916009)(8676002)(36756003)(81156014)(9686003)(956004)(81166007)(2616005)(4326008)(26005)(66556008)(66476007)(66946007)(1076003)(6486002)(8936002)(186003)(498600001)(5660300002)(16526019)(6666004)(2906002); DIR:OUT; SFP:1101; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t52Z90XfBIyc3f9LEo0Wp7i16pMO6mD0mbb3lZ2N29eUYeF8RwoT/nF8NddsaExFmJSqwMit4DHQTP4ByyYGOEcPscqRIsepEOU+psOymJTHjMISMZHSC8vYTx5tH3T/oJFP28fDKiCdqUMHjrDwD55PevNE7aCzfmFUUXSggEOLd7x4/mjnIh//rb8VeHIji9T1+hinogIXk/qGJueeCOacMuFAmMt+PbFE5nGxHIbr9SK5foZokaA5hRg70NCw2axIktLcAxhladRs0s4kjY75OJlopiu1YxcWecUXxyskmT3qdw8PGql6Z4RwuSzj7gid2biAY5HOV4FFpOuCjO4udw+kPssfx6QI+fKlbWkuMBiTxQXI1FT6zffI1RIjDPCJouMrlGFw8N51T3p6oZdNj97zbiV6zTYzETydtjX6xN3l9Fc95sNVBSws6RPE X-MS-Exchange-AntiSpam-MessageData: wXI2Ji1I35TIVm0qeQR0zI2MmtciSpmOYNjgX7GZxit37Gso5o/sTlWiIR/X68bME/Wz+LDPr/dX1/HAXSElArCF32ONAd3sU7cdy16ndJxlfM3UNaAGvE3GIvN6nwwT0t9VX52od04rwJSS6Ci23A== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8cf5e588-4c1d-4520-92d5-08d7db8ba18b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2020 07:08:25.6468 (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: gjGzyNgXZpSPcbuCROdUeEhjEp8gBn2ioGiavRsD7x+mOoHevj4BSiPmCmx4lDjD3k5Q7yRBJD0hOCBPot80ww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3424 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 --- drivers/net/axgbe/axgbe_ethdev.c | 2 + drivers/net/axgbe/axgbe_phy.h | 4 ++ drivers/net/axgbe/axgbe_phy_impl.c | 107 +++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+) 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