net/cnxk: support MAC address set
authorSunil Kumar Kori <skori@marvell.com>
Wed, 23 Jun 2021 04:46:32 +0000 (10:16 +0530)
committerJerin Jacob <jerinj@marvell.com>
Tue, 29 Jun 2021 22:01:39 +0000 (00:01 +0200)
Default mac address set operation is implemented for
cn9k and cn10k platforms.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
drivers/net/cnxk/cnxk_ethdev.c
drivers/net/cnxk/cnxk_ethdev.h
drivers/net/cnxk/cnxk_ethdev_ops.c

index d4587f0..58d2f7d 100644 (file)
@@ -1046,6 +1046,7 @@ rx_disable:
 
 /* CNXK platform independent eth dev ops */
 struct eth_dev_ops cnxk_eth_dev_ops = {
+       .mac_addr_set = cnxk_nix_mac_addr_set,
        .dev_infos_get = cnxk_nix_info_get,
        .link_update = cnxk_nix_link_update,
        .tx_queue_release = cnxk_nix_tx_queue_release,
index 50c75e1..a5380a5 100644 (file)
@@ -218,6 +218,8 @@ extern struct eth_dev_ops cnxk_eth_dev_ops;
 int cnxk_nix_probe(struct rte_pci_driver *pci_drv,
                   struct rte_pci_device *pci_dev);
 int cnxk_nix_remove(struct rte_pci_device *pci_dev);
+int cnxk_nix_mac_addr_set(struct rte_eth_dev *eth_dev,
+                         struct rte_ether_addr *addr);
 int cnxk_nix_info_get(struct rte_eth_dev *eth_dev,
                      struct rte_eth_dev_info *dev_info);
 int cnxk_nix_configure(struct rte_eth_dev *eth_dev);
index 4a45956..87cf4ee 100644 (file)
@@ -69,3 +69,32 @@ cnxk_nix_info_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *devinfo)
                            RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP;
        return 0;
 }
+
+int
+cnxk_nix_mac_addr_set(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr)
+{
+       struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+       struct roc_nix *nix = &dev->nix;
+       int rc;
+
+       /* Update mac address at NPC */
+       rc = roc_nix_npc_mac_addr_set(nix, addr->addr_bytes);
+       if (rc)
+               goto exit;
+
+       /* Update mac address at CGX for PFs only */
+       if (!roc_nix_is_vf_or_sdp(nix)) {
+               rc = roc_nix_mac_addr_set(nix, addr->addr_bytes);
+               if (rc) {
+                       /* Rollback to previous mac address */
+                       roc_nix_npc_mac_addr_set(nix, dev->mac_addr);
+                       goto exit;
+               }
+       }
+
+       /* Update mac address to cnxk ethernet device */
+       rte_memcpy(dev->mac_addr, addr->addr_bytes, RTE_ETHER_ADDR_LEN);
+
+exit:
+       return rc;
+}