net/octeontx2: add unicast MAC filter
authorSunil Kumar Kori <skori@marvell.com>
Wed, 29 May 2019 11:21:55 +0000 (16:51 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 4 Jul 2019 23:52:01 +0000 (01:52 +0200)
Add unicast MAC filter for PF device and
update the respective feature list.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
doc/guides/nics/features/octeontx2.ini
doc/guides/nics/features/octeontx2_vec.ini
doc/guides/nics/octeontx2.rst
drivers/net/octeontx2/otx2_ethdev.c
drivers/net/octeontx2/otx2_ethdev.h
drivers/net/octeontx2/otx2_mac.c

index 9f682609d1c5fc6082c8e040d5bab19fcccb7d17..5664961135c9742552388dedba879d4bdf4fa166 100644 (file)
@@ -12,6 +12,7 @@ Link status          = Y
 Link status event    = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+Unicast MAC filter   = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
index 764e95ce683dafb99ea7707a916d5d620bb7a961..195a48940b69dded82ec2bd0cb85af924d155f63 100644 (file)
@@ -12,6 +12,7 @@ Link status          = Y
 Link status event    = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+Unicast MAC filter   = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
index 9ef7be08f9622ece9da443db5b4fc6b4e04af18a..8385c9c18f2e25448c2698e7d6a059e86c7bd317 100644 (file)
@@ -19,6 +19,7 @@ Features of the OCTEON TX2 Ethdev PMD are:
 - Promiscuous mode
 - SR-IOV VF
 - Lock-free Tx queue
+- MAC filtering
 - Port hardware statistics
 - Link state information
 - Debug utilities - Context dump and error interrupt support
index 826ce7f4e7713d52f91f5272b4db7118df93c5fb..a72c901f4f2bcad3245b4b40f1e784672f98c5e4 100644 (file)
@@ -237,6 +237,9 @@ static const struct eth_dev_ops otx2_eth_dev_ops = {
        .stats_get                = otx2_nix_dev_stats_get,
        .stats_reset              = otx2_nix_dev_stats_reset,
        .get_reg                  = otx2_nix_dev_get_reg,
+       .mac_addr_add             = otx2_nix_mac_addr_add,
+       .mac_addr_remove          = otx2_nix_mac_addr_del,
+       .mac_addr_set             = otx2_nix_mac_addr_set,
        .promiscuous_enable       = otx2_nix_promisc_enable,
        .promiscuous_disable      = otx2_nix_promisc_disable,
        .allmulticast_enable      = otx2_nix_allmulticast_enable,
index 814fd6ec3d3427116f85a8f1b29fb41f0fe5ef05..56517845bd43db113004912c3a72270641fbbe82 100644 (file)
@@ -232,7 +232,13 @@ int otx2_cgx_mac_addr_set(struct rte_eth_dev *eth_dev,
                          struct rte_ether_addr *addr);
 
 /* Mac address handling */
+int otx2_nix_mac_addr_set(struct rte_eth_dev *eth_dev,
+                         struct rte_ether_addr *addr);
 int otx2_nix_mac_addr_get(struct rte_eth_dev *eth_dev, uint8_t *addr);
+int otx2_nix_mac_addr_add(struct rte_eth_dev *eth_dev,
+                         struct rte_ether_addr *addr,
+                         uint32_t index, uint32_t pool);
+void otx2_nix_mac_addr_del(struct rte_eth_dev *eth_dev, uint32_t index);
 int otx2_cgx_mac_max_entries_get(struct otx2_eth_dev *dev);
 
 /* Devargs */
index 89b0ca6b0196f995d27ffd4ba83899cc7990e372..b4bcc61f87decf4ca8d5bbb16f142a276b722e00 100644 (file)
@@ -49,6 +49,83 @@ otx2_cgx_mac_max_entries_get(struct otx2_eth_dev *dev)
        return rsp->max_dmac_filters;
 }
 
+int
+otx2_nix_mac_addr_add(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr,
+                     uint32_t index __rte_unused, uint32_t pool __rte_unused)
+{
+       struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+       struct otx2_mbox *mbox = dev->mbox;
+       struct cgx_mac_addr_add_req *req;
+       struct cgx_mac_addr_add_rsp *rsp;
+       int rc;
+
+       if (otx2_dev_is_vf(dev))
+               return -ENOTSUP;
+
+       if (otx2_dev_active_vfs(dev))
+               return -ENOTSUP;
+
+       req = otx2_mbox_alloc_msg_cgx_mac_addr_add(mbox);
+       otx2_mbox_memcpy(req->mac_addr, addr->addr_bytes, RTE_ETHER_ADDR_LEN);
+
+       rc = otx2_mbox_process_msg(mbox, (void *)&rsp);
+       if (rc) {
+               otx2_err("Failed to add mac address, rc=%d", rc);
+               goto done;
+       }
+
+       /* Enable promiscuous mode at NIX level */
+       otx2_nix_promisc_config(eth_dev, 1);
+
+done:
+       return rc;
+}
+
+void
+otx2_nix_mac_addr_del(struct rte_eth_dev *eth_dev, uint32_t index)
+{
+       struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+       struct otx2_mbox *mbox = dev->mbox;
+       struct cgx_mac_addr_del_req *req;
+       int rc;
+
+       if (otx2_dev_is_vf(dev))
+               return;
+
+       req = otx2_mbox_alloc_msg_cgx_mac_addr_del(mbox);
+       req->index = index;
+
+       rc = otx2_mbox_process(mbox);
+       if (rc)
+               otx2_err("Failed to delete mac address, rc=%d", rc);
+}
+
+int
+otx2_nix_mac_addr_set(struct rte_eth_dev *eth_dev, struct rte_ether_addr *addr)
+{
+       struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+       struct otx2_mbox *mbox = dev->mbox;
+       struct nix_set_mac_addr *req;
+       int rc;
+
+       req = otx2_mbox_alloc_msg_nix_set_mac_addr(mbox);
+       otx2_mbox_memcpy(req->mac_addr, addr->addr_bytes, RTE_ETHER_ADDR_LEN);
+
+       rc = otx2_mbox_process(mbox);
+       if (rc) {
+               otx2_err("Failed to set mac address, rc=%d", rc);
+               goto done;
+       }
+
+       otx2_mbox_memcpy(dev->mac_addr, addr->addr_bytes, RTE_ETHER_ADDR_LEN);
+
+       /* Install the same entry into CGX DMAC filter table too. */
+       otx2_cgx_mac_addr_set(eth_dev, addr);
+
+done:
+       return rc;
+}
+
 int
 otx2_nix_mac_addr_get(struct rte_eth_dev *eth_dev, uint8_t *addr)
 {