net/dpaa2: add support for multicast promiscuous mode
authorHemant Agrawal <hemant.agrawal@nxp.com>
Fri, 26 May 2017 06:51:17 +0000 (12:21 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 12 Jun 2017 09:41:26 +0000 (10:41 +0100)
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
doc/guides/nics/features/dpaa2.ini
drivers/net/dpaa2/dpaa2_ethdev.c
drivers/net/dpaa2/mc/dpni.c
drivers/net/dpaa2/mc/fsl_dpni.h
drivers/net/dpaa2/mc/fsl_dpni_cmd.h

index 470853c..dddf0e0 100644 (file)
@@ -8,6 +8,7 @@ Link status          = Y
 Queue start/stop     = Y
 MTU update           = Y
 Promiscuous mode     = Y
+Allmulticast mode    = Y
 Unicast MAC filter   = Y
 RSS hash             = Y
 L3 checksum offload  = Y
index 5180871..22e0474 100644 (file)
@@ -617,7 +617,11 @@ dpaa2_dev_promiscuous_enable(
 
        ret = dpni_set_unicast_promisc(dpni, CMD_PRI_LOW, priv->token, true);
        if (ret < 0)
-               RTE_LOG(ERR, PMD, "Unable to enable promiscuous mode %d", ret);
+               RTE_LOG(ERR, PMD, "Unable to enable U promisc mode %d", ret);
+
+       ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, true);
+       if (ret < 0)
+               RTE_LOG(ERR, PMD, "Unable to enable M promisc mode %d", ret);
 }
 
 static void
@@ -637,7 +641,58 @@ dpaa2_dev_promiscuous_disable(
 
        ret = dpni_set_unicast_promisc(dpni, CMD_PRI_LOW, priv->token, false);
        if (ret < 0)
-               RTE_LOG(ERR, PMD, "Unable to disable promiscuous mode %d", ret);
+               RTE_LOG(ERR, PMD, "Unable to disable U promisc mode %d", ret);
+
+       if (dev->data->all_multicast == 0) {
+               ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW,
+                                                priv->token, false);
+               if (ret < 0)
+                       RTE_LOG(ERR, PMD, "Unable to disable M promisc mode %d",
+                               ret);
+       }
+}
+
+static void
+dpaa2_dev_allmulticast_enable(
+               struct rte_eth_dev *dev)
+{
+       int ret;
+       struct dpaa2_dev_priv *priv = dev->data->dev_private;
+       struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
+
+       PMD_INIT_FUNC_TRACE();
+
+       if (dpni == NULL) {
+               RTE_LOG(ERR, PMD, "dpni is NULL");
+               return;
+       }
+
+       ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, true);
+       if (ret < 0)
+               RTE_LOG(ERR, PMD, "Unable to enable multicast mode %d", ret);
+}
+
+static void
+dpaa2_dev_allmulticast_disable(struct rte_eth_dev *dev)
+{
+       int ret;
+       struct dpaa2_dev_priv *priv = dev->data->dev_private;
+       struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
+
+       PMD_INIT_FUNC_TRACE();
+
+       if (dpni == NULL) {
+               RTE_LOG(ERR, PMD, "dpni is NULL");
+               return;
+       }
+
+       /* must remain on for all promiscuous */
+       if (dev->data->promiscuous == 1)
+               return;
+
+       ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, false);
+       if (ret < 0)
+               RTE_LOG(ERR, PMD, "Unable to disable multicast mode %d", ret);
 }
 
 static int
@@ -888,6 +943,8 @@ static struct eth_dev_ops dpaa2_ethdev_ops = {
        .dev_close            = dpaa2_dev_close,
        .promiscuous_enable   = dpaa2_dev_promiscuous_enable,
        .promiscuous_disable  = dpaa2_dev_promiscuous_disable,
+       .allmulticast_enable  = dpaa2_dev_allmulticast_enable,
+       .allmulticast_disable = dpaa2_dev_allmulticast_disable,
        .link_update       = dpaa2_dev_link_update,
        .stats_get             = dpaa2_dev_stats_get,
        .stats_reset       = dpaa2_dev_stats_reset,
index 4cea5f2..30bb7ad 100644 (file)
@@ -509,6 +509,47 @@ int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
        return 0;
 }
 
