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 EB649A0597; Wed, 8 Apr 2020 10:34:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5653E1C1FA; Wed, 8 Apr 2020 10:30:09 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2071.outbound.protection.outlook.com [40.107.223.71]) by dpdk.org (Postfix) with ESMTP id 6A2521C1DF for ; Wed, 8 Apr 2020 10:30:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BZiAL7nyzVWZ/a6PaHpUjOXxOitZSHwnakQfZz8eht1htE7XqvoosPzpXRGalU+i/kXYhOoK6BkH1FmJLlrmfR7r+yqkNFsqJiGcoIiFdwoXkDs/QFP+amojxqSEMkz12EY+JLbL2j2EjSodWZVKm0Qp9wtyViCGJCKg03ort7JBMGNtFy80RzaLkNmyMI05Amyzd8LXeAUZugdOWFMUK9RRf65yEC12w3yguJsXyf464kMZddHOnC2465ATpGaUeWTaLcN4kC36UlVNsFWaVM72xIivDjf0iw7YRRgYiT/VHOKG5GytLFQyW0rPG6t8U1ge8C1TIH0qI1qMXpaQLg== 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=bwepQIvoMOg9isAfFaRe3yCrjMjppW+G+SB9v7py8ho=; b=dvjYijdVoSSG7m46OEup39P7uaR9VSVTPMakyUl8vgDFJnbLrItL0yRl77uBnnEMLRsBqIVcnidTcpBQAWX/FWq8L7I6OCFXH5xSHrSIBcDc+bfCjNf+jaVk9eIDyH3BrGDH0s5recJMaLAUsm6ZmBPGl3Sv7McpwmHBcVTpI9V0gOUL+xYmTrIU+fbSD3u6Qf/23kF0gybBpvaIkMD1gDILIL9boYiiWQzwEXAUT6BonR2j1bPfvIHcXuTIx5JZW269l9Bbk+lJM+HbbyhL+DbL8JysWy4rVRNHQGJ8M2zjLpXrhM0UwcJvCJqkOiML15AawyUAB9sSDrRP1dYtwA== 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=bwepQIvoMOg9isAfFaRe3yCrjMjppW+G+SB9v7py8ho=; b=ZLhUjJq4nbQUBFuX33scKofzNI4g9e73QUJwdi1mXYDISQ+jYQGtRR0eZj26qWeOsXVC16lDgHZmgiHj71/sPLQrdLI/FDTQphI6L5DEk16SgzVEA1j4wJPOWA+hiQwt/bvCHzvho15eQXZ228oOIj8xPzkyh8p9e5ZRebkXx5o= Received: from MN2PR12MB3504.namprd12.prod.outlook.com (2603:10b6:208:d1::10) by MN2PR12MB4437.namprd12.prod.outlook.com (2603:10b6:208:26f::17) 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 08:30:01 +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 08:30:01 +0000 From: "Somalapuram, Amaranath" To: "Somalapuram, Amaranath" , "dev@dpdk.org" CC: "Kumar, Ravi1" Thread-Topic: [PATCH v1] net/axgbe: support sfp module EEPROM Thread-Index: AQHWDXR/fzve+cfdX0ecf8CJMoIWoqhu5IJQ Date: Wed, 8 Apr 2020 08:30:01 +0000 Message-ID: References: <20200408070803.32051-1-asomalap@amd.com> In-Reply-To: <20200408070803.32051-1-asomalap@amd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_76546daa-41b6-470c-bb85-f6f40f044d7f_ActionId=27f6ad2a-eacc-4a51-a86c-000060c468d8; MSIP_Label_76546daa-41b6-470c-bb85-f6f40f044d7f_ContentBits=0; MSIP_Label_76546daa-41b6-470c-bb85-f6f40f044d7f_Enabled=true; MSIP_Label_76546daa-41b6-470c-bb85-f6f40f044d7f_Method=Standard; MSIP_Label_76546daa-41b6-470c-bb85-f6f40f044d7f_Name=Internal Use Only - Unrestricted; MSIP_Label_76546daa-41b6-470c-bb85-f6f40f044d7f_SetDate=2020-04-08T08:28:41Z; MSIP_Label_76546daa-41b6-470c-bb85-f6f40f044d7f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; authentication-results: spf=none (sender IP is ) smtp.mailfrom=Amaranath.Somalapuram@amd.com; x-originating-ip: [2405:201:d805:fce:14a:b994:ab15:4d65] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 00242284-26ea-4b26-5b31-08d7db9707ee x-ms-traffictypediagnostic: MN2PR12MB4437:|MN2PR12MB4437: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4303; 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)(376002)(346002)(366004)(39860400002)(136003)(396003)(316002)(478600001)(64756008)(66446008)(76116006)(66556008)(66946007)(2906002)(81166007)(33656002)(4326008)(66476007)(81156014)(186003)(86362001)(110136005)(53546011)(5660300002)(55016002)(9686003)(6506007)(8936002)(52536014)(8676002)(71200400001)(7696005); 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: RgdMcflkrskt46emx1XUqs36sfW1oReZYSB58LyIMxMl5/ELH5Gc+RDp1/ANRyw8GisfV9Vs36vRMpShZWG+R1C+yJ7s64prLPd/6avqQuKoiqYvPTUYEWreRt1k8xcMnMPeNEBos8xNRyRWv9WnhTetU8ZZx+GxyULztdpiY6RWB8RgNxsSoZCT3vIY1jL8xULdHfRNEF+UNRR1yKtdILap4tYL1EgX3vhz+sNFelAu16S1DlfffO06cgMIj3awKIyW9q2O9ojNXSUOW+yISXBKsaSVuDjO+/wTxq5jEPqQY/nU5erfzlqNvYFOxBnHEjJMilYbvdUGFA5/gaNn9N1t0DNkMi3Xh5ZfqXt9sHXp40V5snW6vBMZoTp6ZZ6v2J1fF4maaOoSGg+DFaPXBZkpRQki4T6uEr6LUxvioq6+uMPDKpP+Blw7ILIqhLqT x-ms-exchange-antispam-messagedata: yiiKsmDmOjaf+2zcaa17r6ElGB6Ey1ax/yLWISiAjgEDD0qZdT1lSEbNMEjch4ZTUO3G3e52gyJ9P8P8DAtcZ1r/gr3uOa4VpcEzwUApfdAsLOF6Th0YhRiB3pk4PFYyESG4zPfc2DH4fFshRHxLQ/pcd9PECbqOc0EzgSIGgNJQuRsocmocNSWEZobdhfeHBDPrGKCvIv13y2L4mT0tAg== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00242284-26ea-4b26-5b31-08d7db9707ee X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2020 08:30:01.3002 (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: AISLmAm4lSQbgenuuR5S/0Ymr5ObXyvTHSUfky9m5fvPQ1a25cSfHM9Tq1XSTR5hBKLZ7QWGVMPy6p4Sze4fag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4437 Subject: Re: [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" Hi Ravi, Can you acknowledge this patch. Regards, S.Amarnath -----Original Message----- From: Somalapuram, Amaranath =20 Sent: Wednesday, April 8, 2020 12:38 PM To: dev@dpdk.org Cc: Kumar, Ravi1 Subject: [PATCH v1] net/axgbe: support sfp module EEPROM 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_eth= dev.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 =3D { .dev_supported_ptypes_get =3D axgbe_dev_supported_ptypes_get, .rx_descriptor_status =3D axgbe_dev_rx_descriptor_status, .tx_descriptor_status =3D axgbe_dev_tx_descriptor_status, + .get_module_info =3D axgbe_get_module_info, + .get_module_eeprom =3D axgbe_get_module_eeprom, }; =20 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..d9d7= fde41 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 =20 +int axgbe_get_module_info(struct rte_eth_dev *dev, + struct rte_eth_dev_module_info *modinfo); int=20 +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_p= hy_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 { =20 #define AXGBE_SFP_EXTD_CC 31 =20 +#define AXGBE_SFP_EEPROM_PAGE_SIZE 256 + struct axgbe_sfp_eeprom { u8 base[64]; u8 extd[32]; u8 vendor[32]; }; =20 +struct axgbe_sfp_eeprom_module { + u8 base[256]; +}; + #define AXGBE_BEL_FUSE_VENDOR "BEL-FUSE" #define AXGBE_BEL_FUSE_PARTNO "1GBT-SFP06" =20 @@ -734,6 +740,106 @@ static int axgbe_phy_sfp_read_eeprom(struct axgbe_por= t *pdata) return ret; } =20 +int axgbe_get_module_info(struct rte_eth_dev *dev, + struct rte_eth_dev_module_info *modinfo) { + struct axgbe_port *pdata =3D dev->data->dev_private; + struct axgbe_sfp_eeprom sfp_eeprom; + uint8_t eeprom_addr; + int ret; + + ret =3D axgbe_phy_get_comm_ownership(pdata); + + if (ret) + return -EIO; + + ret =3D axgbe_phy_sfp_get_mux(pdata); + + if (ret) { + PMD_DRV_LOG(ERR, "I2C error setting SFP MUX\n"); + return ret; + } + + eeprom_addr =3D 0; + ret =3D 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] !=3D 0xff) { + if (sfp_eeprom.extd[AXGBE_SFP_EXTD_SFF_8472] =3D=3D 0) { + modinfo->type =3D RTE_ETH_MODULE_SFF_8079; + modinfo->eeprom_len =3D RTE_ETH_MODULE_SFF_8079_LEN; + } else { + modinfo->type =3D RTE_ETH_MODULE_SFF_8472; + modinfo->eeprom_len =3D 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 =3D dev->data->dev_private; + struct axgbe_sfp_eeprom_module sfp_eeprom; + uint8_t eeprom_addr; + uint8_t *data; + uint32_t i; + int ret; + + ret =3D axgbe_phy_get_comm_ownership(pdata); + + if (ret) + return -EIO; + + if (!info || !info->length || !info->data) + return -EINVAL; + + ret =3D axgbe_phy_sfp_get_mux(pdata); + if (ret) { + PMD_DRV_LOG(ERR, "I2C error setting SFP MUX\n"); + return ret; + } + + eeprom_addr =3D 0; + ret =3D 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 =3D info->data; + + /* for AXGBE_SFP_SERIAL_ID_ADDRESS */ + for (i =3D 0; i < AXGBE_SFP_EEPROM_PAGE_SIZE; i++) + data[i] =3D sfp_eeprom.base[i]; + + eeprom_addr =3D 0; + ret =3D 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 =3D 0; i < info->length - AXGBE_SFP_EEPROM_PAGE_SIZE; i++) + data[i + AXGBE_SFP_EEPROM_PAGE_SIZE] =3D 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 =3D 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; =20 + /* Read the input port registers */ gpio_reg =3D 0; ret =3D axgbe_phy_i2c_read(pdata, phy_data->sfp_gpio_address, -- 2.17.1