]> git.droids-corp.org - dpdk.git/commitdiff
net/ngbe: support device promiscuous and allmulticast mode
authorJiawen Wu <jiawenwu@trustnetic.com>
Thu, 21 Oct 2021 09:50:09 +0000 (17:50 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 29 Oct 2021 22:53:19 +0000 (00:53 +0200)
Support to enable/disable promiscuous and allmulticast mode for a port.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
doc/guides/nics/features/ngbe.ini
doc/guides/nics/ngbe.rst
drivers/net/ngbe/ngbe_ethdev.c

index dd98838441d52e6717bb2d1ffec8fd6f6a5f97ea..90e2a38bfb8c52e816642662f63846367d4b7964 100644 (file)
@@ -12,6 +12,8 @@ Burst mode info      = Y
 MTU update           = Y
 Scattered Rx         = Y
 TSO                  = Y
+Promiscuous mode     = Y
+Allmulticast mode    = Y
 VLAN filter          = Y
 CRC offload          = Y
 VLAN offload         = Y
index a180acbea391e9fdd555e261ae4cfa1876fd28be..2a92f91e9f5b22968c0a5aaf6520c3ba3ada4d47 100644 (file)
@@ -16,6 +16,8 @@ Features
 - Checksum offload
 - VLAN/QinQ stripping and inserting
 - TSO offload
+- Promiscuous mode
+- Multicast mode
 - Port hardware statistics
 - Jumbo frames
 - Link state information
index d369cfb6dd66cf38f25de108b298c80364903418..0e588eeccef8a1ecd0cb541951ef33030d7732a9 100644 (file)
@@ -1745,6 +1745,65 @@ ngbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
        return ngbe_dev_link_update_share(dev, wait_to_complete);
 }
 
+static int
+ngbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
+{
+       struct ngbe_hw *hw = ngbe_dev_hw(dev);
+       uint32_t fctrl;
+
+       fctrl = rd32(hw, NGBE_PSRCTL);
+       fctrl |= (NGBE_PSRCTL_UCP | NGBE_PSRCTL_MCP);
+       wr32(hw, NGBE_PSRCTL, fctrl);
+
+       return 0;
+}
+
+static int
+ngbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
+{
+       struct ngbe_hw *hw = ngbe_dev_hw(dev);
+       uint32_t fctrl;
+
+       fctrl = rd32(hw, NGBE_PSRCTL);
+       fctrl &= (~NGBE_PSRCTL_UCP);
+       if (dev->data->all_multicast == 1)
+               fctrl |= NGBE_PSRCTL_MCP;
+       else
+               fctrl &= (~NGBE_PSRCTL_MCP);
+       wr32(hw, NGBE_PSRCTL, fctrl);
+
+       return 0;
+}
+
+static int
+ngbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
+{
+       struct ngbe_hw *hw = ngbe_dev_hw(dev);
+       uint32_t fctrl;
+
+       fctrl = rd32(hw, NGBE_PSRCTL);
+       fctrl |= NGBE_PSRCTL_MCP;
+       wr32(hw, NGBE_PSRCTL, fctrl);
+
+       return 0;
+}
+
+static int
+ngbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
+{
+       struct ngbe_hw *hw = ngbe_dev_hw(dev);
+       uint32_t fctrl;
+
+       if (dev->data->promiscuous == 1)
+               return 0; /* must remain in all_multicast mode */
+
+       fctrl = rd32(hw, NGBE_PSRCTL);
+       fctrl &= (~NGBE_PSRCTL_MCP);
+       wr32(hw, NGBE_PSRCTL, fctrl);
+
+       return 0;
+}
+
 /**
  * It clears the interrupt causes and enables the interrupt.
  * It will be called once only during NIC initialized.
@@ -2169,6 +2228,10 @@ static const struct eth_dev_ops ngbe_eth_dev_ops = {
        .dev_stop                   = ngbe_dev_stop,
        .dev_close                  = ngbe_dev_close,
        .dev_reset                  = ngbe_dev_reset,
+       .promiscuous_enable         = ngbe_dev_promiscuous_enable,
+       .promiscuous_disable        = ngbe_dev_promiscuous_disable,
+       .allmulticast_enable        = ngbe_dev_allmulticast_enable,
+       .allmulticast_disable       = ngbe_dev_allmulticast_disable,
        .link_update                = ngbe_dev_link_update,
        .stats_get                  = ngbe_dev_stats_get,
        .xstats_get                 = ngbe_dev_xstats_get,