+int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
+                              uint32_t cmd_flags,
+                              uint16_t token,
+                              int en)
+{
+       struct mc_command cmd = { 0 };
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_MCAST_PROMISC,
+                                         cmd_flags,
+                                         token);
+       DPNI_CMD_SET_MULTICAST_PROMISC(cmd, en);
+
+       /* send command to mc*/
+       return mc_send_command(mc_io, &cmd);
+}
+
+int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
+                              uint32_t cmd_flags,
+                              uint16_t token,
+                              int *en)
+{
+       struct mc_command cmd = { 0 };
+       int err;
+
+       /* prepare command */
+       cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_MCAST_PROMISC,
+                                         cmd_flags,
+                                         token);
+
+       /* send command to mc*/
+       err = mc_send_command(mc_io, &cmd);
+       if (err)
+               return err;
+
+       /* retrieve response parameters */
+       DPNI_RSP_GET_MULTICAST_PROMISC(cmd, *en);
+
+       return 0;
+}
+
 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
                             uint32_t cmd_flags,
                             uint16_t token,
index dbb3b20..dae57b5 100644 (file)
@@ -797,6 +797,33 @@ int dpni_get_max_frame_length(struct fsl_mc_io     *mc_io,
                              uint16_t          token,
                              uint16_t          *max_frame_length);
 
+/**
+ * dpni_set_multicast_promisc() - Enable/disable multicast promiscuous mode
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:     Token of DPNI object
+ * @en:                Set to '1' to enable; '0' to disable
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpni_set_multicast_promisc(struct fsl_mc_io        *mc_io,
+                              uint32_t         cmd_flags,
+                              uint16_t         token,
+                              int              en);
+
+/**
+ * dpni_get_multicast_promisc() - Get multicast promiscuous mode
+ * @mc_io:     Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:     Token of DPNI object
+ * @en:                Returns '1' if enabled; '0' otherwise
+ *
+ * Return:     '0' on Success; Error code otherwise.
+ */
+int dpni_get_multicast_promisc(struct fsl_mc_io        *mc_io,
+                              uint32_t         cmd_flags,
+                              uint16_t         token,
+                              int              *en);
 
 /**
  * dpni_set_unicast_promisc() - Enable/disable unicast promiscuous mode
index 1ae734a..bd2bb3f 100644 (file)
@@ -65,6 +65,8 @@
 #define DPNI_CMDID_SET_MAX_FRAME_LENGTH                ((0x216 << 4) | (0x1))
 #define DPNI_CMDID_GET_MAX_FRAME_LENGTH                ((0x217 << 4) | (0x1))
 
+#define DPNI_CMDID_SET_MCAST_PROMISC                   ((0x220 << 4) | (0x1))
+#define DPNI_CMDID_GET_MCAST_PROMISC                   ((0x221 << 4) | (0x1))
 #define DPNI_CMDID_SET_UNICAST_PROMISC                 ((0x222 << 4) | (0x1))
 #define DPNI_CMDID_GET_UNICAST_PROMISC                 ((0x223 << 4) | (0x1))
 #define DPNI_CMDID_SET_PRIM_MAC                        ((0x224 << 4) | (0x1))
@@ -246,6 +248,14 @@ do { \
 #define DPNI_RSP_GET_MAX_FRAME_LENGTH(cmd, max_frame_length) \
        MC_RSP_OP(cmd, 0, 0,  16, uint16_t, max_frame_length)
 
+/*                cmd, param, offset, width, type, arg_name */
+#define DPNI_CMD_SET_MULTICAST_PROMISC(cmd, en) \
+       MC_CMD_OP(cmd, 0, 0,  1,  int,      en)
+
+/*                cmd, param, offset, width, type, arg_name */
+#define DPNI_RSP_GET_MULTICAST_PROMISC(cmd, en) \
+       MC_RSP_OP(cmd, 0, 0,  1,  int,      en)
+
 /*                cmd, param, offset, width, type, arg_name */
 #define DPNI_CMD_SET_UNICAST_PROMISC(cmd, en) \
        MC_CMD_OP(cmd, 0, 0,  1,  int,      en)