From: Vamsi Attunuru Date: Fri, 31 May 2019 07:01:49 +0000 (+0530) Subject: net/octeontx2: add module EEPROM dump X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=58f6f93c34c1;p=dpdk.git net/octeontx2: add module EEPROM dump Add module EEPROM dump operation. Signed-off-by: Vamsi Attunuru Acked-by: Jerin Jacob --- diff --git a/doc/guides/nics/features/octeontx2.ini b/doc/guides/nics/features/octeontx2.ini index f07b64f24e..87141244a2 100644 --- a/doc/guides/nics/features/octeontx2.ini +++ b/doc/guides/nics/features/octeontx2.ini @@ -26,6 +26,7 @@ Rx descriptor status = Y Basic stats = Y Stats per queue = Y Extended stats = Y +Module EEPROM dump = Y Registers dump = Y Linux VFIO = Y ARMv8 = Y diff --git a/doc/guides/nics/features/octeontx2_vec.ini b/doc/guides/nics/features/octeontx2_vec.ini index 911c926e4e..dafbe003c6 100644 --- a/doc/guides/nics/features/octeontx2_vec.ini +++ b/doc/guides/nics/features/octeontx2_vec.ini @@ -26,6 +26,7 @@ Rx descriptor status = Y Basic stats = Y Extended stats = Y Stats per queue = Y +Module EEPROM dump = Y Registers dump = Y Linux VFIO = Y ARMv8 = Y diff --git a/doc/guides/nics/features/octeontx2_vf.ini b/doc/guides/nics/features/octeontx2_vf.ini index e275e6469b..7fba7e1d9a 100644 --- a/doc/guides/nics/features/octeontx2_vf.ini +++ b/doc/guides/nics/features/octeontx2_vf.ini @@ -22,6 +22,7 @@ Rx descriptor status = Y Basic stats = Y Extended stats = Y Stats per queue = Y +Module EEPROM dump = Y Registers dump = Y Linux VFIO = Y ARMv8 = Y diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c index 909aad65c1..fcc2504bf4 100644 --- a/drivers/net/octeontx2/otx2_ethdev.c +++ b/drivers/net/octeontx2/otx2_ethdev.c @@ -1319,6 +1319,8 @@ static const struct eth_dev_ops otx2_eth_dev_ops = { .rx_descriptor_status = otx2_nix_rx_descriptor_status, .tx_done_cleanup = otx2_nix_tx_done_cleanup, .pool_ops_supported = otx2_nix_pool_ops_supported, + .get_module_info = otx2_nix_get_module_info, + .get_module_eeprom = otx2_nix_get_module_eeprom, }; static inline int diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h index 8f2691c809..5dd5d8c8bf 100644 --- a/drivers/net/octeontx2/otx2_ethdev.h +++ b/drivers/net/octeontx2/otx2_ethdev.h @@ -274,6 +274,10 @@ otx2_eth_pmd_priv(struct rte_eth_dev *eth_dev) /* Ops */ void otx2_nix_info_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *dev_info); +int otx2_nix_get_module_info(struct rte_eth_dev *eth_dev, + struct rte_eth_dev_module_info *modinfo); +int otx2_nix_get_module_eeprom(struct rte_eth_dev *eth_dev, + struct rte_dev_eeprom_info *info); int otx2_nix_pool_ops_supported(struct rte_eth_dev *eth_dev, const char *pool); void otx2_nix_rxq_info_get(struct rte_eth_dev *eth_dev, uint16_t queue_id, struct rte_eth_rxq_info *qinfo); diff --git a/drivers/net/octeontx2/otx2_ethdev_ops.c b/drivers/net/octeontx2/otx2_ethdev_ops.c index 44cc172009..2a949439af 100644 --- a/drivers/net/octeontx2/otx2_ethdev_ops.c +++ b/drivers/net/octeontx2/otx2_ethdev_ops.c @@ -220,6 +220,57 @@ otx2_nix_pool_ops_supported(struct rte_eth_dev *eth_dev, const char *pool) return -ENOTSUP; } +static struct cgx_fw_data * +nix_get_fwdata(struct otx2_eth_dev *dev) +{ + struct otx2_mbox *mbox = dev->mbox; + struct cgx_fw_data *rsp = NULL; + + otx2_mbox_alloc_msg_cgx_get_aux_link_info(mbox); + + otx2_mbox_process_msg(mbox, (void *)&rsp); + + return rsp; +} + +int +otx2_nix_get_module_info(struct rte_eth_dev *eth_dev, + struct rte_eth_dev_module_info *modinfo) +{ + struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); + struct cgx_fw_data *rsp; + + rsp = nix_get_fwdata(dev); + if (rsp == NULL) + return -EIO; + + modinfo->type = rsp->fwdata.sfp_eeprom.sff_id; + modinfo->eeprom_len = SFP_EEPROM_SIZE; + + return 0; +} + +int +otx2_nix_get_module_eeprom(struct rte_eth_dev *eth_dev, + struct rte_dev_eeprom_info *info) +{ + struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev); + struct cgx_fw_data *rsp; + + if (!info->data || !info->length || + (info->offset + info->length > SFP_EEPROM_SIZE)) + return -EINVAL; + + rsp = nix_get_fwdata(dev); + if (rsp == NULL) + return -EIO; + + otx2_mbox_memcpy(info->data, rsp->fwdata.sfp_eeprom.buf + info->offset, + info->length); + + return 0; +} + void otx2_nix_info_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *devinfo) {