net/cnxk: support EEPROM module queries
authorSunil Kumar Kori <skori@marvell.com>
Wed, 23 Jun 2021 04:46:40 +0000 (10:16 +0530)
committerJerin Jacob <jerinj@marvell.com>
Tue, 29 Jun 2021 23:00:41 +0000 (01:00 +0200)
Patch implements eeprom module info get ethops for cn9k and
cn10k platforms.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
doc/guides/nics/features/cnxk.ini
doc/guides/nics/features/cnxk_vec.ini
doc/guides/nics/features/cnxk_vf.ini
drivers/net/cnxk/cnxk_ethdev.c
drivers/net/cnxk/cnxk_ethdev.h
drivers/net/cnxk/cnxk_ethdev_ops.c

index afd0f01..b1e8641 100644 (file)
@@ -31,6 +31,7 @@ L4 checksum offload  = Y
 Inner L3 checksum    = Y
 Inner L4 checksum    = Y
 Packet type parsing  = Y
+Module EEPROM dump   = Y
 Linux                = Y
 ARMv8                = Y
 Usage doc            = Y
index 4bd11ce..0f99634 100644 (file)
@@ -29,6 +29,7 @@ L4 checksum offload  = Y
 Inner L3 checksum    = Y
 Inner L4 checksum    = Y
 Packet type parsing  = Y
+Module EEPROM dump   = Y
 Linux                = Y
 ARMv8                = Y
 Usage doc            = Y
index 335d082..cecced9 100644 (file)
@@ -26,6 +26,7 @@ L4 checksum offload  = Y
 Inner L3 checksum    = Y
 Inner L4 checksum    = Y
 Packet type parsing  = Y
+Module EEPROM dump   = Y
 Linux                = Y
 ARMv8                = Y
 Usage doc            = Y
index a18d1d5..165c354 100644 (file)
@@ -1191,6 +1191,8 @@ struct eth_dev_ops cnxk_eth_dev_ops = {
        .flow_ctrl_set = cnxk_nix_flow_ctrl_set,
        .dev_set_link_up = cnxk_nix_set_link_up,
        .dev_set_link_down = cnxk_nix_set_link_down,
+       .get_module_info = cnxk_nix_get_module_info,
+       .get_module_eeprom = cnxk_nix_get_module_eeprom,
 };
 
 static int
index 5e982f9..083af29 100644 (file)
@@ -253,6 +253,10 @@ int cnxk_nix_flow_ctrl_get(struct rte_eth_dev *eth_dev,
                           struct rte_eth_fc_conf *fc_conf);
 int cnxk_nix_set_link_up(struct rte_eth_dev *eth_dev);
 int cnxk_nix_set_link_down(struct rte_eth_dev *eth_dev);
+int cnxk_nix_get_module_info(struct rte_eth_dev *eth_dev,
+                            struct rte_eth_dev_module_info *modinfo);
+int cnxk_nix_get_module_eeprom(struct rte_eth_dev *eth_dev,
+                              struct rte_dev_eeprom_info *info);
 
 int cnxk_nix_configure(struct rte_eth_dev *eth_dev);
 int cnxk_nix_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid,
index c8da129..55b0411 100644 (file)
@@ -559,3 +559,42 @@ cnxk_nix_set_link_down(struct rte_eth_dev *eth_dev)
 exit:
        return rc;
 }
+
+int
+cnxk_nix_get_module_info(struct rte_eth_dev *eth_dev,
+                        struct rte_eth_dev_module_info *modinfo)
+{
+       struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+       struct roc_nix_eeprom_info eeprom_info = {0};
+       struct roc_nix *nix = &dev->nix;
+       int rc;
+
+       rc = roc_nix_eeprom_info_get(nix, &eeprom_info);
+       if (rc)
+               return rc;
+
+       modinfo->type = eeprom_info.sff_id;
+       modinfo->eeprom_len = ROC_NIX_EEPROM_SIZE;
+       return 0;
+}
+
+int
+cnxk_nix_get_module_eeprom(struct rte_eth_dev *eth_dev,
+                          struct rte_dev_eeprom_info *info)
+{
+       struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+       struct roc_nix_eeprom_info eeprom_info = {0};
+       struct roc_nix *nix = &dev->nix;
+       int rc = -EINVAL;
+
+       if (!info->data || !info->length ||
+           (info->offset + info->length > ROC_NIX_EEPROM_SIZE))
+               return rc;
+
+       rc = roc_nix_eeprom_info_get(nix, &eeprom_info);
+       if (rc)
+               return rc;
+
+       rte_memcpy(info->data, eeprom_info.buf + info->offset, info->length);
+       return 0;
+}