[dpdk-dev] [PATCH v3 27/34] net/ice: support EEPROM information getting

Wenzhuo Lu wenzhuo.lu at intel.com
Wed Dec 12 07:59:57 CET 2018


Add below ops,
get_eeprom_length
get_eeprom

Signed-off-by: Wei Zhao <wei.zhao1 at intel.com>
Signed-off-by: Wenzhuo Lu <wenzhuo.lu at intel.com>
---
 drivers/net/ice/ice_ethdev.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index aae2c5e..98b17bc 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -56,6 +56,9 @@ static int ice_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
 			      size_t fw_size);
 static int ice_vlan_pvid_set(struct rte_eth_dev *dev,
 			     uint16_t pvid, int on);
+static int ice_get_eeprom_length(struct rte_eth_dev *dev);
+static int ice_get_eeprom(struct rte_eth_dev *dev,
+			  struct rte_dev_eeprom_info *eeprom);
 
 static const struct rte_pci_id pci_id_ice_map[] = {
 	{ RTE_PCI_DEVICE(ICE_INTEL_VENDOR_ID, ICE_DEV_ID_E810C_BACKPLANE) },
@@ -96,6 +99,8 @@ static int ice_vlan_pvid_set(struct rte_eth_dev *dev,
 	.rx_queue_intr_disable        = ice_rx_queue_intr_disable,
 	.fw_version_get               = ice_fw_version_get,
 	.vlan_pvid_set                = ice_vlan_pvid_set,
+	.get_eeprom_length            = ice_get_eeprom_length,
+	.get_eeprom                   = ice_get_eeprom,
 };
 
 static void
@@ -2639,3 +2644,43 @@ static int ice_rx_queue_intr_disable(struct rte_eth_dev *dev,
 
 	return 0;
 }
+
+static int
+ice_get_eeprom_length(struct rte_eth_dev *dev)
+{
+	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	/* Convert word count to byte count */
+	return hw->nvm.sr_words << 1;
+}
+
+static int
+ice_get_eeprom(struct rte_eth_dev *dev,
+	       struct rte_dev_eeprom_info *eeprom)
+{
+	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint16_t *data = eeprom->data;
+	uint16_t offset, length, i;
+	enum ice_status ret_code = ICE_SUCCESS;
+
+	offset = eeprom->offset >> 1;
+	length = eeprom->length >> 1;
+
+	if (offset > hw->nvm.sr_words ||
+	    offset + length > hw->nvm.sr_words) {
+		PMD_DRV_LOG(ERR, "Requested EEPROM bytes out of range.");
+		return -EINVAL;
+	}
+
+	eeprom->magic = hw->vendor_id | (hw->device_id << 16);
+
+	for (i = 0; i < length; i++) {
+		ret_code = ice_read_sr_word(hw, offset + i, &data[i]);
+		if (ret_code != ICE_SUCCESS) {
+			PMD_DRV_LOG(ERR, "EEPROM read failed.");
+			return -EIO;
+		}
+	}
+
+	return 0;
+}
-- 
1.9.3



More information about the dev mailing list